Skip to content

Commit 8ccbf0e

Browse files
committed
Merge branch 'update-cast-to-nanosecond' of https://github.com/spencerkclark/xarray into update-cast-to-nanosecond
2 parents 121a3ad + 662806c commit 8ccbf0e

File tree

9 files changed

+275
-9
lines changed

9 files changed

+275
-9
lines changed

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fetch-depth: 0
2323

2424
- name: Set up conda environment
25-
uses: mamba-org/provision-with-micromamba@v12
25+
uses: mamba-org/provision-with-micromamba@v14
2626
with:
2727
environment-file: ${{env.CONDA_ENV_FILE}}
2828
environment-name: xarray-tests

.github/workflows/ci-additional.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ jobs:
5353
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
5454
5555
- name: Setup micromamba
56-
uses: mamba-org/provision-with-micromamba@34071ca7df4983ccd272ed0d3625818b27b70dcc
56+
uses: mamba-org/provision-with-micromamba@v14
5757
with:
5858
environment-file: ${{env.CONDA_ENV_FILE}}
5959
environment-name: xarray-tests
6060
extra-specs: |
6161
python=${{env.PYTHON_VERSION}}
62+
conda
6263
cache-env: true
6364
cache-env-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
6465

@@ -99,12 +100,13 @@ jobs:
99100
run: |
100101
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
101102
- name: Setup micromamba
102-
uses: mamba-org/provision-with-micromamba@34071ca7df4983ccd272ed0d3625818b27b70dcc
103+
uses: mamba-org/provision-with-micromamba@v14
103104
with:
104105
environment-file: ${{env.CONDA_ENV_FILE}}
105106
environment-name: xarray-tests
106107
extra-specs: |
107108
python=${{env.PYTHON_VERSION}}
109+
conda
108110
cache-env: true
109111
cache-env-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
110112
- name: Install xarray
@@ -152,7 +154,7 @@ jobs:
152154
fetch-depth: 0 # Fetch all history for all branches and tags.
153155

154156
- name: Setup micromamba
155-
uses: mamba-org/provision-with-micromamba@34071ca7df4983ccd272ed0d3625818b27b70dcc
157+
uses: mamba-org/provision-with-micromamba@v14
156158
with:
157159
environment-name: xarray-tests
158160
environment-file: false

.github/workflows/ci.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,15 @@ jobs:
8686
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
8787
8888
- name: Setup micromamba
89-
uses: mamba-org/provision-with-micromamba@34071ca7df4983ccd272ed0d3625818b27b70dcc
89+
uses: mamba-org/provision-with-micromamba@v14
9090
with:
9191
environment-file: ${{ env.CONDA_ENV_FILE }}
9292
environment-name: xarray-tests
9393
cache-env: true
9494
cache-env-key: "${{runner.os}}-${{runner.arch}}-py${{matrix.python-version}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
95+
extra-specs: |
96+
python=${{matrix.python-version}}
97+
conda
9598
9699
# We only want to install this on one run, because otherwise we'll have
97100
# duplicate annotations.

.github/workflows/upstream-dev-ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ jobs:
5454
with:
5555
fetch-depth: 0 # Fetch all history for all branches and tags.
5656
- name: Set up conda environment
57-
uses: mamba-org/provision-with-micromamba@34071ca7df4983ccd272ed0d3625818b27b70dcc
57+
uses: mamba-org/provision-with-micromamba@v14
5858
with:
5959
environment-file: ci/requirements/environment.yml
6060
environment-name: xarray-tests
6161
extra-specs: |
6262
python=${{ matrix.python-version }}
6363
pytest-reportlog
64+
conda
6465
- name: Install upstream versions
6566
run: |
6667
bash ci/install-upstream-wheels.sh
@@ -87,6 +88,6 @@ jobs:
8788
&& steps.status.outcome == 'failure'
8889
&& github.event_name == 'schedule'
8990
&& github.repository_owner == 'pydata'
90-
uses: xarray-contrib/issue-from-pytest-log@v0.1
91+
uses: xarray-contrib/issue-from-pytest-log@v1.1
9192
with:
9293
log-path: output-${{ matrix.python-version }}-log.jsonl

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
hooks:
2020
- id: isort
2121
- repo: https://github.com/asottile/pyupgrade
22-
rev: v3.1.0
22+
rev: v3.2.0
2323
hooks:
2424
- id: pyupgrade
2525
args:

asv_bench/benchmarks/merge.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import numpy as np
2+
13
import xarray as xr
24

35

@@ -13,6 +15,63 @@ def setup(self, existing_elements):
1315
d[f"var{i}"] = i
1416
self.dataset = xr.merge([d])
1517

18+
d = {f"set_2_{i}": i for i in range(existing_elements)}
19+
self.dataset2 = xr.merge([d])
20+
1621
def time_variable_insertion(self, existing_elements):
1722
dataset = self.dataset
1823
dataset["new_var"] = 0
24+
25+
def time_merge_two_datasets(self, existing_elements):
26+
xr.merge([self.dataset, self.dataset2])
27+
28+
29+
class DatasetCreation:
30+
# The idea here is to time how long it takes to go from numpy
31+
# and python data types, to a full dataset
32+
# See discussion
33+
# https://github.com/pydata/xarray/issues/7224#issuecomment-1292216344
34+
param_names = ["strategy", "count"]
35+
params = [
36+
["dict_of_DataArrays", "dict_of_Variables", "dict_of_Tuples"],
37+
[0, 1, 10, 100, 1000],
38+
]
39+
40+
def setup(self, strategy, count):
41+
data = np.array(["0", "b"], dtype=str)
42+
self.dataset_coords = dict(time=np.array([0, 1]))
43+
self.dataset_attrs = dict(description="Test data")
44+
attrs = dict(units="Celcius")
45+
if strategy == "dict_of_DataArrays":
46+
47+
def create_data_vars():
48+
return {
49+
f"long_variable_name_{i}": xr.DataArray(
50+
data=data, dims=("time"), attrs=attrs
51+
)
52+
for i in range(count)
53+
}
54+
55+
elif strategy == "dict_of_Variables":
56+
57+
def create_data_vars():
58+
return {
59+
f"long_variable_name_{i}": xr.Variable("time", data, attrs=attrs)
60+
for i in range(count)
61+
}
62+
63+
elif strategy == "dict_of_Tuples":
64+
65+
def create_data_vars():
66+
return {
67+
f"long_variable_name_{i}": ("time", data, attrs)
68+
for i in range(count)
69+
}
70+
71+
self.create_data_vars = create_data_vars
72+
73+
def time_dataset_creation(self, strategy, count):
74+
data_vars = self.create_data_vars()
75+
xr.Dataset(
76+
data_vars=data_vars, coords=self.dataset_coords, attrs=self.dataset_attrs
77+
)

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ Documentation
8181
By `Jimmy Westling <https://github.com/illviljan>`_.
8282
- Add documentation of specific BackendEntrypoints (:pull:`7200`).
8383
By `Michael Niklas <https://github.com/headtr1ck>`_.
84+
- Add examples to docstring for :py:meth:`DataArray.drop_vars`, :py:meth:`DataArray.reindex_like`, :py:meth:`DataArray.interp_like`. (:issue:`6793`, :pull:`7123`)
85+
By `Daniel Goman <https://github.com/DanielGoman>`_.
8486

8587
Internal Changes
8688
~~~~~~~~~~~~~~~~

xarray/backends/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ def open_mfdataset(
916916
>>> lon_bnds, lat_bnds = (-110, -105), (40, 45)
917917
>>> partial_func = partial(_preprocess, lon_bnds=lon_bnds, lat_bnds=lat_bnds)
918918
>>> ds = xr.open_mfdataset(
919-
... "file_*.nc", concat_dim="time", preprocess=_preprocess
919+
... "file_*.nc", concat_dim="time", preprocess=partial_func
920920
... ) # doctest: +SKIP
921921
922922
References

0 commit comments

Comments
 (0)