Skip to content

Commit

Permalink
Add DataAPI.invrefpool (#53)
Browse files Browse the repository at this point in the history
* Add DataAPI.invrefpool

* Update Project.toml

* Update runtests.jl

* Update Project.toml
  • Loading branch information
bkamins authored Feb 3, 2021
1 parent ff28ff2 commit f1f2055
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name = "PooledArrays"
uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
version = "1.0.0"
version = "1.1.0"

[deps]
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"

[compat]
DataAPI = "1"
DataAPI = "1.5"
julia = "1"

[extras]
Expand Down
1 change: 1 addition & 0 deletions src/PooledArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ PooledArray(t::Type, r::Type) = PooledArray(Array(t,0), r)
DataAPI.refarray(pa::PooledArray) = pa.refs
DataAPI.refvalue(pa::PooledArray, i::Integer) = pa.pool[i]
DataAPI.refpool(pa::PooledArray) = pa.pool
DataAPI.invrefpool(pa::PooledArray) = pa.invpool

Base.size(pa::PooledArray) = size(pa.refs)
Base.length(pa::PooledArray) = length(pa.refs)
Expand Down
5 changes: 3 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Test
using PooledArrays
using DataAPI: refarray, refvalue, refpool
using DataAPI: refarray, refvalue, refpool, invrefpool

@testset "PooledArrays" begin
a = rand(10)
Expand Down Expand Up @@ -87,7 +87,8 @@ using DataAPI: refarray, refvalue, refpool
@test refvalue(s, refarray(s)[i]) == s[i]
end
@test refpool(s) == ["a", "b"]

@test invrefpool(s) == Dict("a" => 1, "b" => 2)

@testset "push!" begin
xs = PooledArray([10, 20, 30])
@test xs === push!(xs, -100)
Expand Down

2 comments on commit f1f2055

@quinnj
Copy link
Member

@quinnj quinnj commented on f1f2055 Feb 3, 2021

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/29249

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.0 -m "<description of version>" f1f205573ca329aa4c23fe44c7a4308b3834b6b1
git push origin v1.1.0

Please sign in to comment.