|
| 1 | +(ns tablecloth.column.api.lift-operators |
| 2 | + (:require [tablecloth.column.api.utils :refer [do-lift lift-op]])) |
| 3 | + |
| 4 | +(def serialized-lift-fn-lookup |
| 5 | + {['* |
| 6 | + '+ |
| 7 | + '- |
| 8 | + '/ |
| 9 | + '< |
| 10 | + '<= |
| 11 | + '> |
| 12 | + '>= |
| 13 | + 'abs |
| 14 | + 'acos |
| 15 | + 'and |
| 16 | + 'asin |
| 17 | + 'atan |
| 18 | + 'atan2 |
| 19 | + 'bit-and |
| 20 | + 'bit-and-not |
| 21 | + 'bit-clear |
| 22 | + 'bit-flip |
| 23 | + 'bit-not |
| 24 | + 'bit-or |
| 25 | + 'bit-set |
| 26 | + 'bit-shift-left |
| 27 | + 'bit-shift-right |
| 28 | + #_bit-test ;; can't get this to work yet. |
| 29 | + 'bit-xor |
| 30 | + 'cbrt |
| 31 | + 'ceil |
| 32 | + 'cos |
| 33 | + 'cosh |
| 34 | + 'distance |
| 35 | + 'distance-squared |
| 36 | + 'dot-product |
| 37 | + 'eq |
| 38 | + 'equals |
| 39 | + 'exp |
| 40 | + 'expm1 |
| 41 | + 'floor |
| 42 | + 'get-significand |
| 43 | + 'hypot |
| 44 | + 'identity |
| 45 | + 'ieee-remainder |
| 46 | + 'log |
| 47 | + 'log10 |
| 48 | + 'log1p |
| 49 | + 'logistic |
| 50 | + 'magnitude |
| 51 | + 'max |
| 52 | + 'min |
| 53 | + 'next-down |
| 54 | + 'next-up |
| 55 | + 'normalize |
| 56 | + 'not-eq |
| 57 | + 'or |
| 58 | + 'pow |
| 59 | + 'quot |
| 60 | + 'rem |
| 61 | + 'rint |
| 62 | + 'signum |
| 63 | + 'sin |
| 64 | + 'sinh |
| 65 | + 'sq |
| 66 | + 'sqrt |
| 67 | + 'tan |
| 68 | + 'tanh |
| 69 | + 'to-degrees |
| 70 | + 'to-radians |
| 71 | + 'ulp |
| 72 | + 'unsigned-bit-shift-right] lift-op |
| 73 | + ['kurtosis |
| 74 | + 'sum |
| 75 | + 'mean |
| 76 | + 'skew |
| 77 | + 'variance |
| 78 | + 'standard-deviation |
| 79 | + 'quartile-3 |
| 80 | + 'quartile-1 |
| 81 | + 'median] (fn [fn-sym fn-meta] |
| 82 | + (lift-op |
| 83 | + fn-sym fn-meta |
| 84 | + {:new-args '([col] [col options]) |
| 85 | + :new-args-lookup {'data 'col |
| 86 | + 'options 'options}})) |
| 87 | + ['even? |
| 88 | + 'finite? |
| 89 | + 'infinite? |
| 90 | + 'mathematical-integer? |
| 91 | + 'nan? |
| 92 | + 'neg? |
| 93 | + 'not |
| 94 | + 'odd? |
| 95 | + 'pos? |
| 96 | + 'round |
| 97 | + 'zero?] |
| 98 | + (fn [fn-sym fn-meta] |
| 99 | + (lift-op |
| 100 | + fn-sym fn-meta |
| 101 | + {:new-args '([x] [x options]) |
| 102 | + :new-args-lookup {'arg 'x |
| 103 | + 'options 'options}})) |
| 104 | + ['percentiles] (fn [fn-sym fn-meta] |
| 105 | + (lift-op |
| 106 | + fn-sym fn-meta |
| 107 | + {:new-args '([x percentiles] [x percentiles options]) |
| 108 | + :new-args-lookup {'data 'x, |
| 109 | + 'percentages 'percentiles, |
| 110 | + 'options 'options}})) |
| 111 | + ['shift] (fn [fn-sym fn-meta] |
| 112 | + (lift-op |
| 113 | + fn-sym fn-meta |
| 114 | + {:new-args '([x n]) |
| 115 | + :new-args-lookup {'rdr 'x |
| 116 | + 'n 'n}})) |
| 117 | + ['descriptive-statistics] (fn [fn-sym fn-meta] |
| 118 | + (lift-op |
| 119 | + fn-sym fn-meta |
| 120 | + {:new-args '([x stats-names stats-data options] |
| 121 | + [x stats-names options] |
| 122 | + [x stats-names] |
| 123 | + [x]) |
| 124 | + :new-args-lookup {'rdr 'x |
| 125 | + 'src-rdr 'x |
| 126 | + 'stats-names 'stats-names |
| 127 | + 'stats-data 'stats-data |
| 128 | + 'options 'options}})) |
| 129 | + ['quartiles] (fn [fn-sym fn-meta] |
| 130 | + (lift-op |
| 131 | + fn-sym fn-meta |
| 132 | + {:new-args '([x options] [x]) |
| 133 | + :new-args-lookup {'item 'x |
| 134 | + 'options 'options}})) |
| 135 | + ['fill-range] (fn [fn-sym fn-meta] |
| 136 | + (lift-op |
| 137 | + fn-sym fn-meta |
| 138 | + {:new-args '([x max-span]) |
| 139 | + :new-args-lookup {'numeric-data 'x |
| 140 | + 'max-span 'max-span}})) |
| 141 | + ['reduce-min |
| 142 | + 'reduce-max |
| 143 | + 'reduce-* |
| 144 | + 'reduce-+] (fn [fn-sym fn-meta] |
| 145 | + (lift-op |
| 146 | + fn-sym fn-meta |
| 147 | + {:new-args '([x]) |
| 148 | + :new-args-lookup {'rdr 'x}})) |
| 149 | + ['mean-fast |
| 150 | + 'sum-fast |
| 151 | + 'magnitude-squared] (fn [fn-sym fn-meta] |
| 152 | + (lift-op |
| 153 | + fn-sym fn-meta |
| 154 | + {:new-args '([x]) |
| 155 | + :new-args-lookup {'data 'x}})) |
| 156 | + ['kendalls-correlation |
| 157 | + 'pearsons-correlation |
| 158 | + 'spearmans-correlation] (fn [fn-sym fn-meta] |
| 159 | + (lift-op |
| 160 | + fn-sym fn-meta |
| 161 | + {:new-args '([x y] [x y options]) |
| 162 | + :new-args-lookup {'lhs 'x |
| 163 | + 'rhs 'y |
| 164 | + 'options 'options}})) |
| 165 | + ['cumprod |
| 166 | + 'cumsum |
| 167 | + 'cummax |
| 168 | + 'cummin] (fn [fn-sym fn-meta] |
| 169 | + (lift-op |
| 170 | + fn-sym fn-meta |
| 171 | + {:new-args '([x] [x options]) |
| 172 | + :new-args-lookup {'data 'x |
| 173 | + 'options 'options}}))}) |
| 174 | + |
| 175 | + |
| 176 | +(defn deserialize-lift-fn-lookup [] |
| 177 | + (reduce (fn [m [symlist liftfn]] |
| 178 | + (loop [syms symlist |
| 179 | + result m] |
| 180 | + (if (empty? syms) |
| 181 | + result |
| 182 | + (recur (rest syms) (assoc result (first syms) liftfn))))) |
| 183 | + {} |
| 184 | + serialized-lift-fn-lookup)) |
| 185 | + |
| 186 | +(comment |
| 187 | + (do-lift (deserialize-lift-fn-lookup) |
| 188 | + 'tablecloth.column.api.operators |
| 189 | + 'tech.v3.datatype.functional |
| 190 | + '[* + - / < <= > >= abs and bit-and bit-and-not bit-clear bit-flip |
| 191 | + bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor |
| 192 | + even? identity infinite? max min neg? not odd? odd? or pos? quot rem |
| 193 | + unsigned-bit-shift-right zero?] |
| 194 | + "src/tablecloth/column/api/operators.clj") |
| 195 | + ,) |
0 commit comments