Skip to content

Commit

Permalink
add error message if detector is missing from factory
Browse files Browse the repository at this point in the history
  • Loading branch information
weninc committed Nov 8, 2023
1 parent 8bb6ffc commit b38278b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion azint/detector.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
try:
import h5py
except ImportError:
Expand All @@ -23,7 +24,11 @@ def __init__(self, pixel1, pixel2, max_shape, pixel_corners=None):

@classmethod
def factory(cls, name, config = {}):
return globals()[name](**config)
cls = globals().get(name)
if inspect.isclass(cls) and issubclass(cls, Detector):
return cls(**config)
else:
raise RuntimeError(f'Detector {name} not supported')


def get_pixel_corners(self, pixel1, pixel2, shape):
Expand Down

0 comments on commit b38278b

Please sign in to comment.