Metadata-Version: 2.4
Name: sktime-cython
Version: 0.1.0
Summary: Cython extensions for sktime
Author-email: sktime developers <sktime.toolbox@gmail.com>
Maintainer-email: sktime developers <sktime.toolbox@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2019 - present, The sktime developers.
        
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the copyright holder nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://github.com/sktime/sktime-cython
Project-URL: Repository, https://github.com/sktime/sktime-cython
Keywords: cython,machine-learning,scikit-learn,time-series,time-series-analysis
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Requires-Python: <3.15,>=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy<2.5,>=1.21
Provides-Extra: dev
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-timeout; extra == "dev"
Requires-Dist: pytest-xdist; extra == "dev"
Requires-Dist: sktime; extra == "dev"
Requires-Dist: numba; extra == "dev"
Dynamic: license-file

# sktime-cython

Cython-compiled estimators for [sktime](https://github.com/sktime/sktime).

This package hosts ahead-of-time compiled implementations of sktime algorithms,
isolating the C-compilation and binary-wheel complexity from the main `sktime`
package. Estimators here expose a plain numpy-in/numpy-out compute layer with
**no sktime runtime dependency**; `sktime` keeps thin `BaseTransformer` /
`BaseEstimator` wrappers that delegate to this package.

Why a separate package: compiled extensions need a C toolchain, per-platform
wheels, and `cibuildwheel` release machinery. Keeping that here lets `sktime`
stay pure-Python while still offering compiled, numba-free fast paths.

## Estimators

| Estimator | Compute API | Notes |
|-----------|-------------|-------|
| Multivariate MiniRocket | `sktime_cython.fit` / `transform` | numba-free; equivalent to `MiniRocketMultivariate`, no JIT warmup |

More estimators are added as `.pyx` kernels under `sktime_cython/_cython/` with
a numpy compute layer alongside.

Each estimator lives in its own submodule (nothing is re-exported at the top
level, so estimators never collide on common names like `fit`/`transform`):

```python
import numpy as np
from sktime_cython.minirocket import fit, transform

X = np.random.rand(100, 6, 500).astype("float32")
params = fit(X, num_kernels=10_000, random_state=42)
features = transform(X, params, n_jobs=-1)   # GIL-released kernel, real threads
```

Runtime dependency: numpy only.

## Development

Requires a C compiler and Python 3.10+. Run from the project root.

```bash
# editable install with the dev extra (pulls sktime + numba for equivalence
# tests, plus pre-commit); compiles the Cython extensions via build isolation
uv pip install -e ".[dev]"        # or: pip install -e ".[dev]"

# install the git pre-commit hooks ONCE — this is what stops CI lint failures
pre-commit install

# run the tests
python -m pytest sktime_cython -v
```

After editing a `.pyx`, recompile with `pip install -e .` again (or `make build`).

`make` shortcuts (auto-detect `uv`, falling back to `pip`/`python`):
`make install`, `make build`, `make test`, `make clean`.

## Before you push (avoid CI failures)

CI runs the pre-commit hooks and **fails if they reformat anything**. Running
`pre-commit install` (above) auto-runs them on every `git commit`. To check the
whole tree on demand:

```bash
pre-commit run --all-files
```

This runs `ruff check` (lint) and `ruff format`. If `ruff format` reports "files
were modified", it already fixed them — `git add` the changes and commit again.

## CI workflows

- **`test.yml`** (push / PR to `main`): a `code-quality` job running the
  pre-commit hooks, plus a matrix that builds the Cython extensions and runs
  pytest across Python 3.10–3.14 on Linux, macOS, and Windows.
- **`release.yml`** (on GitHub release): builds binary wheels with
  [`cibuildwheel`](https://cibuildwheel.pypa.io/) for all platforms, builds an
  sdist (with `.pyx` sources), and publishes to PyPI via trusted publishing.

## Adding an estimator

1. Drop the kernel `.pyx` (and optional `.pyi` stub) in a subfolder of the package.
  The package structure mirrors that of `sktime`, files should be added paralleling
  its primary import location in `sktime`
2. Register the kernel as an `Extension` in `setup.py`.
3. Add a numpy compute-layer module `sktime_cython/<name>.py` exposing the
   estimator's public functions. Keep them in the submodule — do not re-export
   at the top level (avoids name collisions across estimators).
4. Add tests in a subfolder `tests`, in the same folder as the kernel.

## Package structure

Cython kernels and python layers should be added in a parallel location as in the
`sktime` package.

Example for minirocket:

```
sktime_cython/
  transformations/
    rocket/
      __init__.py                           # public compute-layer exports
      _minirocket.py                        # numpy fit/transform layer
      _minirocket_multivariate_cython.pyx   # compiled kernels
      _minirocket_multivariate_cython.pyi   # type stubs
      tests/
        __init__.py
        test_minirocket.py                  # tests
```

## License

BSD 3-Clause License — see [LICENSE](LICENSE).
