def test_dummy_var_naming(self): bs = BatchShaper(x_structure=[('var1', self.lb), (None, 0.), (None, 1.)], y_structure=('label', self.le)) md = bs.get_metadata(self.df) assert type(md) is tuple assert len(md) == 2 assert type(md[0]) is list assert len(md[0]) == 3 assert all([type(m) == dict for m in md[0]]) assert md[0][1]['name'] == 'dummy_constant_0' assert md[0][2]['name'] == 'dummy_constant_1' # test the counter resets with new metadata request md = bs.get_metadata(self.df) assert md[0][1]['name'] == 'dummy_constant_0' assert md[0][2]['name'] == 'dummy_constant_1'
def test_metadata(self): bs = BatchShaper(x_structure=[('var1', self.lb), (None, 0.)], y_structure=('label', self.le)) md = bs.get_metadata(self.df) assert type(md) is tuple assert len(md) == 2 assert type(md[0]) is list assert len(md[0]) == 2 assert type(md[0][0]) == dict assert type(md[0][1]) == dict fields_in_meta = ['name', 'encoder', 'shape', 'dtype'] assert all([all([f in m for f in fields_in_meta]) for m in md[0]]) assert md[0][0]['name'] == 'var1' assert md[0][0]['encoder'] == self.lb assert md[0][0]['shape'] == (None, 3) assert md[0][0]['dtype'] == np.int64 assert md[0][1]['name'] == 'dummy_constant_0' assert md[0][1]['encoder'] is None assert md[0][1]['shape'] == (None, 1) assert md[0][1]['dtype'] == float assert type(md[1]) == dict assert all([f in md[1] for f in fields_in_meta]) assert md[1]['name'] == 'label' assert md[1]['encoder'] == self.le assert md[1]['shape'] == (None, 1) assert md[1]['dtype'] == np.int64