techascent / tech.ml.dataset

A Clojure high performance data processing system
Eclipse Public License 1.0
680 stars 35 forks source link

allow printing precision for doubles #352

Closed genmeblog closed 1 year ago

genmeblog commented 1 year ago

Maybe it's good to introduce dynamic var to control maximum precision for doubles?

https://github.com/techascent/tech.ml.dataset/blob/master/src/tech/v3/dataset/print.clj#L54

cnuernber commented 1 year ago

user> (require '[tech.v3.dataset :as ds])
nil
user> (def ds (ds/->dataset {:a (repeatedly 100 rand)}))
#'user/ds
user> ds
_unnamed [100 1]:

|         :a |
|-----------:|
| 0.19665694 |
| 0.46307367 |
| 0.76538815 |
| 0.54582756 |
| 0.07570895 |
| 0.40522701 |
| 0.47855486 |
| 0.93474881 |
| 0.60427836 |
| 0.62288076 |
|        ... |
| 0.54462287 |
| 0.09558121 |
| 0.53809773 |
| 0.13410423 |
| 0.30965088 |
| 0.38388258 |
| 0.18008029 |
| 0.90002638 |
| 0.31287355 |
| 0.24210655 |
| 0.54967764 |
user> (with-meta ds {:maximum-precision 3})
;; output cleared
user> (with-meta ds {:maximum-precision 3})
null [100 1]:

|    :a |
|------:|
| 0.197 |
| 0.463 |
| 0.765 |
| 0.546 |
| 0.076 |
| 0.405 |
| 0.479 |
| 0.935 |
| 0.604 |
| 0.623 |
|   ... |
| 0.545 |
| 0.096 |
| 0.538 |
| 0.134 |
| 0.310 |
| 0.384 |
| 0.180 |
| 0.900 |
| 0.313 |
| 0.242 |
| 0.550 |
user>