def test_same_plane(self): a = numpy.array([1.0, 0.0, 0.0], floattype) b = numpy.array([0.0, 1.0, 0.0], floattype) c = numpy.array([1.0, 0.0, 0.0], floattype) result = sasmath.signed_angle(a, b, c) expected = util.num_to_floattype(0.0, floattype) self.assertAlmostEqual(result, expected)
def test_zero(self): a = numpy.array([util.ZERO, 3.0, 0.0], floattype) b = numpy.array([6.0, util.ZERO, 2.0], floattype) c = numpy.array([6.7, 1.0, util.ZERO], floattype) result = sasmath.signed_angle(a, b, c) expected = util.num_to_floattype(90.0, floattype) self.assertAlmostEqual(result, expected)
def test_all_zero_arrays(self): a = numpy.array([0.0, 0.0, 0.0], floattype) b = numpy.array([0.0, 0.0, 0.0], floattype) c = numpy.array([0.0, 0.0, 0.0], floattype) result = sasmath.signed_angle(a, b, c) expected = util.num_to_floattype(180.0, floattype) self.assertAlmostEqual(result, expected)
def test_inf_2(self): a=numpy.array([util.INF, 3.0, 0.0],floattype) b=numpy.array([util.INF, 1.2, 2.3],floattype) c=numpy.array([0.3, util.INF, 29.02],floattype) result = sasmath.signed_angle(a,b,c) print result self.assertTrue(numpy.isnan(result) or numpy.isinf(result))
def test_tiny(self): a = numpy.array([util.TINY, 3.0, 0.0], floattype) b = numpy.array([6.0, util.TINY, 2.0], floattype) c = numpy.array([2.0, 3.2, util.TINY], floattype) result = sasmath.signed_angle(a, b, c) expected = util.num_to_floattype(90.0, floattype) self.assertAlmostEqual(result, expected)
def test_inf_2(self): a = numpy.array([util.INF, 3.0, 0.0], floattype) b = numpy.array([util.INF, 1.2, 2.3], floattype) c = numpy.array([0.3, util.INF, 29.02], floattype) result = sasmath.signed_angle(a, b, c) print result self.assertTrue(numpy.isnan(result) or numpy.isinf(result))
def test_same_plane(self): a=numpy.array([1.0, 0.0, 0.0],floattype) b=numpy.array([0.0, 1.0, 0.0],floattype) c=numpy.array([1.0, 0.0, 0.0],floattype) result = sasmath.signed_angle(a,b,c) expected = util.num_to_floattype(0.0, floattype) self.assertAlmostEqual(result,expected)
def test_all_zero_arrays(self): a=numpy.array([0.0, 0.0, 0.0],floattype) b=numpy.array([0.0, 0.0, 0.0],floattype) c=numpy.array([0.0, 0.0, 0.0],floattype) result = sasmath.signed_angle(a,b,c) expected = util.num_to_floattype(180.0, floattype) self.assertAlmostEqual(result,expected)
def test_zero(self): a=numpy.array([util.ZERO, 3.0, 0.0],floattype) b=numpy.array([6.0, util.ZERO, 2.0],floattype) c=numpy.array([6.7, 1.0, util.ZERO],floattype) result = sasmath.signed_angle(a,b,c) expected = util.num_to_floattype(90.0, floattype) self.assertAlmostEqual(result,expected)
def test_tiny(self): a=numpy.array([util.TINY, 3.0, 0.0],floattype) b=numpy.array([6.0, util.TINY, 2.0],floattype) c=numpy.array([2.0, 3.2, util.TINY],floattype) result = sasmath.signed_angle(a,b,c) expected = util.num_to_floattype(90.0, floattype) self.assertAlmostEqual(result,expected)
def test_arb(self): a = numpy.array([1.0168308, -1.35572028, -1.35362422], floattype) b = numpy.array([-0.69958848, 1.66901076, 0.49978462], floattype) # a=numpy.array([1.3, 0.8, -12.8],floattype) # b=numpy.array([-9.76, 12.2, 3.0],floattype) c = numpy.array([0.3, 0.0, -1.2], floattype) result = sasmath.signed_angle(a, b, c) expected = self.calc_expected(a, b, c) self.assertAlmostEqual(result, expected) print "numpy.dot(a,a) ", numpy.dot(a, a) print "numpy.dot(b,b) ", numpy.dot(b, b) print "numpy.dot(a,b) ", numpy.dot(a, b)
def test_arb(self): a=numpy.array([1.0168308, -1.35572028, -1.35362422],floattype) b=numpy.array([-0.69958848, 1.66901076, 0.49978462],floattype) #a=numpy.array([1.3, 0.8, -12.8],floattype) #b=numpy.array([-9.76, 12.2, 3.0],floattype) c=numpy.array([0.3, 0.0, -1.2],floattype) result = sasmath.signed_angle(a,b,c) expected = self.calc_expected(a,b,c) self.assertAlmostEqual(result,expected) print 'numpy.dot(a,a) ',numpy.dot(a,a) print 'numpy.dot(b,b) ',numpy.dot(b,b) print 'numpy.dot(a,b) ',numpy.dot(a,b)
def test_inf_1(self): a = numpy.array([util.HUGE, 3.0, 0.0], floattype) b = numpy.array([22.3, util.HUGE, 2.3], floattype) c = numpy.array([util.HUGE, 1.0, 29.02], floattype) result = sasmath.signed_angle(a, b, c) self.assertTrue(numpy.isnan(result) or numpy.isinf(result))
def test_nan_inf(self): a = numpy.array([util.NAN, 3.0, 0.0], floattype) b = numpy.array([6.0, util.INF, util.NAN], floattype) c = numpy.array([util.NAN, 1.0, util.INF], floattype) result = sasmath.signed_angle(a, b, c) self.assertTrue(numpy.isnan(result) or numpy.isinf(result))
def test_inf_1(self): a=numpy.array([util.HUGE, 3.0, 0.0],floattype) b=numpy.array([22.3, util.HUGE, 2.3],floattype) c=numpy.array([util.HUGE, 1.0, 29.02],floattype) result = sasmath.signed_angle(a,b,c) self.assertTrue(numpy.isnan(result) or numpy.isinf(result))
def test_nan_inf(self): a=numpy.array([util.NAN, 3.0, 0.0],floattype) b=numpy.array([6.0, util.INF, util.NAN],floattype) c=numpy.array([util.NAN, 1.0, util.INF],floattype) result = sasmath.signed_angle(a,b,c) self.assertTrue(numpy.isnan(result) or numpy.isinf(result))