import numpy as np
import physt

histogram = physt.h1(None, "fixed_width", bin_width=0.1, adaptive=True)
histogram

# Big chunk of data
data1 = np.random.normal(0, 1, 10000000)
histogram.fill_n(data1)
histogram

histogram.plot()

"""
Explanation: Interrupted workflow
This example shows that using IO, you can easily interrupt your workflow, save it and continue some other time.
End of explanation
"""


histogram.to_json(path="./histogram.json");
del histogram

"""
Explanation: Store the histogram (and delete it to pretend we come with a fresh table):
End of explanation
"""


histogram = physt.io.load_json(path="./histogram.json")
histogram

histogram.plot()

"""
Explanation: Turn off the machine, go for lunch, return home later...
Read the histogram:
End of explanation
"""


# Another big chunk of data
data1 = np.random.normal(3, 2, 10000000)
histogram.fill_n(data1)
histogram

histogram.plot()

"""
Explanation: The same one ;-)
Continue filling:
End of explanation
"""


