Skip to content

Add tests to confirm: proper de-duplication across -180/180 and 0/360 lon wraps - #1903

Merged
erogluorhan merged 2 commits into
mainfrom
sevans/test_duplicate_nodes_across_lon_wraps
Nov 17, 2026
Merged

erogluorhan merged 2 commits into
mainfrom
sevans/test_duplicate_nodes_across_lon_wraps

Conversation

@Sevans711

Copy link
Copy Markdown
Collaborator

Closes #1039

Overview

This PR adds test_duplicate_nodes_across_lon_wraps which ensures the de-duplication routines introduced by #1692 properly handle duplicates which are at different numerical values but equivalent mod 360. In particular it ensures lon=0 and lon=360 are recognized as equivalent, and that lon=-180 and lon=180 are recognized as equivalent.

The underlying issue (#1039) has basically no context; it links one comment with a minimal example in a separate PR but that example was fixed to be handled properly within that PR already (and I locally confirmed that it remains solved today). I can only guess at what the issue might have been referring to, and recently there have been various fixes to de-duplication and lon wrapping (such as #1692, #1690, #1525), so I get the impression that there is a decent chance the underlying issue which led to this 2+ year-old report has likely already been solved.

Rather than just mark the issue as closed, I'm proposing that maybe a minimal reproducer for it could have looked something like this:

node_lon = np.array([120., 180., 180., -180., -180., -120.])
node_lat = np.array([  0.,   0.,  30.,    0.,   30.,    0.])
fnc = np.array([[0, 1, 2], [3, 5, 4]])
grid = ux.Grid.from_topology(node_lon, node_lat, fnc)
grid.n_edge     # got 6, expected 5; there are 2 triangles, with 1 shared edge

This is covered by the new test, and was solved recently, via #1692.

(Pointing Claude at this problem also didn't lead to discovering any obvious cases where a bug matching this description might still exist in the uxarray codebase.)

PR Checklist

General

  • An issue is created and linked
  • Added appropriate labels (if your uxarray repo permissions allow it)
  • Filled out Overview and Expected Usage (if applicable) sections

Testing & Benchmarking

  • There is adequate test coverage of changes from this PR (add new tests if needed)
  • [N/A] If this PR could affect performance, ran ASV benchmarks and confirmed they show expected behavior (add a new benchmark if necessary)

Documentation and Examples

  • [N/A] Docstrings updated with any function changes, and included in all new functions
  • [N/A] User (public) functions added to docs/api.rst; internal (private) function names start with an underscore (_)
  • [N/A] If touched any notebook files, cleared the output of all cells before committing
  • [N/A] If added new notebook files, put into appropriate directories and referenced in appropriate files

AI Disclosure

AI Usage: Claude Opus 5.5, plus GitHub Copilot inline code suggestions

  • I have tested and take responsibility for all AI-generated content in my PR.

regression test for #1039. (Not enough context to know if this was definitely the original issue, but it might have been one of them / seems related, at least?)
@Sevans711 Sevans711 added the testing Test Cases label Nov 16, 2026

@erogluorhan erogluorhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing #1039 with this test looks right to me: the duplicates it describes are no longer produced, and the test pins that down.

  • The new test passes on the PR. Run against the commit before #1692 (d6adb4e9^), it fails with n_edge 6 instead of 5, so it does guard the fix.
  • The merge compares nodes in xyz, so any longitudes equal mod 360 are merged, not only 0/360 and ±180. -45/315 also gives 5 edges.
  • The same two-triangle grids, written to a file and opened with ux.open_grid(path, chunks=-1), also give 5 edges and the right face_face_connectivity. That covers the lazy path, which skips the merge at construction.
  • The case from the linked #1147 comment (HEALPix corners at 0/360) is also fixed: from_healpix(zoom=0..2) has no duplicate nodes, and n_edge == n_face + n_node - 2 (Euler's formula). test_healpix.py::test_boundaries already checks this through n_node == n_face + 2.

Requested before merge: nothing, once CI is green.

@erogluorhan
erogluorhan merged commit ce8690d into main Nov 17, 2026
19 checks passed
@Sevans711
Sevans711 deleted the sevans/test_duplicate_nodes_across_lon_wraps branch November 17, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Test Cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normalizing longitudes to [-180, 180] from other may ranges introduces duplicate nodes

3 participants