Skip to content

[FIX] util: Fix bincount for object arrays#3831

Merged
janezd merged 1 commit intobiolab:masterfrom
lanzagar:bincount
Jun 2, 2019
Merged

[FIX] util: Fix bincount for object arrays#3831
janezd merged 1 commit intobiolab:masterfrom
lanzagar:bincount

Conversation

@lanzagar
Copy link
Contributor

Issue

bincount failed for object arrays that contained np.nan, but worked on both float arrays with nans and object arrays without them.
This was a problem since metas are often stored as object arrays and contain primitive variables, for which bincount should work (even if there are missing values).

Description of changes

The array must contain numbers anyway (since it is later converted to int32 for np.bincount), so it should not hurt to cast it to float before checking for nans. Almost all arrays in Orange are either float or object anyway, so this should be a noop for float arrays and a fix for object arrays.

Includes
  • Code changes
  • Tests
  • Documentation

@codecov
Copy link

codecov bot commented May 30, 2019

Codecov Report

Merging #3831 into master will not change coverage.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master    #3831   +/-   ##
=======================================
  Coverage   85.06%   85.06%           
=======================================
  Files         374      374           
  Lines       69148    69148           
=======================================
  Hits        58821    58821           
  Misses      10327    10327

@lanzagar lanzagar requested a review from VesnaT May 30, 2019 10:06
@janezd janezd merged commit 8f4aa5f into biolab:master Jun 2, 2019
@lanzagar lanzagar deleted the bincount branch March 14, 2022 14:43
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.

3 participants