Skip to content

Master list: Feature completion for complex-valued columns #3690

Closed

Description

@MichaelChirico

As a follow-up to #1444 and #3689, I think it's useful to keep a list of all the features missing for users who want to do work involving complex-valued columns z:

v1.12.4 NEWS contains :

image


Examples

DT = data.table(a = 1:5, z = 6:10 + (5:1)*1i)

1.

DT[order(z)]

Error in forderv(ans, cols, sort = TRUE, retGrp = FALSE, order = if (decreasing) -order else order, :
Column 1 of by= (1) is type 'complex', not yet supported. Please use the by= argument to specify columns with types that are supported. See NEWS item in v1.12.2 for more information.

2.

DT[ , .N, by = z]

Error in [.data.table(DT, , .N, by = z) :
column or expression 1 of 'by' or 'keyby' is type complex. Do not quote column names. Usage: DT[,sum(colC),by=list(colA,month(colB))]

3.

fwrite(DT)

Error in fwrite(DT) :
Column 2's type is 'complex' - not yet implemented in fwrite.

fread('a\n1+i')
#         a
#    <char>
# 1:    1+i

4.

DT[CJ(a, z)]

Error: Column 1 of by= (1) is type 'complex', not yet supported. Please use the by= argument to specify columns with types that are supported. See NEWS item in v1.12.2 for more information.

Coming from forderv so first this is a repeat of 1

DT[CJ(a, z, sorted = FALSE)]

Error: Type 'complex' not supported by CJ.

5.

DT[ , total := base::sum(z), by = .(a %% 2)]

DT[ , total := base::sum(z), by = .(a %% 2)]
Error in [.data.table(DT, , :=(total_rad, base::sum(z)), by = .(a%%2)) :
Internal error: writeNA passed a vector of type 'complex'

6.

DT[ , sum(z), by = .(a %% 2)]

Error in gsum(z) :
Type 'complex' not supported by GForce sum (gsum). Either add the prefix base::sum(.) or turn off GForce optimization using options(datatable.optimize=1)

7.

DT[DT, on = 'z']

Error in bmerge(i, x, leftcols, rightcols, roll, rollends, nomatch, mult, :
x.z is type complex which is not supported by data.table join

8.

DT[ , coalesce(`is.na<-`(z, 1), 0+0i)]

Error in coalesce(is.na<-(z, 1), 0 + (0+0i)) :
Unsupported type: complex

9.

DT[ , shift(z)]

Error in shift(z) : Unsupported type 'complex'

Activity

  1. MichaelChirico commented on Jul 10, 2019

    @MichaelChirico
    MemberAuthor

    I think we could get away with hacking sorting immediately by morphing order(z) into order(Re(z), Im(z)); is there any immediacy to doing this, or is worth wait until going through and doing it properly in C on the CPLXSXP?

  2. MichaelChirico commented on Jul 11, 2019

    @MichaelChirico
    MemberAuthor

    I don't really know where to start on fread... but Hugh's colTypes generalization already works:

    class(fread('a\n0+1i', colClasses = c(a='complex'))[[1]])
    # [1] "complex"
    

    I'd say this is good enough unless there is some specific demand to speed this up. At a glance it would take significant effort to teach fread to detect & read complex values automatically.

  3. added this to the 1.12.4 milestone on Jul 19, 2019
  4. mattdowle commented on Jul 19, 2019

    @mattdowle
    Member

    Fantastic! Can this be closed now @MichaelChirico ?

  5. MichaelChirico commented on Jul 20, 2019

    @MichaelChirico
    MemberAuthor
  6. mattdowle commented on Jul 20, 2019

    @mattdowle
    Member

    Great. I edited the revised news item into the main comment at the top of this issue. It asks for a use case. Is that ok? I'd prefer not to create a new issue for join-on-complex until someone asks for it.

  7. MichaelChirico commented on Jul 20, 2019

    @MichaelChirico
    MemberAuthor

    Yes that's perfect. Thanks for all your help getting the rest of this issue over the finish line!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions