Git Product home page Git Product logo

Comments (1)

jpivarski avatar jpivarski commented on May 23, 2024

I've looked into this, and while I found and fixed a few corner-case bugs by stressing different ways of having empty lists, I didn't find a place where numpy.maximum or numpy.minimum is mistakenly applied to an empty Numpy array (which is what I was worried about).

Your example above will still fail because awkward.fromiter([]) returns an empty Numpy array, which will always complain about emptyarray.max(). I wish it wouldn't, but I can't change Numpy.

Here's an illustration, using awkward.type.fromarray to show how it depends on the type of the array:

>>> flat = awkward.fromiter([])
>>> type(flat)
<class 'numpy.ndarray'>
>>> print(awkward.type.fromarray(flat))
[0, 0) -> float64
>>> # which is to say that it takes an integer in the interval [0, 0) and returns a float
>>> 
>>> jagged = awkward.JaggedArray([], [], [])   # no starts, no stops, no content
>>> type(jagged)
<class 'awkward.array.jagged.JaggedArray'>
>>> print(awkward.type.fromarray(jagged))
[0, 0) -> [0, inf) -> float64
>>> # which is to say that it takes an integer in [0, 0) and returns something that takes any integer, which in turn returns a float
>>> 
>>> flat.max()    # expect it to fail because "flat" is a numpy.ndarray
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/miniconda3/lib/python3.7/site-packages/numpy/core/_methods.py", line 28, in _amax
    return umr_maximum(a, axis, None, out, keepdims, initial)
ValueError: zero-size array to reduction operation maximum which has no identity
>>> 
>>> jagged.max()    # we want it to pass because "jagged" is a JaggedArray
array([], dtype=float64)

from awkward-0.x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.