Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove more deprecated names. #1499

Merged
merged 3 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 30 additions & 84 deletions hoomd/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,6 @@ def message_filename(self):
"""
return self._message_filename

@property
def msg_file(self):
"""str: Filename to write messages to.

.. deprecated:: v3.10.0
``msg_file`` will be renamed to ``message_Filename`` in v4.
"""
warnings.warn(
"msg_file is deprecated since v3.10.0. Use message_filename.",
FutureWarning)
return self.message_filename

@message_filename.setter
def message_filename(self, filename):
self._message_filename = filename
Expand All @@ -135,13 +123,6 @@ def message_filename(self, filename):
else:
self._cpp_msg.openStd()

@msg_file.setter
def msg_file(self, filename):
warnings.warn(
"msg_file is deprecated since v3.10.0. Use message_filename.",
FutureWarning)
self.message_filename = filename

@property
def devices(self):
"""list[str]: Descriptions of the active hardware devices."""
Expand Down Expand Up @@ -202,23 +183,6 @@ def _create_messenger(mpi_config, notice_level, message_filename):
return msg


def _get_message_filename(msg_file, message_file):
if msg_file is None and message_file is None:
return None

if msg_file is not None and message_file is not None:
raise ValueError("Pass in msg_file or message_file, not both")

if message_file is not None:
return message_file

if msg_file is not None:
warnings.warn(
"msg_file is deprecated since v3.10.0. Use message_filename.",
FutureWarning)
return msg_file


class GPU(Device):
"""Select a GPU or GPU(s) to execute simulations.

Expand All @@ -232,17 +196,12 @@ class GPU(Device):
communicator (hoomd.communicator.Communicator): MPI communicator object.
When `None`, create a default communicator that uses all MPI ranks.

msg_file (str): Alias for ``message_filename``.

.. deprecated:: v3.10.0
``msg_file`` will be renamed to ``message_filename`` in v4.

notice_level (int): Minimum level of messages to print.

message_filename (str): Filename to write messages to. When `None`, use
`sys.stdout` and `sys.stderr`. Messages from multiple MPI
ranks are collected into this file.

notice_level (int): Minimum level of messages to print.

Tip:
Call `GPU.get_available_devices` to get a human readable list of
devices. ``gpu_ids = [0]`` will select the first device in this list,
Expand Down Expand Up @@ -277,16 +236,16 @@ class GPU(Device):

"""

def __init__(self,
gpu_ids=None,
num_cpu_threads=None,
communicator=None,
msg_file=None,
notice_level=2,
message_filename=None):
def __init__(
self,
gpu_ids=None,
num_cpu_threads=None,
communicator=None,
message_filename=None,
notice_level=2,
):

super().__init__(communicator, notice_level,
_get_message_filename(msg_file, message_filename))
super().__init__(communicator, notice_level, message_filename)

if gpu_ids is None:
gpu_ids = []
Expand Down Expand Up @@ -382,31 +341,26 @@ class CPU(Device):
communicator (hoomd.communicator.Communicator): MPI communicator object.
When `None`, create a default communicator that uses all MPI ranks.

msg_file (str): Alias for ``message_filename``.

.. deprecated:: v3.10.0
``msg_file`` will be renamed to ``message_filename`` in v4.

notice_level (int): Minimum level of messages to print.

message_filename (str): Filename to write messages to. When `None`, use
`sys.stdout` and `sys.stderr`. Messages from multiple MPI
ranks are collected into this file.

notice_level (int): Minimum level of messages to print.

.. rubric:: MPI

In MPI execution environments, create a `CPU` device on every rank.
"""

def __init__(self,
num_cpu_threads=None,
communicator=None,
msg_file=None,
notice_level=2,
message_filename=None):
def __init__(
self,
num_cpu_threads=None,
communicator=None,
message_filename=None,
notice_level=2,
):

super().__init__(communicator, notice_level,
_get_message_filename(msg_file, message_filename))
super().__init__(communicator, notice_level, message_filename)

self._cpp_exec_conf = _hoomd.ExecutionConfiguration(
_hoomd.ExecutionConfiguration.executionMode.CPU, [],
Expand All @@ -416,37 +370,29 @@ def __init__(self,
self.num_cpu_threads = num_cpu_threads


def auto_select(communicator=None,
msg_file=None,
notice_level=2,
message_filename=None):
def auto_select(
communicator=None,
message_filename=None,
notice_level=2,
):
"""Automatically select the hardware device.

Args:

communicator (hoomd.communicator.Communicator): MPI communicator object.
When `None`, create a default communicator that uses all MPI ranks.

msg_file (str): Alias for ``message_filename``.

.. deprecated:: v3.10.0
``msg_file`` will be renamed to ``message_filename`` in v4.

notice_level (int): Minimum level of messages to print.

message_filename (str): Filename to write messages to. When `None`, use
`sys.stdout` and `sys.stderr`. Messages from multiple MPI
ranks are collected into this file.

notice_level (int): Minimum level of messages to print.

Returns:
Instance of `GPU` if availabile, otherwise `CPU`.
"""
# Set class according to C++ object
if len(GPU.get_available_devices()) > 0:
return GPU(None, None, communicator,
_get_message_filename(msg_file, message_filename),
notice_level)
return GPU(None, None, communicator, message_filename, notice_level)
else:
return CPU(None, communicator,
_get_message_filename(msg_file, message_filename),
notice_level)
return CPU(None, communicator, message_filename, notice_level)
6 changes: 3 additions & 3 deletions hoomd/md/external/wall.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,20 @@ def __init__(self, walls):
self._add_typeparam(params)


class Gauss(WallPotential):
class Gaussian(WallPotential):
r"""Gaussian wall force.

Args:
walls (`list` [`hoomd.wall.WallGeometry` ]): A list of wall definitions
to use for the force.

Wall force evaluated using the Gaussian force. See `hoomd.md.pair.Gauss`
Wall force evaluated using the Gaussian force. See `hoomd.md.pair.Gaussian`
for the functional form of the force and parameter definitions.

Example::

walls = [hoomd.wall.Sphere(radius=4.0)]
gaussian_wall = hoomd.md.external.wall.Gauss(walls=walls)
gaussian_wall = hoomd.md.external.wall.Gaussian(walls=walls)
gaussian_wall.params['A'] = {"epsilon": 1.0, "sigma": 1.0, "r_cut": 2.5}
gaussian_wall.params[['A','B']] = {
"epsilon": 2.0, "sigma": 1.0, "r_cut": 1.0}
Expand Down
8 changes: 4 additions & 4 deletions hoomd/md/pair/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"""

from . import aniso
from .pair import (Pair, LJ, Gauss, Gaussian, ExpandedLJ, Yukawa, Ewald, Morse,
DPD, DPDConservative, DPDLJ, ForceShiftedLJ, Moliere, ZBL,
Mie, ExpandedMie, ReactionField, DLVO, Buckingham, LJ1208,
LJ0804, Fourier, OPP, Table, TWF, LJGauss)
from .pair import (Pair, LJ, Gaussian, ExpandedLJ, Yukawa, Ewald, Morse, DPD,
DPDConservative, DPDLJ, ForceShiftedLJ, Moliere, ZBL, Mie,
ExpandedMie, ReactionField, DLVO, Buckingham, LJ1208, LJ0804,
Fourier, OPP, Table, TWF, LJGauss)
16 changes: 1 addition & 15 deletions hoomd/md/pair/pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class Gaussian(Pair):
default_r_on (float): Default turn-on radius :math:`[\mathrm{length}]`.
mode (str): Energy shifting/smoothing mode.

`Gauss` computes the Gaussian pair force should on every particle in the
`Gaussian` computes the Gaussian pair force should on every particle in the
simulation state:

.. math::
Expand Down Expand Up @@ -279,20 +279,6 @@ def __init__(self, nlist, default_r_cut=None, default_r_on=0., mode='none'):
self._add_typeparam(params)


class Gauss(Gaussian):
"""Gaussian pair force.

.. deprecated:: v3.10.0
Use `Gaussian`.
"""

def __init__(self, nlist, default_r_cut=None, default_r_on=0., mode='none'):
warnings.warn(
"Gauss is deprecated and will be removed in hoomd 4.0. Use "
"Gaussian instead.", FutureWarning)
super().__init__(nlist, default_r_cut, default_r_on, mode)


class ExpandedLJ(Pair):
r"""Expanded Lennard-Jones pair force.

Expand Down
2 changes: 1 addition & 1 deletion hoomd/md/pytest/forces_and_energies.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
]
]
},
"Gauss": {
"Gaussian": {
"params": [
{
"sigma": 0.5,
Expand Down
2 changes: 1 addition & 1 deletion hoomd/md/pytest/test_half_step_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def sim_factory(particle_types=['A'], dimensions=3, d=1, L=20):
def integrator_elements():
nlist = md.nlist.Cell(buffer=0.4)
lj = md.pair.LJ(nlist=nlist, default_r_cut=2.5)
gauss = md.pair.Gauss(nlist, default_r_cut=3.0)
gauss = md.pair.Gaussian(nlist, default_r_cut=3.0)
lj.params[("A", "A")] = {"epsilon": 1.0, "sigma": 1.0}
gauss.params[("A", "A")] = {"epsilon": 1.0, "sigma": 1.0}
return {
Expand Down
2 changes: 1 addition & 1 deletion hoomd/md/pytest/test_integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def sim_factory(particle_types=['A'], dimensions=3, d=1, L=20):
def integrator_elements():
nlist = md.nlist.Cell(buffer=0.4)
lj = md.pair.LJ(nlist=nlist, default_r_cut=2.5)
gauss = md.pair.Gauss(nlist, default_r_cut=3.0)
gauss = md.pair.Gaussian(nlist, default_r_cut=3.0)
lj.params[("A", "A")] = {"epsilon": 1.0, "sigma": 1.0}
gauss.params[("A", "A")] = {"epsilon": 1.0, "sigma": 1.0}
return {
Expand Down
15 changes: 8 additions & 7 deletions hoomd/md/pytest/test_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _invalid_params():
gauss_valid_dict = {'sigma': 0.05, 'epsilon': 0.05}
gauss_invalid_dicts = _make_invalid_param_dict(gauss_valid_dict)
invalid_params_list.extend(
_make_invalid_params(gauss_invalid_dicts, md.pair.Gauss, {}))
_make_invalid_params(gauss_invalid_dicts, md.pair.Gaussian, {}))

yukawa_valid_dict = {"epsilon": 0.0005, "kappa": 1}
yukawa_invalid_dicts = _make_invalid_param_dict(yukawa_valid_dict)
Expand Down Expand Up @@ -396,7 +396,7 @@ def _valid_params(particle_types=['A', 'B']):
gauss_arg_dict = {'epsilon': [0.025, 0.05, 0.075], 'sigma': [0.5, 1.0, 1.5]}
gauss_valid_param_dicts = _make_valid_param_dicts(gauss_arg_dict)
valid_params_list.append(
paramtuple(md.pair.Gauss, dict(zip(combos, gauss_valid_param_dicts)),
paramtuple(md.pair.Gaussian, dict(zip(combos, gauss_valid_param_dicts)),
{}))

yukawa_arg_dict = {
Expand Down Expand Up @@ -1167,11 +1167,12 @@ def test_lrc_non_lj(simulation_factory, two_particle_snapshot_factory):
# test we can't pass in tail_correction to non-LJ pair potential
cell = md.nlist.Cell(buffer=0.4)
with pytest.raises(TypeError):
# flake8 complains about unused variable with gauss = md.pair.Gauss(...)
md.pair.Gauss(nlist=cell,
default_r_cut=2.5,
mode='none',
tail_correction=True)
# flake8 complains about unused variable with
# gauss = md.pair.Gaussian(...)
md.pair.Gaussian(nlist=cell,
default_r_cut=2.5,
mode='none',
tail_correction=True)


def test_tail_corrections(simulation_factory, two_particle_snapshot_factory):
Expand Down
2 changes: 1 addition & 1 deletion hoomd/md/pytest/test_wall_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def generate_n(cls, N):

_potential_cls = (
md.external.wall.LJ,
md.external.wall.Gauss,
md.external.wall.Gaussian,
md.external.wall.Yukawa,
md.external.wall.Morse,
md.external.wall.ForceShiftedLJ,
Expand Down
2 changes: 1 addition & 1 deletion hoomd/pytest/test_custom_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_flags(self, simulation_factory, two_particle_snapshot_factory):
action = WriteTimestep()
action.flags = [hoomd.custom.Action.Flags.PRESSURE_TENSOR]
sim.operations += hoomd.write.CustomWriter(2, action)
gauss = hoomd.md.pair.Gauss(hoomd.md.nlist.Cell(0.5))
gauss = hoomd.md.pair.Gaussian(hoomd.md.nlist.Cell(0.5))
gauss.params[("A", "A")] = {"sigma": 1.0, "epsilon": 1.0}
gauss.r_cut[("A", "A")] = 2.0
sim.operations += hoomd.md.Integrator(
Expand Down
Loading