Skip to content

[RFC] Dissociate NaN and Inf when considering force_all_finite in check_array #10455

Closed
@glemaitre

Description

@glemaitre

Due to changes proposed in #10404, it seems that check_array as currently a main limitation. force_all_finite will force both NaN and infto be rejected. If preprocessing methods (whenever this is possible) should let pass NaN, this argument is not enough permissive.

Before to implement anything, I think it could be good to have some feedback on the way to go. I see the following solutions:

  1. force_all_finite could still accept a bool to preserve the behaviour. Additionally, it could accept an str to filter only inf.
  2. [MRG] ENH Permit NaN while allowing to filter out inf in validation tools. #7892 proposes to have an additional argument allow_nan. @amueller was worried that it makes check_array to complex.
  3. make a private function _assert_finite_or_nan (similarly to this proposal removing the numpy version checking) in the data.py which can be shared between the preprocessing methods.

They are the solutions that I have in mind for the moment but anything else is welcomed.
@jnothman @agramfort @amueller @lesteve @ogrisel @GaelVaroquaux I would be grateful for any insight.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions