Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change big to BigInt calls #3419

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
([#3393](https://github.com/JuliaData/DataFrames.jl/pull/3393))
* Correctly index `eachrow` and `eachcol` with `CartesianIndex`
([#3413](https://github.com/JuliaData/DataFrames.jl/issues/3413))
* Correctly handle non-standard integers when converting them to `BigInt`
([#3419](https://github.com/JuliaData/DataFrames.jl/issues/3419))


# DataFrames.jl v1.6.1 Release Notes
Expand Down
2 changes: 1 addition & 1 deletion src/abstractdataframe/abstractdataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ function fillcombinations(df::AbstractDataFrame, indexcols;
end

# make sure we do not overflow in the target data frame size
target_rows = Int(prod(x -> big(length(x)), uniquevals))
target_rows = Int(prod(x -> BigInt(length(x)), uniquevals))
if iszero(target_rows)
@assert iszero(nrow(df))
cdf = copy(df)
Expand Down
3 changes: 1 addition & 2 deletions src/dataframe/dataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ function allcombinations(::Type{DataFrame}, pairs::Pair{Symbol, <:Any}...)
@assert length(colvalues) == length(colnames)
@assert all(x -> x isa AbstractVector, colvalues)

target_rows = Int(prod(x -> big(length(x)), colvalues))
target_rows = Int(prod(x -> BigInt(length(x)), colvalues))
out_df = DataFrame()
inner = 1
for (val, cname) in zip(colvalues, colnames)
Expand All @@ -1563,4 +1563,3 @@ function allcombinations(::Type{DataFrame}, pairs::Pair{Symbol, <:Any}...)
end

_try_select_no_copy(df::DataFrame, cols) = select(df, cols, copycols=false)

2 changes: 1 addition & 1 deletion src/groupeddataframe/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function refpool_and_array(x::AbstractArray)
else
minval, maxval = extrema(x)
end
ngroups = big(maxval) - big(minval) + 1
ngroups = BigInt(maxval) - BigInt(minval) + 1
# Threshold chosen with the same rationale as the row_group_slots! refpool method:
# refpool approach is faster but we should not allocate too much memory either
# We also have to avoid overflow, including with ngroups + 1 for missing values
Expand Down
4 changes: 2 additions & 2 deletions src/join/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function _innerjoin_unsorted_int(left::AbstractVector{<:Union{Integer, Missing}}
right::AbstractVector{<:Union{Integer, Missing}})
minv, maxv = extrema_missing(right)

val_range = big(maxv) - big(minv)
val_range = BigInt(maxv) - BigInt(minv)
if val_range > typemax(Int) - 3 || val_range ÷ 2 > max(64, length(right)) ||
minv < typemin(Int) + 2 || maxv > typemax(Int) - 3
return _innerjoin_unsorted(left, right)
Expand Down Expand Up @@ -648,7 +648,7 @@ function _semijoin_unsorted_int(left::AbstractVector{<:Union{Integer, Missing}},
right_shorter::Bool)
minv, maxv = extrema_missing(right)

val_range = big(maxv) - big(minv)
val_range = BigInt(maxv) - BigInt(minv)
if val_range > typemax(Int) - 3 || val_range ÷ 2 > max(64, length(right)) ||
minv < typemin(Int) + 2 || maxv > typemax(Int) - 3
return _semijoin_unsorted(left, right, seen_rows, right_shorter)
Expand Down
Loading