def test_is_x_in_xdata_a_numpy_array_if_list_sent(self): data = DataStructure.DataStructure() x = [0] y = np.zeros([2]) data.add_data_set(x, y) self.assertIsInstance(data.xdata[0], np.ndarray, msg='xdata[0] should be a numpy array')
def test_is_y_in_ydata_a_numpy_array_if_element_sent(self): data = DataStructure.DataStructure() x = [0] y = 0 data.add_data_set(x, y) self.assertIsInstance(data.ydata[0], np.ndarray, msg='ydata[0] should be a numpy array')
def setup_data_set(self, xsh=[2], ysh=[2], nsets=1): data = DataStructure.DataStructure() x = np.zeros(xsh) y = np.zeros(ysh) for _ in range(nsets): data.add_data_set(x, y) data.get_number_of_data_sets() return data
def test_2d_y_output_2d_shape(self): data = DataStructure.DataStructure() x = np.zeros([2]) y = np.zeros([2, 2]) data.add_data_set(x, y) self.assertEqual(len(data.shape[0]), len(data.ydata[0].shape), msg='lengths should match')
def test_does_shape_match_y_shape(self): data = DataStructure.DataStructure() x = np.zeros([2]) y = np.zeros([2]) data.add_data_set(x, y) self.assertEqual(data.shape[0], data.ydata[0].shape, msg='shapes should match')
def test_number_of_observations_match_sum_of_n_with_2d_y(self): data = DataStructure.DataStructure() x = np.zeros([2]) y = np.zeros([2, 2]) data.add_data_set(x, y) nds = data.get_number_of_observations() self.assertEqual( nds[0], 2, msg='total number of observations is number of rows in y')
def test_does_nbatch_equal_length_of_shape_for_1d_y(self): data = DataStructure.DataStructure() x = np.zeros([2]) y = np.zeros([2]) data.add_data_set(x, y) data.get_number_of_batches() self.assertEqual(data.nbatch, 1, msg='nbatch should match number of calls to ' 'add_data_set' '')
def test_does_nbatch_match_for_1d_y_with_multiple_data_sets(self): data = DataStructure.DataStructure() x = np.zeros([2]) y = np.zeros([2]) data.add_data_set(x, y) data.add_data_set(x, y) data.get_number_of_batches() self.assertEqual(data.nbatch, 2, msg='nbatch should match number of calls to ' 'add_data_set' '')
def test_number_of_observations_match_sum_of_n_with_multiple_sets(self): data = DataStructure.DataStructure() x = np.zeros([2]) y = np.zeros([2]) data.add_data_set(x, y) data.add_data_set(x, y) nds = data.get_number_of_observations() self.assertEqual( nds[0], 4, msg= 'total number of observations is number of rows in y - summed over all sets of y' )
def test_is_ydata_a_list(self): data = DataStructure.DataStructure() x = np.zeros([2]) y = np.zeros([2]) data.add_data_set(x, y) self.assertIsInstance(data.ydata, list, msg='ydata should be a list')
def test_does_initialization_yield_udobj(self): data = DataStructure.DataStructure() self.assertTrue(hasattr(data, 'user_defined_object'))
def test_does_initialization_yield_weight(self): data = DataStructure.DataStructure() self.assertTrue(hasattr(data, 'weight'))
def test_does_initialization_yield_shape(self): data = DataStructure.DataStructure() self.assertTrue(hasattr(data, 'shape'))