Skip to content

Fix walrus operator in assert statement, leading to problems with optimized code#407

Open
henrykrumb wants to merge 5 commits into
eigenvivek:mainfrom
henrykrumb:fix-walrus-assertion
Open

Fix walrus operator in assert statement, leading to problems with optimized code#407
henrykrumb wants to merge 5 commits into
eigenvivek:mainfrom
henrykrumb:fix-walrus-assertion

Conversation

@henrykrumb
Copy link
Copy Markdown

Using the optimization flag -O with the Python interpreter eliminates assert statements. Thus, asserts should have no side-effects.

This small PR moves the inline assignment operator (walrus) out of an assert-statement to make it free of side-effects, so that it can be run in deployments where the -O flag is used.

Change is applied both in the original notebook and exported python module code.

eigenvivek and others added 5 commits November 11, 2025 11:26
* Add RoMa to requirements

* Switch to RoMa backend for rotation geodesic

* Fix environment.yml

* Add roma to pip requirements
* Add roma to dependencies

* Add rotation matrix check in inverse

* Make Rigid.Transform__getitem__ return a RigidTransform

* Change check from rotation to orthonormal

* Add roma to requirements

* Roll back Rigid.Transform__getitem__ return a RigidTransform
* If input is RigidTransform, return input

* Remove hardcoded class name

* Make slicing return a RigidTransform

* Add a matmul overload
@eigenvivek
Copy link
Copy Markdown
Owner

hi henry, thanks for the PR! never knew about the -O flag.

I think you just need to run nbdev_clean; nbdev_export and then the tests should pass

apologies for the nbdev framework, I though it was a great idea a few years ago but now i realize how challenging it makes PRs

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.

2 participants