Skip to content

Switch docs to jupyter-execute sphinx extension for HTML reprs #10383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jun 9, 2025
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cf78cf8
switch user-guide from ipython sphinx extenstion to jupyter-execute
scottyhq Jun 1, 2025
b889477
switch internals to jupyter-execute
scottyhq Jun 1, 2025
beacea8
switch remain doc files to jupyter-execute
scottyhq Jun 1, 2025
3b111d9
manual review of data model section
scottyhq Jun 2, 2025
58a5406
manual review core-operations
scottyhq Jun 2, 2025
8765673
manual review of IO
scottyhq Jun 2, 2025
0478087
manual review of plotting
scottyhq Jun 2, 2025
7ec6b56
manual review of interoperability
scottyhq Jun 2, 2025
00aad0b
review domain-specific and testing
scottyhq Jun 2, 2025
e380019
review outputs in internals section
scottyhq Jun 3, 2025
84a7976
fully remove ipython directive
scottyhq Jun 3, 2025
cd35a8d
handle execution warnings in time-coding
scottyhq Jun 3, 2025
420e7fb
use zarr v2 and consolidated=False to silence execution warnings
scottyhq Jun 3, 2025
0f36da2
cleanup, handle more warnings for RTD build
scottyhq Jun 3, 2025
07886df
catch cartopy coastline download warning
scottyhq Jun 3, 2025
6e56985
catch downloading 50m coastline warning too
scottyhq Jun 3, 2025
3de4b5e
silence xmode minimal printouts, more compact numpy printout
scottyhq Jun 3, 2025
22edd95
dont execute code in whatsnew
scottyhq Jun 3, 2025
aeaeff6
fix dark mode for datatrees
scottyhq Jun 4, 2025
673ce44
fix mermaid diagram, kerchunk, ncdata, and zarr sections
scottyhq Jun 4, 2025
fe4ed54
use tree command to check local zarrs
scottyhq Jun 4, 2025
8ca7819
address time-coding review
scottyhq Jun 4, 2025
dea0c23
Merge branch 'main' into jupyter-sphinx
dcherian Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle execution warnings in time-coding
  • Loading branch information
scottyhq committed Jun 3, 2025
commit cd35a8d7ce2e26957921182163ef0d340eab14e3
17 changes: 8 additions & 9 deletions doc/internals/time-coding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,11 @@ For encoding the process is more or less a reversal of the above, but we have to
dtype="datetime64[s]",
)
orig_values = np.array(
[-2002 * 365 - 121, -366, 365, 2000 * 365 + 119], dtype="int64"
[-2002 * 365 - 121, -366, 365, 2000 * 365 + 119], dtype="float64"
)
units = "days since 0001-01-01 00:00:00"
values, _, _ = xr.coding.times.encode_cf_datetime(
dates, units, calendar, dtype=np.dtype("int64")
dates, units, calendar, dtype=np.dtype("float64")
)
print(values)
np.testing.assert_array_equal(values, orig_values)
Expand All @@ -439,11 +439,11 @@ For encoding the process is more or less a reversal of the above, but we have to
dtype="datetime64[s]",
)
orig_values = np.array(
[-2002 * 365 - 121, -366, 365, 2000 * 365 + 119], dtype="int64"
[-2002 * 365 - 121, -366, 365, 2000 * 365 + 119], dtype="float64"
)
units = "days since 0001-01-01 00:00:00"
values, units, _ = xr.coding.times.encode_cf_datetime(
dates, units, calendar, dtype=np.dtype("int64")
dates, units, calendar, dtype=np.dtype("float64")
)
print(values, units)

Expand Down Expand Up @@ -497,17 +497,16 @@ Similar logic applies for decoding timedelta values. The default resolution is
ds.to_netcdf("test-timedeltas1.nc")

.. jupyter-execute::

:stderr:

xr.open_dataset("test-timedeltas1.nc")

By default, timedeltas will be decoded to the same resolution as datetimes:

.. jupyter-execute::


coder = xr.coders.CFDatetimeCoder(time_unit="s")
xr.open_dataset("test-timedeltas1.nc", decode_times=coder)
xr.open_dataset("test-timedeltas1.nc", decode_times=coder, decode_timedelta=True)

but if one would like to decode timedeltas to a different resolution, one can
provide a coder specifically for timedeltas to ``decode_timedelta``:
Expand All @@ -530,12 +529,12 @@ into their native on-disk resolution, if possible:

.. jupyter-execute::

xr.open_dataset("test-timedeltas2.nc")
xr.open_dataset("test-timedeltas2.nc", decode_timedelta=True)

.. jupyter-execute::

coder = xr.coders.CFDatetimeCoder(time_unit="s")
xr.open_dataset("test-timedeltas2.nc", decode_times=coder)
xr.open_dataset("test-timedeltas2.nc", decode_times=coder, decode_timedelta=True)

To opt-out of timedelta decoding (see issue `Undesired decoding to timedelta64 <https://github.com/pydata/xarray/issues/1621>`_) pass ``False`` to ``decode_timedelta``:

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy