eitcom / pyEIT

Python based toolkit for Electrical Impedance Tomography
Other
169 stars 96 forks source link

ver 1.2.2 - examples stopped working #58

Closed mjkrasny closed 1 year ago

mjkrasny commented 2 years ago

After update from ver. 1.1.6 to 1.2.2 I can't run example codes.

i.e.: # eit_dynamic_bp.py

returns:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_39680/3106232781.py in <module>
      8 import matplotlib.pyplot as plt
      9 import numpy as np
---> 10 import pyeit.eit.bp as bp
     11 import pyeit.eit.protocol as protocol
     12 import pyeit.mesh as mesh

C:\ProgramData\Anaconda3\lib\site-packages\pyeit\eit\__init__.py in <module>
     12   - interp2d: Spatial interpolation for EIT
     13 """
---> 14 from .bp import BP
     15 from .jac import JAC
     16 from .svd import SVD

C:\ProgramData\Anaconda3\lib\site-packages\pyeit\eit\bp.py in <module>
      8 from typing import Union
      9 import numpy as np
---> 10 from .base import EitBase
     11 
     12 

C:\ProgramData\Anaconda3\lib\site-packages\pyeit\eit\base.py in <module>
     11 from abc import ABC, abstractmethod
     12 import numpy as np
---> 13 from pyeit.eit.protocol import PyEITProtocol
     14 from pyeit.mesh import PyEITMesh
     15 

C:\ProgramData\Anaconda3\lib\site-packages\pyeit\eit\protocol.py in <module>
    143 def create(
    144     n_el: int = 16,
--> 145     dist_exc: Union[int, list[int]] = 1,
    146     step_meas: int = 1,
    147     parser_meas: Union[str, list[str]] = "std",

TypeError: 'type' object is not subscriptable

[update 25/06/2022]:

I just checked all versions one by one, and it looks like version change from 1.1.9 to 1.2.0 broke something. Codes run until version 1.1.9 with no issues, starting from 1.2.0 one get error:

TypeError                                 Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_76780/2754546162.py in <module>
     16 """ 0. construct mesh """
     17 # Mesh shape is specified with fd parameter in the instantiation, e.g : fd=thorax , Default :fd=circle
---> 18 mesh_obj, el_pos = mesh.create(16, h0=0.1, fd=thorax)
     19 
     20 # extract node, element, alpha

TypeError: cannot unpack non-iterable PyEITMesh object
liubenyuan commented 2 years ago

Which python version are you using? It seems that you should upgrade to Python > 3.9 to using Typing

mjkrasny commented 2 years ago

Python 3.10.4 | packaged by conda-forge | (main, Mar 30 2022, 08:38:02) [MSC v.1916 64 bit (AMD64)] on win32

liubenyuan commented 2 years ago

Hi, I am sorry for the inconvenient. Could you please try the following?

from typing import Union, List
# and replace every occurrence of list[] to List[]

I make a bug-fix branch on: https://github.com/liubenyuan/pyEIT/tree/bug58

I am using

import sys
import numpy
import pyeit

print("python =", sys.version)
print("numpy =", numpy.__version__)
print("pyeit =", pyeit.APP_VERSION)

where

python = 3.10.5 | packaged by conda-forge | (main, Jun 14 2022, 06:57:19) [MSC v.1929 64 bit (AMD64)]
numpy = 1.22.4
pyeit = 1.2.2
liubenyuan commented 1 year ago

This issue might be fixed using commit #72