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

Float datakey value gets converted to int when writing to postgres catalog #879

Open
canismarko opened this issue Feb 6, 2025 · 0 comments

Comments

@canismarko
Copy link
Contributor

I have ophyd-async EpicsMotor devices that produce the following datakey in their configurations.

'sim_motor_2-user_offset':
    {'dtype': 'number',
     'shape': [],
     'dtype_numpy': '<f8',
     'source': 'ca://25idc:simMotor:m2.OFF',
     'units': 'degrees',
     'precision': 5,
     'limits': {'control': {'low': -1e+300, 'high': 1e+300},
      'display': {'low': -1e+300, 'high': 1e+300}}
    }

The 1e300 values comes from the IOC and is consistent across many motors. It seems a bit big for a limit, but it's a float so it should be fine. When writing this to a sqlite catalog, everything works as expected: the data key I get when reading the stream's metadata shows the limits as 1e300.

When I use this device with a postgres catalog, however, I get an exception in Tiled saying that an integer value is out of range. If I stick a print statement in before the data are sent to msgpack, I see that the 1e300 floats have been turned into integers and no longer fit into any c types.

'sim_motor_2-user_offset': {'dtype': 'number',
                            'dtype_numpy': '<f8',
                            'limits': {'control': {'high': 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
                                                   'low': -1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000},
                                       'display': {'high': 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
                                                   'low': -1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000}},
                            'precision': 5,
                            'shape': [],
                            'source': 'ca://25idc:simMotor:m2.OFF',
                            'units': 'degrees'},

Curiously, other float datakey limits do not get turned into ints. Like:

'sim_motor_2-velocity': {'dtype': 'number',
                         'dtype_numpy': '<f8',
                         'limits': {'control': {'high': 200.0,
                                                'low': 0.1},
                                    'display': {'high': 200.0,
                                                'low': 0.1}},
                         'precision': 5,
                         'shape': [],
                         'source': 'ca://25idc:simMotor:m2.VELO',
                         'units': 'degrees'}},

Maybe this only effects floats big enough to be serialized in scientific notation?

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

No branches or pull requests

1 participant