Skip to content

Commit

Permalink
Minor docs and test tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhasself committed Mar 29, 2024
1 parent 854611e commit 6346f62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion docs/cpp_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ indices)``::
# Extract full data without "decompressing" ts.
shape = (len(ts.names), len(ts.times))
dest = np.empty(shape, dtype=ts.dtype)
ts.extract(dest, None, None)
ts.extract(dest)

# Extract only data for detector at index 1.
indices = np.array([1])
Expand All @@ -137,6 +137,10 @@ indices)``::
dest = np.empty((6, len(ts.times)), dtype=ts.dtype)
ts.extract(dest, np.array([0, 2, 4]), np.array([1, 3, 5]))

# Extract all dets, samples [100:200].
dest = np.empty((len(ts.names), 100), dtype=ts.dtype)
ts.extract(dest, None, None, 100, 200)



How to work with float arrays
Expand Down
10 changes: 9 additions & 1 deletion test/test_g3super.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,14 @@ def _get_ts():
with self.assertRaises(ValueError):
ts.extract(dest)

ts = _get_ts()
idx = np.array([2, 1, 3])
dest = np.zeros((len(idx), 100), dtype='float32')
ts = _get_ts()
ts.extract(dest, None, idx)
np.testing.assert_array_equal(dest, ts.data[idx])
ts = _get_ts()
ts.extract(dest, src_indices=idx)
np.testing.assert_array_equal(dest, ts.data[idx])

ts = _get_ts()
dest = np.zeros((1, 2, 100), dtype='float32')
Expand All @@ -380,6 +383,11 @@ def _get_ts():
with self.assertRaises(ValueError):
ts.extract(dest, None, idx)

# Sample subset
ts = _get_ts()
dest = np.zeros((5, 91-10), dtype='float32')
ts.extract(dest, start=10, stop=91)

#Injection test.
ts = _get_ts()
src_i = np.array([2, 1, 3])
Expand Down

0 comments on commit 6346f62

Please sign in to comment.