DanPorter / Dans_Diffraction

Reads crystallographic cif files and simulates diffraction
Apache License 2.0
45 stars 13 forks source link

AttributeError: module 'numpy' has no attribute 'float' #8

Closed MShirazAhmad closed 1 year ago

MShirazAhmad commented 1 year ago

Error Details:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[18], line 1
----> 1 import Dans_Diffraction as dif
      2 xtl = dif.Crystal('2100636.cif')
      3 xtl.info() # print Crystal structure parameters

File ~/opt/anaconda3/envs/Xerus/lib/python3.8/site-packages/Dans_Diffraction/__init__.py:105
      1 """
      2 Dans_Diffraction
      3 Python package for loading crystal structures from cif files and calculating diffraction information.
   (...)
     97  Diamond Light Source, Chilton, Didcot, Oxon, OX11 0DE, U.K.
     98 """
    100 # Set TkAgg environment
    101 #import matplotlib
    102 #matplotlib.use('TkAgg')
    103 
    104 # Dans Diffraction
--> 105 from . import functions_general as fg
    106 from . import functions_plotting as fp
    107 from . import functions_crystallography as fc

File ~/opt/anaconda3/envs/Xerus/lib/python3.8/site-packages/Dans_Diffraction/functions_general.py:647
    643     B = np.dot(A, np.linalg.inv(CELL))
    644     return B
--> 647 def isincell(A, cell_centre=[0, 0, 0], CELL=cell()):
    648     """
    649      Return boolean of whether vector xyx is inside a cell defined by position, size and rotation
    650        A = [x,y,z] or [[x1,y1,z1]] array of positions
   (...)
    659        >>> [False,True,True]
    660     """
    662     A = np.asarray(A, dtype=np.float).reshape((-1, 3))

File ~/opt/anaconda3/envs/Xerus/lib/python3.8/site-packages/Dans_Diffraction/functions_general.py:631, in cell(lengths, rotation)
    624 """
    625 Returns a unit CELL with vectors defined by length and rotation (Deg)
    626 :param lengths:
    627 :param rotation:
    628 :return:
    629 """
    630 CELL = np.eye(3) * lengths
--> 631 CELL = rot3D(CELL, *rotation)
    632 return CELL

File ~/opt/anaconda3/envs/Xerus/lib/python3.8/site-packages/Dans_Diffraction/functions_general.py:200, in rot3D(A, alpha, beta, gamma)
    183 def rot3D(A, alpha=0., beta=0., gamma=0.):
    184     """Rotate 3D vector A by euler angles
    185         A = rot3D(A,alpha=0.,beta=0.,gamma=0.)
    186        where alpha = angle from X axis to Y axis (Yaw)
   (...)
    197             _\/X
    198     """
--> 200     A = np.asarray(A, dtype=np.float).reshape((-1, 3))
    202     # Convert to radians
    203     alpha = alpha * np.pi / 180.

File ~/opt/anaconda3/envs/Xerus/lib/python3.8/site-packages/numpy/__init__.py:305, in __getattr__(attr)
    300     warnings.warn(
    301         f"In the future `np.{attr}` will be defined as the "
    302         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    304 if attr in __former_attrs__:
--> 305     raise AttributeError(__former_attrs__[attr])
    307 # Importing Tester requires importing all of UnitTest which is not a
    308 # cheap import Since it is mainly used in test suits, we lazy import it
    309 # here to save on the order of 10 ms of import time for most users
    310 #
    311 # The previous way Tester was imported also had a side effect of adding
    312 # the full `numpy.testing` namespace
    313 if attr == 'testing':

AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
DanPorter commented 1 year ago

Hi Shiraz,

Thanks for your message and pointing this out. I think you are using an old version of the code as all the "np.float" references have now been removed since version 2.2.2.

You can get the latest version of Dans_Diffraction directly from GitHub: $ pip install git+https://github.com/DanPorter/Dans_Diffraction.git

This reminds me though that I haven't updated the PyPi package for some time so I should get round to this.

Please let me know if you have any further problems or any questions about the software.

DanPorter commented 1 year ago

I have now updated the version available through PyPi, please run the command: $ pip install --upgrade Dans_Diffraction