Feature/point in time series string support - #78
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #78 +/- ##
==========================================
+ Coverage 88.69% 88.78% +0.08%
==========================================
Files 60 60
Lines 5015 5046 +31
Branches 598 602 +4
==========================================
+ Hits 4448 4480 +32
+ Misses 461 460 -1
Partials 106 106
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
is there a reason to change this file in this PR?
| return PointsInTimeSeries(s0.tstarts, operation(s1.values, s0.values)) | ||
| return PointsInTimeSeries(self.tstarts, operation(other, self.values)) | ||
|
|
||
| @_numeric_only |
|
|
||
| def test_empty_series_defaults_to_numeric(): | ||
| # No observed value type -> numeric (backward-compatible default). | ||
| assert PointsInTimeSeries.empty()._is_string is False |
There was a problem hiding this comment.
this will introduce a problem in the method where we determine the return schema of the pandas UDF in the solver. We walk through the AST of every selected time series expression and evaluate with an empty cache. We build empty series objects and eventually derive the expected return type by calling the dtype method.
We need to extend the constructor of PointsInTimeSeries and make it explicit during init of the object whether the underlying data is of string or numerical type. Would this work in combination with the extension of TimeSeriesSelector, which will create the PointsInTimeSeries objects? I recommend to merge this PR with the one where you are extending TimeSeriesSelector.
Summary
Adds string-value support to
PointsInTimeSeries. Previously values were alwayscoerced to
np.float64, so string values raised on construction. String-valuedseries now support the operations that make sense for them — sampling and equality
— while numeric-only operations fail loudly instead of silently corrupting data.
Changes
U/S/Oare stored asobject; everything else staysfloat64. Timestamps remainfloat64. Emptyseries default to numeric (backward-compatible).
@_numeric_onlyguard: a decorator rejects numeric-only operations onstring series with a clear
TypeError. Applied to arithmetic (+ - * /),ordering (
> >= < <=), and reductions (sum/mean/min/max). This blocksthe cases numpy would silently mis-handle for strings (
+concatenates,*repeats,sumconcatenates), not just the ones that already raise.==/!=,synchronized/ sampling,count,len.dtype()/get_data()are value-type aware — string seriesserialize as
array<struct<tstart:double,value:string>>(a nested array can'thold mixed types), built as explicit
[float(t), str(v)]pairs. Numeric pathunchanged.
Test Plan
Checklist