Rdatatable / data.table

R's data.table package extends data.frame:
http://r-datatable.com
Mozilla Public License 2.0
3.58k stars 976 forks source link

Ensure proper handling of "partially missing" complex inputs where appropriate #5797

Open MichaelChirico opened 9 months ago

MichaelChirico commented 9 months ago

Follow-up to #5748.

We need to ensure our complex handling behaves "as expected" in the improved world of missingness for complex values in R.

coalesce() in particular seems worthy of further scrutiny (skipped for now in the interest of just getting tests green as quickly as possible):

showz = \(z) cbind(Re = Re(z), Im = Im(z))

showz(fcoalesce(complex(real = NA, imaginary = NA), 0+1i)) # i.e. NA_complex_
#      Re Im
# [1,]  0  1
showz(fcoalesce(complex(real = 0 , imaginary = NA), 0+1i)) # i.e. unchanged
#      Re Im
# [1,]  0 NA
showz(fcoalesce(complex(real = NA, imaginary = 0 ), 0+1i)) # i.e. unchanged
#      Re Im
# [1,] NA  0

If this is deemed problematic we should check handling elsewhere in the codebase too.

jangorecki commented 9 months ago

I think it is good. If complex number is only partially missing then fcoalesce can ignore it.