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

Python wrapper returns SwigPyObject instead of CPACSWalls #1012

Closed
MarAlder opened this issue Jun 17, 2024 · 6 comments · Fixed by #1035
Closed

Python wrapper returns SwigPyObject instead of CPACSWalls #1012

MarAlder opened this issue Jun 17, 2024 · 6 comments · Fixed by #1035
Assignees

Comments

@MarAlder
Copy link
Collaborator

I still can't figure out why the walls (CPACSWalls.h) are not being exported correctly with the Python bindings. Does anyone have an idea?

Minimal test code:

from tixi3.tixi3wrapper import Tixi3
from tigl3.tigl3wrapper import Tigl3
import tigl3.configuration

tixi_h = Tixi3()
tigl_h = Tigl3()

tixi_h.open("test_fuselage_walls_ex1.xml")
tigl_h.open(tixi_h, "")

mgr = tigl3.configuration.CCPACSConfigurationManager_get_instance()
aircraft_config = mgr.get_configuration(tigl_h._handle.value)
walls = aircraft_config.get_fuselage("fuselage").get_structure().get_walls()

help(walls)

Test data:
test_fuselage_walls_ex1.zip

Output:

class SwigPyObject(object)
 |  Swig object carries a C/C++ instance pointer
 |
 |  Methods defined here:
 |
 |  __eq__(self, value, /)
 |      Return self==value.
 |
 |  __ge__(self, value, /)
 |      Return self>=value.
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
[...]

%boost_optional(tigl::generated::CPACSWalls)
%include "generated/CPACSWalls.h"

@joergbrech
Copy link
Contributor

Is there an #include "generated/CPACSWalls.h" missing in configuration.i? Note the # instead of the %.

@MarAlder
Copy link
Collaborator Author

I also thought so, but no effect (see 2e43950)

@joergbrech
Copy link
Contributor

Sorry, could you try CCPACSWalls instead of generated/CPACSWalls.h?

@MarAlder
Copy link
Collaborator Author

Nice to see progress here, @merakulix! Perhaps we should strive to also cover such Python functions via unittests? I made an example on my fork for the tanks. The pythonwrapper tests are still at the old TiGL/TiXI versions.

@joergbrech
Copy link
Contributor

Perhaps we should strive to also cover such Python functions via unittests?

I totally agree, but I wouldn't want to add it to this issue/PR-pair.

Any idea on a pragmatic way to achieve this? Here are some ramblings:

  • Regardless on how we implement the Python tests, having them in CI would be an improvement.
  • When we implement the python tests, we could agree that we don't actually have to test the functionality of the swig-wrapped classes in the Python unit tests, but that it suffices to just the existence of the classes in the Python interface. This would limit the maintenance overhead of TiGL. It might be possible to achieve this with some degree of automation, not sure. Without automation, every contributor must add these checks themselves and the reviewer must manually verify that all relevant checks are in place, which adds a (small) burden to the maintenance.
  • We try to derive C++ and Python unit tests from a model-based testing approach. This would involve a lot of work to set the system up and the outcome is not clear: It could be an awesome new thing that boosts robustness or it could turn out to be too complex and impracticable, because it is really hard to formally model the process of modelling with TiGL/CPACS.

This is related to #826.

@MarAlder
Copy link
Collaborator Author

True, let's move this discussion to #826.

joergbrech added a commit that referenced this issue Nov 28, 2024
 Fix Python wrapper returns SwigPyObject instead of CPACSWalls (Issue #1012)
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