Skip to content

Commit 643c923

Browse files
committed
Fix type-instability of Probabilities
1 parent ac8dbfe commit 643c923

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
Changelog is kept with respect to version 0.11 of Entropies.jl. From version v2.0 onwards, this package has been renamed to ComplexityMeasures.jl.
44

5+
## 3.7.4
6+
7+
- Critical performance fix: central type `Probabilities` was type unstable.
8+
This fix should see 10-1000x fold performance across most library functions.
9+
510
## 3.7
611

712
- Updated to StateSpaceSets.jl v2.0

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "ComplexityMeasures"
22
uuid = "ab4b797d-85ee-42ba-b621-05d793b346a2"
33
authors = "Kristian Agasøster Haaga <[email protected]>, George Datseries <[email protected]>"
44
repo = "https://github.com/juliadynamics/ComplexityMeasures.jl.git"
5-
version = "3.8.3"
5+
version = "3.8.4"
66

77
[deps]
88
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"

src/core/probabilities.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ julia> c = Counts([12, 16, 12], ["out1", "out2", "out3"]); Probabilities(c)
4646
"out3" 0.3
4747
```
4848
"""
49-
struct Probabilities{T, N, S} <: AbstractArray{T, N}
49+
struct Probabilities{T, N, S, A<:AbstractArray{T, N}, O<:Tuple{Vararg{AbstractVector, N}}} <: AbstractArray{T, N}
5050
# The probabilities table.
51-
p::AbstractArray{T, N}
51+
p::A
5252

5353
# outcomes[i] has the same number of elements as `cts` along dimension `i`.
54-
outcomes::Tuple{Vararg{AbstractVector, N}}
54+
outcomes::O
5555

5656
# A label for each dimension
5757
dimlabels::NTuple{N, S}
@@ -83,7 +83,7 @@ struct Probabilities{T, N, S} <: AbstractArray{T, N}
8383
end
8484
end
8585

86-
return new{eltype(p), N, S}(p, outcomes, dimlabels)
86+
return new{eltype(p), N, S, typeof(p), typeof(outcomes)}(p, outcomes, dimlabels)
8787
end
8888

8989
end

0 commit comments

Comments
 (0)