diff --git a/docs/api.rst b/docs/api.rst index 38e8e4c5..9fb2d129 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -67,7 +67,6 @@ Attributes Dataset.pr.comment Dataset.pr.institution Dataset.pr.history - Dataset.pr.source .. _dsmeth: diff --git a/docs/data_format_details.rst b/docs/data_format_details.rst index 433c8ac5..e20922d8 100644 --- a/docs/data_format_details.rst +++ b/docs/data_format_details.rst @@ -50,7 +50,6 @@ category-set (for example, ``animal (FAOSTAT)``). Additional rules: -* The size of the ``source`` dimension must be exactly 1. * The valid values for the ``provenance`` are ``measured``, ``projected``, and ``derived``. diff --git a/docs/data_format_examples.ipynb b/docs/data_format_examples.ipynb index 0a3a52e2..42876f8b 100644 --- a/docs/data_format_examples.ipynb +++ b/docs/data_format_examples.ipynb @@ -201,7 +201,7 @@ " \"scenario (FAOSTAT)\": np.array([\"highpop\", \"lowpop\"]),\n", " \"provenance\": np.array([\"projected\"]),\n", " \"model\": np.array([\"FANCYFAO\"]),\n", - " \"source\": np.array([\"RAND2020\"]),\n", + " \"source\": np.array([\"RAND2020\", \"RAND2021\"]),\n", "}\n", "\n", "opulent = xr.Dataset(\n", diff --git a/primap2/_data_format.py b/primap2/_data_format.py index 09704fd2..8d859fba 100644 --- a/primap2/_data_format.py +++ b/primap2/_data_format.py @@ -385,10 +385,6 @@ def ensure_valid_dimensions(ds: xr.Dataset): f" sec_cats." ) - if ds.dims["source"] != 1: - logger.error("Exactly one source required per data set.") - raise ValueError("Exactly one source required") - for dim in required_indirect_dims.union(optional_indirect_dims): if dim in ds.attrs: split_dim_name(ds.attrs[dim]) diff --git a/primap2/_metadata.py b/primap2/_metadata.py index 5664a189..964f0d74 100644 --- a/primap2/_metadata.py +++ b/primap2/_metadata.py @@ -72,12 +72,3 @@ def history(self) -> str: @history.setter def history(self, value: str): self._ds.attrs["history"] = value - - @property - def source(self) -> str: - """a short identifier for the source of the data""" - return self._ds["source"].item() - - @source.setter - def source(self, value: str): - self._ds["source"] = [value] diff --git a/primap2/tests/data/test_sum_skip_allna_inhomogeneous_result.nc b/primap2/tests/data/test_sum_skip_allna_inhomogeneous_result.nc index 4e20b427..8d079ad0 100644 Binary files a/primap2/tests/data/test_sum_skip_allna_inhomogeneous_result.nc and b/primap2/tests/data/test_sum_skip_allna_inhomogeneous_result.nc differ diff --git a/primap2/tests/examples.py b/primap2/tests/examples.py index 4a802467..8b5af8a4 100644 --- a/primap2/tests/examples.py +++ b/primap2/tests/examples.py @@ -48,7 +48,7 @@ def opulent_ds(): "scenario (FAOSTAT)": np.array(["highpop", "lowpop"]), "provenance": np.array(["projected"]), "model": np.array(["FANCYFAO"]), - "source": np.array(["RAND2020"]), + "source": np.array(["RAND2020", "RAND2021"]), } # seed the rng with a constant to achieve predictable "randomness" diff --git a/primap2/tests/test_data_format.py b/primap2/tests/test_data_format.py index 61a96b5e..e32bd25c 100644 --- a/primap2/tests/test_data_format.py +++ b/primap2/tests/test_data_format.py @@ -20,10 +20,9 @@ def test_something_else_entirely(caplog): assert "object is not an xarray Dataset." in caplog.text -def test_valid_ds_pass(minimal_ds, opulent_ds, caplog): +def test_valid_ds_pass(any_ds, caplog): caplog.set_level(logging.INFO) - minimal_ds.pr.ensure_valid() - opulent_ds.pr.ensure_valid() + any_ds.pr.ensure_valid() assert not caplog.records @@ -109,22 +108,6 @@ def test_wrong_dimension_key(minimal_ds, caplog): assert "'asdf' not in the format 'dim (category_set)'." in caplog.text -def test_not_one_source(minimal_ds: xr.Dataset, caplog): - ds = minimal_ds.loc[{"source": "RAND2020"}] - ds["source"] = [] - with pytest.raises(ValueError, match=r"Exactly one source required"): - ds.pr.ensure_valid() - assert "ERROR" in caplog.text - assert "Exactly one source required per data set." in caplog.text - - caplog.clear() - ds["source"] = ["a", "b"] - with pytest.raises(ValueError, match=r"Exactly one source required"): - ds.pr.ensure_valid() - assert "ERROR" in caplog.text - assert "Exactly one source required per data set." in caplog.text - - def test_missing_sec_cat(minimal_ds, caplog): minimal_ds.attrs["sec_cats"] = ["missing"] with pytest.raises(ValueError, match="Secondary category 'missing' not in dims"): diff --git a/primap2/tests/test_metadata.py b/primap2/tests/test_metadata.py index 8c344c88..f05bd138 100644 --- a/primap2/tests/test_metadata.py +++ b/primap2/tests/test_metadata.py @@ -12,7 +12,6 @@ def test_metadata_properties(opulent_ds): assert ds.pr.history == ( "2021-01-14 14:50 data invented\n" "2021-01-14 14:51 additional processing step" ) - assert ds.pr.source == "RAND2020" ds.pr.references = "references" assert ds.pr.references == "references" @@ -28,5 +27,3 @@ def test_metadata_properties(opulent_ds): assert ds.pr.institution == "institution" ds.pr.history = "history" assert ds.pr.history == "history" - ds.pr.source = "source" - assert ds.pr.source == "source"