Skip to content

plan for a change in broadcasting rules in Julia 1.7#2937

Merged
bkamins merged 5 commits intomainfrom
bk/plan_broadcasting_change
Nov 14, 2021
Merged

plan for a change in broadcasting rules in Julia 1.7#2937
bkamins merged 5 commits intomainfrom
bk/plan_broadcasting_change

Conversation

@bkamins
Copy link
Copy Markdown
Member

@bkamins bkamins commented Nov 14, 2021

This is a transition PR clearly communicating to users what will happen in DataFrames.jl 1.4 release, see #2804.

Since the change planned in DataFrames.jl 1.4 will be mildly breaking and will introduce an inconsistency between Julia versions an additional transition period is I think a good approach.

@bkamins bkamins added this to the 1.3 milestone Nov 14, 2021
@bkamins
Copy link
Copy Markdown
Member Author

bkamins commented Nov 14, 2021

For a reference. The current behavior is:

julia> df = DataFrame(x=1:3)
3×1 DataFrame
 Row │ x
     │ Int64
─────┼───────
   1 │     1
   2 │     2
   3 │     3

julia> df.x .= 'x'
3-element Vector{Int64}:
 120
 120
 120

julia> df # people typically expect that `:x` column contains 'x' Char values after the previous operation
3×1 DataFrame
 Row │ x
     │ Int64
─────┼───────
   1 │   120
   2 │   120
   3 │   120

julia> df.x .= 1.5 # people typically expect this operation to work
ERROR: InexactError: Int64(1.5)

and after the change both operations will produce the expected result described in the comment under Julia 1.7 and newer. Under Julia 1.6 and older they will remain as they are now as it is impossible to fix this behavior there.

@bkamins bkamins requested a review from nalimilan November 14, 2021 10:38
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
# TODO: remove the deprecation in DataFrames.jl 1.4 release
Base.depwarn("In the 1.4 release of DataFrames.jl this operation will allocate a new column " *
"instead of performing an in-place assignment. "
"To perform an in-place assignment use `df[:, col] .= ...` instead.",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what I would recommend.

@bkamins bkamins merged commit 46d0ff2 into main Nov 14, 2021
@bkamins bkamins deleted the bk/plan_broadcasting_change branch November 14, 2021 15:59
@bkamins
Copy link
Copy Markdown
Member Author

bkamins commented Nov 14, 2021

Thank you!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants