Git Product home page Git Product logo

Comments (6)

jpivarski avatar jpivarski commented on May 23, 2024

Thanks for posting— I intend to do this soon. I'm surprised that the second example doesn't already give you a jagged array, since it would be trivially returning self (a Numpy array would copy in that situation, but awkward arrays are immutable, so they return views in such situations).

from awkward-0.x.

pibion avatar pibion commented on May 23, 2024

Eek, apologies, I thought I'd already tried that call. The call

data["traces"][:]

does in fact return a <class 'awkward.array.jagged.JaggedArray'> that I can iterate over. However, I run into an error when I iterate. I think this is because of how I'm loading my data into awkward-array; the last record is different from all the others and doesn't have digitized data. I'll try to confirm that's what's going on.

Meanwhile, here's the behavior I see:

traces = data["traces"][:]

for trace in traces:
    # length of a trace is always 256
    if numpy.size(trace) != 256:
        print("different size")
        break

from awkward-0.x.

jpivarski avatar jpivarski commented on May 23, 2024

A quicker way:

(traces.counts == 256).all()

would return True if all traces happen to have size 256. traces.counts is just a Numpy array.

from awkward-0.x.

pibion avatar pibion commented on May 23, 2024

Yup, so

(traces.counts == 256).all()

returns False on my data.

Should I open another issue, asking how to sensibly store what's essentially a different kind of data in my awkward-array structure?

from awkward-0.x.

jpivarski avatar jpivarski commented on May 23, 2024

Sure. It sounds like all of this would be fixed by documentation, of course. :)

from awkward-0.x.

jpivarski avatar jpivarski commented on May 23, 2024

Fixed by #34. You should be able to do subslices now:

jaggedarray[:, start:end]

which always return JaggedArrays because start:end might not be within the second axis range for all elements.

There's also

jaggedarray.regular()

which attempts to turn the jagged array into a regular, non-jagged array, throwing an error if not all subentries have the same shape. In your data, you should be able to

jaggedarray[:-1].regular()

because all of your traces have the same size except for the last, which is empty. Actually, having the regular() function makes subslices irrelevant for your case (because you can do normal Numpy axis subslicing), but anyway, you have choices. :)

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.