Fix FeatureGenerator gives wrong units#2921
Conversation
|
Do we rely anywhere on using FeatureGenerator on Tables with unit columns? If not, I can modify the tests and change the API to explicilty require QTables. Supporting both is somewhat annoying. EDIT: I decided to simply change to using internal conversion to QTable, which has the side effect of not allowing one expression we previously tested: |
e78ee74 to
f0b9120
Compare
|
We should just add |
|
Once #2923 is merged, the docs here should pass. |
f0b9120 to
535e8a7
Compare
|
Docs build is fixed in main, please rebase |
When a `Table` class is passed to `FeatureGeneator`, instead of a `QTable`, the units are not correctly propagated. E.g., if a source column `x` has units `m`, a generated column `x**2` should have units `m2`, but does not if the input table is of class Table, where it retains the incorrect unit `m`. Unit propagation works for QTables.
535e8a7 to
789f170
Compare
Co-authored-by: Maximilian Linhoff <maximilian.linhoff@cta-observatory.org>
|




FeatureGeneartors currently support both
TableandQTableas inputs, and both are tested. However, unit propagation is wrong when aTablewith units is used.E.g., if a source column
xhas unitsm, a generated columnx**2should have unitsm2, but does not if the input table is of class Table, where it retains the incorrect unitm. Unit propagation works for QTables. See the test I added to this PR, which currently fails.I found this when looking into a simpler implementation for #2919 .
Possible solutions:
QTablesin ExpressionEngine, and raise an exception if a Table is passed.__call__()(breaks current tests where a feature column callscol.quantity.unit)The reason is that Astropy does not do unit math for columns automatically (which I think is actually quite a strange choice)