Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intro/tomo -> error from scipy.sparse when importing pyxu.abc ("TypeError: Bound must be a type. ") #63

Open
stisa opened this issue Nov 4, 2024 · 1 comment

Comments

@stisa
Copy link

stisa commented Nov 4, 2024

Hi, I am following along the basic tomography tutorial ( https://pyxu-org.github.io/intro/tomo.html ) but I get an error when importing pyxu:

TypeError: Bound must be a type. Got <module 'scipy.sparse' from 'c:\\Users\\silvio.tisato\\AppData\\Local\\miniconda3\\envs\\intel\\lib\.

I installed pyxu by pip install pyxu[complete-cpu] on windows 10, python 3.10, numpy 1.26.4, scipy 1.14.1, pyxu 2.0 in a conda env named intel.
Any idea what is going wrong? Thanks!

Traceback:
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[5], [line 1](vscode-notebook-cell:?execution_count=5&line=1)
----> [1](vscode-notebook-cell:?execution_count=5&line=1) import pyxu.abc as pxa
      [2](vscode-notebook-cell:?execution_count=5&line=2) import pyxu.operator as pxo
      [3](vscode-notebook-cell:?execution_count=5&line=3) from pyxu.operator.interop import from_source

File [c:\Users\silvio.tisato\AppData\Local\miniconda3\envs\intel\lib\site-packages\pyxu\abc\__init__.py:1](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/abc/__init__.py:1)
----> [1](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/abc/__init__.py:1) from pyxu.abc.operator import *
      [2](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/abc/__init__.py:2) from pyxu.abc.solver import *

File [c:\Users\silvio.tisato\AppData\Local\miniconda3\envs\intel\lib\site-packages\pyxu\abc\operator.py:14](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/abc/operator.py:14)
     [11](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/abc/operator.py:11) import scipy.sparse.linalg as spsl
     [13](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/abc/operator.py:13) import pyxu.info.deps as pxd
---> [14](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/abc/operator.py:14) import pyxu.info.ptype as pxt
     [15](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/abc/operator.py:15) import pyxu.info.warning as pxw
     [16](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/abc/operator.py:16) import pyxu.runtime as pxrt

File [c:\Users\silvio.tisato\AppData\Local\miniconda3\envs\intel\lib\site-packages\pyxu\info\ptype.py:32](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/info/ptype.py:32)
     [30](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/info/ptype.py:30) if len(ssm := pxd.supported_sparse_modules()) == 1:
     [31](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/info/ptype.py:31)     print(tuple(ssm)[0])
---> [32](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/info/ptype.py:32)     SparseModule = typ.TypeVar("SparseModule", bound=tuple(ssm)[0])
     [33](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/info/ptype.py:33) else:
     [34](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/site-packages/pyxu/info/ptype.py:34)     SparseModule = typ.TypeVar("SparseModule", *[typ.Literal[_] for _ in ssm])

File [c:\Users\silvio.tisato\AppData\Local\miniconda3\envs\intel\lib\typing.py:804](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:804), in TypeVar.__init__(self, name, bound, covariant, contravariant, *constraints)
    [801](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:801) def __init__(self, name, *constraints, bound=None,
    [802](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:802)              covariant=False, contravariant=False):
    [803](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:803)     self.__name__ = name
--> [804](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:804)     super().__init__(bound, covariant, contravariant)
    [805](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:805)     if constraints and bound is not None:
    [806](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:806)         raise TypeError("Constraints cannot be combined with bound=...")

File [c:\Users\silvio.tisato\AppData\Local\miniconda3\envs\intel\lib\typing.py:731](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:731), in _TypeVarLike.__init__(self, bound, covariant, contravariant)
    [729](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:729) self.__contravariant__ = bool(contravariant)
    [730](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:730) if bound:
--> [731](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:731)     self.__bound__ = _type_check(bound, "Bound must be a type.")
    [732](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:732) else:
    [733](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:733)     self.__bound__ = None

File [c:\Users\silvio.tisato\AppData\Local\miniconda3\envs\intel\lib\typing.py:176](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:176), in _type_check(arg, msg, is_argument, module, allow_special_forms)
    [174](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:174)     return arg
    [175](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:175) if not callable(arg):
--> [176](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:176)     raise TypeError(f"{msg} Got {arg!r:.100}.")
    [177](file:///C:/Users/silvio.tisato/AppData/Local/miniconda3/envs/intel/lib/typing.py:177) return arg
</details>
@SepandKashani
Copy link
Member

Hi @stisa ,

After trying to run the notebook, it seems we forgot to update it to work with Pyxu 2.0: the from_source() function called further down has changed signature for example between v1 and v2. A few other things seem to be problematic too, which may explain your error.

I have my hands full at the moment with a deadline, but will fix this end of next week.

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

No branches or pull requests

2 participants