teamtomo / libtilt

Image processing for cryo-electron microscopy in PyTorch
Other
14 stars 5 forks source link

Torch unravel index #74

Closed McHaillet closed 2 weeks ago

McHaillet commented 2 weeks ago

Ran latest install to work on device agnostic tests, and had some issues with the tests.

Latest install results in numpy=2 which gave some issues with implicit array copying:

    def test_correlate_2d():
        a = torch.zeros((10, 10))
        a[5, 5] = 1
        b = torch.zeros((10, 10))
        b[6, 6] = 1
        cross_correlation = correlate_2d(a, b, normalize=True)
>       peak_position = np.unravel_index(
            indices=torch.argmax(cross_correlation), shape=cross_correlation.shape
        )
E       DeprecationWarning: __array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and 'copy' keyword arguments.

I noticed from torch 2.2 onwards they have their own unravel index, so: I updated the dependency to at least torch 2.2 and switched code to use the torch version.

Also noticed scipy was not listed as a dependency and is used in the code, so I added it to the deps.

alisterburt commented 2 weeks ago

Hey @McHaillet ! Amazing - will merge this but just to let you know

I've been factoring out the different functionalities in libtilt into separate packages

They're all on PyPI I just haven't moved them into the teamtomo org yet, wanted to add docs first

I'm doing this because I noticed some reticence to depend on/use things in libtilt and a general "unsure what it is/what it does" vibe - so this was a move to lower the bar to using/depending on these functionalities

Cool that you've popped up, did you want to work on something specific? Would be fun to hack on something if you've got time :-)