Skip to content

Commit

Permalink
refactor physical scales; enforce more np.ndarray
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkedavida committed Oct 18, 2024
1 parent 02b57b6 commit df01599
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 168 deletions.
20 changes: 18 additions & 2 deletions latqcdtools/math/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def logDet(mat) -> float:
"""
Logarithm of determinant.
"""
checkType(np.ndarray,mat=mat)
checkSquare(mat)
_, ans = np.linalg.slogdet(mat)
return ans
Expand All @@ -137,12 +138,27 @@ def RMS(data) -> float:
Root-mean-square of data
Args:
data (array-like)
data (np.ndarray)
Returns:
float: RMS of data
"""
return np.sqrt(np.mean(np.array(data)**2))
checkType(np.ndarray,data=data)
return np.sqrt(np.mean(data**2))


def quadrature(data) -> float:
"""
Add data in quadrature
Args:
data (np.ndarray)
Returns:
float: data added in quadrature
"""
checkType(np.ndarray,data=data)
return np.sqrt(np.sum(data**2))


def rel_check(a, b, prec = 1e-6, abs_prec = 1e-14) -> bool:
Expand Down
6 changes: 2 additions & 4 deletions latqcdtools/math/num_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ def integrateData(xdata,ydata,method='trapezoid'):
Returns:
float: Area under ydata.
"""
checkType("array",xdata=xdata)
checkType("array",ydata=ydata)
xdata=np.array(xdata)
ydata=np.array(ydata)
checkType(np.ndarray,xdata=xdata)
checkType(np.ndarray,ydata=ydata)

if method=='simpson':
return integrate.simpson(y=ydata,x=xdata)
Expand Down
Loading

0 comments on commit df01599

Please sign in to comment.