-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add array trimming before reshaping #731
Conversation
(cherry picked from commit 4673d19)
@ronpandolfi I wonder if this will blow up if the array is < the product of the array dimensions? I just have a question if we should trap that? This is very possible if the IOC is not configured correctly. |
ophyd/areadetector/base.py
Outdated
array_shape = self.derived_shape[:self.derived_ndims] | ||
if not any(array_shape): | ||
raise RuntimeError(f"Invalid array size {self.derived_shape}") | ||
|
||
array = self._derived_from.get() | ||
return np.array(array).reshape(array_shape) | ||
return np.array(value[:np.prod(array_shape)]).reshape(array_shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be np.array(array[...
using the array
from L108? Not sure there the input value
was used before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What type is value
here? If it already an array (at least sometimes, in some circumstances) using np.asarray
in place of np.array
will save us from making a copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be
np.array(array[...
using thearray
from L108? Not sure there the inputvalue
was used before.
The array value is actually passed into this method as the value
arg; there's no need to get it again, so I've removed that line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left my comment regarding the use of array
vs. value
.
It would be nice to have a test to poke this functionality. Do you think it's possible with the simulated devices?
@ronpandolfi I'm up for tagging a patch release to get this out. Can you look at @mrakitin's and my comments above when you get a chance? |
@danielballan Above comments have been addressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me as long as the existing tests pass.
Is there a way to add a new test covering this fix?
Restarted the failed test. @mrakitin We don't have a good enough test rig for AD stuff to be worth reproducing this issue. |
Following discussion of areaDetector/ADFastCCD#13 with @mrakitin and @stuwilkins, it was decided that it is possible for EPICS to transmit more elements than the product of its shape, as with the FastCCD and "overscan rows".
To accommodate this, the image array must be trimmed before reshaping.