-
Notifications
You must be signed in to change notification settings - Fork 50
Use real copy instead of converting to string for when calling addObject or addChild #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bakpaul
wants to merge
12
commits into
sofa-framework:master
Choose a base branch
from
bakpaul:pr-remove-str-conversion-in-create
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Use real copy instead of converting to string for when calling addObject or addChild #511
bakpaul
wants to merge
12
commits into
sofa-framework:master
from
bakpaul:pr-remove-str-conversion-in-create
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…sion while creating an object.
…h invalid argument. (this was the previous behavior)
The PR is breaking existing code. But the previously working code was, despite being conveniant was not valid and it was using a "flat" array as a multi-dimensionnal structure. It was not noticed before because the lists were converted into a 1D array then into a big string. Two options were possibles: a) not allowing this kind of code (using a 1D array to fill a 2D structure) b) implement kind of de-flattening a python lists into the corresponding multidimmensional matrix For the simplicity I choose option (a), so I updated the tests to use the 'right' syntax.
…r-remove-str-conversion-in-create
… factory itself (e.g. src, template, input...)
…stead parsed by the object
Hello Paul, Thank you so much to rewarming this old fire. For the transition one option could simply be to add a new addComponent/addNode replacing the add addObject |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This supersede PR #45
This takes the work in #45 , update it with master, remove unrelated changes to PrefabLinks, fix it compilation and execution.
This will solve the issue of incompatibility with numpy 2. But at the cost of being way more strict on data structures of lists. Until now, because each input value passed to addObject was processed by the method
toSofaParsableString
we didn't have to make sure the list was correctly formated.Indeed, the method
toSofaParsableString
used a recursive pattern for list object, removing any sort of shape of the list, such as what it is expected in xml: one contiguous chunk of stringed values that will be reshaped in a row major fashion. This allowed to passposition=[0, 0, 0]
for vector, or even worst[0, 0, 0, [0, 1, 0], [0, 2, 0]]
. Now only list of list of three elems (or numpy arrays) will be accepted. So even if only one point is in the mstate we need to putposition=[[0,0,0]]
.This, of course brakes a lot of scenes in a lot of repository. We need to decide what to do. I suggest to make a huge refactoring, by testing this PR on the SOFA CI with a
ci-depend-on
and only merge everything when all scenes are passing.--> 🦸 To make it less breaking, I've added a compat' layer that translate data to string when an error is thrown.
To complete the explanations:
The main difficulty here comes from the factory that takes a structure of type BaseObjectDescription as input of creation of the object. The method that actually creates the object does multiple checks on this description to know if the object can be created regarding the context and tries to fix wrong parametrization as much as possible + it will set the data that are already inside the struc. The issue is that this description object can only store string representation the the datas, which is breaking with numpy 2 because its string representation contains numpy type names which makes no sens in C++.
To solve this, the idea of this work is to, before creating the object, sort the input kwargs to 'createObject' to transform the list into vectors of real data in C++ instead of transforming them to string. But because they are not string anymore, they need to be passed to the object after its creation, so they cannot be used for the factory check and parsing. This is ok for most of the data, but for some such as template, linkslist of link (for multimapping), src and more, this is breaking. Plus there are also some data field that are not real data but only parsed by the object itself. That is the reason of the apparent complexity of the fix.