Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_array2anyscript():
mat33 = array2anyscript( np.array([[1, 0, 0], [0, 1, 0], [0,0,1]]) )
assert mat33 == '{{1,0,0},{0,1,0},{0,0,1}}'
mat31 = array2anyscript( np.array([[1, 0, 0]]) )
assert mat31 == '{{1,0,0}}'
mat13 = array2anyscript( np.array([[1], [0], [0]]) )
assert mat13 == '{{1},{0},{0}}'
mat3 = array2anyscript( np.array([0.333333333, -1.9999999999 , 0.0 ]) )
assert mat3 == '{0.333333333,-1.9999999999,0}'
str2 = array2anyscript( np.array(['hallo', 'world']) )
assert str2 == '{"hallo","world"}'
def test_array2anyscript():
mat33 = array2anyscript( np.array([[1, 0, 0], [0, 1, 0], [0,0,1]]) )
assert mat33 == '{{1,0,0},{0,1,0},{0,0,1}}'
mat31 = array2anyscript( np.array([[1, 0, 0]]) )
assert mat31 == '{{1,0,0}}'
mat13 = array2anyscript( np.array([[1], [0], [0]]) )
assert mat13 == '{{1},{0},{0}}'
mat3 = array2anyscript( np.array([0.333333333, -1.9999999999 , 0.0 ]) )
assert mat3 == '{0.333333333,-1.9999999999,0}'
str2 = array2anyscript( np.array(['hallo', 'world']) )
assert str2 == '{"hallo","world"}'
def test_array2anyscript():
mat33 = array2anyscript( np.array([[1, 0, 0], [0, 1, 0], [0,0,1]]) )
assert mat33 == '{{1,0,0},{0,1,0},{0,0,1}}'
mat31 = array2anyscript( np.array([[1, 0, 0]]) )
assert mat31 == '{{1,0,0}}'
mat13 = array2anyscript( np.array([[1], [0], [0]]) )
assert mat13 == '{{1},{0},{0}}'
mat3 = array2anyscript( np.array([0.333333333, -1.9999999999 , 0.0 ]) )
assert mat3 == '{0.333333333,-1.9999999999,0}'
str2 = array2anyscript( np.array(['hallo', 'world']) )
assert str2 == '{"hallo","world"}'
def test_array2anyscript():
mat33 = array2anyscript( np.array([[1, 0, 0], [0, 1, 0], [0,0,1]]) )
assert mat33 == '{{1,0,0},{0,1,0},{0,0,1}}'
mat31 = array2anyscript( np.array([[1, 0, 0]]) )
assert mat31 == '{{1,0,0}}'
mat13 = array2anyscript( np.array([[1], [0], [0]]) )
assert mat13 == '{{1},{0},{0}}'
mat3 = array2anyscript( np.array([0.333333333, -1.9999999999 , 0.0 ]) )
assert mat3 == '{0.333333333,-1.9999999999,0}'
str2 = array2anyscript( np.array(['hallo', 'world']) )
assert str2 == '{"hallo","world"}'
def test_array2anyscript():
mat33 = array2anyscript( np.array([[1, 0, 0], [0, 1, 0], [0,0,1]]) )
assert mat33 == '{{1,0,0},{0,1,0},{0,0,1}}'
mat31 = array2anyscript( np.array([[1, 0, 0]]) )
assert mat31 == '{{1,0,0}}'
mat13 = array2anyscript( np.array([[1], [0], [0]]) )
assert mat13 == '{{1},{0},{0}}'
mat3 = array2anyscript( np.array([0.333333333, -1.9999999999 , 0.0 ]) )
assert mat3 == '{0.333333333,-1.9999999999,0}'
str2 = array2anyscript( np.array(['hallo', 'world']) )
assert str2 == '{"hallo","world"}'
def _format_macro(self, val):
if isinstance(val, np.ndarray):
val = array2anyscript(val)
elif isinstance(val, float):
val = "{:.12g}".format(val)
elif isinstance(val, int):
val = "{:d}".format(val)
return 'classoperation {0} "Set Value" --value="{1}"'.format(self.var, val)
def _create_set_value_cmd(self,var,val):
"""Creates a set value macro string"""
if isinstance(val,list):
val = np.array(val)
if isinstance(val, np.ndarray):
val = array2anyscript(val).strip('"')
if isinstance(val,float):
val = '{:.12g}'.format(val)
return 'classoperation {0} "Set Value" --value="{1}"'.format(var,val)