From 9e9816144419b35905f31218b900253045030597 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Sun, 12 May 2024 10:09:37 +0200 Subject: [PATCH] everything setup up with logger and runtime typechecking --- PQAnalysis/traj/trajectory.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/PQAnalysis/traj/trajectory.py b/PQAnalysis/traj/trajectory.py index 8ccbfc50..4a994616 100644 --- a/PQAnalysis/traj/trajectory.py +++ b/PQAnalysis/traj/trajectory.py @@ -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 @@ -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. @@ -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: