MPh-py / MPh

Pythonic scripting interface for Comsol Multiphysics
https://mph.readthedocs.io
MIT License
263 stars 67 forks source link

Save model as Java/Matlab/VBA code #29

Closed max3-2 closed 3 years ago

max3-2 commented 3 years ago

This will allow saving to different types. Currently this is handled via a second optional argument to not break the API and still have the call to .save() without arguments as a quick way to save to the same model.

john-hen commented 3 years ago

As mentioned in chat, I was wondering if we should add some Python "magic" here to deduce the file format based on the file's .suffix. Then I remembered that popular image writers, such as ImageIO's imwrite() and Matplotlib's savefig(), do just that. So I shuffled some things around to imitate that kind of API. For that reason, though it wouldn't really matter, I renamed the type argument to format. Other than that, it works the same way as before. See commit a33263a25a342a81b9ab0aea85d5cc91380350e8.