Skip to content

Fix for empty array#85

Merged
JeanLucPons merged 3 commits intomainfrom
fix-for-empty-array
Nov 26, 2025
Merged

Fix for empty array#85
JeanLucPons merged 3 commits intomainfrom
fix-for-empty-array

Conversation

@JeanLucPons
Copy link
Copy Markdown
Contributor

@JeanLucPons JeanLucPons commented Nov 26, 2025

This PR allows empty arrays to be created.

ex:

sr = Accelerator.load(config_path)
element_holder = sr.design

vst = Magnet(MagnetArrayConfigModel(name="NoV",elements=[]))
vst.fill_array(element_holder) # Attach the array

However pre-commit is true nigthmare for me, i got unexpected behaviors.
I need to learn.....

[ubuntu20acu.pons] > git commit -m "Fix for empty array" -a
trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing pyaml/arrays/bpm_array.py

fix end of files.........................................................Passed
ruff (legacy alias)......................................................Passed
ruff format..............................................................Failed

A second execution worked !

[ubuntu20acu.pons] > git commit -m "Fix for empty array" -a
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
ruff (legacy alias)......................................................Passed
ruff format..............................................................Passed
[fix-for-empty-array 5f82541] Fix for empty array
 3 files changed, 11 insertions(+), 10 deletions(-)

@gubaidulinvadim
Copy link
Copy Markdown
Contributor

gubaidulinvadim commented Nov 26, 2025

@JeanLucPons , with how I set up the pre-commit this is normal behaviour. You try to commit once, if there are any errors they are fixed automatically. But you need to commit a second time to apply the changes. That's how we have the formatting set up at SOLEIL for our codes also.

Copy link
Copy Markdown
Contributor

@gubaidulinvadim gubaidulinvadim left a comment

Choose a reason for hiding this comment

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

I think adding a simple test with creation of an empty array will be useful.

@JeanLucPons
Copy link
Copy Markdown
Contributor Author

OK, so we have to know that it works like that.
An other trap, by default pre-commit is not enabled.
As i reset my repo due to too many conflicts, i rerun pre-commit run --allfiles and this time it seems ok.

@gubaidulinvadim
Copy link
Copy Markdown
Contributor

@JeanLucPons , you need to run pre-commit install to enable it. I'm not aware of any way to make it available by default to all collaborators. I think in the hooks part of .git is not tracked and the philosophy is that everyone can configure their own hooks.

@JeanLucPons JeanLucPons merged commit 2f6e594 into main Nov 26, 2025
3 checks passed
@JeanLucPons
Copy link
Copy Markdown
Contributor Author

OK.
PR can be blocked by one single person who asking for a change ?

@gubaidulinvadim
Copy link
Copy Markdown
Contributor

For me something was broken. Because new commits were pushed after I've asked for inclusion of tests. After this the review should not block anything.

@gubaidulinvadim gubaidulinvadim deleted the fix-for-empty-array branch November 26, 2025 13:06
@JeanLucPons
Copy link
Copy Markdown
Contributor Author

JeanLucPons commented Nov 26, 2025

For me something was broken. Because new commits were pushed after I've asked for inclusion of tests. After this the review should not block anything.

OK, that can be annoying if someone ask for a change and take one month of holidays :D

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