Commit 40f16418 authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

adapted egen functions to deal with new numlist format

parent 2a4bc948
......@@ -85,9 +85,9 @@
:rowpctile (make-compute
varname
"rowpctile"
(let [p (:p options [[50]])]
(let [p (:p options {:values [50]})]
[(make-varlist-expression varlist)
{"$type" "NumericConstantExpression" :value (-> p first first)}]
{"$type" "NumericConstantExpression" :value (-> p :values first)}]
)
filter)
:rowtotal (make-compute
......@@ -132,7 +132,7 @@
)
(defn egen-fill [& [varname numlist filter]]
(unsupported-func "fill")
(make-compute varname "fill" [numlist] filter)
)
(defn egen-mtr [& [varname exp1 exp2 filter]]
......@@ -151,11 +151,11 @@
"std_val"
(let [m (get-var-length-option :mean 1 options)
s (get-var-length-option :std 1 options)
m (if m (get options m) [[0]])
s (if s (get options s) [[1]])]
m (if m (get options m) {:values [0]})
s (if s (get options s) {:values [1]})]
[expr
{"$type" "NumericConstantExpression" :value (-> m first first)}
{"$type" "NumericConstantExpression" :value (-> s first first)}]
{"$type" "NumericConstantExpression" :value (-> m :values first)}
{"$type" "NumericConstantExpression" :value (-> s :values first)}]
)
filter)
:pctile (make-aggregate
......@@ -163,7 +163,7 @@
varname
(get aggregate-funcs (keyword funcname))
[expr
{"$type" "NumericConstantExpression" :value (-> (:p options [[50]]) first first)}]
{"$type" "NumericConstantExpression" :value (-> (:p options {:values [50]}) :values first)}]
filter)
;;;----- weird ones -------------
......
......@@ -58,7 +58,7 @@
:variable "some-var"})
)
(is
(= (varlist-compute "some-var" :rowpctile ["a" "b"] 5 {:p [[10]]})
(= (varlist-compute "some-var" :rowpctile ["a" "b"] 5 {:p {:values '(10)}})
'{:command "compute"
:condition 5
:expression {"$type" "FunctionCallExpression"
......@@ -179,7 +179,7 @@
)
)
(is
(= (egen-expr nil "somevar" "std" 5 1 {:mean [[7]]})
(= (egen-expr nil "somevar" "std" 5 1 {:mean {:values '(7)}})
'{:command "compute"
:condition 1
:expression {"$type" "FunctionCallExpression"
......@@ -198,7 +198,7 @@
)
)
(is
(= (egen-expr nil "somevar" "std" 5 1 {:std [[2]] :mean [[7]]})
(= (egen-expr nil "somevar" "std" 5 1 {:std {:values '(2)} :mean {:values '(7)}})
'{:command "compute"
:condition 1
:expression {"$type" "FunctionCallExpression"
......@@ -236,7 +236,7 @@
)
)
(is
(= (egen-expr ["a" "b"] "somevar" "pctile" 5 1 {:p [[10]]})
(= (egen-expr ["a" "b"] "somevar" "pctile" 5 1 {:p {:values '(10)}})
'{:aggregateVariables [{:command "compute"
:condition 1
:expression {"$type" "FunctionCallExpression"
......@@ -254,4 +254,23 @@
:mod-varlist ["somevar"]}
)
)
)
(deftest egen-fill-test
(is
(=
(egen-fill "somevar" {:values '(1 2 3)} nil)
'{:command "compute"
:condition nil
:expression {"$type" "FunctionCallExpression"
:arguments ({:argumentName "EXP1"
:argumentValue {:values (1
2
3)}})
:function "fill"
:isSdtlName true}
:mod-varlist ["somevar"]
:variable "somevar"}
)
)
)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment