Skip to content

Commit 88c3a2a

Browse files
authored
Document the 1.x stability policy, 0.x to 1.0 migration, and the .xrs accessor (#3761)
* Document the 1.x semver and deprecation policy, add the 0.x to 1.0 migration page and accessor reference (#3760) * Pin the deprecated-since column to the release that added each warning (#3760) * Add the accessor spellings of the basins and crop aliases to the migration table (#3760)
1 parent 50cdaee commit 88c3a2a

7 files changed

Lines changed: 182 additions & 11 deletions

File tree

‎docs/source/reference/accessor.rst‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. _reference.accessor:
2+
3+
*********************
4+
The ``.xrs`` accessor
5+
*********************
6+
7+
``import xrspatial`` registers an ``xrs`` accessor on ``xarray.DataArray``
8+
and ``xarray.Dataset``. Every method forwards to the top-level function of
9+
the same name with the array as the first argument, so
10+
``dem.xrs.slope()`` is ``xrspatial.slope(dem)``.
11+
12+
The accessor is part of the 1.x LTS surface (see
13+
:ref:`user_guide.stability_policy`). Methods that forward to
14+
``xrspatial.experimental`` say so in their docstring and are not covered.
15+
16+
.. code-block:: python
17+
18+
import xrspatial
19+
20+
dem = xrspatial.open_geotiff("dem.tif")
21+
dem.xrs.slope()
22+
dem.xrs.hillshade().xrs.to_geotiff("hillshade.tif")
23+
24+
DataArray accessor
25+
==================
26+
27+
.. autoclass:: xrspatial.accessor.XrsSpatialDataArrayAccessor
28+
:members:
29+
:undoc-members:
30+
31+
Dataset accessor
32+
================
33+
34+
.. autoclass:: xrspatial.accessor.XrsSpatialDatasetAccessor
35+
:members:
36+
:undoc-members:

‎docs/source/reference/geotiff_release_contract.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ deprecation window. You can rely on these in production.
2626

2727
### advanced
2828

29-
An `advanced` feature works and is tested, but its surface may change before a
30-
1.0 release. Behaviour is documented and exercised by tests, but the contract is
31-
narrower than `stable`. Edge cases on rare codecs, transport quirks on HTTP, and
29+
An `advanced` feature works and is tested, and its function signature is
30+
covered by the 1.x LTS promise, but the behavioural contract is narrower than
31+
`stable` and edge-case behaviour may change in a minor release. Behaviour is
32+
documented and exercised by tests. Edge cases on rare codecs, transport quirks on HTTP, and
3233
metadata interop with the wider GDAL ecosystem are not all pinned down. Use
3334
these in production with the expectation that you may need to follow a
3435
release-note migration.

‎docs/source/reference/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Reference
77
.. toctree::
88
:maxdepth: 2
99

10+
accessor
1011
dask_laziness
1112
classification
1213
dasymetric

‎docs/source/user_guide/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ User Guide
2121
attrs_contract
2222
geotiff_safe_io
2323
local-migration
24+
migration_1_0
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.. _migration_1_0:
2+
3+
**********************************
4+
Migrating from 0.x to 1.0
5+
**********************************
6+
7+
xarray-spatial 1.0.0 removes the keyword and function aliases that 0.10.x had
8+
deprecated. Each one warned with a ``DeprecationWarning`` that named its
9+
replacement; from 1.0.0 the old spelling raises ``TypeError`` (for keyword
10+
arguments) or ``AttributeError`` / ``ImportError`` (for functions).
11+
12+
Everything else on the public surface is unchanged. If your code ran on
13+
0.10.20 without warnings, it runs on 1.0.0.
14+
15+
Removed aliases
16+
===============
17+
18+
.. list-table::
19+
:header-rows: 1
20+
:widths: 40 40 20
21+
22+
* - Removed in 1.0.0
23+
- Use instead
24+
- Deprecated since
25+
* - ``xrspatial.basins`` / ``xrspatial.hydro.basins`` / ``basins_d8`` / ``.xrs.basins()``
26+
- ``basin`` / ``basin_d8`` / ``.xrs.basin()``
27+
- 0.10.2
28+
* - ``crop(zones_ids=...)`` and ``.xrs.crop(zones, zones_ids=...)``
29+
- ``crop(zone_ids=...)`` / ``.xrs.crop(zones, zone_ids=...)``
30+
- 0.10.1
31+
* - ``focal.apply(raster=...)`` and ``hotspots(raster=...)``
32+
- ``agg=``
33+
- 0.10.2
34+
* - ``natural_breaks(agg, k, name, num_sample)`` positional ``num_sample``
35+
- ``natural_breaks(agg, k, num_sample=...)``
36+
- 0.10.11
37+
* - ``rasterize(use_cuda=...)``
38+
- ``rasterize(gpu=...)``
39+
- 0.10.7
40+
* - ``reproject(src_vertical_crs=..., tgt_vertical_crs=...)``
41+
- ``source_vertical_crs=``, ``target_vertical_crs=``
42+
- 0.10.2
43+
* - ``open_geotiff(mask_nodata=...)``
44+
- ``open_geotiff(masked=...)``. Note the default is ``False``.
45+
- 0.10.5
46+
* - ``open_geotiff(name=...)``
47+
- ``open_geotiff(default_name=...)``
48+
- 0.10.5
49+
* - ``open_geotiff(mask_and_scale=...)``
50+
- ``open_geotiff(unpack=...)``
51+
- 0.10.7
52+
* - ``plot_geotiff(...)``
53+
- ``da.xrs.plot(...)``
54+
- 0.10.0
55+
* - ``owa(criterion_weights=...)``
56+
- ``owa(weights=...)``
57+
- 0.10.7
58+
59+
Two private helpers also lost old spellings: the VRT writer's ``vrt_path=``
60+
and ``crs_wkt=`` (now ``path=`` and ``crs=``) and the GPU reader's
61+
``gpu='auto'`` / ``gpu='strict'`` (now ``on_gpu_failure=``). Neither was
62+
part of the public surface; ``open_geotiff`` takes ``gpu=True`` and
63+
``on_gpu_failure='auto'|'strict'`` as before.
64+
65+
Finding the old spellings
66+
=========================
67+
68+
Run your test suite on 0.10.20 with warnings turned into errors:
69+
70+
.. code-block:: bash
71+
72+
python -W error::DeprecationWarning -m pytest
73+
74+
Every failure points at a line in the table above.
75+
76+
See the :ref:`stability policy <user_guide.stability_policy>` for how
77+
deprecations work from 1.0 on.

‎docs/source/user_guide/stability_policy.rst‎

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,64 @@ Stability policy and LTS commitment
44
===================================
55

66
This page states which parts of xarray-spatial are covered by long-term
7-
support (LTS) in the 1.0.0 series, and what "stable" means here.
7+
support (LTS) in the 1.x series, how deprecations work, and what "stable"
8+
means here.
9+
10+
Versioning
11+
----------
12+
13+
xarray-spatial follows semantic versioning from 1.0.0 on.
14+
15+
- Patch releases (1.0.1, 1.0.2, ...) fix bugs and do not change behaviour
16+
for documented inputs.
17+
- Minor releases (1.1.0, 1.2.0, ...) may add functions, add optional keyword
18+
arguments, promote a function to a higher tier, raise a dependency floor,
19+
and deprecate names. They do not remove or rename anything on the LTS
20+
surface.
21+
- Major releases (2.0.0) are the only place where deprecated names are
22+
removed or where a documented contract changes incompatibly.
823

924
What LTS covers
1025
---------------
1126

12-
The high-level public spellings are the LTS surface: the names exported from
13-
``xrspatial/__init__.py`` and the ``.xrs`` accessor on
14-
``xarray.DataArray`` and ``xarray.Dataset``. Within the 1.0.x series these
15-
names, their call signatures, and their documented return contracts do not
16-
change in backward-incompatible ways. New optional keyword arguments may be
17-
added; existing behavior for documented inputs is preserved.
27+
The high-level public spellings are the LTS surface:
28+
29+
- every name listed in ``xrspatial.__all__`` (the names you get from
30+
``import xrspatial``),
31+
- the public names of the ``xrspatial.mcda`` subpackage,
32+
- the ``.xrs`` accessor on ``xarray.DataArray`` and ``xarray.Dataset`` (see
33+
:ref:`reference.accessor`).
34+
35+
For the whole 1.x series these names, their call signatures, and their
36+
documented return contracts do not change in backward-incompatible ways.
37+
New optional keyword arguments may be added; existing behaviour for
38+
documented inputs is preserved.
39+
40+
Functions that live only in a submodule (for example
41+
``xrspatial.experimental.min_observable_height``) and anything with a leading
42+
underscore are not part of the LTS surface and may change in a minor release.
43+
44+
Deprecation window
45+
------------------
46+
47+
When a name or keyword argument on the LTS surface is replaced:
48+
49+
1. The old spelling keeps working and emits a ``DeprecationWarning`` that
50+
names the replacement and the release that will remove it.
51+
2. The warning ships in at least one minor release before removal.
52+
3. Removal happens in the next major release, never in a minor or patch.
53+
54+
The 0.x aliases that 1.0.0 removed are listed on the
55+
:ref:`migration_1_0` page.
56+
57+
Dependencies
58+
------------
59+
60+
The minimum supported Python and dependency versions are the ones pinned in
61+
the ``min-deps`` job of the test workflow. Raising a floor is a minor-release
62+
change and is called out in the changelog. The package declares an upper
63+
bound on NumPy only; new NumPy minors are tested and the bound lifted in a
64+
patch or minor release.
1865

1966
What "stable" requires
2067
----------------------
@@ -34,3 +81,11 @@ Tiers below stable
3481
caveats or make no cross-backend parity claim. GPU and some Dask paths
3582
usually stay at these tiers. The README feature matrix is the per-backend
3683
source of truth for each function's tier.
84+
85+
Changing a tier
86+
---------------
87+
88+
A tier moves in a pull request that edits the README matrix cell and states
89+
the reason. Promotion can happen in any release. Demoting a cell from
90+
``stable`` is an incompatible contract change and waits for a major release;
91+
until then the behaviour stays and the caveat goes in the docs.

‎setup.cfg‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[metadata]
22
author = Xarray-Spatial Developers
33
classifiers =
4-
Development Status :: 4 - Beta
4+
Development Status :: 5 - Production/Stable
55
Intended Audience :: Developers
66
Intended Audience :: Science/Research
77
License :: OSI Approved :: MIT License

0 commit comments

Comments
 (0)