Skip to content
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

Flattening a model seems to change the model #1174

Closed
nickerso opened this issue Aug 10, 2023 · 2 comments · Fixed by #1175
Closed

Flattening a model seems to change the model #1174

nickerso opened this issue Aug 10, 2023 · 2 comments · Fixed by #1175

Comments

@nickerso
Copy link
Contributor

If I have things right, flattening a model should not in any way change the model. If I have this wrong, stop reading here :)

It seems that using the bug.py in the attached zip file I'm seeing the original model being changed following the call to flatten it. Found this when I was accidentally validating the wrong model object and first thought this was a bug in the flattening.

bug.zip

This is using a windows build of the current main HEAD code (if I have things right..)

@agarny
Copy link
Contributor

agarny commented Aug 10, 2023

To flatten a model should clearly not change the model.

I have just tried your bug.py script using the main branch on macOS and I got the following output:

The method "parse_model" found 1 issues:
    - (Message) Given model is a CellML 1.1 model, the parser will try to represent this model in CellML 2.0.
The method "validate_model" found 0 issues:
The method "resolve_imports" found 1 issues:
    - (Message) Given model is a CellML 1.1 model, the parser will try to represent this model in CellML 2.0.
The method "validate_resolved_model" found 0 issues:
The method "validate_flattened_model" found 0 issues:
The method "validate_original_model" found 1 issues:
    - (Error) Imported component 'child_main' is not valid because:
  -> Component 'child_main' importing 'main' from 'child.cellml' has an error:
   - Variable 'TAveabsE' in component 'main' has a units reference 'perS' which is neither standard nor defined in the parent model.
swig/python detected a memory leak of type 'std::shared_ptr< libcellml::Parser > *', no destructor found.
swig/python detected a memory leak of type 'std::shared_ptr< libcellml::Model > *', no destructor found.
swig/python detected a memory leak of type 'std::shared_ptr< libcellml::Validator > *', no destructor found.
swig/python detected a memory leak of type 'std::shared_ptr< libcellml::Importer > *', no destructor found.
swig/python detected a memory leak of type 'std::shared_ptr< libcellml::Model > *', no destructor found.

Is that what you are getting? If so, then yeah, the original model gets changed and this is bad. :/

@hsorby
Copy link
Contributor

hsorby commented Aug 10, 2023

Technically it is not the original model that is getting changed, it is the imported child model. The child's units are getting removed resulting in the validation error. But otherwise I agree, it is bad.

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 a pull request may close this issue.

3 participants