JuliaDynamics / ComplexityMeasures.jl

Estimators for probabilities, entropies, and other complexity measures derived from data in the context of nonlinear dynamics and complex systems
MIT License
48 stars 11 forks source link

It shouldn't be possible to construct an empty `CombinationEncoding` #380

Closed kahaaga closed 4 months ago

kahaaga commented 5 months ago

Currently the following is valid:

julia> CombinationEncoding()

However, this should throw an error, because an empty encoding can't be used for anything. There must be at least one Encoding input to the constructor for it to be used.

The fix is simple. Just add a check that N is not zero in the following code chunk:

function CombinationEncoding(encodings::Vararg{Encoding, N}) where N
    ranges = tuple([1:total_outcomes(e) for e in encodings]...)
    linear_indices = LinearIndices(ranges)
    cartesian_indices = CartesianIndices(ranges)
    return CombinationEncoding(tuple(encodings...), linear_indices, cartesian_indices)
end

TODO:

ShrutiRDalvi commented 4 months ago

Hi, I've added the suggested changes and test cases to the clone of the repo on my local. How do I run the test cases and check if it's working? Apologies for the trivial doubt, I'm very new to open-source

Datseris commented 4 months ago

Hi, how did you add the package? If you have done the simple

] dev ComplexityMeasures

then you can then just do

] test ComplexityMeasures

The symbol ] means to press it to go into package manager mode in the REPL.

For your tests to run they need to be part of one of the files in the test subfolder.

kahaaga commented 4 months ago

Closed with #395.