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

import GPUNotAvailableError to error.py #1694

Merged
merged 6 commits into from
Jan 12, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion hoomd/data/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ def _repr_html_(self):
return "<emph>" + name + "</emph>" \
+ "(<strong>INVALID</strong>)"
else:
from hoomd.util import _NoGPU
from hoomd.error import _NoGPU

class HOOMDGPUArray(_NoGPU):
"""GPU arrays are not available on the CPU."""
Expand Down
2 changes: 1 addition & 1 deletion hoomd/data/local_access_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, state):
self._constraints = ConstraintLocalAccessGPU(state)

else:
from hoomd.util import _NoGPU
from hoomd.error import _NoGPU

class BondLocalAccessGPU(_NoGPU):
"""GPU data access is not available in CPU builds."""
Expand Down
13 changes: 13 additions & 0 deletions hoomd/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ class TypeConversionError(ValueError):
pass


class GPUNotAvailableError(NotImplementedError):
"""Error for when a GPU specific feature was requested without a GPU."""
pass


class _NoGPU:
melodyyzh marked this conversation as resolved.
Show resolved Hide resolved
"""Used in nonGPU builds of hoomd to raise errors for attempted use."""

def __init__(self, *args, **kwargs):
raise GPUNotAvailableError(
"This build of HOOMD-blue does not support GPUs.")


class IncompleteSpecificationError(ValueError):
"""Error when a value is missing."""
pass
Expand Down
2 changes: 1 addition & 1 deletion hoomd/md/data/local_access_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NeighborListLocalAccessGPU(_NeighborListLocalAccessBase):
_array_cls = HOOMDGPUArray

else:
from hoomd.util import _NoGPU
from hoomd.error import _NoGPU

class ForceLocalAccessGPU(_NoGPU):
"""GPU data access is not available in CPU builds."""
Expand Down
14 changes: 1 addition & 13 deletions hoomd/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import hoomd
import io
from collections.abc import Iterable, Mapping, MutableMapping
from hoomd.error import GPUNotAvailableError # noqa: F401


def _to_camel_case(string):
Expand Down Expand Up @@ -252,19 +253,6 @@ def __setitem__(self, namespace, value):
super().__setitem__(namespace, value)


class GPUNotAvailableError(NotImplementedError):
"""Error for when a GPU specific feature was requested without a GPU."""
pass


class _NoGPU:
"""Used in nonGPU builds of hoomd to raise errors for attempted use."""

def __init__(self, *args, **kwargs):
raise GPUNotAvailableError(
"This build of HOOMD-blue does not support GPUs.")


def make_example_simulation(device=None, dimensions=3, particle_types=['A']):
"""Make an example Simulation object.

Expand Down
5 changes: 5 additions & 0 deletions sphinx-doc/deprecated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ documentation for more information on warning filters.

* ``HPMCIntegrator.depletant_fugacity > 0`` (since 4.4.0).


* ``hoomd.util.GPUNotAvailableError`` (since 4.5.0).

* use ``hoomd.error.GPUNotAvailableError``.

* ``_InternalCustomUpdater.update`` (since 4.5.0)
* ``_InternalCustomTuner.tune`` (since 4.5.0)
* ``_InternalCustomWriter.write`` (since 4.5.0)
Expand Down
4 changes: 3 additions & 1 deletion sphinx-doc/module-hoomd-error.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ hoomd.error
DataAccessError
TypeConversionError
MutabilityError
GPUNotAvailableError

.. rubric:: Details

.. automodule:: hoomd.error
:synopsis: HOOMD errors
:members: DataAccessError,
TypeConversionError,
MutabilityError
MutabilityError,
GPUNotAvailableError
:no-inherited-members:
:show-inheritance:
4 changes: 1 addition & 3 deletions sphinx-doc/module-hoomd-util.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ hoomd.util
.. autosummary::
:nosignatures:

GPUNotAvailableError
make_example_simulation

.. rubric:: Details

.. automodule:: hoomd.util
:synopsis: Utilities
:members: GPUNotAvailableError,
make_example_simulation
:members: make_example_simulation