Skip to content

Commit

Permalink
added UsageError
Browse files Browse the repository at this point in the history
  • Loading branch information
wolearyc committed Aug 13, 2024
1 parent f1c6a13 commit 20d1007
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
12 changes: 12 additions & 0 deletions ramannoodle/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ def __init__(self, reason: str):
pass


class UsageError(Exception):
"""Raised when a user does something they shouldn't.
This exception is used sparingly, as (ideally) the structure of the API should
dictate what the user should and shouldn't do.
"""

def __init__(self, reason: str):
pass


def _shape_string(shape: Sequence[int | None]) -> str:
"""Get a string representing a shape.
Expand Down
15 changes: 13 additions & 2 deletions ramannoodle/polarizability/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
get_shape_error,
verify_ndarray_shape,
InvalidDOFException,
UsageError,
)


Expand Down Expand Up @@ -77,9 +78,13 @@ def add_dof( # pylint: disable=too-many-arguments
) -> None:
"""Disable add_dof.
Raises
------
UsageError
:meta private:
"""
raise AttributeError("'ARTModel' object has no attribute 'add_dof'")
raise UsageError("add_dof should not be used; use add_art instead")

def add_dof_from_files(
self,
Expand All @@ -89,9 +94,15 @@ def add_dof_from_files(
) -> None:
"""Disable add_dof_from_files.
Raises
------
UsageError
:meta private:
"""
raise AttributeError("'ARTModel' object has no attribute 'add_dof_from_files'")
raise UsageError(
"add_dof_from_files should not be used; use add_art_from_files instead"
)

def add_art(
self,
Expand Down

0 comments on commit 20d1007

Please sign in to comment.