Skip to content

Broadcast type-stability for ArrayPartition #8

Description

@rdeits

Just saw your blog post, and I'm excited to try out the ArrayPartition type. But I'm seeing some type instability for a simple example when broadcasting. Am I doing something wrong?

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0-pre.beta.461 (2017-05-09 18:23 UTC)
 _/ |\__'_|_|_|\__'_|  |  release-0.6/518b9d92e4* (fork: 1 commits, 7 days)
|__/                   |  x86_64-linux-gnu

julia> using RecursiveArrayTools

julia> x = ArrayPartition([1, 2], [3.0, 4.0])
RecursiveArrayTools.ArrayPartition{Tuple{Array{Int64,1},Array{Float64,1}}}(([1, 2], [3.0, 4.0]))

julia> f(y) = y + 1
f (generic function with 1 method)

julia> f.(x)
RecursiveArrayTools.ArrayPartition{Tuple{Array{Int64,1},Array{Float64,1}}}(([2, 3], [4.0, 5.0]))

julia> @code_warntype f.(x)
Variables:
  #self#::Base.#broadcast
  f::#f
  B::Tuple{RecursiveArrayTools.ArrayPartition{Tuple{Array{Int64,1},Array{Float64,1}}}}
  A::RecursiveArrayTools.ArrayPartition{_} where _

Body:
  begin  # line 106:
      A::RecursiveArrayTools.ArrayPartition{_} where _ = (Core._apply)(RecursiveArrayTools.ArrayPartition, $(Expr(:new, Base.Generator{Tuple{Array{Int64,1},Array{Float64,1}},Base.#similar}, :($(QuoteNode(similar))), :((Core.getfield)((Base.getfield)(B, 1)::RecursiveArrayTools.ArrayPartition{Tuple{Array{Int64,1},Array{Float64,1}}}, :x)::Tuple{Array{Int64,1},Array{Float64,1}}))))::RecursiveArrayTools.ArrayPartition{_} where _
      (RecursiveArrayTools.broadcast!)(f::#f, A::RecursiveArrayTools.ArrayPartition{_} where _, (Core.getfield)(B::Tuple{RecursiveArrayTools.ArrayPartition{Tuple{Array{Int64,1},Array{Float64,1}}}}, 1)::RecursiveArrayTools.ArrayPartition{Tuple{Array{Int64,1},Array{Float64,1}}})::Any
      return A::RecursiveArrayTools.ArrayPartition{_} where _
  end::RecursiveArrayTools.ArrayPartition{_} where _

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions