File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ def ListMedian(items):
3131
3232
3333def NearestPowerOfTwo (val : float | int | NDArray [np .floating ] | NDArray [np .integer ]) -> NDArray [np .integer ]:
34+ """Return the nearest power of two greater than or equal to val"""
3435 return np .power (2 , np .ceil (np .log2 (val ))).astype (int , copy = False )
3536
3637
@@ -42,5 +43,15 @@ def RoundingPrecision(dtype: DTypeLike) -> int:
4243 return int (np .abs (np .log10 (np .finfo (dtype ).eps )))
4344
4445
46+ def max_shape (shapes : list [np .integer ]) -> NDArray [np .integer ]:
47+ """A function that returns the maximum value for each shape in the array"""
48+ if len (shapes ) == 0 :
49+ return np .zeros (0 , dtype = int )
50+
51+ shapes = np .vstack (shapes )
52+ max_shape = np .max (shapes , axis = 0 )
53+ return max_shape
54+
55+
4556if __name__ == '__main__' :
4657 pass
You can’t perform that action at this time.
0 commit comments