msoechting / lexcube

Lexcube: 3D Data Cube Visualization in Jupyter Notebooks
https://www.lexcube.org
GNU General Public License v3.0
116 stars 7 forks source link

[BUG] lexcube works only for NumPy < 2.0.0 #6

Closed fotakide closed 2 months ago

fotakide commented 3 months ago

Describe the bug Hello @msoechting , I am using lexcube frequently and it is a much-appreciated and excellent tool, thanks for your work! I am in the process of transition to NumPy 2.0.1 and I have an issue. For NumPy 1.26.4 it works just fine.

To Reproduce Steps to reproduce the behavior: Install lexcube 0.4.16 and numpy 2.0.1 in a Python 3.11 conda environment run: import lexcube This error occurs:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 31
     29 # Import visualization libraries for creating plots and interactive maps
     30 import leafmap
---> 31 import lexcube # wait for new release
     32 import matplotlib.pyplot as plt
     33 from matplotlib_scalebar.scalebar import ScaleBar

File [~\anaconda3\envs\tsa\Lib\site-packages\lexcube\__init__.py:20](http://localhost:8888/lab/tree/AUTH_PROJECTS/PHD/PhD_Fotakidis/2_NRT/notebooks/~/anaconda3/envs/tsa/Lib/site-packages/lexcube/__init__.py#line=19)
      1 #!/usr/bin/env python
      2 # coding: utf-8
      3 
   (...)
     17 # You should have received a copy of the GNU General Public License
     18 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
---> 20 from .cube3d import Cube3DWidget, Sliders
     21 from ._version import __version__
     23 def _jupyter_labextension_paths():

File ~\anaconda3\envs\tsa\Lib\site-packages\lexcube\cube3d.py:30
     28 from ._frontend import module_name, module_version
     29 import ipywidgets as widgets
---> 30 from lexcube.lexcube_server.src.lexcube_widget import start_tile_server_in_widget_mode
     32 class Timer:
     33     def __init__(self, timeout, callback):

File [~\anaconda3\envs\tsa\Lib\site-packages\lexcube\lexcube_server\src\lexcube_widget.py:18](http://localhost:8888/lab/tree/AUTH_PROJECTS/PHD/PhD_Fotakidis/2_NRT/notebooks/~/anaconda3/envs/tsa/Lib/site-packages/lexcube/lexcube_server/src/lexcube_widget.py#line=17)
      1 # Lexcube - Interactive 3D Data Cube Visualization
      2 # Copyright (C) 2022 Maximilian Söchting <maximilian.soechting@uni-leipzig.de>
      3 # 
   (...)
     14 # You should have received a copy of the GNU General Public License
     15 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     17 from __future__ import annotations
---> 18 from .tile_server import TileServer, calculate_max_lod, API_VERSION, get_dimension_labels
     19 from typing import Union
     20 import ipywidgets as widgets

File ~\anaconda3\envs\tsa\Lib\site-packages\lexcube\lexcube_server\src\tile_server.py:39
     37 import cv2
     38 import fsspec
---> 39 import numcodecs
     40 import numpy as np
     41 import psutil

File [~\anaconda3\envs\tsa\Lib\site-packages\numcodecs\__init__.py:64](http://localhost:8888/lab/tree/AUTH_PROJECTS/PHD/PhD_Fotakidis/2_NRT/notebooks/~/anaconda3/envs/tsa/Lib/site-packages/numcodecs/__init__.py#line=63)
     61     register_codec(LZ4)
     63 with suppress(ImportError):
---> 64     from numcodecs.zfpy import ZFPY
     65     register_codec(ZFPY)
     67 from numcodecs.astype import AsType

File [~\anaconda3\envs\tsa\Lib\site-packages\numcodecs\zfpy.py:5](http://localhost:8888/lab/tree/AUTH_PROJECTS/PHD/PhD_Fotakidis/2_NRT/notebooks/~/anaconda3/envs/tsa/Lib/site-packages/numcodecs/zfpy.py#line=4)
      3 _zfpy = None
      4 with suppress(ImportError):
----> 5     import zfpy as _zfpy
      8 if _zfpy:
     10     from .abc import Codec

File zfpy.pyx:1, in init zfpy()

ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Expected behavior To smoothly import lexcube.

Desktop (please complete the following information):

Best regards, Vangelis

msoechting commented 3 months ago

Hi @fotakide, thanks for the report. I have noticed the same thing in the last days. It is a problem in the zfpy dependency that is only compatible with Numpy < 2.0 for now (https://github.com/LLNL/zfp/issues/210). I will investigate if there is solution to not use the package as is it not strictly required for the widget operation of the Lexcube package. I will try to come with a fix this week, or otherwise put a requirement for Numpy 1 in the project.

msoechting commented 2 months ago

Hi @fotakide, this has been fixed in the new version 0.4.18. I have removed zfpy for the core widget operation. Therefore, using Numpy 2 with Lexcube should be possible now.