(self, x_or_data, y=None)
| 12 | |
| 13 | class DataTable: |
| 14 | def __init__(self, x_or_data, y=None): |
| 15 | self.__handle = None # Handle to instance in the library |
| 16 | self.__x_dim = None |
| 17 | self.__num_samples = 0 # Number of samples not yet transferred to back end |
| 18 | self.__samples = [] |
| 19 | |
| 20 | if is_string(x_or_data): |
| 21 | self.__handle = splinter._call(splinter._get_handle().splinter_datatable_load_init, get_c_string(x_or_data)) |
| 22 | self.__x_dim = splinter._call(splinter._get_handle().splinter_datatable_get_num_variables, self.__handle) |
| 23 | else: |
| 24 | self.__handle = splinter._call(splinter._get_handle().splinter_datatable_init) |
| 25 | |
| 26 | if y is None: |
| 27 | raise Exception("No y-values supplied.") |
| 28 | |
| 29 | if len(x_or_data) != len(y): |
| 30 | raise Exception("x and y must be of the same length!") |
| 31 | |
| 32 | # If x_or_data is not a string, we expect it to be lists of x values which has corresponding y values in 'y'. |
| 33 | for idx in range(len(x_or_data)): |
| 34 | self.add_sample(x_or_data[idx], y[idx]) |
| 35 | # if x_or_data is not None: |
| 36 | # for data_row in x_or_data: |
| 37 | # self.add_sample(list(data_row[:-1]), data_row[-1]) |
| 38 | |
| 39 | # "Public" methods (for use by end user of the library) |
| 40 | def add_sample(self, x, y): |
nothing calls this directly
no test coverage detected