Skip to content

Commit f720999

Browse files
committed
Merge branch 'main' into rajeeja/yac
2 parents 65c765f + c7dea8c commit f720999

9 files changed

Lines changed: 118 additions & 15 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Upstream testing failure
2+
3+
**Workflow:** {{WORKFLOW}}
4+
**Run:** [{{RUN_ID}}]({{RUN_URL}})
5+
**Date:** {{DATE}}
6+
7+
Upstream testing has failed.
8+
9+
Please check the [workflow run]({{RUN_URL}}) for details.
10+
11+
This issue was automatically generated from the CI Upstream workflow.

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: [ "3.11", "3.12", "3.13"]
2323
steps:
2424
- name: Cancel previous runs
25-
uses: styfle/cancel-workflow-action@0.13.0
25+
uses: styfle/cancel-workflow-action@0.13.1
2626
with:
2727
access_token: ${{ github.token }}
2828

@@ -67,6 +67,7 @@ jobs:
6767
python -m pytest test
6868
6969
link-check:
70+
if: github.event_name != 'pull_request'
7071
runs-on: ubuntu-latest
7172
defaults:
7273
run:
@@ -106,12 +107,13 @@ jobs:
106107
conda list
107108
108109
- name: Make docs with linkcheck
109-
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
110+
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
110111
with:
111112
timeout_minutes: 20
112113
max_attempts: 3
113114
command: |
114115
eval "$(micromamba shell hook --shell bash)"
115116
micromamba activate uxarray-docs
116117
cd docs
118+
echo 'nb_execution_mode = "off"' >> conf.py
117119
make linkcheck

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

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ jobs:
1212
upstream-dev:
1313
name: upstream-dev
1414
runs-on: ubuntu-latest
15+
continue-on-error: true
1516
defaults:
1617
run:
1718
shell: bash -l {0}
1819
strategy:
1920
fail-fast: false
2021
matrix:
21-
python-version: [ "3.12" ]
22+
python-version: [ "3.13" ]
23+
outputs:
24+
testresults: ${{ steps.tests.outcome }}
2225

2326
steps:
2427
- name: Checkout
@@ -50,5 +53,66 @@ jobs:
5053
conda list
5154
5255
- name: Running Tests
56+
id: tests
5357
run: |
5458
python -m pytest test -v --cov=./uxarray --cov-report=xml
59+
60+
failure-issue:
61+
name: failure-issue
62+
needs: [upstream-dev]
63+
if: |
64+
needs.upstream-dev.testresults != 'success'
65+
&& github.repository == 'UXARRAY/uxarray'
66+
&& github.ref == 'refs/heads/main'
67+
runs-on: ubuntu-latest
68+
defaults:
69+
run:
70+
shell: bash -l {0}
71+
steps:
72+
- name: checkout
73+
uses: actions/checkout@v6.0.2
74+
75+
- name: Create or update failure issue
76+
shell: bash
77+
run: |
78+
# Read the template
79+
template=$(cat .github/upstream-failure-issue-template.md)
80+
81+
# Replace placeholders
82+
issue_body="${template//\{\{WORKFLOW\}\}/${{ github.workflow }}}"
83+
issue_body="${issue_body//\{\{RUN_ID\}\}/${{ github.run_id }}}"
84+
issue_body="${issue_body//\{\{RUN_URL\}\}/${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}}"
85+
issue_body="${issue_body//\{\{DATE\}\}/$(date -u)}"
86+
87+
# Check for existing open issue with same title
88+
issue_title="🤖 Upstream testing failure"
89+
existing_issue=$(gh issue list --state open --label "CI" --search "\"$issue_title\" in:title" --json number --jq '.[0].number // empty')
90+
91+
if [ -n "$existing_issue" ]; then
92+
echo "Found existing open issue #$existing_issue, updating it..."
93+
echo "$issue_body" | gh issue edit "$existing_issue" --body-file -
94+
echo "Updated existing issue #$existing_issue"
95+
else
96+
echo "No existing open issue found, creating new one..."
97+
echo "$issue_body" | gh issue create \
98+
--title "$issue_title" \
99+
--body-file - \
100+
--label "CI"
101+
echo "Created new issue"
102+
fi
103+
env:
104+
GH_TOKEN: ${{ github.token }}
105+
106+
report-failed:
107+
name: report-failed
108+
needs: [ upstream-dev, failure-issue ]
109+
if: ${{needs.upstream-dev.outputs.testresults != 'success'}}
110+
runs-on: ubuntu-latest
111+
defaults:
112+
run:
113+
shell: bash -l {0}
114+
steps:
115+
- name: make sure to report a failed workflow
116+
shell: bash
117+
run: |
118+
exit 1;

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414

1515
- repo: https://github.com/astral-sh/ruff-pre-commit
1616
# Ruff version.
17-
rev: v0.15.2
17+
rev: v0.15.7
1818
hooks:
1919
- id: ruff
2020
name: lint with ruff

docs/user-guide/grid-formats.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ References
4343
----------
4444
* https://ugrid-conventions.github.io/ugrid-conventions/#ugrid-conventions-v10
4545
* https://github.com/ugrid-conventions/ugrid-conventions
46-
* https://cfconventions.org/Data/cf-conventions/cf-conventions-1.11/cf-conventions.html#ugrid-conventions
47-
* https://cfconventions.org/Data/cf-conventions/cf-conventions-1.11/cf-conventions.html#mesh-topology-variables
46+
* https://cf-convention.github.io/Data/cf-conventions/cf-conventions-1.13/cf-conventions.html#ugrid-conventions
47+
* https://cf-convention.github.io/Data/cf-conventions/cf-conventions-1.13/cf-conventions.html#mesh-topology-variables
4848

4949
MPAS
5050
====

test/grid/grid/test_io.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,26 @@ def test_grid_ugrid_exodus_roundtrip(gridpath):
174174
for filepath in test_files:
175175
if os.path.exists(filepath):
176176
os.remove(filepath)
177+
178+
179+
def test_exodus_roundtrip_rll1deg_node_lonlat(gridpath, tmp_path):
180+
"""Check Exodus round-trip coordinate stability for the RLL1deg grid."""
181+
grid = ux.open_grid(gridpath("ugrid", "outRLL1deg", "outRLL1deg.ug"))
182+
183+
exodus_filepath = tmp_path / "outRLL1deg.exo"
184+
grid.to_xarray("Exodus").to_netcdf(exodus_filepath)
185+
186+
reloaded_exodus = ux.open_grid(exodus_filepath)
187+
188+
np.testing.assert_allclose(
189+
grid.node_lon.values,
190+
reloaded_exodus.node_lon.values,
191+
err_msg="Exodus longitude mismatch for RLL1deg",
192+
rtol=ERROR_TOLERANCE,
193+
)
194+
np.testing.assert_allclose(
195+
grid.node_lat.values,
196+
reloaded_exodus.node_lat.values,
197+
err_msg="Exodus latitude mismatch for RLL1deg",
198+
rtol=ERROR_TOLERANCE,
199+
)

test/test_plot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import pytest
55
import numpy as np
66

7+
import matplotlib
8+
matplotlib.use("Agg")
79
import matplotlib.pyplot as plt
810
import cartopy.crs as ccrs
911

uxarray/core/dataarray.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,19 @@ def zonal_mean(self, lat=(-90, 90, 10), conservative: bool = False, **kwargs):
745745
dims = list(self.dims)
746746
dims[face_axis] = "latitudes"
747747

748+
# Assign coords from `self` to the result except one that corresponds to `dims[face_axis]`
749+
new_coords = {
750+
k: v
751+
for k, v in self.coords.items()
752+
if self.dims[face_axis] not in v.dims
753+
}
754+
# Add latitudes to the resulting coords
755+
new_coords["latitudes"] = centers
756+
748757
return xr.DataArray(
749758
res,
750759
dims=dims,
751-
coords={"latitudes": centers},
760+
coords=new_coords,
752761
name=self.name + "_zonal_mean"
753762
if self.name is not None
754763
else "zonal_mean",

uxarray/grid/coordinates.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ def _xyz_to_lonlat_rad_no_norm(
6868
def _xyz_to_lonlat_rad_scalar(x, y, z, normalize=True):
6969
if normalize:
7070
x, y, z = _normalize_xyz_scalar(x, y, z)
71-
denom = abs(x * x + y * y + z * z)
72-
x /= denom
73-
y /= denom
74-
z /= denom
7571

7672
lon = np.arctan2(y, x)
7773
lat = np.asin(z)
@@ -121,10 +117,6 @@ def _xyz_to_lonlat_rad(
121117

122118
if normalize:
123119
x, y, z = _normalize_xyz(x, y, z)
124-
denom = np.abs(x * x + y * y + z * z)
125-
x /= denom
126-
y /= denom
127-
z /= denom
128120

129121
lon = np.arctan2(y, x)
130122
lat = np.arcsin(z)

0 commit comments

Comments
 (0)