scicloj/tablecloth

Infinite sequence in dataset fn

Closed this issue · 1 comments

Problem:

Infinite sequences are a relatively common clojure idiom, encountered when for example creating columns from something made with cycle or repeat.
This works fine (if there is a column that has a length) with the current version of tmd's constructor, but loops forever with tablecloth.

I believe the proper behavior is to do the same as the tmd constructor?

Open questions

How does this work with ragged tables? I don't know, maybe it is worth making a test for.

Demo code:

(require '[tech.v3.dataset :as ds])
(require '[tablecloth.api :as api])

(api/dataset
  {:date (repeat "22/07/88")
   :data [1 2 3 4]})
; => infinite loop

(ds/->dataset
  {:date (repeat "22/07/88")
   :data [1 2 3 4]})
 ;; => _unnamed [4 2]:
 ;;
 ;;    |    :date | :data |
 ;;    |----------|------:|
 ;;    | 22/07/88 |     1 |
 ;;    | 22/07/88 |     2 |
 ;;    | 22/07/88 |     3 |
 ;;    | 22/07/88 |     4 |

It's fixed and api now delegates creation to TMD. Be aware that TMD also has a lot of corner cases, see some examples in following thread: https://clojurians.zulipchat.com/#narrow/stream/236259-tech.2Eml.2Edataset.2Edev/topic/api