Skip to content

RWAnalyzer tour notebook complains about numpy #38

@francoislaurent

Description

@francoislaurent

Code cell 7 crashes with the following stack trace:

AttributeError                            Traceback (most recent call last)
Cell In[7], line 6
      2 import matplotlib.pyplot as plt
      4 fig, ax        = plt.subplots(figsize=(8,7))
----> 6 movie          = a.mapper.mpl.animate(fig, maps, feature='potential',
      7                     axes=ax, unit='std', overlay_locations=True)

File .../tramway/analyzer/mapper/mpl.py:534, in Mpl.animate(self, fig, maps, feature, sampling, overlay_locations, axes, aspect, logscale, composable, **kwargs)
    532 #
    533 _iter = self._eldest_parent.time.as_time_segments
--> 534 patches = self.plotter(
    535     axes,
    536     sampling.tessellation.spatial_mesh,
    537     sampling.bounding_box,
    538     **map_kwargs,
    539 )
    540 #
    541 if isinstance(fig, FuncAnimations):

File .../tramway/analyzer/mapper/mpl.py:80, in PatchCollection.__init__(self, ax, mesh, bounding_box, overlay_locations, time_label_fmt, time_label_loc, **kwargs)
     53 """
     54 Arguments:
     55 
   (...)
     73 Extra keyword arguments are passed to :func:`~tramway.plot.map.scalar_map_2d`.
     74 """
     75 if not isinstance(mesh, Partition):
     76     mesh = Partition(
     77         pd.DataFrame([], columns=list("nxyt")),
     78         mesh,
     79         location_count=np.full(
---> 80             mesh.number_of_cells, np.iinfo(np.int).max, dtype=np.int
     81         ),
     82         bounding_box=bounding_box,
     83     )
     84 self.glyphs, self.bin_indices = scalar_map_2d(
     85     mesh,
     86     pd.Series(np.zeros(mesh.number_of_cells, dtype=np.float)),
   (...)
     89     **kwargs,
     90 )
     91 if overlay_locations not in (None, False):

File .../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 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
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

Rant: once again, NumPy proves to be the most unstable package of the numeric Python stack. Not a single project of mine has not been affected by a Numpy issue over the last year.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions