Skip to content

min ignores nan #3288

@jl-wynen

Description

@jl-wynen

As a side note that probably should be the topic of another issue: When looking into this issue I noticed that sc.nanmin and sc.min does the same thing

# Both return -1
sc.array(dims=['x'], values=[1, float('nan'), -1]).min()
sc.array(dims=['x'], values=[1, float('nan'), -1]).nanmin()

while

# Only nanmin returns -1
np.min([1, float('nan'), -1])
np.nanmin([1, float('nan'), -1])

I think the reason is that in the implementation of sc.min we use std::min(a, b) equivalent to (b < a) ? b : a; and if b=nan we get a.

Originally posted by @jokasimr in #3287 (review)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions