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

BUG: Change declaration of SynAxis components such that describe() works properly. #1154

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

marrable
Copy link
Contributor

@marrable marrable commented Aug 23, 2023

What is this PR about?

When using SynAxis for simulated testing, calling .describe() on an instance returns a descriptor for integers rather than floats.

Example code that demonstrates the issue

from ophyd.sim import SynAxis

if __name__ == "__main__":
    sim_motor = SynAxis(name="motor1", value=3.14)
    print(sim_motor.describe())

Which produces:

OrderedDict([('motor1', {'source': 'SIM:motor1', 'dtype': 'integer', 'shape': [], 'precision': 3}), ('motor1_setpoint', {'source': 'SIM:motor1_setpoint', 'dtype': 'integer', 'shape': [], 'precision': 3})])

What is the fix?

Declaring the components for SynAxis with a value of 0.0 rather than 0. Running demonstration code above with the fix in this PR produces:

OrderedDict([('motor1', {'source': 'SIM:motor1', 'dtype': 'number', 'shape': [], 'precision': 3}), ('motor1_setpoint', {'source': 'SIM:motor1_setpoint', 'dtype': 'number', 'shape': [], 'precision': 3})])

How did I encounter this issue?

While using the bluesky LiveTable callback, format errors were occurring where string format was being called for float values on integer format strings.

@marrable marrable changed the title Change declaration of SynAxis components such that describe() works properly. BUG: Change declaration of SynAxis components such that describe() works properly. Aug 23, 2023
@tacaswell tacaswell merged commit d05262d into bluesky:master Jan 9, 2024
7 of 8 checks passed
@tacaswell
Copy link
Contributor

Thank you @marrable

It would not hurt if we also added an internal cast to float, but this way at least the default value is not a trap.

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