Skip to content

Commit e4b4e98

Browse files
authored
Remove base class check in Effect.apply_to() (#620)
* Remove base class check in `Effect.apply_to()` This caused a lot more trouble than it's worth (e.g. in the scope of #241). The various effect subclasses each perform the appropriate check anyway. Ultimately, the `Effect` base class might be turned into an ABC, but that's for later... * Add test to satisfy codecov * Forgot argument, this is not the error you're looking for...
1 parent d048af6 commit e4b4e98

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

scopesim/effects/effects.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from typing import NewType, ClassVar
88

99
from .data_container import DataContainer
10-
from .. import base_classes as bc
1110
from ..utils import from_currsys, write_report
1211
from ..reports.rst_utils import table_to_rst
1312

@@ -57,15 +56,8 @@ def __init__(self, filename=None, **kwargs):
5756
self.meta.update(kwargs)
5857

5958
def apply_to(self, obj, **kwargs):
60-
"""TBA."""
61-
if not isinstance(obj, (bc.FOVSetupBase, bc.SourceBase,
62-
bc.FieldOfViewBase, bc.ImagePlaneBase,
63-
bc.DetectorBase)):
64-
raise ValueError("object must one of the following: FOVSetupBase, "
65-
"Source, FieldOfView, ImagePlane, Detector: "
66-
f"{type(obj)}")
67-
68-
return obj
59+
"""Apply the effect to the corresponding object."""
60+
raise NotImplementedError("Subclasses should implement this.")
6961

7062
def fov_grid(self, which="", **kwargs):
7163
"""

scopesim/tests/tests_effects/test_Effects.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def test_initalising_with_arrays_creates_table(self):
2222
def test_has_method_apply_to(self):
2323
assert hasattr(Effect(), "apply_to")
2424

25+
def test_base_class_apply_to_throws(self):
26+
with pytest.raises(NotImplementedError):
27+
Effect().apply_to("bogus")
28+
2529
def test_has_method_waveset(self):
2630
assert hasattr(Effect(), "fov_grid")
2731

0 commit comments

Comments
 (0)