Skip to content

Commit

Permalink
cleaned up after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 committed Aug 21, 2024
1 parent e1ed77b commit e3b149c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/ophyd_async/epics/signal/_aioca.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ def make_converter(
# Allow int signals to represent float records when prec is 0
is_prec_zero_float = (
isinstance(value, float)
and get_unique({k: v.precision for k, v in values.items()}, "precision")
and get_unique(
{k: v.precision for k, v in values.items()}, "precision"
)
== 0
)
if not (datatype is int and is_prec_zero_float):
Expand Down
8 changes: 7 additions & 1 deletion src/ophyd_async/epics/signal/_p4p.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,15 @@ def write_value(self, value: Union[BaseModel, Dict[str, Any]]):
A user can put whichever form to the signal.
This is required for yaml deserialization.
"""
if isinstance(value, dict):
# If the device is being deserialized
return self.datatype(**value).model_dump(mode="python")
if isinstance(value, self.datatype):
return value.model_dump(mode="python")
return value



class PvaConverterFactory(BackendConverterFactory):
_ALLOWED_TYPES = (
bool,
Expand Down Expand Up @@ -398,7 +402,9 @@ def make_converter(
== 0
)
if not (datatype is int and is_prec_zero_float):
raise TypeError(f"{pv} has type {typ.__name__} not {datatype.__name__}")
raise TypeError(
f"{pv} has type {typ.__name__} not {datatype.__name__}"
)
return PvaConverter()
elif "NTTable" in typeid:
return PvaTableConverter()
Expand Down

0 comments on commit e3b149c

Please sign in to comment.