File tree Expand file tree Collapse file tree 2 files changed +43
-9
lines changed
Expand file tree Collapse file tree 2 files changed +43
-9
lines changed Original file line number Diff line number Diff line change @@ -270,13 +270,13 @@ test/data/stocks.csv [5 6]:
270270| AMZN | 2000-01-01 | 64.56 | 60.09222222 | 106.11 | 28.66 |
271271| AAPL | 2000-02-01 | 28.66 | 57.56583333 | 106.11 | 28.37 |
272272```"
273- ([ds window reducer-map _options ]
273+ ([ds window reducer-map options ]
274274 (let [n-rows (ds-base/row-count ds)
275- window-data (if (integer? window)
276- {:window-size window
277- :relative-position :center
278- :window-type :fixed }
279- window )
275+ window-data (merge ( if (integer? window)
276+ {:window-size window
277+ :window-type :fixed }
278+ window)
279+ options )
280280 windows
281281 (case (:window-type window-data :fixed )
282282 :fixed
Original file line number Diff line number Diff line change 18021802(deftest clone-causes-filter-fail
18031803 (let [ds (-> (ds/->dataset " test/data/stocks.csv" {:key-fn keyword})
18041804 (ds/filter (fn [row]
1805- (and
1805+ (and
18061806 (.isAfter ^LocalDate (get row :date ) (LocalDate/parse " 2009-06-01" ))
18071807 (= (get row :symbol ) " AMZN" )))))]
18081808 (is (= (vec (:date ds))
18181818 :age nil }])
18191819 (ds/replace-missing [:age ] :value 100 )
18201820 (ds/column :age )
1821- vec)))
1822- )
1821+ vec))))
1822+
1823+ (defn rolling-off-edge-fn
1824+ []
1825+ (let [ds-fn (fn [relative-window-position]
1826+ (-> (ds/->dataset {:x (concat (repeat 20 1 )
1827+ (repeat 20 0 ))})
1828+ (ds-roll/rolling 10 {:mean-x (ds-roll/mean :x )} {:relative-window-position relative-window-position})
1829+ (ds/print-all )))]
1830+ (is (not= (ds-fn :left )
1831+ (ds-fn :center )))
1832+ (is (not= (ds-fn :center )
1833+ (ds-fn :right )))
1834+ (is (not= (ds-fn :left )
1835+ (ds-fn :right )))))
1836+
1837+ (deftest rolling-off-edge
1838+ (rolling-off-edge-fn ))
1839+
1840+ (defn stacked-rolling-fn
1841+ []
1842+ (let [ds0 (-> (ds/->dataset {:y (repeat 20 2 )
1843+ :x (range )
1844+ :t 0 })
1845+ (ds-roll/rolling 10 {:mean-y (ds-roll/mean :y )} {:relative-window-position :left }))
1846+ ds1 (-> (ds/->dataset {:y (repeat 40 1 )
1847+ :x (range )
1848+ :t 1 })
1849+ (ds-roll/rolling 10 {:mean-y (ds-roll/mean :y )} {:relative-window-position :left }))
1850+ ds (-> (ds/concat ds0 ds1)
1851+ (ds/print-all ))]
1852+ ; ; HH: 2025-09-08 - My condolences if this fails on your architecture
1853+ (is (every? #{1.0 2.0 } (:mean-y ds)))))
1854+
1855+ (deftest stacked-rolling
1856+ (stacked-rolling-fn ))
18231857
18241858(comment
18251859 (require '[criterium.core :as crit])
You can’t perform that action at this time.
0 commit comments