ubarsc / pyshepseg

Python implementation of image segmentation algorithm of Shepherd et al (2019) Operational Large-Scale Segmentation of Imagery Based on Iterative Elimination. Remote Sensing 11(6).
https://www.pyshepseg.org
MIT License
10 stars 4 forks source link

Numpydoc and jitclass #36

Closed neilflood closed 1 year ago

neilflood commented 1 year ago

This kludge will allow classes decorated with @jitclass to also render in Sphinx with the numpydoc extension. These two don't play well together, so this fakes the jitclass decorator when running with sphinx.

The last bit of ugliness I had to do was in shepseg.py, where I needed to make the RowColArray_Type declaration conditional on no sphinx. I tried several ways around this, but they either failed with sphinx, or failed when running for real, so this is all I have left.

One thing I had hopes for was making the fake jitclass decorator return a derived class with an extra field for .class_type.instance_type. This works, in principle, but numpydoc won't render the resulting class, whereas if it returns the real original class, numpydoc renders it fine. I don't understand why.

@gillins Any thoughts?

gillins commented 1 year ago

No thoughts, happy to go with this for now. This stuff may start working in future without this (?) so probably not worth spending too much effort. Merge when ready.

neilflood commented 1 year ago

That's a good point. OK, merging.