feat: Adds between utility function
This commit is contained in:
@@ -31,3 +31,10 @@ def fast_vs_for_dipoles(dot_inputs: numpy.ndarray, dipoles: numpy.ndarray) -> nu
|
||||
bses = (1 / numpy.pi) * (ws[:, None] / (fs**2 + ws[:, None]**2))
|
||||
_logger.debug(f"bses: {bses}")
|
||||
return ases * bses
|
||||
|
||||
|
||||
def between(a: numpy.ndarray, low: numpy.ndarray, high: numpy.ndarray) -> numpy.ndarray:
|
||||
'''
|
||||
Intended specifically for the case where a is a list of arrays, and each array must be between the single array low and high, but without error checking.
|
||||
'''
|
||||
return numpy.all(numpy.logical_and(low < a, high > a), axis=1)
|
||||
|
||||
@@ -18,3 +18,16 @@ def test_fast_v_calc():
|
||||
expected = numpy.array([[expected_11, expected_21], [expected_12, expected_22]])
|
||||
|
||||
numpy.testing.assert_allclose(pdme.util.fast_v_calc.fast_vs_for_dipoles(dot_inputs, dipoles), expected, err_msg="Voltages at dot aren't as expected.")
|
||||
|
||||
|
||||
def test_between():
|
||||
low = numpy.array([1, 2, 3])
|
||||
high = numpy.array([6, 7, 8])
|
||||
|
||||
# FALSE FALSE TRUE
|
||||
a = [[0, 1, 2], [0, 9, 5], [4, 5, 6]]
|
||||
|
||||
actual = pdme.util.fast_v_calc.between(a, low, high)
|
||||
expected = numpy.array([False, False, True])
|
||||
|
||||
numpy.testing.assert_array_equal(actual, expected, err_msg="Between calc wrong")
|
||||
|
||||
Reference in New Issue
Block a user