Skip to content

Commit

Permalink
Merge pull request #731 from ronpandolfi/shaped_image_truncate
Browse files Browse the repository at this point in the history
Add array trimming before reshaping
  • Loading branch information
mrakitin authored Aug 5, 2019
2 parents 9ecca69 + 4196ac1 commit 691193f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ophyd/areadetector/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,13 @@ def inverse(self, value):
array_shape = self.derived_shape[:self.derived_ndims]
if not any(array_shape):
raise RuntimeError(f"Invalid array size {self.derived_shape}")

array_len = np.prod(array_shape)
if len(value) < array_len:
raise RuntimeError(f"cannot reshape array of size {array_len} into shape {tuple(array_shape)}. Check IOC configuration.")

return np.asarray(value[:array_len]).reshape(array_shape)

return np.array(value).reshape(array_shape)

def subscribe(self, callback, event_type=None, run=True):
cid = super().subscribe(callback, event_type=event_type, run=run)
Expand Down

0 comments on commit 691193f

Please sign in to comment.