Skip to content

Commit 41966f3

Browse files
authored
add support for preliz distributions and update dependencies (#70)
* add support for preliz distributions and update dependencies * update rtd config * support scipy RVs and add type hints * update version and rerun notebooks
1 parent 9d7b447 commit 41966f3

27 files changed

+2940
-1215
lines changed

.github/workflows/publish.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,40 @@ on:
1010
- v*
1111

1212
jobs:
13-
publish:
13+
build-package:
1414
runs-on: ubuntu-latest
1515
permissions:
16+
# write attestations and id-token are necessary for attest-build-provenance-github
17+
attestations: write
1618
id-token: write
1719
steps:
1820
- uses: actions/checkout@v4
19-
- name: Set up Python
20-
uses: actions/setup-python@v5
2121
with:
22-
python-version: "3.11"
23-
- name: Install build dependencies
24-
run: python -m pip install build
25-
- name: Build package
26-
run: python -m build
22+
fetch-depth: 0
23+
persist-credentials: false
24+
- uses: hynek/build-and-inspect-python-package@v2
25+
with:
26+
# Prove that the packages were built in the context of this workflow.
27+
attest-build-provenance-github: true
28+
publish:
29+
runs-on: ubuntu-latest
30+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
31+
# Use the `release` GitHub environment to protect the Trusted Publishing (OIDC)
32+
# workflow by requiring signoff from a maintainer.
33+
environment:
34+
name: publish
35+
url: https://pypi.org/p/xarray-einstats
36+
needs: build-package
37+
permissions:
38+
# write id-token is necessary for trusted publishing (OIDC)
39+
id-token: write
40+
steps:
41+
- name: Download Distribution Artifacts
42+
uses: actions/download-artifact@v4
43+
with:
44+
# The build-and-inspect-python-package action invokes upload-artifact.
45+
# These are the correct arguments from that action.
46+
name: Packages
47+
path: dist
2748
- name: Publish to PyPI
2849
uses: pypa/gh-action-pypi-publish@release/v1
29-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.10", "3.11", "3.12"]
14+
python-version: ["3.11", "3.12", "3.13"]
1515
fail-fast: false
1616
steps:
1717
- uses: actions/checkout@v4

.readthedocs.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
version: 2
44

55
build:
6-
os: ubuntu-22.04
6+
os: ubuntu-24.04
77
tools:
8-
python: "3.10"
8+
python: "3.12"
99

1010
sphinx:
1111
fail_on_warning: true
12+
configuration: docs/source/conf.py
1213

1314
python:
1415
install:

docs/source/api/linalg.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
6868
solve
6969
inv
70+
pinv
7071
```
7172

7273
## Convenience functions

docs/source/changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Change Log
22

3+
## v0.9.0 (2025 May 22)
4+
### New features
5+
* Support PreliZ distributions as input to RV wrappers {pull}`70`
6+
* Support new SciPy random variables as input to RV wrappers {pull}`70`
7+
* Allow specifying the shape of `.rvs` output through `coords` argument {pull}`70`
8+
9+
### Maintenance and fixes
10+
* Update publish workflow to follow best practices {pull}`70`
11+
* Use `dim` in `xarray.dot` instead of deprecated `dims` {pull}`70`
12+
* Add type hints from docstrings through `docstub` {pull}`70`
13+
* Remove coordinate values of sorted dimension in `sort` {pull}`70`
14+
315
## v0.8.0 (2024 Sep 19)
416
### New features
517
* Add `numpy.linalg.pinv` wrapper {pull}`63`

docs/source/conf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,19 @@
8080

8181
numpydoc_show_class_members = False
8282
numpydoc_xref_param_type = True
83-
numpydoc_xref_ignore = {"of", "or", "optional", "scalar"}
83+
numpydoc_xref_ignore = {"of", "or", "optional"}
8484
singulars = ("int", "list", "dict", "float")
8585
numpydoc_xref_aliases = {
8686
"DataArray": ":class:`xarray.DataArray`",
8787
"Dataset": ":class:`xarray.Dataset`",
8888
"pattern_list": "list of str, list or dict",
8989
"DimHandler": ":class:`~xarray_einstats.einops.DimHandler`",
9090
**{f"{singular}s": f":any:`{singular}s <{singular}>`" for singular in singulars},
91+
"scalar": ":term:`numpy:scalar`",
92+
"iterable": ":term:`python:iterable`",
93+
"sequence": ":term:`python:sequence`",
94+
"mapping": ":term:`python:mapping`",
95+
"hashable": ":term:`python:hashable`",
9196
}
9297

9398
# Include the example source for plots in API docs

docs/source/tutorials/einops-basics-port.ipynb

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,14 @@
122122
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
123123
"}\n",
124124
"\n",
125-
"html[theme=dark],\n",
126-
"body[data-theme=dark],\n",
125+
"html[theme=\"dark\"],\n",
126+
"html[data-theme=\"dark\"],\n",
127+
"body[data-theme=\"dark\"],\n",
127128
"body.vscode-dark {\n",
128129
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
129130
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
130131
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
131-
" --xr-border-color: #1F1F1F;\n",
132+
" --xr-border-color: #1f1f1f;\n",
132133
" --xr-disabled-color: #515151;\n",
133134
" --xr-background-color: #111111;\n",
134135
" --xr-background-color-row-even: #111111;\n",
@@ -173,15 +174,17 @@
173174
".xr-sections {\n",
174175
" padding-left: 0 !important;\n",
175176
" display: grid;\n",
176-
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
177+
" grid-template-columns: 150px auto auto 1fr 0 20px 0 20px;\n",
177178
"}\n",
178179
"\n",
179180
".xr-section-item {\n",
180181
" display: contents;\n",
181182
"}\n",
182183
"\n",
183184
".xr-section-item input {\n",
184-
" display: none;\n",
185+
" display: inline-block;\n",
186+
" opacity: 0;\n",
187+
" height: 0;\n",
185188
"}\n",
186189
"\n",
187190
".xr-section-item input + label {\n",
@@ -193,6 +196,10 @@
193196
" color: var(--xr-font-color2);\n",
194197
"}\n",
195198
"\n",
199+
".xr-section-item input:focus + label {\n",
200+
" border: 2px solid var(--xr-font-color0);\n",
201+
"}\n",
202+
"\n",
196203
".xr-section-item input:enabled + label:hover {\n",
197204
" color: var(--xr-font-color0);\n",
198205
"}\n",
@@ -214,7 +221,7 @@
214221
"\n",
215222
".xr-section-summary-in + label:before {\n",
216223
" display: inline-block;\n",
217-
" content: '►';\n",
224+
" content: \"\";\n",
218225
" font-size: 11px;\n",
219226
" width: 15px;\n",
220227
" text-align: center;\n",
@@ -225,7 +232,7 @@
225232
"}\n",
226233
"\n",
227234
".xr-section-summary-in:checked + label:before {\n",
228-
" content: '▼';\n",
235+
" content: \"\";\n",
229236
"}\n",
230237
"\n",
231238
".xr-section-summary-in:checked + label > span {\n",
@@ -297,15 +304,15 @@
297304
"}\n",
298305
"\n",
299306
".xr-dim-list:before {\n",
300-
" content: '(';\n",
307+
" content: \"(\";\n",
301308
"}\n",
302309
"\n",
303310
".xr-dim-list:after {\n",
304-
" content: ')';\n",
311+
" content: \")\";\n",
305312
"}\n",
306313
"\n",
307314
".xr-dim-list li:not(:last-child):after {\n",
308-
" content: ',';\n",
315+
" content: \",\";\n",
309316
" padding-right: 5px;\n",
310317
"}\n",
311318
"\n",
@@ -455,11 +462,11 @@
455462
" stroke: currentColor;\n",
456463
" fill: currentColor;\n",
457464
"}\n",
458-
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
465+
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt; Size: 1MB\n",
459466
"Dimensions: (batch: 6, height: 96, width: 96, channel: 3)\n",
460467
"Dimensions without coordinates: batch, height, width, channel\n",
461468
"Data variables:\n",
462-
" ims (batch, height, width, channel) float64 1.0 0.902 ... 1.0 0.8039</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-3eec4040-5856-441f-a836-5e03835a0b88' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-3eec4040-5856-441f-a836-5e03835a0b88' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span>batch</span>: 6</li><li><span>height</span>: 96</li><li><span>width</span>: 96</li><li><span>channel</span>: 3</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-9c5bf0d5-07dc-410d-bccd-6bfff020901b' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-9c5bf0d5-07dc-410d-bccd-6bfff020901b' class='xr-section-summary' title='Expand/collapse section'>Coordinates: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-acd7bcef-aff7-4348-9b27-01a4199bfc36' class='xr-section-summary-in' type='checkbox' checked><label for='section-acd7bcef-aff7-4348-9b27-01a4199bfc36' class='xr-section-summary' >Data variables: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>ims</span></div><div class='xr-var-dims'>(batch, height, width, channel)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>1.0 0.902 0.902 ... 1.0 1.0 0.8039</div><input id='attrs-f0841d19-41a9-4c43-8827-96261613a4f8' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-f0841d19-41a9-4c43-8827-96261613a4f8' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f3e88cda-9cfd-4a98-9234-0151154149e7' class='xr-var-data-in' type='checkbox'><label for='data-f3e88cda-9cfd-4a98-9234-0151154149e7' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[[[1. , 0.90196078, 0.90196078],\n",
469+
" ims (batch, height, width, channel) float64 1MB 1.0 0.902 ... 0.8039</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-183bfbe5-29c2-4615-8069-a8d0dcdd35e2' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-183bfbe5-29c2-4615-8069-a8d0dcdd35e2' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span>batch</span>: 6</li><li><span>height</span>: 96</li><li><span>width</span>: 96</li><li><span>channel</span>: 3</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-b3551b06-e4e0-40cb-a65a-03044daab9b1' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-b3551b06-e4e0-40cb-a65a-03044daab9b1' class='xr-section-summary' title='Expand/collapse section'>Coordinates: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-9f26d6c0-72b4-469a-8b15-df753c57cca2' class='xr-section-summary-in' type='checkbox' checked><label for='section-9f26d6c0-72b4-469a-8b15-df753c57cca2' class='xr-section-summary' >Data variables: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>ims</span></div><div class='xr-var-dims'>(batch, height, width, channel)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>1.0 0.902 0.902 ... 1.0 1.0 0.8039</div><input id='attrs-63bae9eb-1de0-4adf-b6ef-293a1d0d95f1' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-63bae9eb-1de0-4adf-b6ef-293a1d0d95f1' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-7ead5f62-d0fc-43fd-8b90-7358da393ba9' class='xr-var-data-in' type='checkbox'><label for='data-7ead5f62-d0fc-43fd-8b90-7358da393ba9' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[[[1. , 0.90196078, 0.90196078],\n",
463470
" [1. , 0.90196078, 0.90196078],\n",
464471
" [1. , 0.90196078, 0.90196078],\n",
465472
" ...,\n",
@@ -499,14 +506,14 @@
499506
" ...,\n",
500507
" [1. , 1. , 0.80392157],\n",
501508
" [1. , 1. , 0.80392157],\n",
502-
" [1. , 1. , 0.80392157]]]])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-f0211063-41d1-4cdb-83e8-d05358d2138e' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-f0211063-41d1-4cdb-83e8-d05358d2138e' class='xr-section-summary' title='Expand/collapse section'>Indexes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-dea59cb1-db8d-4a0e-9112-3183be97db31' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-dea59cb1-db8d-4a0e-9112-3183be97db31' class='xr-section-summary' title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
509+
" [1. , 1. , 0.80392157]]]], shape=(6, 96, 96, 3))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-fc40f28e-40d9-42e2-aace-4a2d88f53180' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-fc40f28e-40d9-42e2-aace-4a2d88f53180' class='xr-section-summary' title='Expand/collapse section'>Indexes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-ce584ea3-9ca1-4794-8959-5568b323983d' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-ce584ea3-9ca1-4794-8959-5568b323983d' class='xr-section-summary' title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
503510
],
504511
"text/plain": [
505-
"<xarray.Dataset>\n",
512+
"<xarray.Dataset> Size: 1MB\n",
506513
"Dimensions: (batch: 6, height: 96, width: 96, channel: 3)\n",
507514
"Dimensions without coordinates: batch, height, width, channel\n",
508515
"Data variables:\n",
509-
" ims (batch, height, width, channel) float64 1.0 0.902 ... 1.0 0.8039"
516+
" ims (batch, height, width, channel) float64 1MB 1.0 0.902 ... 0.8039"
510517
]
511518
},
512519
"execution_count": 2,
@@ -1702,20 +1709,20 @@
17021709
"name": "stdout",
17031710
"output_type": "stream",
17041711
"text": [
1705-
"Last updated: Wed Jan 17 2024\n",
1712+
"Last updated: Thu May 22 2025\n",
17061713
"\n",
17071714
"Python implementation: CPython\n",
1708-
"Python version : 3.11.7\n",
1709-
"IPython version : 8.18.1\n",
1715+
"Python version : 3.12.7\n",
1716+
"IPython version : 8.29.0\n",
17101717
"\n",
1711-
"einops : 0.7.0\n",
1712-
"xarray_einstats: 0.7.0\n",
1718+
"einops : 0.8.1\n",
1719+
"xarray_einstats: 0.9.0\n",
17131720
"\n",
1714-
"sys : 3.11.7 | packaged by conda-forge | (main, Dec 15 2023, 08:38:37) [GCC 12.3.0]\n",
1715-
"numpy : 1.26.2\n",
1716-
"xarray: 2023.12.0\n",
1721+
"numpy : 2.2.6\n",
1722+
"xarray : 2025.4.0\n",
1723+
"xarray_einstats: 0.9.0\n",
17171724
"\n",
1718-
"Watermark: 2.4.3\n",
1725+
"Watermark: 2.5.0\n",
17191726
"\n"
17201727
]
17211728
}
@@ -1735,9 +1742,9 @@
17351742
],
17361743
"metadata": {
17371744
"kernelspec": {
1738-
"display_name": "ArviZ (minimal env)",
1745+
"display_name": "Python 3 (ipykernel)",
17391746
"language": "python",
1740-
"name": "arviz"
1747+
"name": "python3"
17411748
},
17421749
"language_info": {
17431750
"codemirror_mode": {
@@ -1749,7 +1756,7 @@
17491756
"name": "python",
17501757
"nbconvert_exporter": "python",
17511758
"pygments_lexer": "ipython3",
1752-
"version": "3.11.7"
1759+
"version": "3.12.7"
17531760
}
17541761
},
17551762
"nbformat": 4,

0 commit comments

Comments
 (0)