Illumina / interop

C++ Library to parse Illumina InterOp files
http://illumina.github.io/interop/index.html
GNU General Public License v3.0
75 stars 26 forks source link

AttributeError: module 'numpy' has no attribute 'object' in index_summary(run_metrics, level='Barcode') #307

Closed hotsoupisgood closed 1 year ago

hotsoupisgood commented 1 year ago

Hi I am getting what seems to be an error with how you call np.object in your code. My code:

  from datetime import datetime
  from interop import py_interop_run_metrics, py_interop_run, py_interop_summary, index_summary
  import json, os
  import numpy as np

  run = '/path/to/run/dir'

  run_metrics = py_interop_run_metrics.run_metrics()
  print("Reading run")
  run_metrics.read(run)
  summary = py_interop_summary.run_summary()

  print("Summarizing metrics")
  py_interop_summary.summarize_run_metrics(run_metrics, summary)
  lanes = summary.lane_count()
  index_summary(run_metrics, level='Barcode')

And the error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[6], line 16
     14 py_interop_summary.summarize_run_metrics(run_metrics, summary)
     15 lanes = summary.lane_count()
---> 16 index_summary(run_metrics, level='Barcode')

File ~/Library/Python/3.8/lib/python/site-packages/interop/core.py:184, in index_summary(run_metrics, level, columns, dtype, **extra)
    182     return np.asarray([])
    183 _str_types = ('Index1', 'Index2', 'Sample Id', 'Project Name')
--> 184 return np.asarray(data, dtype=extra_cols+[(col, dtype if col not in _str_types else np.object) for col in header])

File ~/Library/Python/3.8/lib/python/site-packages/interop/core.py:184, in <listcomp>(.0)
    182     return np.asarray([])
    183 _str_types = ('Index1', 'Index2', 'Sample Id', 'Project Name')
--> 184 return np.asarray(data, dtype=extra_cols+[(col, dtype if col not in _str_types else np.object) for col in header])

File ~/Library/Python/3.8/lib/python/site-packages/numpy/__init__.py:284, in __getattr__(attr)
    281     from .testing import Tester
    282     return Tester
--> 284 raise AttributeError("module {!r} has no attribute "
    285                      "{!r}".format(__name__, attr))

AttributeError: module 'numpy' has no attribute 'object'
hotsoupisgood commented 1 year ago

When changed to np.object_ it works again

ezralanglois commented 1 year ago

thanks for the bug report, looks like this only happens with recent versions of numpy. We will fix this in the next release