Skip to content

np.bool error in gr.head() #386

Description

@davidhbrann

Right now gr.head() fails due to a reference to np.bool insteal of bool. I'm using numpy version '1.26.4'.

gr = pr.from_dict({'Chromosome': ['chr1', 'chr1'], 'Start': [3, 5], 'End': [9, 7],'Strand': ["+", "-"]})
gr.head()
np.bool` will be defined as the corresponding NumPy scalar.
  subsetter = np.zeros(len(self), dtype=np.bool)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[52], line 1
----> 1 fragments.head()

File ~/micromamba/envs/scenicplus/lib/python3.11/site-packages/pyranges/pyranges.py:1708, in PyRanges.head(self, n)
   1650 def head(self, n=8):
   1652     """Return the n first rows.
   1653 
   1654     Parameters
   (...)
   1705     For printing, the PyRanges was sorted on Chromosome and Strand.
   1706     """
-> 1708     subsetter = np.zeros(len(self), dtype=np.bool)
   1709     subsetter[:n] = True
   1710     return self[subsetter]

File ~/micromamba/envs/scenicplus/lib/python3.11/site-packages/numpy/__init__.py:324, in __getattr__(attr)
    319     warnings.warn(
    320         f"In the future `np.{attr}` will be defined as the "
    321         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    323 if attr in __former_attrs__:
--> 324     raise AttributeError(__former_attrs__[attr])
    326 if attr == 'testing':
    327     import numpy.testing as testing

AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions