Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitinformation along dimensions of size 2 fails when masked_value given #50

Closed
observingClouds opened this issue Aug 4, 2024 · 5 comments · Fixed by #51
Closed

Bitinformation along dimensions of size 2 fails when masked_value given #50

observingClouds opened this issue Aug 4, 2024 · 5 comments · Fixed by #51
Labels
bug Something isn't working

Comments

@observingClouds
Copy link

observingClouds commented Aug 4, 2024

In observingClouds/xbitinfo#286 popped up a test case, where the dimension along which the bitinformation shall be retrieved has a size of 2. I could trace this back to the Julia implementation:

>>> using BitInformation
>>> A = [1. 2. 3. 4. ; 5. 6. 7. 8.]
2×4 Matrix{Float64}:
 1.0  2.0  3.0  4.0
 5.0  6.0  7.0  8.0

>>> BitInformation.bitinformation(A, dim=1, masked_value=nothing)
64-element Vector{Float64}:
 0.0
 0.0
 0.0
 0.0
 0.0

>>> BitInformation.bitinformation(A, dim=2, masked_value=999.)
64-element Vector{Float64}:
 0.0
 0.0
 0.0
 0.0

>>> BitInformation.bitinformation(A, dim=1, masked_value=999.)
ERROR: AssertionError: Mask has 4 unmasked values, 0 entries are adjacent.
Stacktrace:
 [1] bitinformation(A::Matrix{Float64}, mask::BitMatrix; dim::Int64, set_zero_insignificant::Bool, confidence::Float64)
   @ BitInformation ~/.julia/packages/BitInformation/rcCbn/src/mutual_information.jl:105
 [2] bitinformation
   @ ~/.julia/packages/BitInformation/rcCbn/src/mutual_information.jl:90 [inlined]
 [3] bitinformation(A::Matrix{Float64}; dim::Int64, masked_value::Float64, kwargs::@Kwargs{})
   @ BitInformation ~/.julia/packages/BitInformation/rcCbn/src/mutual_information.jl:72
 [4] top-level scope
   @ REPL[66]:1

Shouldn't the last call work?

@observingClouds observingClouds changed the title Bitinformation along dimensions of size 2 fails when masked given Bitinformation along dimensions of size 2 fails when masked_value given Aug 4, 2024
@milankl
Copy link
Owner

milankl commented Aug 5, 2024

Yes, this should work, but this is currently implemented as masking the last element in the first dimension to not count bitpairs across boundaries. Hence, right now you're actually counting bitpairs for

julia> mask
2×4 BitMatrix:
 0  0  0  0
 1  1  1  1

where there is no adjacent pairs to count, hence the assertion error. Not the best algorithm I agree, will change this to a loop that doesn't have that problem!

@milankl
Copy link
Owner

milankl commented Aug 12, 2024

@JuliaRegistrator register

@JuliaRegistrator
Copy link

Registration pull request created: JuliaRegistries/General/112971

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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 v0.6.2 -m "<description of version>" bda307edfe0b73bf0d296e167246a9fdd9a42516
git push origin v0.6.2

@milankl
Copy link
Owner

milankl commented Aug 14, 2024

@JuliaRegistrator register

@JuliaRegistrator
Copy link

Registration pull request created: JuliaRegistries/General/113147

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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 v0.6.3 -m "<description of version>" afcc1da45914283da61ff10ab81c412fc9e77929
git push origin v0.6.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants