You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
base_ops are empty - arithmetic fails e.g. when extending class_double #320
A simple class & object x extending double does work in sin(x) but not with x + 1 or x < 3, because the (internal) base_ops all have no methods defined.
It is easiest to see in an example {latest version of S7}:
I think this is something that's worth more discussion in a call. It's not clear to me that preserving the existing class (and properties) is the right default because the transformation might break expected relationships between the data and the attributes. There's some question of whether we want to provide a default implementation that's sometimes wrong (forcing the implementor to carefully consider all existing generics and whether the behaviour is correct) or never provide a default so that the implementor is forced to.
Either way, we should consider this with the behaviour for generics like sin() and what the consequences will be for backward compatibility. (IOTW do we need to provide methods for the Math, Summary, and Complex group generics?).
Probably easiest to argue that it should be consistent with S3. You are inheriting from an base type so that you are choosing the chaos. If you don't want the chaos then:
Activity
hadley commentedon Aug 18, 2023
What would you expect the default method to do?
mmaechler commentedon Aug 18, 2023
The same it does e.g. for
sin(){as I wrote already}: Treat its "interior" the same as"double"and do the computation;"Math"functions do.hadley commentedon Aug 21, 2023
Should the result still have an S7 class? I assume not.
mmaechler commentedon Aug 22, 2023
Yes, I think it should, when we are talking about the "default" method: It does keep the class in S3 and S4, too, when combined with a simple numeric
Interestingly, that changes when the other vector is of different length, in the same way for S3 and S4:
and ditto for S3:
hadley commentedon Aug 23, 2023
I think this is something that's worth more discussion in a call. It's not clear to me that preserving the existing class (and properties) is the right default because the transformation might break expected relationships between the data and the attributes. There's some question of whether we want to provide a default implementation that's sometimes wrong (forcing the implementor to carefully consider all existing generics and whether the behaviour is correct) or never provide a default so that the implementor is forced to.
Either way, we should consider this with the behaviour for generics like
sin()and what the consequences will be for backward compatibility. (IOTW do we need to provide methods for theMath,Summary, andComplexgroup generics?).hadley commentedon Oct 13, 2023
I think this puts all the current inconsistencies in one place:
Created on 2023-10-13 with reprex v2.0.2
hadley commentedon Oct 16, 2023
Probably easiest to argue that it should be consistent with S3. You are inheriting from an base type so that you are choosing the chaos. If you don't want the chaos then:
Ensure Ops falls back to base behaviour
Ensure Ops falls back to base behaviour (#382)