From 884f0cb20f5dccc346ae1a2114e25839de6bc57e Mon Sep 17 00:00:00 2001 From: Joe Hamman Date: Tue, 9 Nov 2021 10:15:01 -0800 Subject: [PATCH 1/7] Create CITATION.cff (#5956) * Create CITATION.cff * Update CITATION.cff Co-authored-by: Tom Nicholas <35968931+TomNicholas@users.noreply.github.com> * Update CITATION.cff Co-authored-by: Mathias Hauser * Update CITATION.cff Co-authored-by: Tom Nicholas <35968931+TomNicholas@users.noreply.github.com> Co-authored-by: Mathias Hauser --- CITATION.cff | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 CITATION.cff diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 00000000000..fcc04a6f3e4 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,96 @@ +cff-version: 1.2.0 +message: "If you use this software, please cite it as below." +authors: +- family-names: "Hoyer" + given-names: "Stephan" + orcid: "https://orcid.org/0000-0002-5207-0380" +- family-names: "Roos" + given-names: "Maximilian" +- family-names: "Joseph" + given-names: "Hamman" + orcid: "https://orcid.org/0000-0001-7479-8439" +- family-names: "Magin" + given-names: "Justus" +- family-names: "Cherian" + given-names: "Deepak" + orcid: "https://orcid.org/0000-0002-6861-8734" +- family-names: "Fitzgerald" + given-names: "Clark" + orcid: "https://orcid.org/0000-0003-3446-6389" +- family-names: "Hauser" + given-names: "Mathias" + orcid: "https://orcid.org/0000-0002-0057-4878" +- family-names: "Fujii" + given-names: "Keisuke" + orcid: "https://orcid.org/0000-0003-0390-9984" +- family-names: "Maussion" + given-names: "Fabien" + orcid: "https://orcid.org/0000-0002-3211-506X" +- family-names: "Imperiale" + given-names: "Guido" +- family-names: "Clark" + given-names: "Spencer" + orcid: "https://orcid.org/0000-0001-5595-7895" +- family-names: "Kleeman" + given-names: "Alex" +- family-names: "Nicholas" + given-names: "Thomas" + orcid: "https://orcid.org/0000-0002-2176-0530" +- family-names: "Kluyver" + given-names: "Thomas" + orcid: "https://orcid.org/0000-0003-4020-6364" +- family-names: "Westling" + given-names: "Jimmy" +- family-names: "Munroe" + given-names: "James" + orcid: "https://orcid.org/0000-0001-9098-6309" +- family-names: "Amici" + given-names: "Alessandro" + orcid: "https://orcid.org/0000-0002-1778-4505" +- family-names: "Barghini" + given-names: "Aureliana" +- family-names: "Banihirwe" + given-names: "Anderson" + orcid: "https://orcid.org/0000-0001-6583-571X" +- family-names: "Bell" + given-names: "Ray" + orcid: "https://orcid.org/0000-0003-2623-0587" +- family-names: "Hatfield-Dodds" + given-names: "Zac" + orcid: "https://orcid.org/0000-0002-8646-8362" +- family-names: "Abernathey" + given-names: "Ryan" + orcid: "https://orcid.org/0000-0001-5999-4917" +- family-names: "Bovy" + given-names: "Benoît" +- family-names: "Omotani" + given-names: "John" + orcid: "https://orcid.org/0000-0002-3156-8227" +- family-names: "Mühlbauer" + given-names: "Kai" + orcid: "https://orcid.org/0000-0001-6599-1034" +- family-names: "Roszko" + given-names: "Maximilian K." + orcid: "https://orcid.org/0000-0001-9424-2526" +- family-names: "Wolfram" + given-names: "Phillip J." + orcid: "https://orcid.org/0000-0001-5971-4241" +title: "xarray" +doi: 10.5281/zenodo.598201 +url: "https://github.com/pydata/xarray" +preferred-citation: + type: article + authors: + - family-names: "Hoyer" + given-names: "Stephan" + orcid: "https://orcid.org/0000-0002-5207-0380" + - family-names: "Joseph" + given-names: "Hamman" + orcid: "https://orcid.org/0000-0001-7479-8439" + doi: "10.5334/jors.148" + journal: "Journal of Open Research Software" + month: 4 + title: "xarray: N-D labeled Arrays and Datasets in Python" + volume: 5 + issue: 1 + year: 2017 From 5871637873cd83c3a656ee6f4df86ea6628cf68a Mon Sep 17 00:00:00 2001 From: Giacomo Caria <44147817+gcaria@users.noreply.github.com> Date: Tue, 9 Nov 2021 21:28:13 +0100 Subject: [PATCH 2/7] Do not change coordinate inplace when throwing error (#5957) --- xarray/core/variable.py | 5 +++++ xarray/tests/test_dataarray.py | 12 ++++++++++++ xarray/tests/test_variable.py | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/xarray/core/variable.py b/xarray/core/variable.py index a96adb31e64..52125ec4113 100644 --- a/xarray/core/variable.py +++ b/xarray/core/variable.py @@ -2813,6 +2813,11 @@ def name(self): def name(self, value): raise AttributeError("cannot modify name of IndexVariable in-place") + def _inplace_binary_op(self, other, f): + raise TypeError( + "Values of an IndexVariable are immutable and can not be modified inplace" + ) + # for backwards compatibility Coordinate = utils.alias(IndexVariable, "Coordinate") diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py index 53c650046e7..5e9c1b87ce2 100644 --- a/xarray/tests/test_dataarray.py +++ b/xarray/tests/test_dataarray.py @@ -1987,6 +1987,18 @@ def test_inplace_math_basics(self): assert_array_equal(b.values, x) assert source_ndarray(b.values) is x + def test_inplace_math_error(self): + data = np.random.rand(4) + times = np.arange(4) + foo = DataArray(data, coords=[times], dims=["time"]) + b = times.copy() + with pytest.raises( + TypeError, match=r"Values of an IndexVariable are immutable" + ): + foo.coords["time"] += 1 + # Check error throwing prevented inplace operation + assert_array_equal(foo.coords["time"], b) + def test_inplace_math_automatic_alignment(self): a = DataArray(range(5), [("x", range(5))]) b = DataArray(range(1, 6), [("x", range(1, 6))]) diff --git a/xarray/tests/test_variable.py b/xarray/tests/test_variable.py index 9c0e45c5da9..3267af8b45b 100644 --- a/xarray/tests/test_variable.py +++ b/xarray/tests/test_variable.py @@ -1656,6 +1656,14 @@ def test_inplace_math(self): with pytest.raises(ValueError, match=r"dimensions cannot change"): v += Variable("y", np.arange(5)) + def test_inplace_math_error(self): + x = np.arange(5) + v = IndexVariable(["x"], x) + with pytest.raises( + TypeError, match=r"Values of an IndexVariable are immutable" + ): + v += 1 + def test_reduce(self): v = Variable(["x", "y"], self.d, {"ignored": "attributes"}) assert_identical(v.reduce(np.std, "x"), Variable(["y"], self.d.std(axis=0))) From b1392d03d5081c04b8188f4a92a8d4a95fea1b51 Mon Sep 17 00:00:00 2001 From: Maximilian Roos <5635139+max-sixty@users.noreply.github.com> Date: Thu, 11 Nov 2021 18:55:14 -0800 Subject: [PATCH 3/7] Remove pre-commit auto update (#5958) --- .../workflows/ci-pre-commit-autoupdate.yaml | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 .github/workflows/ci-pre-commit-autoupdate.yaml diff --git a/.github/workflows/ci-pre-commit-autoupdate.yaml b/.github/workflows/ci-pre-commit-autoupdate.yaml deleted file mode 100644 index b10a541197e..00000000000 --- a/.github/workflows/ci-pre-commit-autoupdate.yaml +++ /dev/null @@ -1,44 +0,0 @@ -name: "pre-commit autoupdate CI" - -on: - schedule: - - cron: "0 0 * * 0" # every Sunday at 00:00 UTC - workflow_dispatch: - - -jobs: - autoupdate: - name: 'pre-commit autoupdate' - runs-on: ubuntu-latest - if: github.repository == 'pydata/xarray' - steps: - - name: checkout - uses: actions/checkout@v2 - - name: Cache pip and pre-commit - uses: actions/cache@v2 - with: - path: | - ~/.cache/pre-commit - ~/.cache/pip - key: ${{ runner.os }}-pre-commit-autoupdate - - name: setup python - uses: actions/setup-python@v2 - - name: upgrade pip - run: python -m pip install --upgrade pip - - name: install dependencies - run: python -m pip install --upgrade pre-commit pyyaml packaging - - name: version info - run: python -m pip list - - name: autoupdate - uses: technote-space/create-pr-action@837dbe469b39f08d416889369a52e2a993625c84 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - EXECUTE_COMMANDS: | - python -m pre_commit autoupdate - python -m pre_commit run --all-files - COMMIT_MESSAGE: 'pre-commit: autoupdate hook versions' - COMMIT_NAME: 'github-actions[bot]' - COMMIT_EMAIL: 'github-actions[bot]@users.noreply.github.com' - PR_TITLE: 'pre-commit: autoupdate hook versions' - PR_BRANCH_PREFIX: 'pre-commit/' - PR_BRANCH_NAME: 'autoupdate-${PR_ID}' From 242200458c58206f135e83726e4dcce471d8ac3f Mon Sep 17 00:00:00 2001 From: Maximilian Roos <5635139+max-sixty@users.noreply.github.com> Date: Fri, 12 Nov 2021 09:51:46 -0800 Subject: [PATCH 4/7] Fix mypy issue with entry_points (#5979) --- xarray/backends/plugins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index bcaee498b90..a0f46fad5b7 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -9,7 +9,7 @@ from importlib.metadata import entry_points except ImportError: # if the fallback library is missing, we are doomed. - from importlib_metadata import entry_points # type: ignore[no-redef] + from importlib_metadata import entry_points # type: ignore STANDARD_BACKENDS_ORDER = ["netcdf4", "h5netcdf", "scipy"] From efe3b1bb9f93cd92378cb859f6f4550bcdbaad72 Mon Sep 17 00:00:00 2001 From: Matt Henderson Date: Fri, 12 Nov 2021 21:16:48 -0800 Subject: [PATCH 5/7] Alternate method using inline css to hide regular html output in an untrusted notebook (#5880) * Update formatting_html.py * override inline display:none when css is loaded * remove semicolon Co-authored-by: Illviljan <14371165+Illviljan@users.noreply.github.com> --- xarray/core/formatting_html.py | 2 +- xarray/static/css/style.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/core/formatting_html.py b/xarray/core/formatting_html.py index faad06d8093..072a932b943 100644 --- a/xarray/core/formatting_html.py +++ b/xarray/core/formatting_html.py @@ -255,7 +255,7 @@ def _obj_repr(obj, header_components, sections): "
" f"{icons_svg}" f"
{escape(repr(obj))}
" - "