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

Add signed and compress to constructor args #48

Merged
merged 3 commits into from
Jan 30, 2021
Merged

Add signed and compress to constructor args #48

merged 3 commits into from
Jan 30, 2021

Conversation

dmbates
Copy link
Contributor

@dmbates dmbates commented Jan 29, 2021

Per the discussion in #47 this PR adds keyword arguments signed and compress to a constructor.

@codecov
Copy link

codecov bot commented Jan 29, 2021

Codecov Report

Merging #48 (e3ed925) into main (28c9f1f) will increase coverage by 0.60%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #48      +/-   ##
==========================================
+ Coverage   75.63%   76.23%   +0.60%     
==========================================
  Files           1        1              
  Lines         197      202       +5     
==========================================
+ Hits          149      154       +5     
  Misses         48       48              
Impacted Files Coverage Δ
src/PooledArrays.jl 76.23% <75.00%> (+0.60%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28c9f1f...0e0d38e. Read the comment docs.

@test eltype(PooledArray(s).refs) == UInt32
@test eltype(PooledArray(s, signed=true).refs) == Int32
@test eltype(PooledArray(s, compress=true).refs) == UInt8
@test eltype(PooledArray(s, signed=true, compress=true).refs) == Int8
Copy link
Member

Choose a reason for hiding this comment

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

can we please add a test when signed widening happens?

@@ -123,13 +126,16 @@ function PooledArray{T}(d::AbstractArray, r::Type{R}) where {T,R<:Integer}
PooledArray(RefArray(refs::Vector{R}), invpool::Dict{T,R}, pool)
end

function PooledArray{T}(d::AbstractArray) where T
refs, invpool, pool = _label(d, T)
function PooledArray{T}(d::AbstractArray; signed::Bool=false, compress::Bool=false) where {T}
Copy link
Member

Choose a reason for hiding this comment

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

docstring above requires an update about kwargs.

@quinnj quinnj merged commit 9b17883 into main Jan 30, 2021
@quinnj quinnj deleted the db/signedref branch January 30, 2021 06:29
# Constructor from array, invpool, and ref type

"""
PooledArray(array, [reftype])
PooledArray(array, [reftype]; signed=false, compress=false)

Freshly allocate `PooledArray` using the given array as a source where each
element will be referenced as an integer of the given type.
If no `reftype` is specified one is chosen automatically based on the number of unique elements.
Copy link
Member

Choose a reason for hiding this comment

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

This isn't correct now. See #57.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants