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_binary_deserialize_exp_test(self):
math_binary_tf = MathBinary(input_features=['a', 'b'], output_features=['a_plus_b'], transform_type='add')
Xres = math_binary_tf.fit_transform(self.df[['a', 'b']])
self.assertEqual( self.df.a[0] + self.df.b[0], Xres[0])
math_binary_tf.serialize_to_bundle(self.tmp_dir, math_binary_tf.name)
node_name = "{}.node".format(math_binary_tf.name)
math_binary_ds_tf = MathBinary()
math_binary_ds_tf = math_binary_ds_tf.deserialize_from_bundle(self.tmp_dir, node_name)
res_a = math_binary_tf.transform(self.df[['a', 'b']])
res_b = math_binary_ds_tf.transform(self.df[['a', 'b']])
self.assertEqual(res_a[0], res_b[0])
def math_binary_divide_test(self):
math_binary_tf = MathBinary(input_features=['a', 'b'], output_features=['a_mul_b'], transform_type='div')
Xres = math_binary_tf.fit_transform(self.df[['a', 'b']])
self.assertEqual(self.df.a[0] / self.df.b[0], Xres[0])
math_binary_tf.serialize_to_bundle(self.tmp_dir, math_binary_tf.name)
expected_model = {
"op": "math_binary",
"attributes": {
"operation": {
"string": 'div'
}
}
}
def math_binary_multiply_test(self):
math_binary_tf = MathBinary(input_features=['a', 'b'], output_features=['a_mul_b'], transform_type='mul')
Xres = math_binary_tf.fit_transform(self.df[['a', 'b']])
self.assertEqual(self.df.a[0] * self.df.b[0], Xres[0])
math_binary_tf.serialize_to_bundle(self.tmp_dir, math_binary_tf.name)
expected_model = {
"op": "math_binary",
"attributes": {
"operation": {
"string": 'mul'
}
}
}
def math_binary_subtract_test(self):
math_binary_tf = MathBinary(input_features=['a', 'b'], output_features=['a_less_b'], transform_type='sub')
Xres = math_binary_tf.fit_transform(self.df[['a', 'b']])
self.assertEqual(self.df.a[0] - self.df.b[0], Xres[0])
math_binary_tf.serialize_to_bundle(self.tmp_dir, math_binary_tf.name)
expected_model = {
"op": "math_binary",
"attributes": {
"operation": {
"string": 'sub'
}
}
}
def math_binary_deserialize_exp_test(self):
math_binary_tf = MathBinary(input_features=['a', 'b'], output_features=['a_plus_b'], transform_type='add')
Xres = math_binary_tf.fit_transform(self.df[['a', 'b']])
self.assertEqual( self.df.a[0] + self.df.b[0], Xres[0])
math_binary_tf.serialize_to_bundle(self.tmp_dir, math_binary_tf.name)
node_name = "{}.node".format(math_binary_tf.name)
math_binary_ds_tf = MathBinary()
math_binary_ds_tf = math_binary_ds_tf.deserialize_from_bundle(self.tmp_dir, node_name)
res_a = math_binary_tf.transform(self.df[['a', 'b']])
res_b = math_binary_ds_tf.transform(self.df[['a', 'b']])
self.assertEqual(res_a[0], res_b[0])
def math_binary_test(self):
math_binary_tf = MathBinary(input_features=['a', 'b'], output_features=['a_plus_b'], transform_type='add')
Xres = math_binary_tf.fit_transform(self.df[['a', 'b']])
self.assertEqual( self.df.a[0] + self.df.b[0], Xres[0])
math_binary_tf.serialize_to_bundle(self.tmp_dir, math_binary_tf.name)
expected_model = {
"op": "math_binary",
"attributes": {
"operation": {
"string": 'add'
}
}
}