PeterRochford / SkillMetrics

A Python library for calculating and displaying the skill of model predictions against observations.
GNU General Public License v3.0
201 stars 92 forks source link

Outdated numpy dependancy #41

Closed Sonia-Heye closed 1 year ago

Sonia-Heye commented 1 year ago

Good Day,

The latest version of SkillMetrics that I can install with pip crashes when I try to plot target diagrams with this numpy error below. I see this issue is resolved on GitHub as I couldn't trace back the numpy code line giving the issue from: get_target_diagram_axes.py:116. Is it possible to make a new version of installable by pip so this issue can be avoided?

Thanks!

`--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[21], line 3 1 ## My package seems to be out-dated. Using np.asscalar = depreciated but not on GitHub. See if can copy code and use this? ----> 3 target_diagram(np.array(bias_tot),np.array(crmsd_tot),np.array(rmsd_tot), markerLabel = label_tot, 4 markerLabelColor = 'k', markerLegend = 'on', markersymbol = symbols_tot, 5 markerSize=5, markerColor = color_tot, 6 ticks = np.arange(-2,2.5,0.5), 7 axismax = 2.0, 8 circles = [0.5,1,2], 9 circleLineSpec = 'k--', circleLineWidth = 0.5) 11 # plt.savefig(os.path.join(outdir, f'TargetDiagramallvars{tdate}_max2.png'), dpi=600, bbox_inches="tight") 12 # plt.close()

File P:\11206304-futuremares\python_scripts\plot_results3D\WQ_validation\target_diagram.py:232, in target_diagram(*args, kwargs) 229 option = get_target_diagram_options(kwargs) 231 # Get axis values for plot --> 232 axes = get_target_diagram_axes(RMSDs,Bs,option) 234 # Overlay circles 235 overlay_target_diagram_circles(ax, option)

File ~\Anaconda3\envs\dfm_tools_env\lib\site-packages\skill_metrics\get_target_diagram_axes.py:116, in get_target_diagram_axes(x, y, option) 114 # Set tick labels at 0 to blank 115 index = np.where(abs(xtick) < 1.e-7) --> 116 index = np.asscalar(index[0]) 117 xlabel[index] = '' 119 # Set y tick labels

File ~\Anaconda3\envs\dfm_tools_env\lib\site-packages\numpy__init.py:311, in getattr(attr) 308 from .testing import Tester 309 return Tester --> 311 raise AttributeError("module {!r} has no attribute " 312 "{!r}".format(name__, attr))

AttributeError: module 'numpy' has no attribute 'asscalar'`

PeterRochford commented 1 year ago

Sonia-Heye,

Are you using Anaconda? If so I suggest you exit Anaconda with the command "conda deactivate" and try running in your regular operating system environment. I have experienced numerous problems with packages such as numpy in Anaconda that report problems I don't see when using Python in common environments. Trying to fix with pip installs often proves to be fraught with problems.

That said, yes, 'asscalar' is an attribute that is no longer supported by numpy and which I have now replaced in the SkillMetrics package. This will be fixed in the next pip release that I hope to publish within the next couple of days. I'll post another comment here once it is available.

Peter

Sonia-Heye commented 1 year ago

Dear Peter,  Amazing, thank you so much for the tips - yes, I was using Anaconda. I will give this a try and am looking forward to the new release! Thanks a lot! Sonia

PeterRochford commented 1 year ago

Sonia,

SkillMetrics version 1.2.3 is now available that should resolve your numpy problem. It passed all my regression tests using a pip install of the package on a separate laptop.

To upgrade your version:

$ pip install --upgrade SkillMetrics

To check whether you've installed the latest version:

$ pip show SkillMetrics

Please let me know if it works for you now so I can close this issue.

Regards, Peter

PeterRochford commented 1 year ago

I assume this issue is now resolved as I've received no further reports there is a problem.

Sonia-Heye commented 1 year ago

Dear Peter,

Sorry about my delayed response! Yes, it is working now, thank you!

All the Best, Sonia

On Sun, Sep 3, 2023 at 11:58 PM Peter Rochford @.***> wrote:

I assume this issue is now resolved as I've received no further reports there is a problem.

— Reply to this email directly, view it on GitHub https://github.com/PeterRochford/SkillMetrics/issues/41#issuecomment-1704415927, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL4MPX42GYBEAQZVFFWAAZTXYT4NXANCNFSM6AAAAAAZAX3NUA . You are receiving this because you authored the thread.Message ID: @.***>