Git Product home page Git Product logo

Comments (4)

cuviper avatar cuviper commented on July 18, 2024

I don't understand the question. Are you getting errors from this? Are the return types not what you intended?

from rayon.

kurt-rhee avatar kurt-rhee commented on July 18, 2024

Hello,

Apologies for my unclear question. I am not getting errors, but you are right that my return types are not what I expected.

The first function returns a tuple of vectors, while the second function returns a vector of tuples. I am not sure why function 1 would return a different type than function 2 given the underlying functions that are being mapped.

from rayon.

cuviper avatar cuviper commented on July 18, 2024

The collect() method is generic, where its return type can be anything that implements FromParallelIterator, and that is usually inferred from the surrounding context. So in the first case:

let (azimuth_series, zenith_series) = (/*iter*/).collect();

Your let pattern is forcing the result to be a tuple, and you must have some other code that is driving type inference for each of those "series" to end up fully resolved as (Vec<T>, Vec<U>). Rayon has an implementation of FromParallelIterator for tuple pairs that acts pretty much like unzip().

In the second case, your code is explicitly forcing the Vec<(X, Y, Z)> type for collect():

let spherical_coordinates: Vec<(SunCartesianX, SunCartesianY, SunCartesianZ)> = (/*iter*/).collect();

We don't have a direct way to collect (Vec<X>, Vec<Y>, Vec<Z>), if that's what you wanted, but you can use nested tuple pairs for this if you produce parallel items of the same shape, like:

let (vx, (vy, vz)) = (/* iter with Item=(x, (y, z)) */).collect();
// or
let ((vx, vy), vz) = (/* iter with Item=((x, y), z) */).collect();

from rayon.

kurt-rhee avatar kurt-rhee commented on July 18, 2024

Thank you! That was a very clear explanation. Closing as complete.

from rayon.

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.