Skip to content

Optimize interface a python basic#843

Merged
dmitry-kabanov merged 58 commits intoMaRDI4NFDI:mainfrom
dmitry-kabanov:optimize-interface-a-python-basic
Jan 28, 2026
Merged

Optimize interface a python basic#843
dmitry-kabanov merged 58 commits intoMaRDI4NFDI:mainfrom
dmitry-kabanov:optimize-interface-a-python-basic

Conversation

@dmitry-kabanov
Copy link
Copy Markdown
Collaborator

  • Add a basic version of the Optim interface and a Python implementation using scipy.optimize.
  • Add an ability to return values from implementations, because Python cannot mutate strings and we need it to return a message about optimization results.
  • Add tests

@dmitry-kabanov dmitry-kabanov force-pushed the optimize-interface-a-python-basic branch from b7192db to f6b8df7 Compare January 27, 2026 15:36
Somehow, this small refactoring took too much time, and I still do not quite understand why.
For some reason, the reference to the sysconfig module must be preserved.
…object

For some reason, this problem has never manifested itself before,
although it is clear from the code that I have the same fix
for a Python OIF_CALLBACK object.
When I have started to work on the `optim` interface, this reference deficit
started to happen quite often, hence the fix with `Py_INCREF`.
Reference deficit is when a `PyObject *` does not have its refcount
incremented enough times.
…ointers

If the user passes to `oif_create_array_f64` for the `dimensions` parameter
a stack-allocated array, then it can easily happen that in the created array
the field `dimensions` will be a dangling pointer at some point.
To prevent this, we copy the passed array so that it stays with the array
during its lifetime.
…imensions

I really do not know how this thing were working before:
Python was using 32-bit integers while C and Julia 64-bit integers to represent
dimensions of an array.
How they were able to convert them, remains unknown.
@dmitry-kabanov dmitry-kabanov force-pushed the optimize-interface-a-python-basic branch from f6b8df7 to 1009373 Compare January 27, 2026 16:19
@dmitry-kabanov dmitry-kabanov force-pushed the optimize-interface-a-python-basic branch from 2c5ad6f to 413e47b Compare January 28, 2026 17:39
@dmitry-kabanov dmitry-kabanov merged commit cfe7623 into MaRDI4NFDI:main Jan 28, 2026
7 checks passed
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 this pull request may close these issues.

1 participant