Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def math_unary_deserialize_exp_test(self):
math_unary_tf = MathUnary(input_features=['a'], output_features=['log_a'], transform_type='exp')
Xres = math_unary_tf.fit_transform(self.df.a)
self.assertEqual(np.exp(self.df.a[0]), Xres[0])
math_unary_tf.serialize_to_bundle(self.tmp_dir, math_unary_tf.name)
node_name = "{}.node".format(math_unary_tf.name)
math_unary_ds_tf = MathUnary()
math_unary_ds_tf = math_unary_ds_tf.deserialize_from_bundle(self.tmp_dir, node_name)
with open("{}/{}.node/model.json".format(self.tmp_dir, math_unary_tf.name)) as json_data:
model = json.load(json_data)
res_a = math_unary_tf.transform(self.df['a'])
res_b = math_unary_ds_tf.transform(self.df['a'])
def math_unary_deserialize_exp_test(self):
math_unary_tf = MathUnary(input_features=['a'], output_features=['log_a'], transform_type='exp')
Xres = math_unary_tf.fit_transform(self.df.a)
self.assertEqual(np.exp(self.df.a[0]), Xres[0])
math_unary_tf.serialize_to_bundle(self.tmp_dir, math_unary_tf.name)
node_name = "{}.node".format(math_unary_tf.name)
math_unary_ds_tf = MathUnary()
math_unary_ds_tf = math_unary_ds_tf.deserialize_from_bundle(self.tmp_dir, node_name)
with open("{}/{}.node/model.json".format(self.tmp_dir, math_unary_tf.name)) as json_data:
model = json.load(json_data)
res_a = math_unary_tf.transform(self.df['a'])
res_b = math_unary_ds_tf.transform(self.df['a'])
self.assertEqual(res_a[0], res_b[0])
def math_unary_sin_test(self):
math_unary_tf = MathUnary(input_features=['a'], output_features=['sin_a'], transform_type='sin')
Xres = math_unary_tf.fit_transform(self.df.a)
self.assertEqual(np.sin(self.df.a[0]), Xres[0])
math_unary_tf.serialize_to_bundle(self.tmp_dir, math_unary_tf.name)
expected_model = {
"op": "math_unary",
"attributes": {
"operation": {
"string": 'sin'
}
}
}
def math_unary_exp_test(self):
math_unary_tf = MathUnary(input_features=['a'], output_features=['log_a'], transform_type='exp')
Xres = math_unary_tf.fit_transform(self.df.a)
self.assertEqual(np.exp(self.df.a[0]), Xres[0])
math_unary_tf.serialize_to_bundle(self.tmp_dir, math_unary_tf.name)
expected_model = {
"op": "math_unary",
"attributes": {
"operation": {
"string": 'exp'
}
}
}