Giter Site home page Giter Site logo

Comments (4)

shenvitor avatar shenvitor commented on June 29, 2024 1

The previous way to address the problem is possible and not bad.

But now the strategy has changed.
To do the concatenation for each vector in 4-vector one by one, and not do it converted to np.ndarray then all-in-one and convert back.

"Added" since e.g. p1. px, p1.py, p1.pz, and p1.e is directly a numpy array.
Thus no conversion is needed
The latest solution for this is something like this

def concatenate_data(
    data1: tuple[MomentumNumpy4D, ...],
    data2: tuple[MomentumNumpy4D, ...],
) -> tuple[MomentumNumpy4D, ...]:
    return tuple(concatenate_vectors((pi1, pj2)) for pi1, pj2 in zip(data1, data2))


def concatenate_vectors(vectors: tuple[MomentumNumpy4D]) -> MomentumNumpy4D:
    return vector.array(
        {
            "px": np.concatenate([p.px for p in vectors]),
            "py": np.concatenate([p.py for p in vectors]),
            "pz": np.concatenate([p.pz for p in vectors]),
            "E": np.concatenate([p.e for p in vectors]),
        }
    )

from compwa.github.io.

redeboer avatar redeboer commented on June 29, 2024 1

Thus no conversion is needed

Behind the scenes, concatenate_vectors() is still converting between numpy and the vector package, so performance-wise this is not a good solution. But for the notebook, this is fine, the implementation in that function can be replaced by a cleaner, more efficient solution later.

from compwa.github.io.

shenvitor avatar shenvitor commented on June 29, 2024

Done!

from compwa.github.io.

shenvitor avatar shenvitor commented on June 29, 2024

Thus no conversion is needed

Behind the scenes, concatenate_vectors() is still converting between numpy and the vector package, so performance-wise this is not a good solution. But for the notebook, this is fine, the implementation in that function can be replaced by a cleaner, more efficient solution later.

Agree.
Conversion is still there at the end.

from compwa.github.io.

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.