posit-dev / positron

Positron, a next-generation data science IDE
Other
1.92k stars 57 forks source link

Define summary statistics behavior for complex numbers in data explorer #3421

Open wesm opened 1 month ago

wesm commented 1 month ago

In Python at least, np.std on complex numbers yields NaN, as discussed in #3420:

image

We should decide on the expected behavior and make it consistent between R and Python

jthomasmock commented 1 month ago

An example for creating complex in R, which can be evaluated with Mean/Median, but no SD/min/max.

z <- complex(real = stats::rnorm(100), imaginary = stats::rnorm(100))

> mean(z)
[1] -0.03505+0.07687i
> median(z)
[1] -0.1236+1.367i
wesm commented 1 month ago

I think it probably makes sense to return "undefined" for the SD/min/max (rather than returning a bogus number) and just hide these statistics in the UI. Should be pretty simple to do

jthomasmock commented 1 month ago

I think it probably makes sense to return "undefined" for the SD/min/max (rather than returning a bogus number) and just hide these statistics in the UI. Should be pretty simple to do

Yah, I think we should not calculate or at least hide the other stats that aren't valid.