-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
33 lines (23 loc) · 754 Bytes
/
utils.py
File metadata and controls
33 lines (23 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# !/usr/bin/env python3
import numpy as np
# Define constants for evaluation
ANGLE_SAMPLES = np.linspace(- np.pi, np.pi, 1000)
def is_zero(x, tol=1e-8):
"""
Check if a number or array of numbers is close to zero within a given tolerance.
Args:
x (float or np.ndarray): Input number or array.
tol (float, optional): Tolerance value. Default is 1e-8.
Returns:
bool or np.ndarray: True if input is within tolerance of zero, False otherwise.
"""
return np.abs(x) < tol
def abs_max(x):
"""
Compute the maximum absolute value of an array.
Args:
x (np.ndarray): Input array.
Returns:
float: Maximum absolute value of the input array.
"""
return np.max(np.abs(x))