def test_calculate_angle(): '''Test the calculate_angle function''' rA = np.array([1, 0, 0]) rB = np.array([0, 0, 0]) rC = np.array([0, 1, 0]) expected_angle = 90 calculated_angle = geometry_analysis.calculate_angle(rA, rB, rC, degrees=True) assert expected_angle == calculated_angle # Second assert expected_angle_rad = math.radians(90) calculated_angle_rad = geometry_analysis.calculate_angle(rA, rB, rC, degrees=False) assert expected_angle_rad == calculated_angle_rad
def test_calculate_angle(p1, p2, p3, expected_angle): calculated_angle = geometry_analysis.calculate_angle(p1, p2, p3, degrees=True) assert np.isclose(expected_angle, calculated_angle)
def test_calculate_angle_60(): r1 = np.array([0, 0, -1]) r2 = np.array([0, 1, 0]) r3 = np.array([1, 0, 0]) expected_value = 60 calculated_value = geometry_analysis.calculate_angle(r1, r2, r3, degrees = True) assert np.isclose(expected_value, calculated_value)
def test_calculate_angles_60(): """ Test the calculate_angle function""" r1 = np.array([0,0,-1]) r2 = np.array([0,1,0]) r3 = np.array([1,0,0]) calculate_angle = geometry_analysis.calculate_angle (r1,r2,r3, degrees=True) expected_angle = 60 assert np.isclose (calculate_angle, expected_angle)
def test_calculate_angle_90(): """Test the calculate angle function""" r1 = np.array([1, 0, 0]) r2 = np.array([0, 0, 0]) r3 = np.array([0, 1, 0]) expected_angle = 90 calculted_angle = geometry_analysis.calculate_angle(r1, r2, r3, degrees=True) assert expected_angle == calculted_angle
def test_calculate_angle(): r1 = np.array([1, 0, 0]) r2 = np.array([0, 0, 0]) r3 = np.array([0, 1, 0]) expected_value = 90 calculated_value = geometry_analysis.calculate_angle(r1, r2, r3, degrees=True) assert expected_value == calculated_value
def test_calculate_angle(): """ Test the test_calculate_angle function """ r1 = np.random.rand(3) r2 = np.random.rand(3) r3 = np.random.rand(3) dr1 = r2 - r1 dr2 = r2 - r3 expected_angle = np.arccos( np.dot(dr1, dr2) / (np.linalg.norm(dr1) * np.linalg.norm(dr2))) calculate_angle = geometry_analysis.calculate_angle(r1, r2, r3) assert np.isclose(expected_angle, calculate_angle)
def test_calculate_angle_90(): """Test the calculate_angle function""" A = np.array([1, 0, 0]) B = np.array([0, 0, 0]) C = np.array([0, 1, 0]) expected_angle = 90 calculated_angle = geometry_analysis.calculate_angle(A, B, C, True) assert expected_angle == calculated_angle
def test_calculate_angle_90(): """Test the calculate_distance function""" r1 = np.array([1, 0, 0]) r2 = np.array([0, 0, 0]) r3 = np.array([0, 1, 0]) expected_theta = (math.pi) / 2 calculated_theta = geometry_analysis.calculate_angle(r1, r2, r3) assert expected_theta == calculated_theta
def test_calculate_angle_fail(p1, p2, p3, expected_angle): calculated_angle = geometry_analysis.calculate_angle(p1, p2, p3, degrees=True) ## Test that this failure returns a failure if np.isclose(expected_angle, calculated_angle) == True: fail = False else: fail = True ## needs to fail, True is a failure assert fail == True
def test_calculate_angle_90(): """Test the calculate_angle function for resulting angle = 90""" r1 = np.array([1, 0, 0]) r2 = np.array([0, 0, 0]) r3 = np.array([0, 1, 0]) expected_angle = np.arccos(0) calculated_angle = geometry_analysis.calculate_angle(r1, r2, r3) assert expected_angle == calculated_angle
def test_calculate_angle_60(): """Test another value of the calculate angle function""" r1 = np.array([0, 0, -1]) r2 = np.array([0, 1, 0]) r3 = np.array([1, 0, 0]) expected_value = 60 calculated_value = geometry_analysis.calculate_angle(r1, r2, r3, degrees=True) assert np.isclose(expected_value, calculated_value)
def test_calculate_angle_60(): """Test another value of the calculate_angle function""" A = np.array([0, 0, -1]) B = np.array([0, 1, 0]) C = np.array([1, 0, 0]) expected_value = 60 calculated_value = geometry_analysis.calculate_angle(A, B, C, True) assert np.isclose(expected_value, calculated_value)
def test_calculate_angle(): """Test the calculate_angle function""" r1 = np.array([1, 0, 0]) r2 = np.array([0, 0, 0]) r3 = np.array([1, 1, 0]) expected_angle = 45.0 calculated_angle = geometry_analysis.calculate_angle(r1, r2, r3, True) assert np.isclose(expected_angle, calculated_angle)
def test_calculate_angle_60(): ''' test the calculate_angle funtion''' r1 = np.array([0, 0 , -1]) r2 = np.array([0, 1, 0]) r3 = np.array([1, 0, 0]) expected_angle = 60 calculated_angle = geometry_analysis.calculate_angle(r1, r2, r3, degrees=True) assert np.isclose(expected_angle, calculated_angle)
def test_calculate_angle(): """Test the calculate_angle function""" rA = np.array([0, 0, 1]) rB = np.array([0, 1, 0]) rC = np.array([1, 0, 0]) expected_angle = 60 calculated_angle = geometry_analysis.calculate_angle(rA, rB, rC, degrees=True) assert np.isclose(calculated_angle, expected_angle) print("This angle test: ", calculated_angle)
def test_calculate_angle_60(): """Test the calculate_angle function""" rA = np.array([1., 0, 0]) rB = np.array([0, 1., 0]) rC = np.array([0, 0, 1.]) expected_angle_degree = 60. calculated_angle_degree = geometry_analysis.calculate_angle(rA, rB, rC, degrees=True) assert np.isclose(expected_angle_degree, calculated_angle_degree)
def test_calcaulte_angle_90(): """Test the calcaulte_distance_function""" r1 = np.array([0, 1, 0]) r2 = np.array([0, 0, 0]) r3 = np.array([1, 0, 0]) expected_angle = 90 calculated_angle = geometry_analysis.calculate_angle(r1, r2, r3, degrees=True) assert np.isclose(expected_angle, calculated_angle)
def test_angle_calculation_angle_60(): """Test the calculate_angle function: this is a case where the answer is not exact""" rA = np.array([0, 0, -1]) rB = np.array([0, 1, 0]) rC = np.array([1, 0, 0]) expected_angle = 60. calculated_angle = geometry_analysis.calculate_angle(rA, rB, rC, degrees=True) assert np.isclose(expected_angle, calculated_angle)
def test_angle_calculation_angle_90(): """Test the calculate_angle function: this is a case where the answer is exact""" rA = np.array([1, 0, 0]) rB = np.array([0, 0, 0]) rC = np.array([0, 1, 0]) expected_angle = 90 calculated_angle = geometry_analysis.calculate_angle(rA, rB, rC, degrees=True) assert expected_angle == calculated_angle
def test_calculate_angle_90(): """Test the caclulate_angle function""" rA = np.array([1, 0, 0]) rB = np.array([0, 0, 0]) rC = np.array([0, 1, 0]) expected_angle = 90 caclulagted_angle = geometry_analysis.calculate_angle(rA, rB, rC, degrees=True) assert expected_angle == caclulagted_angle
def test_calculate_angle_60_rads(): """Test the calculate_angle function""" r1 = np.array([0, 0, -1]) r2 = np.array([0, 1, 0]) r3 = np.array([1, 0, 0]) expect_angle = np.pi / 3 calculated_angle = geometry_analysis.calculate_angle(r1, r2, r3, degrees=False) assert (np.isclose(expect_angle, calculated_angle))
def test_angle_60(): """ Test the calculate_angle function """ r1 = np.array([0, 0, -1]) r2 = np.array([0, 1, 0]) r3 = np.array([1, 0, 0]) calculated_angle_degree = geometry_analysis.calculate_angle( r1, r2, r3, True) angle_degree = 60 assert np.isclose(calculated_angle_degree, angle_degree)
def test_angle_90(): """ Test the calculate_angle function """ r1 = np.array([0, 0, 1]) r2 = np.array([0, 0, 0]) r3 = np.array([0, 1, 0]) calculated_angle_degree = geometry_analysis.calculate_angle( r1, r2, r3, True) angle_degree = 90 assert calculated_angle_degree == angle_degree
def test_calculate_angle_60(): """Test the calculate_angle function""" r1 = np.array([0, 0, -1]) r2 = np.array([0, 1, 0]) r3 = np.array([1, 0, 0]) expected_value = 60 calculated_value = geometry_analysis.calculate_angle(r1, r2, r3, degrees=True) #evaluate to true of close enough assert np.isclose( expected_value, calculated_value) #add ,rtol=... to change default tolerance
def test_calculate_angle_45(): """ Test the calculate_angle function for 90 degree """ r1 = np.array([0, 0, 0]) r2 = np.array([0, 1, 0]) r3 = np.array([0, 0, 1]) expected_value = 45.0 calculated_value = geometry_analysis.calculate_angle(r1, r2, r3, degrees=True) np.testing.assert_almost_equal(expected_value, calculated_value, decimal=7)
def test_calculate_angle_90(): """Test the calculate_angle function""" rA = np.array([1., 0, 0]) rB = np.array([0, 0, 0]) rC = np.array([0, 0, 1.]) expected_angle_degree = 90. calculated_angle_degree = geometry_analysis.calculate_angle(rA, rB, rC, degrees=True) np.testing.assert_almost_equal(calculated_angle_degree, expected_angle_degree, decimal=13)
def test_calculate_angle_60(): """Test another value of the caclulate_angle function""" rA = np.array([0, 0, -1]) rB = np.array([0, 1, 0]) rC = np.array([1, 0, 0]) expected_angle = 60 caclulagted_angle = geometry_analysis.calculate_angle(rA, rB, rC, degrees=True) assert np.isclose( expected_angle, caclulagted_angle) # tolerance can be set by specifying rtol
def test_calculate_angle(): """Calculate angle between points A, B, and C Parameters ---------- rA : numpy array The x, y, z coordinates of point A rB : numpy array The x, y, z coordinates of point B degrees : bool, optional Return the calculated angle in degrees. Returns ------- angle : float The distance between points A and B. """ rA = np.array([0, 1, 1]) rB = np.array([0, 0, 0]) rC = np.array([1, 0, 0]) expected_angle = 90 calculated_angle = geometry_analysis.calculate_angle(rA, rB, rC, degrees = True) assert expected_angle == calculated_angle
def test_calculate_angle(p1, p2, p3, expected_angle): """Test the calculate_angle function""" assert round(expected_angle, 10) == round(geometry_analysis.calculate_angle(p1, p2, p3), 10)