diff --git a/bilby/gw/detector/interferometer.py b/bilby/gw/detector/interferometer.py index c82683f1fe00c5382ed97bec411d4a19633a48e5..7ee47ba114242e87bd6c2d6039e3537ead3e55f4 100644 --- a/bilby/gw/detector/interferometer.py +++ b/bilby/gw/detector/interferometer.py @@ -9,7 +9,7 @@ from bilby.core.utils import logger from bilby.gw import utils as gwutils from bilby.gw.calibration import Recalibrate from bilby.gw.detector.geometry import InterferometerGeometry -from bilby.gw.detector.utils import SubclassPropertyAccessor +from bilby.gw.utils import SubclassPropertyAccessor from .strain_data import InterferometerStrainData try: diff --git a/bilby/gw/detector/strain_data.py b/bilby/gw/detector/strain_data.py index 47d7c280a8d6f4681de5d30562c9d92f2f1a38f0..46d62d69e0c8bd1ed7d295ad133f99a1a2b01894 100644 --- a/bilby/gw/detector/strain_data.py +++ b/bilby/gw/detector/strain_data.py @@ -5,7 +5,7 @@ from bilby.core import utils from bilby.core.series import CoupledTimeAndFrequencySeries from bilby.core.utils import logger from bilby.gw import utils as gwutils -from bilby.gw.detector.utils import SubclassPropertyAccessor +from bilby.gw.utils import SubclassPropertyAccessor try: import gwpy diff --git a/bilby/gw/detector/utils.py b/bilby/gw/detector/utils.py deleted file mode 100644 index c14856197b0da90f716788a8b273ba3f1a7f4893..0000000000000000000000000000000000000000 --- a/bilby/gw/detector/utils.py +++ /dev/null @@ -1,29 +0,0 @@ -class SubclassPropertyAccessor(object): - """ - Generic descriptor class that allows handy access of properties without long - boilerplate code. The properties of Interferometer are defined as instances - of this class. Don't touch this if you don't know what you are doing. - - This avoids lengthy code like - ``` - @property - def length(self): - return self.geometry.length - - @length_setter - def length(self, length) - self.geometry.length = length - - in the Interferometer class - ``` - """ - - def __init__(self, property_name, container_instance_name): - self.property_name = property_name - self.container_instance_name = container_instance_name - - def __get__(self, instance, owner): - return getattr(getattr(instance, self.container_instance_name), self.property_name) - - def __set__(self, instance, value): - setattr(getattr(instance, self.container_instance_name), self.property_name, value) diff --git a/bilby/gw/utils.py b/bilby/gw/utils.py index 789d602284f260358d70b92fc7ee95e397095f3f..bf0cff4d17a85c0c8c69a5a9fb5b3d585ef253df 100644 --- a/bilby/gw/utils.py +++ b/bilby/gw/utils.py @@ -926,3 +926,34 @@ def plot_spline_pos(log_freqs, samples, nfreqs=100, level=0.9, color='k', label= plt.fill_between(freqs, credible_interval(data, level), credible_interval(data, level, lower=False), color=color, alpha=.1, linewidth=0.1) plt.xlim(freq_points.min() - .5, freq_points.max() + 50) + + +class SubclassPropertyAccessor(object): + """ + Generic descriptor class that allows handy access of properties without long + boilerplate code. The properties of Interferometer are defined as instances + of this class. Don't touch this if you don't know what you are doing. + + This avoids lengthy code like + ``` + @property + def length(self): + return self.geometry.length + + @length_setter + def length(self, length) + self.geometry.length = length + + in the Interferometer class + ``` + """ + + def __init__(self, property_name, container_instance_name): + self.property_name = property_name + self.container_instance_name = container_instance_name + + def __get__(self, instance, owner): + return getattr(getattr(instance, self.container_instance_name), self.property_name) + + def __set__(self, instance, value): + setattr(getattr(instance, self.container_instance_name), self.property_name, value) \ No newline at end of file