Skip to content

Conversation

@ljahn
Copy link
Contributor

@ljahn ljahn commented May 26, 2025

If a StateSpaceSet containing vectors is used to construct a FixedRectangularBinning, the element type T is determined as the vector type, not the underlying element type. Subsequent construction of a helper array for dealing with bounds therefore fails.

Fixed by determining the type of the underlying elements.

If a `StateSpaceSet` containing vectors is used to construct a `FixedRectangularBinning`, the element type `T` is determined as the vector type, not the underlying element type. Subsequent construction of a helper array for dealing with bounds therefore fails.

Fixed by determining the type of the underlying elements.
Copy link
Member

@Datseris Datseris left a comment

Choose a reason for hiding this comment

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

Thanks @ljahn ! Hope you are doing well!

This is a repercusion of StateSpaceSets.jl v2.4, so we are still fixing the bugs... The fact that we missed this is because there are no tests for it. Can you 1) add a trivial test for this and 2) bump patch version in Project.toml? Thanks.

@ljahn
Copy link
Contributor Author

ljahn commented May 26, 2025

Hi @Datseris, I'm fine, still in Göttingen, working on my PhD.

I had a look at the tests and figured the case should be covered by

seeds = [1234, 57772, 90897, 2158081, 888]
# Note that if `false` is used for `precise` the tests will fail.
# But that's okay, since we do not do guarantees for that case.
binnings = [
RectangularBinning(3, true),
RectangularBinning(3, false),
RectangularBinning(0.2, true),
RectangularBinning(0.2, false),
RectangularBinning([2, 3], true),
RectangularBinning([2, 3], false),
RectangularBinning([0.2, 0.3], true),
FixedRectangularBinning(range(0, 1; length = 5), 2, true),
FixedRectangularBinning(range(0, 1; length = 5), 2, false),
]
@testset "seed $(seed)" for seed in seeds
D = StateSpaceSet(rand(MersenneTwister(seed), 100, 2))
@testset "Binning $i" for i in eachindex(binnings)
encoding = RectangularBinEncoding(binnings[i], D)
outs = [encode(encoding, χ) for χ in D]
unique!(outs)
@test -1 unique!(outs)
decs = [decode(encoding, i) for i in outs]
end
end

In line
encoding = RectangularBinEncoding(binnings[i], D)
FixedRectangularBinnings of a 2D StateSpaceSet get constructed.
So I ran the tests to check and they indeed fail as expected for me. For Binnings 3,4 and 7, the ones affected by this bug, tests fail.

Details
Test Summary:                                   | Pass  Fail  Error  Total     Time
ComplexityMeasures.jl                           | 1207     1     23   1231  2m59.4s
  Counts                                        |   53                  53     6.0s
  Probabilities                                 |   26                  26     5.9s
  Pretty printing                               |    4                   4     4.1s
  Outcome spaces                                |   37                  37    10.7s
  Unique elements                               |   25                  25     2.0s
  Value binning                                 |  100            4    104     6.9s
    Standard ranges binning                     |   84            2     86     5.7s
      bin isa RectangularBinning                |   13                  13     1.4s
      bin isa RectangularBinning                |   13                  13     0.1s
      bin isa RectangularBinning                |                 1      1     3.1s
      bin isa RectangularBinning                |   13                  13     0.2s
      bin isa RectangularBinning                |                 1      1     0.2s
      bin isa FixedRectangularBinning           |   13                  13     0.1s
      bin isa FixedRectangularBinning           |   13                  13     0.0s
      bin isa FixedRectangularBinning           |   13                  13     0.0s
      vector                                    |    4                   4     0.1s
      convenience                               |    2                   2     0.0s
    Encodings, edge cases                       |    8                   8     0.1s
    All points covered                          |    1            1      2     0.3s
    Codification of vector inputs (time series) |    7            1      8     0.6s
  Transfer operator                             |   24            2     26    14.1s
    test set                                    |    1                   1     8.4s
    Binning test 1                              |    6                   6     2.1s
    Binning test 2                              |                 1      1     0.2s
    Binning test 3                              |    6                   6     0.2s
    Binning test 4                              |                 1      1     0.1s
    Binning test 5                              |    6                   6     0.3s
  Naive kernel                                  |   10                  10     0.8s
  Permutation                                   |   39                  39     4.3s
  Timescales                                    |   12                  12     2.4s
  Dispersion                                    |    8                   8     1.7s
  Cosine similarity binning                     |    9                   9     1.1s
  Sequential pair distances                     |   15                  15     2.3s
  Bubble sort swaps                             |    7                   7     0.6s
  Spatial ordinal patterns                      |   18                  18     8.8s
  Spatial dispersion                            |   12                  12     1.0s
  Spatial bubble sort swaps                     |   10                  10     1.9s
  Probabilities estimators                      |  307                 307    14.7s
  Interface                                     |   19                  19     0.9s
  Renyi                                         |   13                  13     0.2s
  Shannon                                       |    6                   6     0.1s
  Tsallis                                       |    8                   8     0.4s
  Curado                                        |    4                   4     0.6s
  Stretched exponential                         |    3                   3     0.6s
  Kaniadakis                                    |    5                   5     0.2s
  Identification                                |    4                   4     0.0s
  Estimators                                    |   59                  59    40.7s
  Discrete estimators                           |   22                  22    11.6s
  Complexity                                    |   56     1            57    12.1s
    Interface                                   |    1                   1     0.0s
    Reverse dispersion                          |    5                   5     0.1s
    Missing dispersion                          |    8                   8     2.4s
    Entropy approx                              |    4                   4     1.3s
    Entropy sample                              |    6                   6     0.6s
    Statistical complexity                      |   23     1            24     7.2s
      Statistical Complexity                    |   16     1            17     6.3s
      StatisticalComplexity with extropy        |    2                   2     0.1s
    Lempel ziv                                  |    3                   3     0.1s
    Entropy bubble                              |    2                   2     0.4s
    Missing outcomes                            |    4                   4     0.1s
  Regular                                       |   17                  17     0.9s
  Composite                                     |   17                  17     1.7s
  Encodings                                     |  165           17    182    14.4s
    Utils                                       |   56                  56     1.1s
    Relative mean encoding                      |   11                  11     0.7s
    Relative first difference encoding          |   11                  11     1.8s
    Gaussian cdf encoding                       |   18                  18     2.0s
    Ordinal pattern encoding                    |   13                  13     2.5s
    Rectangular bin encoding                    |   33           17     50     3.2s
      RectangularBinEncoding                    |    3                   3     0.1s
      seed 1234                                 |    6            3      9     0.6s
        Binning 1                               |    1                   1     0.1s
        Binning 2                               |    1                   1     0.0s
        Binning 3                               |                 1      1     0.2s
        Binning 4                               |                 1      1     0.2s
        Binning 5                               |    1                   1     0.0s
        Binning 6                               |    1                   1     0.0s
        Binning 7                               |                 1      1     0.2s
        Binning 8                               |    1                   1     0.0s
        Binning 9                               |    1                   1     0.0s
      seed 57772                                |    6            3      9     0.5s
        Binning 1                               |    1                   1     0.0s
        Binning 2                               |    1                   1     0.0s
        Binning 3                               |                 1      1     0.2s
        Binning 4                               |                 1      1     0.2s
        Binning 5                               |    1                   1     0.0s
        Binning 6                               |    1                   1     0.0s
        Binning 7                               |                 1      1     0.2s
        Binning 8                               |    1                   1     0.0s
        Binning 9                               |    1                   1     0.0s
      seed 90897                                |    6            3      9     0.5s
        Binning 1                               |    1                   1     0.0s
        Binning 2                               |    1                   1     0.0s
        Binning 3                               |                 1      1     0.2s
        Binning 4                               |                 1      1     0.2s
        Binning 5                               |    1                   1     0.0s
        Binning 6                               |    1                   1     0.0s
        Binning 7                               |                 1      1     0.2s
        Binning 8                               |    1                   1     0.0s
        Binning 9                               |    1                   1     0.0s
      seed 2158081                              |    6            3      9     0.5s
        Binning 1                               |    1                   1     0.0s
        Binning 2                               |    1                   1     0.0s
        Binning 3                               |                 1      1     0.2s
        Binning 4                               |                 1      1     0.2s
        Binning 5                               |    1                   1     0.0s
        Binning 6                               |    1                   1     0.0s
        Binning 7                               |                 1      1     0.2s
        Binning 8                               |    1                   1     0.0s
        Binning 9                               |    1                   1     0.0s
      seed 888                                  |    6            3      9     0.5s
        Binning 1                               |    1                   1     0.0s
        Binning 2                               |    1                   1     0.0s
        Binning 3                               |                 1      1     0.2s
        Binning 4                               |                 1      1     0.2s
        Binning 5                               |    1                   1     0.0s
        Binning 6                               |    1                   1     0.0s
        Binning 7                               |                 1      1     0.2s
        Binning 8                               |    1                   1     0.0s
        Binning 9                               |    1                   1     0.0s
      maxi in range corrected (###)             |                 2      2     0.4s
        0.1 rad                                 |                 1      1     0.2s
        0.05 rad                                |                 1      1     0.2s
    Unique elements encoding                    |    3                   3     1.1s
    Distance pair encoding                      |    6                   6     0.1s
    Bubble sort swaps encoding                  |    1                   1     0.0s
    Combination encoding                        |   13                  13     1.9s
  Convenience                                   |   12                  12     0.4s
  Deprecations                                  |   45                  45     3.9s
ERROR: LoadError: Some tests did not pass: 1207 passed, 1 failed, 23 errored, 0 broken.

@Datseris Datseris merged commit 8315002 into JuliaDynamics:main May 26, 2025
2 checks passed
@Datseris
Copy link
Member

okay, thanks, not sure how we missed this then...

Good luck with your PhD!

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.

2 participants