Skip to content

Use the shared finite-scalar validator for axis tick values #440

Description

@Alek99

Summary

Most numeric builder arguments use XY's canonical validation rule: reject booleans, coerce numeric scalar-likes, reject NaN/infinity, and raise a contextual ValueError. x_axis() and y_axis() bypass that rule for major and minor tick values by calling float() directly.

Audited at 99eda6d.

Current behavior

Both axis factories convert tick_values and minor_tick_values with raw list comprehensions in x_axis() and y_axis().

Consequences include:

  • tick_values=[True] is accepted as [1.0];
  • NaN and positive/negative infinity are accepted into a public axis spec;
  • invalid values leak raw float() conversion messages rather than a stable error naming the axis and tick index.

The repository already has the intended primitive in _validate.finite_scalar.

Proposed direction

Add a small shared sequence validator that applies finite_scalar with indexed labels, and use it for major and minor tick values on both axes (and any equivalent polar-axis input that shares the same public contract).

Acceptance criteria

  • Major and minor tick values reject Python/NumPy booleans.
  • Major and minor tick values reject NaN and infinities before compilation.
  • Conversion failures raise a contextual ValueError naming x_axis/y_axis, the argument, and ideally the index.
  • Valid Python numbers and NumPy numeric scalar-likes continue to work.
  • Tests cover x/y, major/minor, bool, non-finite, invalid-string, and valid NumPy-scalar inputs.

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