Skip to content

Differences between tmap and map/pmap #154

@lcontento

Description

@lcontento

There are some differences between tmap from OhMyThreads and map/pmap from Base/Distributed when dealing with arrays having different axes.
I think it would be great if the behaviour would be the same so that tmap could be used in place of map without worrying about getting different results.
Same examples:

using Distributed
using OffsetArrays
using OhMyThreads

v = OffsetVector(rand(10), 11:20)

# tmap always returns an Array
map(x -> x + 1, v) isa OffsetVector
pmap(x -> x + 1, v) isa OffsetVector
tmap(x -> x + 1, v) isa Vector

# Different exception type when axes do not match
map(+, v, 1:10) # throws DimensionMismatch
pmap(+, v, 1:10) # throws DimensionMismatch
tmap(+, v, 1:10) # throws ErrorException

# In the case the inputs are vectors and have no offset axes, map/pmap allow them to have different lengths
map(+, 1:5, 1:10) # 5-element Vector{Int64}
pmap(+, 1:5, 1:10) # 5-element Vector{Int64}
tmap(+, 1:5, 1:10) # throws ErrorException

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions