pysal / mgwr

Multiscale Geographically Weighted Regression (MGWR)

Home Page:https://mgwr.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compatibility issue with numpy version 1.20 and later

opened this issue · comments

Hello,

I've encountered an issue when using the mgwr package with numpy version 1.20 and later. The error message I receive is:

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

This error occurs when I try to fit a GWR model and print the summary:

# Fit the GWR model
gwr_model = GWR(coords, np.log(y), X, gwr_bw, kernel = 'gaussian', spherical = True)
gwr_results = gwr_model.fit()

# Print the summary of the model
print(gwr_results.summary())

The specific line causing the error is in the iwls.py file of the spglm package:

betas = np.zeros((x.shape[1], 1), np.float)
Issue can be fixed by replacing np.float with float or np.float64. Here's the corrected line:

betas = np.zeros((x.shape[1], 1), float)
or

betas = np.zeros((x.shape[1], 1), np.float64)