Skip to content

feat(api): expose trend_analysis at top level (broken — listed in __all__ but unimportable) #81

Description

@BnJam

Problem

trend_analysis is listed in __all__ at python/eo_processor/__init__.py:151 and documented as a public top-level function in the README, but it is neither imported from ._core nor defined as a wrapper anywhere in __init__.py.

This means:

  • from eo_processor import trend_analysisImportError
  • from eo_processor import *ImportError (star-import resolves every name in __all__, and trend_analysis is unbound)
  • The README itself works around the bug by telling users to import from the private module: from eo_processor._core import trend_analysis

This directly violates the project's own invariant from skills/python-api-surface/SKILL.md: "if it's public, it must be importable, typed, tested, and documented."

The Rust kernel works

The function is fully implemented in src/trends.rs:20 and registered into _core at src/lib.rs:100. Only the Python public surface is broken.

Scope

File Change
python/eo_processor/__init__.py Add trend_analysis as _trend_analysis and TrendSegment as _TrendSegment to the from ._core import (...) block. Add a thin wrapper def trend_analysis(y, threshold): ... following the existing pattern (e.g. linear_regression at ~line 349).
python/eo_processor/__init__.pyi Add stub for trend_analysis(y: Sequence[float], threshold: float) -> list[TrendSegment]: ... and a class TrendSegment matching the Rust struct fields (start_index, end_index, slope, intercept).
tests/test_trends.py Add tests: no-break case (large threshold → single segment), a break case (linspace(0,10,50) + linspace(10,0,50) → ≥2 segments), invalid inputs (negative threshold, NaN in y).
README.md:321 Replace from eo_processor._core import trend_analysis with from eo_processor import trend_analysis.

Acceptance criteria

  • from eo_processor import trend_analysis works
  • from eo_processor import * works (no ImportError)
  • Type stub present in __init__.pyi
  • At least 3 tests covering the function
  • README import example updated to use the public API
  • ruff check python/eo_processor/ passes
  • CI green

Version impact

Per the project's SemVer section: exposing a previously-unexported-but-documented function is a minor bump (new public surface, backward-compatible).


Note: A bump:minor label will be needed on the PR to trigger the automated version bump and release pipeline.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions