MCPcopy Create free account
hub / github.com/bgrimstad/splinter / __init__

Method __init__

python/splinter/datatable.py:14–37  ·  view source on GitHub ↗
(self, x_or_data, y=None)

Source from the content-addressed store, hash-verified

12
13class 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):

Callers

nothing calls this directly

Calls 5

add_sampleMethod · 0.95
is_stringFunction · 0.85
get_c_stringFunction · 0.85
ExceptionClass · 0.85
_get_handleMethod · 0.80

Tested by

no test coverage detected