Skip to content
Snippets Groups Projects

Base knife-edge scan analysis implementation

Merged Cammille Carinan requested to merge knife-edge-base into master
2 files
+ 19
3
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -45,7 +45,7 @@ def test_range_mask():
@@ -45,7 +45,7 @@ def test_range_mask():
np.testing.assert_array_equal(slice_, [False, False, True, False, True])
np.testing.assert_array_equal(slice_, [False, False, True, False, True])
def test_prepare_arrays():
def test_prepare_arrays_nans():
# Setup test values
# Setup test values
trains, pulses = 5, 10
trains, pulses = 5, 10
size = trains * pulses
size = trains * pulses
@@ -74,6 +74,23 @@ def test_prepare_arrays():
@@ -74,6 +74,23 @@ def test_prepare_arrays():
assert np.isfinite(intensities).all()
assert np.isfinite(intensities).all()
 
def test_prepare_arrays_size():
 
trains, pulses = 5, 10
 
size = trains * pulses
 
motor = np.arange(trains)
 
signal = np.random.randint(100, size=(trains, pulses))
 
 
# Test finite motor and 2D signals
 
positions, intensities = prepare_arrays(motor, signal)
 
assert positions.shape == (size,)
 
assert intensities.shape == (size,)
 
 
# Test finite motor and 1D signals
 
positions, intensities = prepare_arrays(motor, signal.reshape(1, -1))
 
assert positions.shape == (size,)
 
assert intensities.shape == (size,)
 
 
def with_values(array, value, num=5):
def with_values(array, value, num=5):
copy = array.astype(np.float)
copy = array.astype(np.float)
copy.ravel()[np.random.choice(copy.size, num, replace=False)] = value
copy.ravel()[np.random.choice(copy.size, num, replace=False)] = value
Loading