{"diffoscope-json-version": 1, "source1": "/srv/reproducible-results/rbuild-debian/r-b-build.wiJQ12FD/b1/python-xarray_2025.03.1-8_amd64.changes", "source2": "/srv/reproducible-results/rbuild-debian/r-b-build.wiJQ12FD/b2/python-xarray_2025.03.1-8_amd64.changes", "unified_diff": null, "details": [{"source1": "Files", "source2": "Files", "unified_diff": "@@ -1,3 +1,3 @@\n \n- 1d4f5d95dc59ea8eb1adbca5b6d63c0b 5274756 doc optional python-xarray-doc_2025.03.1-8_all.deb\n+ 54168f92d91c2eac2c9a77632cff3253 5274612 doc optional python-xarray-doc_2025.03.1-8_all.deb\n 290b2f0830b312db0f155225dfe879d5 820184 python optional python3-xarray_2025.03.1-8_all.deb\n"}, {"source1": "python-xarray-doc_2025.03.1-8_all.deb", "source2": "python-xarray-doc_2025.03.1-8_all.deb", "unified_diff": null, "details": [{"source1": "file list", "source2": "file list", "unified_diff": "@@ -1,3 +1,3 @@\n -rw-r--r-- 0 0 0 4 2025-05-05 09:04:03.000000 debian-binary\n--rw-r--r-- 0 0 0 7560 2025-05-05 09:04:03.000000 control.tar.xz\n--rw-r--r-- 0 0 0 5267004 2025-05-05 09:04:03.000000 data.tar.xz\n+-rw-r--r-- 0 0 0 7568 2025-05-05 09:04:03.000000 control.tar.xz\n+-rw-r--r-- 0 0 0 5266852 2025-05-05 09:04:03.000000 data.tar.xz\n"}, {"source1": "control.tar.xz", "source2": "control.tar.xz", "unified_diff": null, "details": [{"source1": "control.tar", "source2": "control.tar", "unified_diff": null, "details": [{"source1": "./control", "source2": "./control", "unified_diff": "@@ -1,13 +1,13 @@\n Package: python-xarray-doc\n Source: python-xarray\n Version: 2025.03.1-8\n Architecture: all\n Maintainer: Debian Science Maintainers Let\u2019s create a simple plot of 2-m air temperature in degrees Celsius: Write equations to calculate the vertical coordinate. These will be only evaluated when data is requested. Information about the ROMS vertical coordinate can be found (here)[https://www.myroms.org/wiki/Vertical_S-coordinate] In short, for The function we will apply is Plot the first timestep: We first have to come up with the weights, - calculate the month length for each monthly data record - calculate weights using Finally, we just need to multiply our weights by the In this example, the logical coordinates are Control the map projection parameters on multiple axes This example illustrates how to plot multiple maps and control their extent and aspect ratio. For more details see this discussion on github. Visualizing your datasets is quick and convenient: Note the automatic labeling with names and units. Our effort in adding metadata attributes has paid off! Many aspects of these figures are customizable: see Plotting.[3]:\n
\n-Error in callback <function _draw_all_if_interactive at 0x7f7079310040> (for post_execute), with arguments args (),kwargs {}:\n+Error in callback <function _draw_all_if_interactive at 0x7f20167c4040> (for post_execute), with arguments args (),kwargs {}:\n \n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -93,15 +93,15 @@\n File /usr/lib/python3/dist-packages/urllib3/connection.py:205, in\n HTTPConnection._new_conn(self)\n 204 except socket.gaierror as e:\n --> 205 raise NameResolutionError(self.host, self, e) from e\n 206 except SocketTimeout as e:\n \n NameResolutionError: Add a lazilly calculated vertical coordinates\u00b6
\n Vtransform==2 as used in this example,np.interp which expects 1D numpy arrays. This functionality is already implemented in xarray so we use that capability to make sure we are not making mistakes.[2]:\n
[3]:\n
[ ]:\n
\n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -92,15 +92,15 @@\n File /usr/lib/python3/dist-packages/urllib3/connection.py:205, in\n HTTPConnection._new_conn(self)\n 204 except socket.gaierror as e:\n --> 205 raise NameResolutionError(self.host, self, e) from e\n 206 except SocketTimeout as e:\n \n NameResolutionError: Now for the heavy lifting:\u00b6
\n groupby('time.season')Dataset and sum along the time dimension. Creating a DataArray for the month length is as easy as using the days_in_month accessor on the time coordinate. The calendar type, in this case 'noleap', is automatically considered in this operation.x and y, while the physical coordinates are xc and yc, which represent the longitudes and latitudes of the data.[3]:\n
Multiple plots and map projections\u00b6
\n <xarray.Dataset> Size: 41kB\n Dimensions: (time: 731, location: 3)\n Coordinates:\n * time (time) datetime64[ns] 6kB 2000-01-01 2000-01-02 ... 2001-12-31\n * location (location) <U2 24B 'IA' 'IN' 'IL'\n Data variables:\n tmin (time, location) float64 18kB -8.037 -1.788 ... -1.346 -4.544\n- tmax (time, location) float64 18kB 12.98 3.31 6.779 ... 3.343 3.805
PandasIndex(Index(['IA', 'IN', 'IL'], dtype='object', name='location'))
Examine a dataset with pandas and seaborn\u00b6
\n Convert to a pandas DataFrame\u00b6
\n [2]:\n@@ -697,15 +697,15 @@\n
[5]:\n
\n-<seaborn.axisgrid.PairGrid at 0x7f8b7a99eba0>\n+<seaborn.axisgrid.PairGrid at 0x7f6a31f5aba0>\n
\n@@ -1110,26 +1110,26 @@\n [0. , 0. , 0. ],\n [0. , 0. , 0. ],\n [0. , 0.01612903, 0. ],\n [0.33333333, 0.35 , 0.23333333],\n [0.93548387, 0.85483871, 0.82258065]])\n Coordinates:\n * location (location) <U2 24B 'IA' 'IN' 'IL'\n- * month (month) int64 96B 1 2 3 4 5 6 7 8 9 10 11 12array(['IA', 'IN', 'IL'], dtype='<U2')
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
PandasIndex(Index(['IA', 'IN', 'IL'], dtype='object', name='location'))
PandasIndex(Index([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], dtype='int64', name='month'))
[7]:\n
freeze.to_pandas().plot()\n
PandasIndex(Index(['IA', 'IN', 'IL'], dtype='object', name='location'))
[12]:\n
df = both.sel(time="2000").mean("location").reset_coords(drop=True).to_dataframe()\n df.head()\n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -142,15 +142,15 @@\n [4]:\n
array(['IA', 'IN', 'IL'], dtype='<U2')
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
PandasIndex(Index(['IA', 'IN', 'IL'], dtype='object', name='location'))
PandasIndex(Index([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], dtype='int64', name='month'))
Plotting\u00b6
\n In [37]: data.plot()\n-Out[37]: <matplotlib.collections.QuadMesh at 0x7f099b2a27b0>\n+Out[37]: <matplotlib.collections.QuadMesh at 0x7f3b8d98e7b0>\n
\n pandas\u00b6
\n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -253,15 +253,15 @@\n [0.37342613, 1.49497537, 1.33584385]])\n Coordinates:\n * x (x) int64 16B 10 20\n Dimensions without coordinates: y\n *\b**\b**\b**\b**\b* P\bPl\blo\bot\btt\bti\bin\bng\bg_\b?\b\u00b6 *\b**\b**\b**\b**\b*\n Visualizing your datasets is quick and convenient:\n In [37]: data.plot()\n-Out[37]: apply_ufunc\", \"Compare weighted and unweighted mean temperature\", \"Blank template\", \"Calculating Seasonal Averages from Time Series of Monthly Means\", \"Working with Multidimensional Coordinates\", \"Visualization Gallery\", \"Toy weather data\", \"Gallery\", \"Frequently Asked Questions\", \"Getting Started\", \"Installation\", \"Quick overview\", \"Overview: Why xarray?\", \"Getting Help\", \"How do I \\u2026\", \"Xarray documentation\", \"Alternative chunked array types\", \"Integrating with duck arrays\", \"Extending xarray using accessors\", \"How to add a new backend\", \"How to create a custom index\", \"Xarray Internals\", \"Internal Design\", \"Interoperability of Xarray\", \"Time Coding\", \"Zarr Encoding Specification\", \"Development roadmap\", \"Tutorials and Videos\", \"Combining data\", \"Computation\", \"Parallel Computing with Dask\", \"Data Structures\", \"Working with numpy-like arrays\", \"GroupBy: Group and Bin Data\", \"Hierarchical data\", \"User Guide\", \"Indexing and selecting data\", \"Interpolating data\", \"Reading and writing files\", \"Configuration\", \"Working with pandas\", \"Plotting\", \"Reshaping and reorganizing data\", \"Terminology\", \"Testing your code\", \"Time series data\", \"Weather and climate data\", \"What\\u2019s New\"],\n \"titleterms\": {\n \"\": [13, 16, 55],\n \"0\": 55,\n \"01\": 55,\n \"02\": 55,\n"}]}, {"source1": "./usr/share/doc/python-xarray-doc/html/user-guide/data-structures.html", "source2": "./usr/share/doc/python-xarray-doc/html/user-guide/data-structures.html", "unified_diff": "@@ -731,18 +731,18 @@\n a method call with an external function (e.g., ds.pipe(func)) instead of\n simply calling it (e.g., func(ds)). This allows you to write pipelines for\n transforming your data (using \u201cmethod chaining\u201d) instead of writing hard to\n follow nested function calls:
# these lines are equivalent, but with pipe we can make the logic flow\n # entirely from left to right\n In [64]: plt.plot((2 * ds.temperature.sel(loc=0)).mean("instrument"))\n-Out[64]: [<matplotlib.lines.Line2D at 0x7f098217afd0>]\n+Out[64]: [<matplotlib.lines.Line2D at 0x7f3b80972e90>]\n \n In [65]: (ds.temperature.sel(loc=0).pipe(lambda x: 2 * x).mean("instrument").pipe(plt.plot))\n-Out[65]: [<matplotlib.lines.Line2D at 0x7f098217ad50>]\n+Out[65]: [<matplotlib.lines.Line2D at 0x7f3b80972c10>]\n Both pipe and assign replicate the pandas methods of the same names\n (DataFrame.pipe and\n DataFrame.assign).
With xarray, there is no performance penalty for creating new datasets, even if\n variables are lazily loaded from a file on disk. Creating new objects instead\n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -585,19 +585,19 @@\n There is also the pipe() method that allows you to use a method call with an\n external function (e.g., ds.pipe(func)) instead of simply calling it (e.g.,\n func(ds)). This allows you to write pipelines for transforming your data (using\n \u201cmethod chaining\u201d) instead of writing hard to follow nested function calls:\n # these lines are equivalent, but with pipe we can make the logic flow\n # entirely from left to right\n In [64]: plt.plot((2 * ds.temperature.sel(loc=0)).mean(\"instrument\"))\n-Out[64]: [ If you were a previous user of the prototype xarray-contrib/datatree package, this is different from what you\u2019re used to!\n In that package the data model was that the data stored in each node actually was completely unrelated. The data model is now slightly stricter.\n This allows us to provide features like Coordinate Inheritance. To demonstrate, let\u2019s first generate some example datasets which are not aligned with one another: To select and assign values to a portion of a You can also assign values to all variables of a Additional keyword arguments can be passed to scipy\u2019s functions. Let\u2019s see how (The suffix To read back a zarr dataset that has been created this way, we use the\n Now, a Zarr store with the correct variable shapes and attributes exists that\n can be filled out by subsequent calls to Concurrent writes with As a safety check to make it harder to inadvertently override existing values,\n if you set Chunk sizes may be specified in one of three ways when writing to a zarr store: For example, let\u2019s say we\u2019re working with a dataset with dimensions\n These multi-dimensional coordinates are only two-dimensional and take up very little\n space on disk or in memory, yet when writing to disk the default zarr behavior is to\n split them into chunks: Ncdata provides more sophisticated means of transferring data, including entire\n datasets. It uses the file saving and loading functions in both projects to provide a\n more \u201ccorrect\u201d translation between them, but still with very low overhead and not\n using actual disk files. For example: For these examples we\u2019ll use the North American air temperature dataset. Same plot can be displayed using the dataset: Now suppose we want to scatter the The You can force a legend instead of a colorbar by setting The The Faceting is also possible And adding the z-axis For more advanced scatter plots, we recommend converting the relevant data variables\n to a pandas DataFrame and using the extensive plotting capabilities of Visualizing vector fields is supported with quiver plots: where Visualizing vector fields is also supported with streamline plots: where To follow this section you\u2019ll need to have Cartopy installed and working. This script will plot the air temperature on a map. The plot will produce an image corresponding to the values of the array.\n Hence the top left pixel will be a different color than the others.\n Before reading on, you may want to look at the coordinates and\n think carefully about what the limits, labels, and orientation for\n each of the axes should be. It may seem strange that\n the values on the y axis are decreasing with -0.5 on the top. This is because\n the pixels are centered over their coordinates, and the\n@@ -1122,57 +1122,57 @@\n .....: np.arange(20).reshape(4, 5),\n .....: dims=["y", "x"],\n .....: coords={"lat": (("y", "x"), lat), "lon": (("y", "x"), lon)},\n .....: )\n .....: \n \n In [139]: da.plot.pcolormesh(x="lon", y="lat")\n-Out[139]: <matplotlib.collections.QuadMesh at 0x7f09dba111d0>\n+Out[139]: <matplotlib.collections.QuadMesh at 0x7f3bc2e3d590>\n Note that in this case, xarray still follows the pixel centered convention.\n This might be undesirable in some cases, for example when your data is defined\n on a polar projection (GH781). This is why the default is to not follow\n this convention when plotting on a map: You can however decide to infer the cell boundaries and use the\n Note The data model of xarray does not support datasets with cell boundaries\n@@ -1180,26 +1180,26 @@\n outside the xarray framework. One can also make line plots with multidimensional coordinates. In this case, Whilst Taking our example tutorial air temperature dataset over the Northern US To see an example of what each of these strategies might produce, you can call one followed by the You can see that calling In your tests however you should not use Xarray\u2019s strategies can accept other strategies as arguments, allowing you to customise the contents of the generated\n examples. This also works with custom strategies, or strategies defined in other packages.\n For example you could imagine creating a If you want to fix one aspect of the data structure, whilst allowing variation in the generated examples\n over all other aspects, then use (This is technically another example of chaining strategies - To fix the length of dimensions you can instead pass You can also use this to specify that you want examples which are missing some part of the data structure, for instance Through a combination of chaining strategies and fixing arguments, you can specify quite complicated requirements on the\n objects your chained strategy will generate. Here we have used one of hypothesis\u2019 built-in strategies Another array API-compliant duck array library would replace the import, e.g. A common task when testing xarray user code is checking that your function works for all valid input dimensions.\n We can chain strategies to achieve this, for which the helper strategy It works for lists of dimension names as well as for mappings of dimension names to sizes This is useful because operations like reductions can be performed over any subset of the xarray object\u2019s dimensions.\n For example we can write a pytest test that tests that a reduction gives the expected result when applying that reduction\n along any possible valid subset of the Variable\u2019s dimensions. New Added new methods # (drop the attributes just to make the printed representation shorter)\n In [89]: ds = xr.tutorial.open_dataset("air_temperature").drop_attrs()\n-ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f0980c62710>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n+ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f3b803125d0>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n \n \n In [90]: ds_daily = ds.resample(time="D").mean("time")\n KeyError: "No variable named 'time'. Variables on the dataset include ['foo', 'x', 'letters']"\n \n \n In [91]: ds_weekly = ds.resample(time="W").mean("time")\n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -871,15 +871,15 @@\n To demonstrate, let\u2019s first generate some example datasets which are not\n aligned with one another:\n # (drop the attributes just to make the printed representation shorter)\n In [89]: ds = xr.tutorial.open_dataset(\"air_temperature\").drop_attrs()\n ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries\n exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by\n NameResolutionError(\"
In [52]: ds = xr.tutorial.open_dataset("air_temperature")\n-ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f0980c62710>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n+ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f3b803125d0>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n \n \n # Define target latitude and longitude (where weather stations might be)\n In [53]: target_lon = xr.DataArray([200, 201, 202, 205], dims="points")\n \n In [54]: target_lat = xr.DataArray([31, 41, 42, 42], dims="points")\n \n@@ -697,15 +697,15 @@\n
Assigning values with indexing\u00b6
\n DataArray() you\n can use indexing with .loc :In [57]: ds = xr.tutorial.open_dataset("air_temperature")\n-ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f0980c61810>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n+ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f3b803116d0>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n \n \n # add an empty 2D dataarray\n In [58]: ds["empty"] = xr.full_like(ds.air.mean("time"), fill_value=0)\n AttributeError: 'Dataset' object has no attribute 'air'\n \n \n@@ -869,15 +869,15 @@\n
Dataset at once:In [83]: ds_org = xr.tutorial.open_dataset("eraint_uvz").isel(\n ....: latitude=slice(56, 59), longitude=slice(255, 258), level=0\n ....: )\n ....: \n-ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/eraint_uvz.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f0980c611d0>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n+ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/eraint_uvz.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f3b80311090>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n \n \n # set all values to 0\n In [84]: ds = xr.zeros_like(ds_org)\n NameError: name 'ds_org' is not defined\n \n \n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -476,15 +476,15 @@\n with a new shared output dimension name. In the example below, the selections\n of the closest latitude and longitude are renamed to an output dimension named\n \u201cpoints\u201d:\n In [52]: ds = xr.tutorial.open_dataset(\"air_temperature\")\n ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries\n exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by\n NameResolutionError(\"
\n \n # fill 0 for the outside of the original coordinates.\n In [21]: da.interp(x=np.linspace(-0.5, 1.5, 10), kwargs={"fill_value": 0.0})\n@@ -439,15 +439,15 @@\n see Missing values.\n \n
Example\u00b6
\n interp() works on real data.# Raw data\n In [44]: ds = xr.tutorial.open_dataset("air_temperature").isel(time=0)\n-ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f09c0c57890>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n+ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f3b8d9bbd90>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n \n \n In [45]: fig, axes = plt.subplots(ncols=2, figsize=(10, 4))\n \n In [46]: ds.air.plot(ax=axes[0])\n AttributeError: 'Dataset' object has no attribute 'air'\n \n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -153,26 +153,26 @@\n ....: np.sin(np.linspace(0, 2 * np.pi, 10)),\n ....: dims=\"x\",\n ....: coords={\"x\": np.linspace(0, 1, 10)},\n ....: )\n ....:\n \n In [17]: da.plot.line(\"o\", label=\"original\")\n-Out[17]: [
.zarr is optional\u2013just a reminder that a zarr store lives\n there.) If the directory does not exist, it will be created. If a zarr\n store is already present at that path, an error will be raised, preventing it\n from being overwritten. To override this behavior and overwrite an existing\n store, add mode='w' when invoking to_zarr().open_zarr() method:In [14]: ds_zarr = xr.open_zarr("path/to/directory.zarr")\n \n In [15]: ds_zarr\n Out[15]: \n <xarray.Dataset> Size: 264B\n-Dimensions: (y: 5, x: 4)\n+Dimensions: (x: 4, y: 5)\n Coordinates:\n- * y (y) datetime64[ns] 40B 2000-01-01 2000-01-02 ... 2000-01-05\n z (x) object 32B dask.array<chunksize=(4,), meta=np.ndarray>\n+ * y (y) datetime64[ns] 40B 2000-01-01 2000-01-02 ... 2000-01-05\n * x (x) int64 32B 10 20 30 40\n Data variables:\n foo (x, y) float64 160B dask.array<chunksize=(4, 5), meta=np.ndarray>\n
Cloud Storage Buckets\u00b6
\n@@ -724,36 +724,36 @@\n \n In [18]: ds = xr.Dataset({"foo": ("x", dummies)}, coords={"x": np.arange(30)})\n \n In [19]: path = "path/to/directory.zarr"\n \n # Now we write the metadata without computing any array values\n In [20]: ds.to_zarr(path, compute=False)\n-Out[20]: Delayed('_finalize_store-dca0f46a-d07f-482a-9fb1-685ac9a9d0fe')\n+Out[20]: Delayed('_finalize_store-ce219574-e6bf-4b08-aaf1-966501061b1f')\n to_zarr.\n Setting region="auto" will open the existing store and determine the\n correct alignment of the new data with the existing dimensions, or as an\n explicit mapping from dimension names to Python slice objects indicating\n where the data should be written (in index space, not label space), e.g.,# For convenience, we'll slice a single dataset, but in the real use-case\n # we would create them separately possibly even from separate processes.\n In [21]: ds = xr.Dataset({"foo": ("x", np.arange(30))}, coords={"x": np.arange(30)})\n \n # Any of the following region specifications are valid\n In [22]: ds.isel(x=slice(0, 10)).to_zarr(path, region="auto")\n-Out[22]: <xarray.backends.zarr.ZarrStore at 0x7f09811b69e0>\n+Out[22]: <xarray.backends.zarr.ZarrStore at 0x7f3b733faa70>\n \n In [23]: ds.isel(x=slice(10, 20)).to_zarr(path, region={"x": "auto"})\n-Out[23]: <xarray.backends.zarr.ZarrStore at 0x7f09811b6680>\n+Out[23]: <xarray.backends.zarr.ZarrStore at 0x7f3b733fa680>\n \n In [24]: ds.isel(x=slice(20, 30)).to_zarr(path, region={"x": slice(20, 30)})\n-Out[24]: <xarray.backends.zarr.ZarrStore at 0x7f09813849d0>\n+Out[24]: <xarray.backends.zarr.ZarrStore at 0x7f3b735c89d0>\n
region are safe as long as they modify distinct\n chunks in the underlying Zarr arrays (or use an appropriate lock).region then all variables included in a Dataset must have\n dimensions included in region. Other variables (typically coordinates)\n@@ -816,28 +816,28 @@\n ....: "y": [1, 2, 3, 4, 5],\n ....: "t": pd.date_range("2001-01-01", periods=2),\n ....: },\n ....: )\n ....: \n \n In [30]: ds1.to_zarr("path/to/directory.zarr")\n-Out[30]: <xarray.backends.zarr.ZarrStore at 0x7f09811b7c70>\n+Out[30]: <xarray.backends.zarr.ZarrStore at 0x7f3b733fbc70>\n \n In [31]: ds2 = xr.Dataset(\n ....: {"foo": (("x", "y", "t"), np.random.rand(4, 5, 2))},\n ....: coords={\n ....: "x": [10, 20, 30, 40],\n ....: "y": [1, 2, 3, 4, 5],\n ....: "t": pd.date_range("2001-01-03", periods=2),\n ....: },\n ....: )\n ....: \n \n In [32]: ds2.to_zarr("path/to/directory.zarr", append_dim="t")\n-Out[32]: <xarray.backends.zarr.ZarrStore at 0x7f09811b7b50>\n+Out[32]: <xarray.backends.zarr.ZarrStore at 0x7f3b733fbd90>\n Specifying chunks in a zarr store\u00b6
\n \n@@ -861,15 +861,15 @@\n positional ordering of the dimensions in each array. Watch out for arrays with\n differently-ordered dimensions within a single Dataset.\n
('time', 'x', 'y'), a variable Tair which is chunked in x and y,\n and two multi-dimensional coordinates xc and yc:In [33]: ds = xr.tutorial.open_dataset("rasm")\n-ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/rasm.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f09812b3390>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n+ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/rasm.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f3b734f7250>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n \n \n In [34]: ds["Tair"] = ds["Tair"].chunk({"x": 100, "y": 100})\n KeyError: "No variable named 'Tair'. Variables on the dataset include ['foo', 'x']"\n \n \n In [35]: ds\n@@ -882,15 +882,15 @@\n foo (x) int64 240B 0 1 2 3 4 5 6 7 8 9 ... 21 22 23 24 25 26 27 28 29\n
In [36]: ds.to_zarr("path/to/directory.zarr", mode="w")\n-Out[36]: <xarray.backends.zarr.ZarrStore at 0x7f098106c0d0>\n+Out[36]: <xarray.backends.zarr.ZarrStore at 0x7f3bc4d200d0>\n \n In [37]: ! ls -R path/to/directory.zarr\n path/to/directory.zarr:\n foo x\tzarr.json\n \n path/to/directory.zarr/foo:\n c zarr.json\n@@ -1081,15 +1081,15 @@\n
Ncdata\u00b6
\n In [48]: ds = xr.tutorial.open_dataset("air_temperature_gradient")\n-ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature_gradient.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f09dd500a50>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n+ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature_gradient.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f3bc4d78910>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n \n \n In [49]: cubes = ncdata.iris_xarray.cubes_from_xarray(ds)\n NameError: name 'ncdata' is not defined\n \n \n In [50]: print(cubes)\n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -481,15 +481,15 @@\n ....: \"y\": pd.date_range(\"2000-01-01\", periods=5),\n ....: \"z\": (\"x\", list(\"abcd\")),\n ....: },\n ....: )\n ....:\n \n In [13]: ds.to_zarr(\"path/to/directory.zarr\")\n-Out[13]:
In [5]: airtemps = xr.tutorial.open_dataset("air_temperature")\n-ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f09dd503d90>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n+ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f3bc4d7a350>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n \n \n In [6]: airtemps\n NameError: name 'airtemps' is not defined\n \n \n # Convert to celsius\n@@ -445,15 +445,15 @@\n \n # Apply a nonlinear transformation to one of the coords\n In [50]: b.coords["lat"] = np.log(b.coords["lat"])\n KeyError: 'lat'\n \n \n In [51]: b.plot()\n-Out[51]: [<matplotlib.lines.Line2D at 0x7f098124fb10>]\n+Out[51]: [<matplotlib.lines.Line2D at 0x7f3bc460f750>]\n
\n \n \n Other types of plot\u00b6
\n@@ -857,117 +857,117 @@\n * y (y) float64 88B 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n * z (z) int64 32B 0 1 2 3\n * w (w) <U5 80B 'one' 'two' 'three' 'five'\n Attributes:\n units: Aunits\n \n In [99]: ds.A.plot.scatter(x="y")\n-Out[99]: <matplotlib.collections.PathCollection at 0x7f0981051550>\n+Out[99]: <matplotlib.collections.PathCollection at 0x7f3b73491160>\n
\n In [100]: ds.plot.scatter(x="y", y="A")\n-Out[100]: <matplotlib.collections.PathCollection at 0x7f09dcca5e50>\n+Out[100]: <matplotlib.collections.PathCollection at 0x7f3bc44d5950>\n
\n A DataArray against the B DataArrayIn [101]: ds.plot.scatter(x="A", y="B")\n-Out[101]: <matplotlib.collections.PathCollection at 0x7f09dcf90a50>\n+Out[101]: <matplotlib.collections.PathCollection at 0x7f3bc4502c10>\n
\n hue kwarg lets you vary the color by variable valueIn [102]: ds.plot.scatter(x="A", y="B", hue="w")\n-Out[102]: <matplotlib.collections.PathCollection at 0x7f09dce6e0d0>\n+Out[102]: <matplotlib.collections.PathCollection at 0x7f3b734f7d90>\n
\n add_legend=True, add_colorbar=False.In [103]: ds.plot.scatter(x="A", y="B", hue="w", add_legend=True, add_colorbar=False)\n-Out[103]: <matplotlib.collections.PathCollection at 0x7f099b51fd90>\n+Out[103]: <matplotlib.collections.PathCollection at 0x7f3b8da0d590>\n
\n In [104]: ds.plot.scatter(x="A", y="B", hue="w", add_legend=False, add_colorbar=True)\n-Out[104]: <matplotlib.collections.PathCollection at 0x7f099b321450>\n+Out[104]: <matplotlib.collections.PathCollection at 0x7f3b8d9ba710>\n
\n markersize kwarg lets you vary the point\u2019s size by variable value.\n You can additionally pass size_norm to control how the variable\u2019s values are mapped to point sizes.In [105]: ds.plot.scatter(x="A", y="B", hue="y", markersize="z")\n-Out[105]: <matplotlib.collections.PathCollection at 0x7f09c0a779d0>\n+Out[105]: <matplotlib.collections.PathCollection at 0x7f3bc4501810>\n
\n z kwarg lets you plot the data along the z-axis as well.In [106]: ds.plot.scatter(x="A", y="B", z="z", hue="y", markersize="x")\n-Out[106]: <mpl_toolkits.mplot3d.art3d.Path3DCollection at 0x7f099b303890>\n+Out[106]: <mpl_toolkits.mplot3d.art3d.Path3DCollection at 0x7f3bc44d51d0>\n
\n In [107]: ds.plot.scatter(x="A", y="B", hue="y", markersize="x", row="x", col="w")\n-Out[107]: <xarray.plot.facetgrid.FacetGrid at 0x7f0981050050>\n+Out[107]: <xarray.plot.facetgrid.FacetGrid at 0x7f3b73493b60>\n
\n In [108]: ds.plot.scatter(x="A", y="B", z="z", hue="y", markersize="x", row="x", col="w")\n-Out[108]: <xarray.plot.facetgrid.FacetGrid at 0x7f09dc5eccd0>\n+Out[108]: <xarray.plot.facetgrid.FacetGrid at 0x7f3bc3e1d6d0>\n
\n seaborn.Quiver\u00b6
\n In [109]: ds.isel(w=1, z=1).plot.quiver(x="x", y="y", u="A", v="B")\n-Out[109]: <matplotlib.quiver.Quiver at 0x7f0980cac1a0>\n+Out[109]: <matplotlib.quiver.Quiver at 0x7f3b734916a0>\n
\n u and v denote the x and y direction components of the arrow vectors. Again, faceting is also possible:In [110]: ds.plot.quiver(x="x", y="y", u="A", v="B", col="w", row="z", scale=4)\n-Out[110]: <xarray.plot.facetgrid.FacetGrid at 0x7f09dc40bd90>\n+Out[110]: <xarray.plot.facetgrid.FacetGrid at 0x7f3bc3c61d10>\n
\n scale is required for faceted quiver plots.\n The scale determines the number of data units per arrow length unit, i.e. a smaller scale parameter makes the arrow longer.Streamplot\u00b6
\n In [111]: ds.isel(w=1, z=1).plot.streamplot(x="x", y="y", u="A", v="B")\n-Out[111]: <matplotlib.collections.LineCollection at 0x7f09dbf92350>\n+Out[111]: <matplotlib.collections.LineCollection at 0x7f3bc426cb90>\n
\n u and v denote the x and y direction components of the vectors tangent to the streamlines.\n Again, faceting is also possible:In [112]: ds.plot.streamplot(x="x", y="y", u="A", v="B", col="w", row="z")\n-Out[112]: <xarray.plot.facetgrid.FacetGrid at 0x7f0980ff15b0>\n+Out[112]: <xarray.plot.facetgrid.FacetGrid at 0x7f3bc49f7bb0>\n
\n Maps\u00b6
\n In [113]: import cartopy.crs as ccrs\n \n In [114]: air = xr.tutorial.open_dataset("air_temperature").air\n-ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f09dc559810>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n+ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f3bc3bce350>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n \n \n In [115]: p = air.isel(time=0).plot(\n .....: subplot_kws=dict(projection=ccrs.Orthographic(-80, 35), facecolor="gray"),\n .....: transform=ccrs.PlateCarree(),\n .....: )\n .....: \n@@ -1024,24 +1024,24 @@\n
In [121]: import xarray.plot as xplt\n \n In [122]: da = xr.DataArray(range(5))\n \n In [123]: fig, axs = plt.subplots(ncols=2, nrows=2)\n \n In [124]: da.plot(ax=axs[0, 0])\n-Out[124]: [<matplotlib.lines.Line2D at 0x7f09db631a90>]\n+Out[124]: [<matplotlib.lines.Line2D at 0x7f3bc30e5f90>]\n \n In [125]: da.plot.line(ax=axs[0, 1])\n-Out[125]: [<matplotlib.lines.Line2D at 0x7f09db631950>]\n+Out[125]: [<matplotlib.lines.Line2D at 0x7f3bc30e60d0>]\n \n In [126]: xplt.plot(da, ax=axs[1, 0])\n-Out[126]: [<matplotlib.lines.Line2D at 0x7f09db631f90>]\n+Out[126]: [<matplotlib.lines.Line2D at 0x7f3bc30e6210>]\n \n In [127]: xplt.line(da, ax=axs[1, 1])\n-Out[127]: [<matplotlib.lines.Line2D at 0x7f09db6325d0>]\n+Out[127]: [<matplotlib.lines.Line2D at 0x7f3bc30e6350>]\n \n In [128]: plt.tight_layout()\n \n In [129]: plt.draw()\n
\n@@ -1091,15 +1091,15 @@\n In [134]: a.plot()\n-Out[134]: <matplotlib.collections.QuadMesh at 0x7f09db8e9450>\n+Out[134]: <matplotlib.collections.QuadMesh at 0x7f3bc3859f90>\n
\n \n
\n \n In [140]: import cartopy.crs as ccrs\n \n In [141]: ax = plt.subplot(projection=ccrs.PlateCarree())\n \n In [142]: da.plot.pcolormesh(x="lon", y="lat", ax=ax)\n-Out[142]: <cartopy.mpl.geocollection.GeoQuadMesh at 0x7f09db9b3ed0>\n+Out[142]: <cartopy.mpl.geocollection.GeoQuadMesh at 0x7f3bc32791d0>\n \n In [143]: ax.scatter(lon, lat, transform=ccrs.PlateCarree())\n-Out[143]: <matplotlib.collections.PathCollection at 0x7f09dba7fed0>\n+Out[143]: <matplotlib.collections.PathCollection at 0x7f3bc30e7b10>\n \n In [144]: ax.coastlines()\n-Out[144]: <cartopy.mpl.feature_artist.FeatureArtist at 0x7f0981050590>\n+Out[144]: <cartopy.mpl.feature_artist.FeatureArtist at 0x7f3b80358440>\n \n In [145]: ax.gridlines(draw_labels=True)\n-Out[145]: <cartopy.mpl.gridliner.Gridliner at 0x7f0982fddd30>\n+Out[145]: <cartopy.mpl.gridliner.Gridliner at 0x7f3b80358830>\n
\n \n infer_intervals keyword:In [146]: ax = plt.subplot(projection=ccrs.PlateCarree())\n \n In [147]: da.plot.pcolormesh(x="lon", y="lat", ax=ax, infer_intervals=True)\n-Out[147]: <cartopy.mpl.geocollection.GeoQuadMesh at 0x7f09dc166e90>\n+Out[147]: <cartopy.mpl.geocollection.GeoQuadMesh at 0x7f3bc334ac10>\n \n In [148]: ax.scatter(lon, lat, transform=ccrs.PlateCarree())\n-Out[148]: <matplotlib.collections.PathCollection at 0x7f09db705a90>\n+Out[148]: <matplotlib.collections.PathCollection at 0x7f3bc3c78690>\n \n In [149]: ax.coastlines()\n-Out[149]: <cartopy.mpl.feature_artist.FeatureArtist at 0x7f09db705950>\n+Out[149]: <cartopy.mpl.feature_artist.FeatureArtist at 0x7f3bc3c787d0>\n \n In [150]: ax.gridlines(draw_labels=True)\n-Out[150]: <cartopy.mpl.gridliner.Gridliner at 0x7f09db705f90>\n+Out[150]: <cartopy.mpl.gridliner.Gridliner at 0x7f3bc3c78a50>\n
\n \n hue must be a dimension name, not a coordinate name.In [151]: f, ax = plt.subplots(2, 1)\n \n In [152]: da.plot.line(x="lon", hue="y", ax=ax[0])\n Out[152]: \n-[<matplotlib.lines.Line2D at 0x7f09dbf9d590>,\n- <matplotlib.lines.Line2D at 0x7f09dbf9e210>,\n- <matplotlib.lines.Line2D at 0x7f09dbf2ccd0>,\n- <matplotlib.lines.Line2D at 0x7f09dbfb8b90>]\n+[<matplotlib.lines.Line2D at 0x7f3bc3974cd0>,\n+ <matplotlib.lines.Line2D at 0x7f3bc3974b90>,\n+ <matplotlib.lines.Line2D at 0x7f3bc3974a50>,\n+ <matplotlib.lines.Line2D at 0x7f3bc3975090>]\n \n In [153]: da.plot.line(x="lon", hue="x", ax=ax[1])\n Out[153]: \n-[<matplotlib.lines.Line2D at 0x7f09dbfbb390>,\n- <matplotlib.lines.Line2D at 0x7f09dbfbb250>,\n- <matplotlib.lines.Line2D at 0x7f09dbfbb110>,\n- <matplotlib.lines.Line2D at 0x7f09dbfb8190>,\n- <matplotlib.lines.Line2D at 0x7f09dbfb8050>]\n+[<matplotlib.lines.Line2D at 0x7f3bc3983110>,\n+ <matplotlib.lines.Line2D at 0x7f3bc3982fd0>,\n+ <matplotlib.lines.Line2D at 0x7f3bc3982e90>,\n+ <matplotlib.lines.Line2D at 0x7f3bc3982d50>,\n+ <matplotlib.lines.Line2D at 0x7f3bc3982c10>]\n
\n Reshaping via coarsen\u00b6
\n coarsen is normally used for reducing your data\u2019s resolution by applying a reduction function\n (see the page on computation),\n it can also be used to reorganise your data without applying a computation via construct().In [56]: air = xr.tutorial.open_dataset("air_temperature")["air"]\n-ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f09dbf9d1d0>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n+ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f3bc3977b10>: Failed to resolve 'github.com' ([Errno -3] Temporary failure in name resolution)"))\n \n \n In [57]: air.isel(time=0).plot(x="lon", y="lat")\n NameError: name 'air' is not defined\n
\n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -442,15 +442,15 @@\n a reduction function (see the _\bp_\ba_\bg_\be_\b _\bo_\bn_\b _\bc_\bo_\bm_\bp_\bu_\bt_\ba_\bt_\bi_\bo_\bn), it can also be used to\n reorganise your data without applying a computation via construct().\n Taking our example tutorial air temperature dataset over the Northern US\n In [56]: air = xr.tutorial.open_dataset(\"air_temperature\")[\"air\"]\n ConnectionError: HTTPSConnectionPool(host='github.com', port=443): Max retries\n exceeded with url: /pydata/xarray-data/raw/master/air_temperature.nc (Caused by\n NameResolutionError(\"Generating Examples\u00b6
\n .example() method,\n which is a general hypothesis method valid for all strategies.In [2]: import xarray.testing.strategies as xrst\n \n In [3]: xrst.variables().example()\n Out[3]: \n-<xarray.Variable (O\u0108u\u00e5\u012f: 2, \u011c: 6)> Size: 12B\n-array([[241, 68, 235, 217, 21, 91],\n- [153, 140, 208, 175, 42, 189]], shape=(2, 6), dtype=uint8)\n+<xarray.Variable (0: 1)> Size: 8B\n+array([0.+0.j], dtype=complex64)\n \n In [4]: xrst.variables().example()\n Out[4]: \n-<xarray.Variable (\u017b: 3, P: 5, \u014d\u017e: 2)> Size: 60B\n-array([[[ 10520, 11759],\n- [ 13423, -13318],\n- [ 13423, -31480],\n- [-25022, 13423],\n- [-27367, 15001]],\n-\n- [[ 13423, 13423],\n- [-25508, 32766],\n- [ 13423, 31390],\n- [-11856, -13222],\n- [ 13423, -9107]],\n-\n- [[ 7687, -14898],\n- [-25949, 21830],\n- [ 13423, 13423],\n- [-22643, 13423],\n- [ 13423, 13423]]], shape=(3, 5, 2), dtype=int16)\n+<xarray.Variable (\u017d\u017bQ\u0100\u00c9: 2, \u015b\u017e\u013f: 2)> Size: 4B\n+array([[138, 138],\n+ [ 81, 191]], dtype=uint8)\n Attributes:\n- S: {'\u0114\u0151\u00de2\u00e2': array(['\\x1a\u00f8\u00d6\u00c1\\x8f\\U000e6328\\xa0\\x98\\U00054f7ax\u00f9\\U00...\n- : {'\u017d\u00ec\u011a\u0113\u0119': array([['NaT'],\\n ['NaT']], dtype='>M8[us]'), '...\n- I\u0168f: {'\u00e4\u0153\u014bo': '\u0166\u017c', '\u0101Y': None, '\u0152\u017c\u0149\u017d\u00d0': array([[b'N%\\x9b;\\x05-\\t\\xa...\n+ \u017e\u00bc: [['\u00fb\ud862\udde6\u00a8' '\\x88\\U000dc243\\U00070d58']\\n ['\\U0001a9b27\\x10' '\\U001...\n+ : True\n+ \u017e\u017ep: None\n+ \u00fe\u015c: [b'' b'\\x9d']\n \n In [5]: xrst.variables().example()\n Out[5]: \n-<xarray.Variable (\u0148: 2, \u00d6e\u00e59K: 6, \u0122\u0179\u017c\u017e\u00f6: 4)> Size: 48B\n-array([[[255, 255, 65, 79],\n- [167, 255, 255, 255],\n- [ 66, 255, 156, 206],\n- [239, 60, 255, 135],\n- [255, 255, 255, 255],\n- [255, 255, 255, 151]],\n-\n- [[255, 255, 110, 132],\n- [255, 135, 17, 116],\n- [ 52, 255, 64, 100],\n- [255, 211, 254, 255],\n- [ 94, 113, 255, 255],\n- [255, 255, 255, 255]]], shape=(2, 6, 4), dtype=uint8)\n-Attributes:\n- \u010c: {'\u017e\u00e5\u00f0\u00d8\u0173': array([['NaT']], dtype='timedelta64[ns]'), '\u00b9\u0100U6': ar...\n+<xarray.Variable (0: 1)> Size: 1B\n+array([0], dtype=int8)\n
.example() multiple times will generate different examples, giving you an idea of the wide\n range of data that the xarray strategies can generate..example() - instead you should parameterize your tests with the\n hypothesis.given() decorator:In [6]: from hypothesis import given\n@@ -156,84 +127,70 @@\n
# generate a Variable containing an array with a complex number dtype, but all other details still arbitrary\n In [8]: from hypothesis.extra.numpy import complex_number_dtypes\n \n In [9]: xrst.variables(dtype=complex_number_dtypes()).example()\n Out[9]: \n-<xarray.Variable (\u00d6: 2, g\u0142: 1, \u00f86\u00e7\u0176: 4)> Size: 64B\n-array([[[ 1.1 -infj, nan +nanj, nan+5.00e-01j, -0. +2.22e-16j]],\n-\n- [[-0. +2.22e-16j, nan-5.96e-08j, -0. -1.90e+00j, -0. +2.22e-16j]]], dtype='>c8')\n-Attributes:\n- \u00b3: None\n- \u013e\u0141\u017f\u017c\u017b: None\n- \u0158\u017c\u017fw: True\n- : \u017c\u00d0o\n+<xarray.Variable (j\u0109\u00ec: 2, \u0165: 3, \u017b\u0152: 5)> Size: 480B\n+array([[[ 3.333e-001 +nanj, 3.333e-001 +nanj, 3.333e-001 +nanj,\n+ 3.333e-001 +nanj, 3.333e-001 +nanj],\n+ [ 3.333e-001 +nanj, 1.798e+308+1.900e+000j, 3.333e-001 +nanj,\n+ 3.333e-001 +nanj, 3.333e-001 +nanj],\n+ [ 3.333e-001 +nanj, inf+1.113e-308j, 3.333e-001 +nanj,\n+ 3.333e-001 +nanj, 3.333e-001 +nanj]],\n+\n+ [[-7.204e+016 +nanj, 3.333e-001 +nanj, 3.333e-001 +nanj,\n+ 3.333e-001 +nanj, 3.333e-001 +nanj],\n+ [ 3.333e-001 +nanj, 2.220e-016-1.620e+016j, nan +nanj,\n+ 3.333e-001 +nanj, inf-3.333e-001j],\n+ [ 3.333e-001 +nanj, 3.333e-001 +nanj, 3.333e-001 +nanj,\n+ 3.333e-001 +nanj, 3.333e-001 +nanj]]], shape=(2, 3, 5), dtype='>c16')\n
chunks strategy to specify particular chunking patterns for a dask-backed array.Fixing Arguments\u00b6
\n hypothesis.strategies.just().In [10]: import hypothesis.strategies as st\n \n # Generates only variable objects with dimensions ["x", "y"]\n In [11]: xrst.variables(dims=st.just(["x", "y"])).example()\n Out[11]: \n-<xarray.Variable (x: 4, y: 1)> Size: 16B\n-array([[0.000e+00],\n- [6.601e+16],\n- [0.000e+00],\n- [1.000e-05]], dtype=float32)\n+<xarray.Variable (x: 2, y: 1)> Size: 4B\n+array([[53800],\n+ [25368]], dtype=uint16)\n Attributes:\n- \u00bd\u016f\u017ci\u017f: {}\n- C\u00fb\u0157: {'F\u0130\u011b': False}\n+ \u00ed\u00f1\u0138: False\n+ \u00c8\u0158: \u017f\u00ba\u017f\u0123\u016c\n+ Y: True\n
hypothesis.strategies.just() is simply a\n special strategy that just contains a single example.)dims as a mapping of dimension names to lengths\n (i.e. following xarray objects\u2019 .sizes() property), e.g.# Generates only variables with dimensions ["x", "y"], of lengths 2 & 3 respectively\n In [12]: xrst.variables(dims=st.just({"x": 2, "y": 3})).example()\n Out[12]: \n <xarray.Variable (x: 2, y: 3)> Size: 12B\n-array([[16348, 16348, 915],\n- [ -932, 8699, 16348]], dtype=int16)\n-Attributes: (12/13)\n- \u013dLk\u017b\u017e: \n- a: ['\\U000414aa\\x15\\U000ff8eb\u00e0\u00e5']\n- null: True\n- \u00ce\u00c9\u0137: \u017c\u017c\n- \u00eb\u00df: [[b'b']]\n- : \n- ... ...\n- true: None\n- 1P\u017f\u015cK: False\n- \u010d\u014dp\u0171: [b'&^C' b'\\xecN\\x9b\\\\\\xd9\\x06\\xebg\\x89']\n- \u0171\u0149\u0114: None\n- \u00ce\u0137\u00fa\u017d: [[b'' b'\\xe4']]\n- \u017d\u00ee\u0115M: None\n+array([[0., 0., 0.],\n+ [0., 0., 0.]], dtype=float16)\n
# Generates a Variable with no attributes\n In [13]: xrst.variables(attrs=st.just({})).example()\n Out[13]: \n-<xarray.Variable (\u0152A\u017c\u00ca\u0123: 6, \u0155\u00cb\u00ec\u0120g: 3)> Size: 36B\n-array([[ 0.000e+00, inf, inf],\n- [ nan, nan, -1.192e-07],\n- [-1.192e-07, -6.104e-05, -inf],\n- [-2.000e+00, 0.000e+00, nan],\n- [ 0.000e+00, -1.100e+00, 5.960e-08],\n- [ 0.000e+00, -inf, 0.000e+00]], shape=(6, 3), dtype=float16)\n+<xarray.Variable (\u014e: 5)> Size: 80B\n+array([3.909e+16-1.261e-270j, 3.909e+16-1.261e-270j, 3.909e+16-1.261e-270j, 3.909e+16-1.261e-270j,\n+ 3.909e+16-1.261e-270j])\n
In [14]: fixed_x_variable_y_maybe_z = st.fixed_dictionaries(\n ....: {"x": st.just(2), "y": st.integers(3, 4)}, optional={"z": st.just(2)}\n ....: )\n@@ -242,26 +199,44 @@\n In [15]: fixed_x_variable_y_maybe_z.example()\n Out[15]: {'x': 2, 'y': 4}\n \n In [16]: special_variables = xrst.variables(dims=fixed_x_variable_y_maybe_z)\n \n In [17]: special_variables.example()\n Out[17]: \n-<xarray.Variable (x: 2, y: 4)> Size: 16B\n-array([[ 1.900e+00, 6.104e-05, inf, 0.000e+00],\n- [ -inf, -inf, nan, -1.500e+00]], dtype=float16)\n-Attributes:\n- \u00cb1S\u0122\u017c: None\n- \u017f\u0156\u017c\u0146\u014e: True\n+<xarray.Variable (x: 2, y: 3, z: 2)> Size: 24B\n+array([[[26442, 33322],\n+ [65534, 50204],\n+ [32377, 1603]],\n+\n+ [[63087, 31914],\n+ [28160, 54842],\n+ [22705, 64501]]], shape=(2, 3, 2), dtype=uint16)\n+Attributes: (12/19)\n+ \u00cc: [[b'' b'']]\n+ \u0155\u017fz\u0163: True\n+ \u017e: None\n+ \u017bQ\u013c\u017b\u013c: [-1.192e-07 +nanj 2.000e+00+5.96e-08j]\n+ if: \u00c8\u00e5\u0118\n+ \u0110\u0103\u011b\u00fc\u00e6: [[44055 20317]\\n [14596 44055]]\n+ ... ...\n+ \u012f\u014e: True\n+ \u014c: True\n+ \u017c\u017e\u0113: None\n+ \u00db\u017bH\u017e\u0111: [[b'\\xb9']]\n+ 0: \u013e\u013f\n+ \u0101\u017e\u00c3: False\n \n In [18]: special_variables.example()\n Out[18]: \n-<xarray.Variable (x: 2, y: 3)> Size: 48B\n-array([[0.+0.j, 0.+0.j, 0.+0.j],\n- [0.+0.j, 0.+0.j, 0.+0.j]], dtype=complex64)\n+<xarray.Variable (x: 2, y: 3)> Size: 24B\n+array([[ 2147483647, -2147483627, 258452228],\n+ [-2147483576, -2147419656, -774267279]], dtype=int32)\n+Attributes:\n+ : {'\u017cS\u0160\u00c5': '\u00cb\u00d2'}\n
hypothesis.strategies.fixed_dictionaries() to create a\n strategy which generates mappings of dimension names to lengths (i.e. the size of the xarray object we want).\n This particular strategy will always generate an x dimension of length 2, and a y dimension of\n length either 3 or 4, and will sometimes also generate a z dimension of length 2.\n By feeding this strategy for dictionaries into the dims argument of xarray\u2019s variables() strategy,\n@@ -362,50 +337,89 @@\n ....: array_strategy_fn=xps.arrays,\n ....: dtype=xps.scalar_dtypes(),\n ....: )\n ....: \n \n In [32]: xp_variables.example()\n Out[32]: \n-<xarray.Variable (\u0163: 6, \u017fN\u00d0g\u017f: 1)> Size: 12B\n-array([[35938],\n- [ 8015],\n- [45245],\n- [65534],\n- [33527],\n- [14542]], dtype=uint16)\n+<xarray.Variable (\u017c\u017dvl: 3, \u00b9\u00e0\u00e1: 6, \u0158\u017es\u017d\u00ee: 4)> Size: 576B\n+array([[[-1.175e-38+9.007e+15j, -1.000e+00-2.000e+00j, -5.000e-01-9.007e+15j,\n+ -1.900e+00-3.671e+16j],\n+ [ nan+6.104e-05j, nan+6.104e-05j, nan+6.104e-05j,\n+ nan+6.104e-05j],\n+ [ nan+6.104e-05j, nan+6.104e-05j, nan+6.104e-05j,\n+ -5.960e-08+1.175e-38j],\n+ [ nan+6.104e-05j, nan+6.104e-05j, nan+6.104e-05j,\n+ 2.000e+00+1.000e-05j],\n+ [ nan+6.104e-05j, nan+6.104e-05j, nan+6.104e-05j,\n+ nan+6.104e-05j],\n+ [-3.603e+16+1.790e+22j, nan+6.104e-05j, -inf+0.000e+00j,\n+ nan+6.104e-05j]],\n+\n+ [[ 1.000e-05-1.900e+00j, nan+6.104e-05j, nan+6.104e-05j,\n+ nan+6.104e-05j],\n+ [-0.000e+00-0.000e+00j, -1.733e+16 +nanj, nan+6.104e-05j,\n+ nan+6.104e-05j],\n+ [-1.175e-38 +nanj, 0.000e+00 +infj, nan+6.104e-05j,\n+ nan+6.104e-05j],\n+ [ nan+6.104e-05j, -inf +nanj, nan+6.104e-05j,\n+ -1.100e+00 +infj],\n+ [ nan+6.104e-05j, -1.000e+07-1.401e-45j, 1.401e-45 -infj,\n+ -0.000e+00+0.000e+00j],\n+ [ nan+6.104e-05j, 2.220e-16-0.000e+00j, nan+6.104e-05j,\n+ 0.000e+00 +nanj]],\n+\n+ [[ nan+6.104e-05j, nan+6.104e-05j, -2.000e+00+1.192e-07j,\n+ -inf+3.403e+38j],\n+ [-3.333e-01 +infj, nan+6.104e-05j, nan+6.104e-05j,\n+ nan+6.104e-05j],\n+ [ nan+6.104e-05j, nan +nanj, inf+1.500e+00j,\n+ -1.175e-38-2.391e+16j],\n+ [ nan+6.104e-05j, inf-1.900e+00j, nan+6.104e-05j,\n+ 0.000e+00 +nanj],\n+ [ nan+6.104e-05j, nan+6.104e-05j, nan+1.000e-05j,\n+ nan+6.104e-05j],\n+ [ inf-4.681e+16j, -1.500e+00-0.000e+00j, 2.364e+16+0.000e+00j,\n+ nan+6.104e-05j]]], shape=(3, 6, 4), dtype=complex64)\n Attributes:\n- FL: {'\u00f2\u00f4\u00ca': None, '\u015f\u010e\u0155\u015e\u016e': array([['^\u00e1\u00dcI\\x14\u00be\u00d8\\U000657ac\\x0bLh']], ...\n+ \u017a: None\n+ \u00e7\u00d0U\u00e1\u00df: True\n+ \u0108\u00c8\u00d8\u017b: True\n+ n\u0156\u00f2: [b'v\\xd0\\x96\\xa3\\x16' b'TP\\xc1|']\n+ : \u00df\n+ \u017f\u0118\u015a\u0154\u0130: True\n+ \u017a\u014e: True\n+ \u01337\u0133\u017f\u017b: [[-9223372036854756294]\\n [ 'NaT']]\n import cupy as cp instead.Testing over Subsets of Dimensions\u00b6
\n unique_subset_of()\n is useful.In [33]: dims = ["x", "y", "z"]\n \n In [34]: xrst.unique_subset_of(dims).example()\n-Out[34]: ['x', 'z', 'y']\n+Out[34]: ['y']\n \n In [35]: xrst.unique_subset_of(dims).example()\n-Out[35]: ['x', 'z', 'y']\n+Out[35]: ['z', 'y', 'x']\n
In [36]: dim_sizes = {"x": 2, "y": 3, "z": 4}\n \n In [37]: xrst.unique_subset_of(dim_sizes).example()\n-Out[37]: {'x': 2, 'y': 3}\n+Out[37]: {'y': 3, 'z': 4, 'x': 2}\n \n In [38]: xrst.unique_subset_of(dim_sizes).example()\n-Out[38]: {'x': 2, 'z': 4, 'y': 3}\n+Out[38]: {'y': 3, 'z': 4}\n
import numpy.testing as npt\n \n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -28,65 +28,33 @@\n To see an example of what each of these strategies might produce, you can call\n one followed by the .example() method, which is a general hypothesis method\n valid for all strategies.\n In [2]: import xarray.testing.strategies as xrst\n \n In [3]: xrst.variables().example()\n Out[3]:\n-
xray.Dataset.where method for masking xray objects according\n to some criteria. This works particularly well with multi-dimensional data:In [45]: ds = xray.Dataset(coords={"x": range(100), "y": range(100)})\n \n In [46]: ds["distance"] = np.sqrt(ds.x**2 + ds.y**2)\n \n In [47]: ds.distance.where(ds.distance < 100).plot()\n-Out[47]: <matplotlib.collections.QuadMesh at 0x7f0981209bd0>\n+Out[47]: <matplotlib.collections.QuadMesh at 0x7f3bc3980a50>\n
\n \n xray.DataArray.diff and xray.Dataset.diff\n for finite difference calculations along a given axis.