JuliaParallel / JuliaParallel/DistributedArrays.jl

ddata doesn't work as intended when length(data) = length(pids)

未关闭
#239 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Julia
星标
205
派生
34
PR 合并指标
30 天内没有已合并 PR

描述

The documentation says the following about `ddata`:

> The function `ddata(;T::Type=Any, init::Function=I->nothing, pids=workers(), data::Vector=[])` can be used to created a distributed vector whose localparts need not be Arrays.
> ...
> Argument `data` if supplied is distributed over the `pids`. `length(data)` must be a multiple of `length(pids)`. **If the multiple is 1, returns a `DArray{T,1,T}` where T is `eltype(data)`**. If the multiple is greater than 1, returns a `DArray{T,1,Array{T,1}}`, i.e., it is equivalent to calling `distribute(data)`.

The case when "_the multiple is 1_" is giving me trouble:

```Julia
julia> using Distributed; addprocs(2)
julia> using DistributedArrays

julia> ddata(data=["foo", "bar"])

2-element DArray{String, 1, String}:
ERROR: TypeError: in typeassert, expected String, got a value of type Char
...
```
```Julia
julia> ddata()

ERROR: On worker 2:
MethodError: no method matching getindex(::Nothing, ::Int64)
...
```

Note that `ddata` works as intended for multiples greater than 1:

```julia
julia> ddata(data=["foo", "bar", "foo", "bar"])

4-element DArray{String, 1, Vector{String}}:
"foo"
"bar"
"foo"
"bar"
```

```julia
julia> ddata(;T=Any, init=I->nothing, pids=workers(), data=[nothing, nothing, nothing, nothing])

4-element DArray{Nothing, 1, Vector{Nothing}}:
nothing
nothing
nothing
nothing
```

First time posting an issue, hope I'm doing things right!

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。