Skip to content

fix(fakefocuser): return primitive types to keep metadata bus-serializable#241

Open
wschoenell wants to merge 1 commit into
astroufsc:masterfrom
wschoenell:fix-focuser-numpy-types
Open

fix(fakefocuser): return primitive types to keep metadata bus-serializable#241
wschoenell wants to merge 1 commit into
astroufsc:masterfrom
wschoenell:fix-focuser-numpy-types

Conversation

@wschoenell

Copy link
Copy Markdown
Contributor

Summary

  • FakeFocuser.get_position and get_temperature could leak numpy scalar types (e.g. np.int64) into the FITS metadata returned by FocuserBase.get_metadata, which the bus encoder cannot serialize.
  • Coerce _position to int on assignment and cast get_position/get_temperature return values to native Python int/float.

Context

Observed in the wild as:

TypeError: Encoding objects of type numpy.int64 is unsupported

…raised from chimera/core/bus.py when a remote bus tried to serialize a Response containing ('FOCUS', np.int64(2500), ...). The numpy value originates from autofocus routines that call move_to(position) with a numpy scalar; _set_position previously stored it as-is.

The fix is at the source (the focuser itself) rather than papering over it in get_metadata, so all consumers of get_position / get_temperature see a primitive.

Test plan

  • Run a fake focuser with the metadata pipeline and confirm no numpy.int64 serialization error
  • Verify move_to still works when called with numpy scalars

🤖 Generated with Claude Code

…ature

Coerce internal state and return values to Python int/float so metadata
remains serializable over the bus. Previously, callers (e.g. autofocus
routines) could pass numpy scalars into move_to/_set_position, causing
get_metadata to emit np.int64 values that the bus encoder rejects.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant