Skip to content

Commit

Permalink
raising NotImplementedError on abstract methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindlewis23 committed Jul 5, 2024
1 parent d1d9057 commit 586fa7d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 2 additions & 0 deletions hexrd/distortion/distortionabc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class DistortionABC(metaclass=abc.ABCMeta):
@abc.abstractmethod
def apply(self, xy_in):
"""Apply distortion mapping"""
raise NotImplementedError

@abc.abstractmethod
def apply_inverse(self, xy_in):
"""Apply inverse distortion mapping"""
raise NotImplementedError
6 changes: 6 additions & 0 deletions hexrd/fitting/calibration/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Calibrator(ABC):
@abstractmethod
def type(self):
"""The type of the calibrator"""
raise NotImplementedError

@abstractmethod
def create_lmfit_params(self, current_params):
Expand All @@ -24,6 +25,7 @@ def create_lmfit_params(self, current_params):
for the lattice parameters. The Laue calibrator creates lmfit
parameters for crystal parameters.
"""
raise NotImplementedError

@abstractmethod
def update_from_lmfit_params(self, params_dict):
Expand All @@ -36,6 +38,7 @@ def update_from_lmfit_params(self, params_dict):
For example, the powder calibrator will update the lattice parameters
on the material. The Laue calibrator will update crystal parameters.
"""
raise NotImplementedError

@abstractmethod
def residual(self, calibration_data=None):
Expand All @@ -45,6 +48,7 @@ def residual(self, calibration_data=None):
the calibration class instead, in which case, calibration_data can
be `None`.
"""
raise NotImplementedError

@property
@abstractmethod
Expand All @@ -69,8 +73,10 @@ def calibration_picks(self):
string of the hkl. And "picks" are either a list of points (powder)
or a single point (laue). The picks are in cartesian coordinates.
"""
raise NotImplementedError

@calibration_picks.setter
@abstractmethod
def calibration_picks(self, val):
"""Setter for calibration_picks. See getter docs for details."""
raise NotImplementedError
22 changes: 13 additions & 9 deletions hexrd/instrument/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Detector:
@property
@abstractmethod
def detector_type(self):
pass
raise NotImplementedError

@abstractmethod
def cart_to_angles(self, xy_data, rmat_s=None, tvec_s=None,
Expand Down Expand Up @@ -91,6 +91,7 @@ def cart_to_angles(self, xy_data, rmat_s=None, tvec_s=None,
DESCRIPTION.
"""
raise NotImplementedError

@abstractmethod
def angles_to_cart(self, tth_eta,
Expand Down Expand Up @@ -125,22 +126,24 @@ def angles_to_cart(self, tth_eta,
The (n, 2) array on the n input coordinates in the .
"""
raise NotImplementedError

@abstractmethod
def cart_to_dvecs(self, xy_data):
"""Convert cartesian coordinates to dvectors"""
raise NotImplementedError

@abstractmethod
def pixel_angles(self, origin=ct.zeros_3):
pass
raise NotImplementedError

@abstractmethod
def pixel_tth_gradient(self, origin=ct.zeros_3):
pass
raise NotImplementedError

@abstractmethod
def pixel_eta_gradient(self, origin=ct.zeros_3):
pass
raise NotImplementedError

@property
@abstractmethod
Expand All @@ -149,6 +152,7 @@ def beam_position(self):
returns the coordinates of the beam in the cartesian detector
frame {Xd, Yd, Zd}. NaNs if no intersection.
"""
raise NotImplementedError


@property
Expand Down Expand Up @@ -727,11 +731,11 @@ def config_dict(self, chi=0, tvec=ct.zeros_3,
elif panel_buffer is None:
# still None on self
# !!! this gets handled by unwrap_dict_to_h5 now
'''
if style.lower() == 'hdf5':
# !!! can't write None to hdf5; substitute with zeros
panel_buffer = np.r_[0., 0.]
'''

# if style.lower() == 'hdf5':
# # !!! can't write None to hdf5; substitute with zeros
# panel_buffer = np.r_[0., 0.]
pass
det_dict['buffer'] = panel_buffer

det_dict.update(self.extra_config_kwargs)
Expand Down

0 comments on commit 586fa7d

Please sign in to comment.