Skip to content

Commit

Permalink
everything setup up with logger and runtime typechecking
Browse files Browse the repository at this point in the history
  • Loading branch information
97gamjak committed May 12, 2024
1 parent 1c761d4 commit 9e98161
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions PQAnalysis/traj/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from PQAnalysis.topology import Topology
from PQAnalysis.types import Np2DNumberArray, Np1DNumberArray
from PQAnalysis.exceptions import PQIndexError
from PQAnalysis.exceptions import PQIndexError, PQTypeError
from PQAnalysis.core import Cell
from PQAnalysis.atomic_system import AtomicSystem
from PQAnalysis.utils.custom_logging import setup_logger
Expand Down Expand Up @@ -309,7 +309,6 @@ def __contains__(self, item: AtomicSystem) -> bool:
"""
return item in self.frames

@runtime_type_checking
def __add__(self, other: "Trajectory") -> "Trajectory":
"""
This method allows two trajectories to be added together.
Expand All @@ -320,6 +319,12 @@ def __add__(self, other: "Trajectory") -> "Trajectory":
The other trajectory to add.
"""

if not isinstance(other, Trajectory):
self.logger.error(
"Only Trajectory objects can be added to a Trajectory.",
exception=PQTypeError,
)

return Trajectory(self.frames + other.frames)

def __eq__(self, other: Any) -> bool:
Expand Down

0 comments on commit 9e98161

Please sign in to comment.