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

reduce: count_nonzero results in AttributeError on numpy arrays #119

Open
wctaylor opened this issue Apr 3, 2020 · 1 comment
Open

reduce: count_nonzero results in AttributeError on numpy arrays #119

wctaylor opened this issue Apr 3, 2020 · 1 comment

Comments

@wctaylor
Copy link

wctaylor commented Apr 3, 2020

While the numpy package has a count_nonzero function, it is not an attribute of numpy arrays. Not quite sure what the best way to fix this is.

Relevant processing configuration info

stages:
    - pulse_cleaning: fast_carpenter.Define
pulse_cleaning:
    variables:
        - S2pulse: pulse_classification == 2
        - nS2pulses: {reduce: count_nonzero, formula: S2pulse}
        - S2area: {reduce: sum, formula: S2pulse * xyz_corrected_pulse_area_all_phe}

Stack Trace:

Traceback (most recent call last):
  File "/global/common/cori/software/python/3.6-anaconda-5.2/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/global/homes/w/wtaylor/.local/cori/3.6-anaconda-5.2/lib/python3.6/site-packages/mantichora/hubmp.py", line 251, in run
    self._run_tasks()
  File "/global/homes/w/wtaylor/.local/cori/3.6-anaconda-5.2/lib/python3.6/site-packages/mantichora/hubmp.py", line 271, in _run_tasks
    result = task_func()
  File "/global/homes/w/wtaylor/.local/cori/3.6-anaconda-5.2/lib/python3.6/site-packages/mantichora/main.py", line 18, in __call__
    return self.task(*self.args, **self.kwargs)
  File "/global/homes/w/wtaylor/.local/cori/3.6-anaconda-5.2/lib/python3.6/site-packages/alphatwirl/concurrently/CommunicationChannel.py", line 16, in __call__
    return self.task(*self.args, **self.kwargs)
  File "/global/homes/w/wtaylor/.local/cori/3.6-anaconda-5.2/lib/python3.6/site-packages/alphatwirl/loop/EventLoop.py", line 45, in __call__
    self.reader.event(event)
  File "/global/homes/w/wtaylor/.local/cori/3.6-anaconda-5.2/lib/python3.6/site-packages/alphatwirl/loop/ReaderComposite.py", line 43, in event
    if reader.event(event) is False:
  File "/global/homes/w/wtaylor/.local/cori/3.6-anaconda-5.2/lib/python3.6/site-packages/fast_carpenter/define/variables.py", line 73, in event
    mask=mask, reduction=reduction)
  File "/global/homes/w/wtaylor/.local/cori/3.6-anaconda-5.2/lib/python3.6/site-packages/fast_carpenter/define/variables.py", line 148, in full_evaluate
    result = reduction(result)
  File "/global/homes/w/wtaylor/.local/cori/3.6-anaconda-5.2/lib/python3.6/site-packages/fast_carpenter/define/reductions.py", line 52, in __call__
    return getattr(array, self.method_name)()
AttributeError: 'numpy.ndarray' object has no attribute 'count_nonzero'
@kreczko
Copy link
Contributor

kreczko commented Mar 28, 2022

Fixed in #144

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