Skip to content
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

New signal typing #594

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

New signal typing #594

wants to merge 7 commits into from

Conversation

coretl
Copy link
Collaborator

@coretl coretl commented Sep 24, 2024

WIP for review by @evalott100

@coretl
Copy link
Collaborator Author

coretl commented Sep 24, 2024

Apologies, another unreviewable PR, but if you start from the tests you can see the changes needed

Copy link
Contributor

@evalott100 evalott100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these are discussion points more than "requested changes". I definitely like abstracting out connection logic.

"numpy<2.0.0",
"numpy",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not have this working with numpy >=2? That's what's being installed currently right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes will make use of np.dtypes.StringDType() as discussed with @danielballan which is only available in numpy 2, so yes I should make it numpy >= 2

"packaging",
"pint",
"bluesky>=1.13.0a3",
"event_model",
"p4p",
"event-model @ git+https://github.com/bluesky/event-model@main",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to pin main here? Using latest release would incentivize regular event-model patch releases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see you're using Limits

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will probably be a few other import level changes to event model before I'm done, then we can release event model too and go back to a release here

src/ophyd_async/core/_device.py Outdated Show resolved Hide resolved
src/ophyd_async/core/_device.py Outdated Show resolved Hide resolved
src/ophyd_async/core/_device.py Outdated Show resolved Hide resolved
src/ophyd_async/core/_soft_signal_backend.py Outdated Show resolved Hide resolved
src/ophyd_async/core/_table.py Outdated Show resolved Hide resolved
Comment on lines +134 to +138
if not get_origin(datatype) == np.ndarray:
raise TypeError(f"Expected np.ndarray, got {datatype}")
# datatype = numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]
# so extract numpy.float64 from it
return np.dtype(get_args(get_args(datatype)[1])[0])
Copy link
Contributor

@evalott100 evalott100 Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we allow for np arrays without subtype? If so we need:

Suggested change
if not get_origin(datatype) == np.ndarray:
raise TypeError(f"Expected np.ndarray, got {datatype}")
# datatype = numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]
# so extract numpy.float64 from it
return np.dtype(get_args(get_args(datatype)[1])[0])
if get_origin(datatype) == np.ndarray:
# np.ndarray[typing.Any, np.dtype[np.float64]] returns np.float64
return np.dtype(get_args(get_args(datatype)[1])[0])
elif datatype == np.ndarray:
return np.float64
else:
raise TypeError(f"Expected np.ndarray, got {datatype}")

If not then perhaps a modification to the error message that the numpy array must be explicitly typed in the npt.NDArray format?

src/ophyd_async/epics/signal/_signal.py Outdated Show resolved Hide resolved
src/ophyd_async/epics/signal/_signal.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants