Skip to content

katcp.Message.format_argument parser doesnt handle numpy float correctly #267

Description

@sr-cdf

Passing np.float32 type such as np.float32(0.0) gives b'np.float32(0.0)' instead of b'0.0'.

Casting to python float before generating the printable representation fixes this for me:

katcp-python/katcp/core.py

Lines 316 to 317 in 7a94c7d

elif isinstance(arg, numbers.Real):
return repr(arg).encode('ascii')

        elif isinstance(arg, numbers.Real):
            return repr(float(arg)).encode('ascii')

This was on RFSoC ARM with Ubuntu 24.04.03, Python 3.12.3, Numpy 2.4.3 and katcp 0.9.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions