# reload library
%load_ext autoreload
%autoreload 2
from collector import Collector
from collector import nuke
import numpy as np
c = Collector()
c.timestamp = False
d = np.array([[1,2,3],[4.,5.,6.]])
i = {"b":[1,2,3,4]}
c.write("test_test_now.csv",d)
dd = c.read("test_test_now.csv")
# print(dd["info"] == i)
print(dd["data"] == d)
dd
Saving 2 data points in csv to: --> test_test_now.csv Loaded 2 data points from: --> test_test_now.csv [[ True True True] [ True True True]]
{'data': [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]}
c.write("test_test_now.gzip",d,i)
dd = c.read("test_test_now.gzip")
print(dd["info"] == i)
print(dd["data"] == d)
dd
Saving 2 data points in json gzip to: --> test_test_now.gzip Loaded 2 data points from: --> test_test_now.gzip True [[ True True True] [ True True True]]
{'info': {'b': [1, 2, 3, 4]}, 'data': [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]}
c.write("test_test_now.json",d,i)
dd = c.read("test_test_now.json")
print(dd["info"] == i)
print(dd["data"] == d)
Saving 2 data points in json to: --> test_test_now.json Loaded 2 data points from: --> test_test_now.json True [[ True True True] [ True True True]]
fname = c.write("test_test_now.pkl",d,i)
dd = c.read(fname)
print(dd["info"] == i)
print(dd["data"] == d)
dd
Saving 2 data points in pickle to: --> 2023-08-08T18:53:53_test_test_now.pkl Loaded 2 data points from: --> 2023-08-08T18:53:53_test_test_now.pkl True [[ True True True] [ True True True]]
{'info': {'b': [1, 2, 3, 4]}, 'data': [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]}
c.timestamp = True
fname = c.write("data/test_test_now.pkl",d,i)
dd = c.read(fname)
print(dd["info"] == i)
print(dd["data"] == d)
Saving 2 data points in pickle to: --> data/2023-08-08T18:57:52_test_test_now.pkl Loaded 2 data points from: --> data/2023-08-08T18:57:52_test_test_now.pkl True [[ True True True] [ True True True]]
nuke(recursive=True)