diff --git a/changes/101.bugfix.rst b/changes/101.bugfix.rst new file mode 100644 index 00000000..6d909db5 --- /dev/null +++ b/changes/101.bugfix.rst @@ -0,0 +1 @@ +Fixed a bug that could cause printing lightcone summary to fail when column originally contained "redshift" column that had been dropped. diff --git a/src/opencosmo/collection/lightcone/lightcone.py b/src/opencosmo/collection/lightcone/lightcone.py index 75fc930f..30f3d689 100644 --- a/src/opencosmo/collection/lightcone/lightcone.py +++ b/src/opencosmo/collection/lightcone/lightcone.py @@ -105,7 +105,7 @@ def __repr__(self): else: repr_ds = self.take(10, at="start") table_head = "First 10 rows:\n" - if self.__hide_redshift: + if self.__hide_redshift and "redshift" in self.columns: repr_ds = repr_ds.drop("redshift") table_repr = repr_ds.data.__repr__() diff --git a/test/test_diffsky.py b/test/test_diffsky.py index 79c5844c..54c3f5e3 100644 --- a/test/test_diffsky.py +++ b/test/test_diffsky.py @@ -61,3 +61,10 @@ def test_cone_search(core_path_475, core_path_487): ds = oc.open(core_path_487, core_path_475, synth_cores=True) region = oc.make_cone(center, radius) ds = ds.bound(region) + + +def test_repr(core_path_475, core_path_487): + ds = oc.open(core_path_487, core_path_475) + ds = ds.with_redshift_range(0, 0.1) + ds = ds.select(["ra", "dec"]) + assert str(ds) diff --git a/uv.lock b/uv.lock index 2005de7b..70ca1e60 100644 --- a/uv.lock +++ b/uv.lock @@ -515,7 +515,7 @@ wheels = [ [[package]] name = "opencosmo" -version = "0.8.1" +version = "0.9.0b1" source = { editable = "." } dependencies = [ { name = "astropy" },