Skip to content

[MNT]: Consider consolidating the Formatter API #31396

@timhoffm

Description

@timhoffm

Summary

Inspired by #31392 (review)

Should we constrain the public API?

In particular, I don't think set_locs is needed publically. Calling format_ticks(values) should be sufficent and it should be possible to make the locs state an implementation detail.

Additionally, one could check / clarify the relation of __call__ and format_data. Are both needed publically?

Also #5804 may be considered.

Proposed fix

This is a tracking item for the idea. It's not yet ready to be worked on, because we first need a deeper analysis on the current usage and a discussion on the desired API.

Possible improvements:

  • Distinguish between configuration (e.g. base for LogFormatter) and context. Context is information extracted from a set of tick values that may influence how single ticks are rendered (e.g. precision or offset). The context is currently partly public. As a first step, we can make the context private (MNT: Privatize Formatter attributes #31416). This will open up possibilities for re-architecting internal logic: Currently context is stored as persistent state on the Formatter, but we may be able to remove this state (will also require making set_locs() private.
  • ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions