fixed resizing of digital frames
This commit is contained in:
parent
43f0f0e43a
commit
ad953aefde
@ -136,12 +136,18 @@ static PyObject *RawFileReader_read(RawFileReader *self, PyObject *args) {
|
|||||||
// resize the array to match the number of clusters read
|
// resize the array to match the number of clusters read
|
||||||
PyArray_Resize((PyArrayObject *)frames, &new_shape, 1, NPY_ANYORDER);
|
PyArray_Resize((PyArrayObject *)frames, &new_shape, 1, NPY_ANYORDER);
|
||||||
|
|
||||||
|
if(digital_frames){
|
||||||
|
PyArray_Resize((PyArrayObject *)digital_frames, &new_shape, 1, NPY_ANYORDER);
|
||||||
|
}
|
||||||
|
|
||||||
// if we also read header we need to reshape the header
|
// if we also read header we need to reshape the header
|
||||||
if (self->read_header) {
|
if (self->read_header) {
|
||||||
new_shape.len = 1;
|
new_shape.len = 1;
|
||||||
PyArray_Resize((PyArrayObject *)header, &new_shape, 1,
|
PyArray_Resize((PyArrayObject *)header, &new_shape, 1,
|
||||||
NPY_ANYORDER);
|
NPY_ANYORDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build up a tuple with the return values
|
// Build up a tuple with the return values
|
||||||
|
@ -67,3 +67,12 @@ def test_references_on_m04_ad_with_header(data_path):
|
|||||||
assert analog.shape == (3,400,400)
|
assert analog.shape == (3,400,400)
|
||||||
assert sys.getrefcount(digital) == 2
|
assert sys.getrefcount(digital) == 2
|
||||||
assert sys.getrefcount(header) == 2
|
assert sys.getrefcount(header) == 2
|
||||||
|
|
||||||
|
def test_read_too_many_m04_frames(data_path):
|
||||||
|
fname= data_path/'Moench04_digital_d0_f0_0.raw'
|
||||||
|
r = RawFileReader(fname, m04ad, header = True)
|
||||||
|
analog, digital, header = r.read(150)
|
||||||
|
assert analog.shape == (100,400,400)
|
||||||
|
assert digital.shape == (100, 400, 400)
|
||||||
|
assert header.size == 100
|
||||||
|
assert sys.getrefcount(digital) == 2
|
Reference in New Issue
Block a user