diff --git a/src/tdastro/base_models.py b/src/tdastro/base_models.py index 50341d1c..b7b68fbc 100644 --- a/src/tdastro/base_models.py +++ b/src/tdastro/base_models.py @@ -37,7 +37,6 @@ def __init__(self, **kwargs): **kwargs : `dict`, optional Any additional keyword arguments. """ - self.model_name = "ParameterizedModel" self.setters = {} self.sample_iteration = 0 diff --git a/src/tdastro/sources/spline_model.py b/src/tdastro/sources/spline_model.py index 199b1b78..29a5925f 100644 --- a/src/tdastro/sources/spline_model.py +++ b/src/tdastro/sources/spline_model.py @@ -76,7 +76,7 @@ def __init__( def __str__(self): """Return the string representation of the model.""" - return f"SplineSource{self.name}" + return f"SplineModel({self.name})" def _evaluate(self, times, wavelengths, **kwargs): """Draw effect-free observations for this object. diff --git a/src/tdastro/sources/static_source.py b/src/tdastro/sources/static_source.py index bdcaa036..9813f5a6 100644 --- a/src/tdastro/sources/static_source.py +++ b/src/tdastro/sources/static_source.py @@ -27,7 +27,7 @@ def __init__(self, brightness, **kwargs): def __str__(self): """Return the string representation of the model.""" - return "StaticSource(self.brightness)" + return f"StaticSource({self.brightness})" def _evaluate(self, times, wavelengths, **kwargs): """Draw effect-free observations for this object. diff --git a/src/tdastro/sources/step_source.py b/src/tdastro/sources/step_source.py index 59552c01..7d54ecde 100644 --- a/src/tdastro/sources/step_source.py +++ b/src/tdastro/sources/step_source.py @@ -36,7 +36,7 @@ def __init__(self, brightness, t_start, t_end, **kwargs): def __str__(self): """Return the string representation of the model.""" - return f"StepSource(self.brightness)_{self.t_start}_to_{self.t_end}" + return f"StepSource({self.brightness})_{self.t_start}_to_{self.t_end}" def _evaluate(self, times, wavelengths, **kwargs): """Draw effect-free observations for this object. diff --git a/tests/tdastro/sources/test_spline_source.py b/tests/tdastro/sources/test_spline_source.py index 7160748a..c91d7503 100644 --- a/tests/tdastro/sources/test_spline_source.py +++ b/tests/tdastro/sources/test_spline_source.py @@ -8,6 +8,7 @@ def test_spline_model_flat() -> None: wavelengths = np.linspace(100.0, 500.0, 25) fluxes = np.full((len(times), len(wavelengths)), 1.0) model = SplineModel(times, wavelengths, fluxes) + assert str(model) == "SplineModel(None)" test_times = np.array([0.0, 1.0, 2.0, 3.0, 10.0]) test_waves = np.array([0.0, 100.0, 200.0, 1000.0]) @@ -17,7 +18,9 @@ def test_spline_model_flat() -> None: expected = np.full_like(values, 1.0) np.testing.assert_array_almost_equal(values, expected) - model2 = SplineModel(times, wavelengths, fluxes, amplitude=5.0) + model2 = SplineModel(times, wavelengths, fluxes, amplitude=5.0, name="test") + assert str(model2) == "SplineModel(test)" + values2 = model2.evaluate(test_times, test_waves) assert values2.shape == (5, 4) expected2 = np.full_like(values2, 5.0) diff --git a/tests/tdastro/sources/test_static_source.py b/tests/tdastro/sources/test_static_source.py index d6950309..834c2899 100644 --- a/tests/tdastro/sources/test_static_source.py +++ b/tests/tdastro/sources/test_static_source.py @@ -24,6 +24,7 @@ def test_static_source() -> None: assert model.ra is None assert model.dec is None assert model.distance is None + assert str(model) == "StaticSource(10.0)" times = np.array([1, 2, 3, 4, 5, 10]) wavelengths = np.array([100.0, 200.0, 300.0]) diff --git a/tests/tdastro/sources/test_step_source.py b/tests/tdastro/sources/test_step_source.py index c3e9e4ce..98a62f56 100644 --- a/tests/tdastro/sources/test_step_source.py +++ b/tests/tdastro/sources/test_step_source.py @@ -41,6 +41,7 @@ def test_step_source() -> None: assert model.ra == 1.0 assert model.dec == 2.0 assert model.distance == 3.0 + assert str(model) == "StepSource(15.0)_1.0_to_2.0" times = np.array([0.0, 1.0, 2.0, 3.0]) wavelengths = np.array([100.0, 200.0])