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

未关闭
#239 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
julia

调研方向

从 ddata 入口点开始,比较其文档所述行为与所提供的复现示例,针对长度等于 worker 数量的数据,包括不带数据的 ddata()。使用 Distributed 和 DistributedArrays 重新运行这些示例;完成的标准是两种情况都能正常工作,不再出现所示的 TypeError 或 MethodError,同时文档所述行为保持准确。

由索引模型根据 Issue 内容生成。

描述

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> 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> ddata() 

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

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

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

4-element DArray{String, 1, Vector{String}}:
 "foo"
 "bar"
 "foo"
 "bar"
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!

主要语言
Julia
星标
205
派生
34
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

JuliaParallel/DistributedArrays.jl 的其他 Issue

查看 JuliaParallel/DistributedArrays.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 发到你的邮箱

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