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

Numpy 2.0 related issue - use of 'np.Inf`' #179

Closed
brianmcdonald opened this issue Jun 24, 2024 · 3 comments
Closed

Numpy 2.0 related issue - use of 'np.Inf`' #179

brianmcdonald opened this issue Jun 24, 2024 · 3 comments

Comments

@brianmcdonald
Copy link

Updating to Numpy 2.0 appears to cause an issue for adjust_text.

AttributeError                            Traceback (most recent call last)
Cell In[6], line 15
     13 coordination.plot(ax=ax, color='#0033a1')
     14 texts = [plt.annotate(text=row['Mission'], xy=row['coords'], horizontalalignment='center', path_effects=[pe.withStroke(linewidth=3, foreground="white")]) for idx, row in coordination.iterrows()]
---> 15 adjust_text(texts)
     16 fig.savefig("outputs/map-coord-2023.svg", format="svg", transparent=True, bbox_inches='tight', pad_inches=.2)  

File [~\AppData\Local\miniforge3\envs\cccm\Lib\site-packages\adjustText\__init__.py:514](http://localhost:8888/lab/tree/Institutional%20Questionaire/2024(2023%20data)/~/AppData/Local/miniforge3/envs/cccm/Lib/site-packages/adjustText/__init__.py#line=513), in adjust_text(texts, x, y, objects, avoid_self, force_text, force_static, force_pull, force_explode, expand, explode_radius, ensure_inside_axes, expand_axes, only_move, ax, min_arrow_len, time_lim, iter_lim, *args, **kwargs)
    509         explode_y = np.zeros_like(explode_y)
    510     coords = apply_shifts(
    511         coords, -explode_x * force_explode[0], -explode_y * force_explode[1]
    512     )
--> 514 error = np.Inf
    516 # i_0 = 100
    517 # i = i_0
    518 # expand_start = 1.05, 1.5
   (...)
    522 # expands = list(zip(np.linspace(expand_start[0], expand_end[0], expand_steps),
    523 #                 np.linspace(expand_start[1], expand_end[1], expand_steps)))
    525 if expand_axes:

File [~\AppData\Local\miniforge3\envs\cccm\Lib\site-packages\numpy\__init__.py:397](http://localhost:8888/lab/tree/Institutional%20Questionaire/2024(2023%20data)/~/AppData/Local/miniforge3/envs/cccm/Lib/site-packages/numpy/__init__.py#line=396), in __getattr__(attr)
    394     raise AttributeError(__former_attrs__[attr])
    396 if attr in __expired_attributes__:
--> 397     raise AttributeError(
    398         f"`np.{attr}` was removed in the NumPy 2.0 release. "
    399         f"{__expired_attributes__[attr]}"
    400     )
    402 if attr == "chararray":
    403     warnings.warn(
    404         "`np.chararray` is deprecated and will be removed from "
    405         "the main namespace in the future. Use an array with a string "
    406         "or bytes dtype instead.", DeprecationWarning, stacklevel=2)

AttributeError: `np.Inf` was removed in the NumPy 2.0 release. Use `np.inf` instead. 
@Phlya
Copy link
Owner

Phlya commented Jun 24, 2024

Thank you, I believe this was fixed last week, can you try the master branch?

@brianmcdonald
Copy link
Author

Thank you for making such a useful tool. Its very helpful for lableing maps.
I was using the latest package from conda forge.
I tried installing from the master branch using pip, but it installed the latest release version: 1.1.1, which looks to have been released in March.

@brianmcdonald
Copy link
Author

Correction. The master branch fixed the issue.

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