# Path: pythics/lib.py
# class GrowableArray(object):
#     def __init__(self, length, cols=1, dtype=np.float64):
#         self.__cols = cols
#         self.__initial_length = int(length)
#         # number of rows to grow by if we run out of space
#         self.__n_grow = self.__initial_length
#         self.__dtype = dtype
#         self.clear()
#         # properties of arrays
#         self.ndim = 2
# 
#     def clear(self):
#         # actual array size
#         self.__N = self.__initial_length
#         # the next place to put a value in the buffer
#         #   also the number of rows that have been filled
#         self.__n = 0
#         # allocate the initial data
#         self.__data = np.zeros((self.__N, self.__cols), dtype=self.__dtype)
# 
#     def append(self, value):
#         # convert the appended object to an array if it starts as something else
#         if type(value) is not np.ndarray:
#             value = np.array(value)
#         # add the data
#         if value.ndim == 1:
#             # adding a single row of data
#             n = self.__n
#             if n + 1 > self.__N:
#                 # need to allocate more memory
#                 self.__N += self.__n_grow
#                 self.__data = np.resize(self.__data, (self.__N, self.__cols))
#             self.__data[n] = value
#             self.__n = n + 1
#         elif value.ndim == 2:
#             # adding multiple rows of data
#             # avoid loops for appending large arrays
#             n = self.__n
#             L = value.shape[0]
#             N_needed = n + L - self.__N
#             if N_needed > 0:
#                 # need to allocate more memory
#                 self.__N += (N_needed / self.__n_grow + 1) * self.__n_grow
#                 self.__data = np.resize(self.__data, (self.__N, self.__cols))
#             self.__data[n:n+L] = value
#             self.__n += L
# 
#     def __as_array(self):
#         return self.__data[:self.__n]
# 
#     # some standard array methods
# 
#     @property
#     def shape(self):
#         return (self.__n, self.__cols)
# 
#     def __getitem__(self, key):
#         return self.__as_array().__getitem__(key)
# 
#     def __iter__(self):
#         return self.__as_array().__iter__()
# 
#     def __len__(self):
#         return self.__n
# 
#     def __repr__(self):
#         return self.__as_array().__repr__()
# 
#     def __setitem__(self, key, value):
#         return self.__as_array().__setitem__(key, value)
# 
#     def __str__(self):
#         return self.__as_array().__str__()
# 
#     def sum(self, *args, **kwargs):
#         return self.__as_array().sum(*args, **kwargs)


from collections import namedtuple
from pythics.lib import GrowableArray
import numpy as np
    C.data_chart.clear_data()
    if C.dwell_time.value < 0.1:
        # use fast plotting (hidden axes) for data taken faster than 10 Hz
        #  you may want to change this depending on the speed of your computer
        C.data_chart.fast = True
    t = 0.0
    while(C.start_stop.value):
        # read and show voltages
        new_y1 = 5*np.random.rand()
        new_y2 = 4*np.random.rand()
        new_y3 = 2*np.random.rand()
        new_y4 = 3*np.random.rand()
        C.voltage_1.value = new_y1
        C.voltage_2.value = new_y2
        C.voltage_3.value = new_y3
        C.voltage_4.value = new_y4
        new_data = np.array([t, new_y1, new_y2, new_y3, new_y4])
        private.data.append(new_data)
        C.data_chart.append_data(new_data)
        dt = C.dwell_time.value
        t += dt
        yield dt
    # turn axes drawing back on
    C.data_chart.fast = False
    

#def save_data(**kwargs):
@kwargs_to_namedtuple
def save_data(C):
    np.savetxt(C.data_filename.value, private.data, 

# Path: pythics/lib.py
# class GrowableArray(object):
#     def __init__(self, length, cols=1, dtype=np.float64):
#         self.__cols = cols
#         self.__initial_length = int(length)
#         # number of rows to grow by if we run out of space
#         self.__n_grow = self.__initial_length
#         self.__dtype = dtype
#         self.clear()
#         # properties of arrays
#         self.ndim = 2
# 
#     def clear(self):
#         # actual array size
#         self.__N = self.__initial_length
#         # the next place to put a value in the buffer
#         #   also the number of rows that have been filled
#         self.__n = 0
#         # allocate the initial data
#         self.__data = np.zeros((self.__N, self.__cols), dtype=self.__dtype)
# 
#     def append(self, value):
#         # convert the appended object to an array if it starts as something else
#         if type(value) is not np.ndarray:
#             value = np.array(value)
#         # add the data
#         if value.ndim == 1:
#             # adding a single row of data
#             n = self.__n
#             if n + 1 > self.__N:
#                 # need to allocate more memory
#                 self.__N += self.__n_grow
#                 self.__data = np.resize(self.__data, (self.__N, self.__cols))
#             self.__data[n] = value
#             self.__n = n + 1
#         elif value.ndim == 2:
#             # adding multiple rows of data
#             # avoid loops for appending large arrays
#             n = self.__n
#             L = value.shape[0]
#             N_needed = n + L - self.__N
#             if N_needed > 0:
#                 # need to allocate more memory
#                 self.__N += (N_needed / self.__n_grow + 1) * self.__n_grow
#                 self.__data = np.resize(self.__data, (self.__N, self.__cols))
#             self.__data[n:n+L] = value
#             self.__n += L
# 
#     def __as_array(self):
#         return self.__data[:self.__n]
# 
#     # some standard array methods
# 
#     @property
#     def shape(self):
#         return (self.__n, self.__cols)
# 
#     def __getitem__(self, key):
#         return self.__as_array().__getitem__(key)
# 
#     def __iter__(self):
#         return self.__as_array().__iter__()
# 
#     def __len__(self):
#         return self.__n
# 
#     def __repr__(self):
#         return self.__as_array().__repr__()
# 
#     def __setitem__(self, key, value):
#         return self.__as_array().__setitem__(key, value)
# 
#     def __str__(self):
#         return self.__as_array().__str__()
# 
#     def sum(self, *args, **kwargs):
#         return self.__as_array().sum(*args, **kwargs)


# Path: pythics/examples/chart_recorder-namedtuple.py
from collections import namedtuple
from pythics.lib import GrowableArray
import numpy as np

    C.data_chart.clear_data()
    if C.dwell_time.value < 0.1:
        # use fast plotting (hidden axes) for data taken faster than 10 Hz
        #  you may want to change this depending on the speed of your computer
        C.data_chart.fast = True
    t = 0.0
    while(C.start_stop.value):
        # read and show voltages
        new_y1 = 5*np.random.rand()
        new_y2 = 4*np.random.rand()
        new_y3 = 2*np.random.rand()
        new_y4 = 3*np.random.rand()
        C.voltage_1.value = new_y1
        C.voltage_2.value = new_y2
        C.voltage_3.value = new_y3
        C.voltage_4.value = new_y4
        new_data = np.array([t, new_y1, new_y2, new_y3, new_y4])
        private.data.append(new_data)
        C.data_chart.append_data(new_data)
        dt = C.dwell_time.value
        t += dt
        yield dt
    # turn axes drawing back on
    C.data_chart.fast = False
    

#def save_data(**kwargs):
@kwargs_to_namedtuple
def save_data(C):
    np.savetxt(C.data_filename.value, private.data, 

                  fmt='%.18e', 