Title: [Binding/Sofa.Core] Call init() by default when creating a python object by damienmarchal · Pull Request #173 · sofa-framework/SofaPython3 · GitHub
Open Graph Title: [Binding/Sofa.Core] Call init() by default when creating a python object by damienmarchal · Pull Request #173 · sofa-framework/SofaPython3
X Title: [Binding/Sofa.Core] Call init() by default when creating a python object by damienmarchal · Pull Request #173 · sofa-framework/SofaPython3
Description: The default behavior should be the most common use case while more rare scenario should be accessible but with explicit call api (opt-in vs opt-out strategy). Currently the default case is: m = r.addObject("MechanicalObject", position=[1,2,3]) m.init() l.rest_position() ## Rest position is created from position at init This is a bit weird as one may expect that once "created" in python the object is immediately accessible in an inited state (not doing so imply user to call init() at every lines). After the PR the default case become: m = r.addObject("MechanicalObject", position=[1,2,3]) l.rest_position() But for rare use case where it makes sense the no init behavior can still be done explicitly: m = r.addObject("MechanicalObject", position=[1,2,3], __noInit=True) l.rest_position() # Rest position is "uninited" m.init() # You can control when you init the object l.rest_position() # Unit tests are provided to validate the behavior. The PR use the Sofa.future module to let users to enable/disable the behavior. By default, the SofaPython behavior is preserved (so no auto-init) If you want to test you just need to do from Sofa.Lifetime import __feature__ def createScene(root) with __feature__("object_auto_init", True): root.addObject(....) This PR depends on #184
Open Graph Description: The default behavior should be the most common use case while more rare scenario should be accessible but with explicit call api (opt-in vs opt-out strategy). Currently the default case is: m = ...
X Description: The default behavior should be the most common use case while more rare scenario should be accessible but with explicit call api (opt-in vs opt-out strategy). Currently the default case is: m = ...
Opengraph URL: https://github.com/sofa-framework/SofaPython3/pull/173
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:ea172b64-672f-11f3-e3d3-bd0f8988216f |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | C2CC:27367:A5E80F:D34BBA:697F7056 |
| html-safe-nonce | 2fb5b5e85f4096f6cb5ec6861835faf77ba7bc89016e4b0dec46154eee6fba70 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkNDOjI3MzY3OkE1RTgwRjpEMzRCQkE6Njk3RjcwNTYiLCJ2aXNpdG9yX2lkIjoiMzY0NDU4MjA2MjI4OTAyMzA2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6670204c16ce67ae62cc3538c31fd6af910088ceb772eadfe8113647db934cfb |
| hovercard-subject-tag | pull_request:731379177 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/sofa-framework/SofaPython3/pull/173/checks |
| twitter:image | https://avatars.githubusercontent.com/u/12644882?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/12644882?s=400&v=4 |
| og:image:alt | The default behavior should be the most common use case while more rare scenario should be accessible but with explicit call api (opt-in vs opt-out strategy). Currently the default case is: m = ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/sofa-framework/SofaPython3 git https://github.com/sofa-framework/SofaPython3.git |
| octolytics-dimension-user_id | 11028508 |
| octolytics-dimension-user_login | sofa-framework |
| octolytics-dimension-repository_id | 260159147 |
| octolytics-dimension-repository_nwo | sofa-framework/SofaPython3 |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 260159147 |
| octolytics-dimension-repository_network_root_nwo | sofa-framework/SofaPython3 |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7c85641c598ad130c74f7bcc27f58575cac69551 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width