libigl-python-bindings icon indicating copy to clipboard operation
libigl-python-bindings copied to clipboard

How to serialize from Xcode and deserialize from python

Open stigersh opened this issue 3 years ago • 5 comments

Hey, I'm trying to serialize from Xcode and deserialize from python. I fail to find the interface to deserialize from python. Can you please refer to some example? Best, Anna

Originally posted by @stigersh in https://github.com/libigl/libigl/issues/496#issuecomment-1104841542

stigersh avatar Apr 21 '22 08:04 stigersh

Hi,

In the new version of python binding, serialization is not yet implemented. I would recommend using pickle/numpy in a pure python environment, and use hdf5 in a mixed C++/python environment

jiangzhongshi avatar Apr 21 '22 18:04 jiangzhongshi

Thanks for the quick reply

I found https://github.com/garrison/eigen3-hdf5 for eigen to hdf5, but I still need to come up with some convention parsing it from python into numpy - like saving matrix size, if it's sparse and so on.. Right?

How can I use the old interface? May be it's easier.. It's very convenient for debugging matrices in python vs Xcode

stigersh avatar Apr 22 '22 12:04 stigersh

Hi Anna,

The tools I personally use is https://github.com/BlueBrain/HighFive on the C++ side and https://pypi.org/project/h5py/ on the python side (this is very good)

But admittedly dense matrices are not supported very well, you need a separate parser of the indices.

If you really want to use the old pipeline, there are two ways to go

  • Use the legacy version of libigl (release from circa 2018), not recommended.
  • Use pybind11 to wrap a python interface. https://pybind11.readthedocs.io/en/stable/
  • @teseoch how much effort it is to add deserialize function in the new python binding? Would there be confusion about class names, layout etc?

jiangzhongshi avatar Apr 22 '22 14:04 jiangzhongshi

my workaround was serialize through matfiles which can be read from python

stigersh avatar Apr 27 '23 14:04 stigersh

I'm personally not going to add the serialization bindings. Happy to merge a PR if someone else does.

alecjacobson avatar Sep 26 '23 00:09 alecjacobson