Skip to content

Allow in place operators to modify coordinates#5214

Open
dham wants to merge 2 commits into
releasefrom
dham/inplace_coordinate_operators
Open

Allow in place operators to modify coordinates#5214
dham wants to merge 2 commits into
releasefrom
dham/inplace_coordinate_operators

Conversation

@dham

@dham dham commented Jul 3, 2026

Copy link
Copy Markdown
Member

Replacing the coordinates property of a mesh is not allowed for lots of good reasons.

However, the Python implementation of in place operators does assignment. That is to say:

mesh.coordinates += 1.

is equivalent to:

mesh.coordinates = mesh.coordinates.__iadd__(1.)

This triggers the error even though mesh.coordinates.__iadd__ returns mesh.coordinates. This PR relaxes the error check so that assigning mesh.coordinates itself (i.e. a no-op) is allowed.

connorjward
connorjward previously approved these changes Jul 7, 2026
@connorjward

Copy link
Copy Markdown
Contributor

Should this go into release?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this go in firedrake/regression/test_change_coordinates.py instead of a new file?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great point

@dham dham force-pushed the dham/inplace_coordinate_operators branch from b268e8f to 8c24472 Compare July 7, 2026 13:34
@dham dham changed the base branch from main to release July 7, 2026 13:35
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.

3 participants