Skip to content

Commit

Permalink
allowed the python datatype to be int even if p4p gives a float (#276)
Browse files Browse the repository at this point in the history
This should be adjusted to only allow this if .PREC is 0
  • Loading branch information
evalott100 committed May 2, 2024
1 parent 58e1cf4 commit b5df007
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ophyd_async/epics/_backend/_p4p.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,13 @@ def make_converter(datatype: Optional[Type], values: Dict[str, Any]) -> PvaConve
)
return PvaEnumConverter(get_supported_enum_class(pv, datatype, pv_choices))
elif "NTScalar" in typeid:
if datatype and not issubclass(typ, datatype):
if (
datatype
and not issubclass(typ, datatype)
and not (
typ is float and datatype is int
) # Allow float -> int since prec can be 0
):
raise TypeError(f"{pv} has type {typ.__name__} not {datatype.__name__}")
return PvaConverter()
elif "NTTable" in typeid:
Expand Down

0 comments on commit b5df007

Please sign in to comment.