Skip to content

Commit

Permalink
fix(_caput): Better handle numpy arrays.
Browse files Browse the repository at this point in the history
  • Loading branch information
tristpinsm committed Jun 21, 2024
1 parent 2275c25 commit 02e9da5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions python/pysmurf/client/command/smurf_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@ def _caput(self, pvname, val, atca=False, cast_type=True, **kwargs):
var.setDisp(val)
else:
if not atca and cast_type:
# python types are better handled by rogue
if isinstance(val, np.ndarray):
val = [i.item() for i in val]
elif isinstance(val, np.generic):
val = val.item()
# also check that the type matches variable type
var_type = type(var.value())
val = var_type(val)
val = val.astype(var.value().dtype)
else:
if isinstance(val, np.generic):
val = val.item()
var_type = type(var.value())
val = var_type(val)
var.set(val)

def _caget(self, pvname, atca=False, **kwargs):
Expand Down

0 comments on commit 02e9da5

Please sign in to comment.