Skip to content

Fix node coordinates data type#614

Merged
isteinbrecher merged 2 commits intobeamme-py:mainfrom
isteinbrecher:fix-node-coordinates-data-type
Mar 23, 2026
Merged

Fix node coordinates data type#614
isteinbrecher merged 2 commits intobeamme-py:mainfrom
isteinbrecher:fix-node-coordinates-data-type

Conversation

@isteinbrecher
Copy link
Copy Markdown
Collaborator

@isteinbrecher isteinbrecher commented Mar 23, 2026

Force node coordinates to be of floating type. This fixes the previously existing bug:

node = Node([1, 2, 3])
node.coordinates += [0.0, 1.1, 2.2] # Causes error because flat can not be added to a int array.

Copy link
Copy Markdown
Collaborator

@davidrudlstorfer davidrudlstorfer left a comment

Choose a reason for hiding this comment

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

nice:) thanks for the nice unit test as well

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a type-casting bug in beamme.core.node.Node by ensuring node coordinates are always stored as floating-point arrays, preventing in-place vector additions from failing when initialized with integer coordinates.

Changes:

  • Force Node.coordinates to be created with dtype=float during initialization.
  • Add a parametrized test covering mixed input types (lists and NumPy arrays, int and float) and in-place coordinate increments.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/beamme/core/node.py Ensures self.coordinates is always a float NumPy array to support += with float increments safely.
tests/beamme/core/test_beamme_core_node.py Adds coverage to verify coordinates are handled correctly across multiple input/increment type combinations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@isteinbrecher isteinbrecher temporarily deployed to cubit_secrets_trusted March 23, 2026 09:22 — with GitHub Actions Inactive
@isteinbrecher isteinbrecher merged commit 1d9157e into beamme-py:main Mar 23, 2026
17 checks passed
@isteinbrecher isteinbrecher deleted the fix-node-coordinates-data-type branch March 23, 2026 09:28
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