Skip to content

Commit

Permalink
implement copy for dataset (#111)
Browse files Browse the repository at this point in the history
* implement copy for dataset

Can't believe we've missed that...

* bump proejct version
  • Loading branch information
Datseris committed Sep 30, 2022
1 parent ebebc40 commit 70d1ef4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DelayEmbeddings"
uuid = "5732040d-69e3-5649-938a-b6b4f237613f"
repo = "https://github.com/JuliaDynamics/DelayEmbeddings.jl.git"
version = "2.3.1"
version = "2.3.2"

[deps]
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
Expand Down
7 changes: 4 additions & 3 deletions src/datasets/dataset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ abstract type AbstractDataset{D, T} end
Return the dimension of the `thing`, in the sense of state-space dimensionality.
"""
dimension(::AbstractDataset{D,T}) where {D,T} = D
@inline Base.eltype(d::AbstractDataset{D,T}) where {D,T} = T
import Base: ==
==(d1::AbstractDataset, d2::AbstractDataset) = d1.data == d2.data
Base.eltype(::AbstractDataset{D,T}) where {D,T} = T
Base.:(==)(d1::AbstractDataset, d2::AbstractDataset) = d1.data == d2.data
Base.vec(d::AbstractDataset) = d.data
Base.copy(d::AbstractDataset) = typeof(d)(copy(d.data))


# Size:
@inline Base.length(d::AbstractDataset) = length(d.data)
Expand Down
11 changes: 10 additions & 1 deletion test/dataset_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ println("\nTesting Dataset...")
data = Dataset(rand(1001,3))
xs = columns(data)

@testset "Concatenation/Append" begin
@testset "Concatenation/Append" begin
x, y, z = Dataset(rand(10, 2)), Dataset(rand(10, 2)), rand(10)
@test Dataset(x) == x
@test Dataset(x, y) isa Dataset
Expand Down Expand Up @@ -62,6 +62,15 @@ println("\nTesting Dataset...")
@test_throws ErrorException (data[:,1] .= 0)
end

@testset "copy" begin
d = Dataset(rand(10, 2))
v = vec(d)
d2 = copy(d)
d2[1] == d[1]
d2[1] = SVector(5.0, 5.0)
@test d2[1] != d[1]
end

@testset "minmax" begin
mi = minima(data)
ma = maxima(data)
Expand Down

0 comments on commit 70d1ef4

Please sign in to comment.