Skip to content

Keep the physical dimension of mappings in Domain.export / Domain.from_file - #201

Merged
yguclu merged 7 commits into
pyccel:masterfrom
syahra712:fix/domain-export-pdim
Oct 30, 2026
Merged

yguclu merged 7 commits into
pyccel:masterfrom
syahra712:fix/domain-export-pdim

Conversation

@syahra712

@syahra712 syahra712 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #200, following the proposal in the issue:

  • Domain.todict (and so Domain.export) writes ldim and pdim instead of dim. pdim comes from the domain's mappings, or equals ldim for an unmapped domain. A ValueError is raised if the mappings have different physical dimensions.
  • Domain.from_file creates each mapping with ldim and pdim.
  • A file with the old dim key raises a ValueError saying it was written by an older version of SymPDE and that dim must be replaced by ldim and pdim. This is a breaking change.
  • The # TODO add pdim comment is removed.
  • Two CHANGELOG entries are added: the new file format under Changed, and the fix under Fixed.
  • The author is added to AUTHORS.

Tests in test_topology.py:

  • test_export_surface_mapping: a round trip of Mapping('F', ldim=2, pdim=3)(Square('Omega')) keeps pdim == 3.
  • test_from_file_with_old_dim_key: a file with dim raises the error.
  • test_export_mappings_with_different_pdim: exporting a domain whose mappings have different physical dimensions raises a ValueError.

The full test suite passes (183 passed, 2 skipped).

@yguclu yguclu 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.

Thanks for this contribution!

I have posted a couple of suggestions below.

If you are comfortable with adding your full name to the bottom of the AUTHORS file, please feel free to do so. We do not list contributors under their GitHub username or other aliases

Comment thread sympde/topology/domain.py Resolved
Comment thread sympde/topology/tests/test_topology.py Resolved
Comment thread CHANGELOG.md Resolved
Comment thread CHANGELOG.md Resolved
@yguclu

yguclu commented Oct 29, 2026

Copy link
Copy Markdown
Member

@syahra712 Have you read my comments from last week? If not, you should check your notification settings

- Domain.todict() raises ValueError when the mappings disagree on pdim
- Add test_export_mappings_with_different_pdim
- Shorten the Fixed entry and add a Changed entry for the ldim/pdim format change
- Add myself to AUTHORS
@syahra712

Copy link
Copy Markdown
Contributor Author

@yguclu Sorry, I missed your review last week. That one's on me, and I've fixed how I track notifications.

All of your suggestions are in now:

  • Domain.todict() raises a ValueError if the mappings have different pdim. I renamed the set to pdims so it doesn't clash with the pdim string below it.
  • Added test_export_mappings_with_different_pdim. It fails on the previous commit and passes now.
  • Shortened the Fixed entry, and added the breaking-change note under Changed.
  • Added my full name to AUTHORS.

All 21 topology tests pass locally.

Comment thread CHANGELOG.md Resolved
@yguclu

yguclu commented Oct 29, 2026

Copy link
Copy Markdown
Member

This PR should be merged after PR #205, which fixes issue #204

yguclu added a commit that referenced this pull request Oct 30, 2026
## Summary

Write the HDF5 files of the unit tests to the `tmp_path` fixture instead
of the working directory, so that the tests can run in parallel without
the `xdist_group` marker (fixes #204).

## Problem

The six export/import tests of `sympde/topology/tests/test_gallery.py`
all wrote and read the same file `domain.h5` in the working directory.
They relied on `@pytest.mark.xdist_group('h5py')` and `--dist loadgroup`
to run one after another on the same worker.

pytest 9.2.0 (released 2026-10-27) changed how node IDs are stored, and
pytest-xdist 3.8.0 can no longer assign tests to their group (see
pytest-dev/pytest-xdist#1386, fixed in pytest-dev/pytest-xdist#1388 but
not released yet). The grouped tests were therefore spread over the
workers and failed randomly with `BlockingIOError` or `OSError` when two
of them opened `domain.h5` at the same time. This is what currently
makes CI fail in #201.

## Changes

- Each test in `test_gallery.py` that exports a domain writes it to its
own `tmp_path`, and the `xdist_group('h5py')` markers are removed.
- `test_topology_1` in `test_topology.py` writes `omega.h5` to
`tmp_path` too.
- The removal of the output files in `teardown_module` is no longer
needed and is deleted.
- Remove `--dist loadgroup` from the pytest commands in CI and in the
README, since no test uses the `xdist_group` marker anymore.
- Add a `[DEVELOPER]` entry to the CHANGELOG.

## Validation

With pytest 9.2.0 and pytest-xdist 3.8.0, `pytest -n auto --dist
loadgroup --pyargs sympde -ra` passed 5 times in a row (180 passed, 2
skipped) and left no files in the working directory. On `master`, the
same command failed in all 3 runs, with 2 or 3 failing tests each time.
CI passes in all jobs with the final command `pytest -n auto --pyargs
sympde -ra`.
@yguclu
yguclu merged commit b22ced9 into pyccel:master Oct 30, 2026
16 checks passed
yguclu added a commit that referenced this pull request Oct 30, 2026
#201 renamed the local variable dim to ldim in Domain.from_file, but the
new code path for topological domains still used dim, which raised a
NameError when reading a domain without dtype.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Domain.export and Domain.from_file lose the physical dimension of the mappings

2 participants