Skip to content

Commit

Permalink
Chore2024/cleanup pyproject (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
baggiponte authored Mar 13, 2024
1 parent 52537bd commit 9a9b471
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 63 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
rev: 0.7.1
hooks:
- id: nbstripout
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8
rev: v0.3.2
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand All @@ -22,20 +22,20 @@ repos:
- id: ruff-format
types_or: [python, pyi, jupyter]
- repo: https://github.com/MarcoGorelli/polars-upgrade/
rev: 0.1.19
rev: 0.3.2
hooks:
- id: polars-upgrade
args: [--target-version=0.19.15]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.5.3
rev: 1.7.0
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
rev: v0.16
hooks:
- id: validate-pyproject
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.13.0
rev: v3.18.3
hooks:
- id: commitizen-branch
stages: [push]
12 changes: 4 additions & 8 deletions functime/base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,15 @@ def _reset_string_cache(


class Regressor(Protocol):
def fit(self, X, y, sample_weight=None):
...
def fit(self, X, y, sample_weight=None): ...

def predict(self, X):
...
def predict(self, X): ...


class Classifier(Protocol):
def fit(self, X, y, sample_weight=None):
...
def fit(self, X, y, sample_weight=None): ...

def predict_proba(self, X):
...
def predict_proba(self, X): ...


# functime uses immutable dataclases to store artifacts returned by `fit`/
Expand Down
3 changes: 1 addition & 2 deletions functime/metrics/multi_objective.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Module with functions to compute, compare, and optimize multi-objective forecasts.
"""
"""Module with functions to compute, compare, and optimize multi-objective forecasts."""

from dataclasses import dataclass
from functools import partial, reduce
Expand Down
103 changes: 57 additions & 46 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ version = "0.9.5"
description = "Time-series machine learning at scale."
readme = "README.md"
authors = [
{ name = "functime Team", email = "[email protected]" },
{ name = "Chris Lo", email = "[email protected]" },
{ name = "Daryl Lim", email = "[email protected]" },
{ name = "Chris Lo", email = "[email protected]" },
{ name = "Daryl Lim", email = "[email protected]" },
]
maintainers = [
{ name = "functime Team", email = "[email protected]" },
{ name = "Luca Baggi" }
]
requires-python = ">=3.8"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
Expand All @@ -28,6 +30,8 @@ classifiers = [
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
]

requires-python = ">=3.8"
dependencies = [
"cloudpickle",
"flaml<3,>=2.0.2",
Expand All @@ -39,14 +43,38 @@ dependencies = [
"tqdm",
'typing-extensions; python_version < "3.10"',
]

[project.optional-dependencies]
plot = [
"kaleido==0.2.1",
"pandas",
"plotly",
]
cat = [
"catboost",
]
lgb = [
"lightgbm",
]
xgb = [
"pyarrow",
"xgboost",
]
ann = [
"pyarrow",
"pylance",
]
cat = [
"catboost",
tree = [
"functime[cat,lgb,xgb]"
]
llm = [
"openai",
"tabulate",
"tenacity",
"tiktoken",
]

# provisionally here until PEP 735 is approved: https://peps.python.org/pep-0735/
dev = [
"pre-commit",
"functime[doc,plot,test]"
Expand All @@ -58,24 +86,9 @@ doc = [
"mkdocs-material",
"mkdocstrings-python",
]
lgb = [
"lightgbm",
]
llm = [
"openai",
"tabulate",
"tenacity",
"tiktoken",
]
plot = [
"kaleido==0.2.1",
"pandas",
"plotly",
]
test = [
"aeon<0.5.0",
"coverage[toml]",
"fastapi",
"joblib",
"mlforecast==0.8.1",
"pandas",
Expand All @@ -86,50 +99,48 @@ test = [
"statsmodels",
"tsfresh",
]
xgb = [
"pyarrow",
"xgboost",
]

[tool.maturin]
module-name = "functime._functime_rust"
features = ["pyo3/extension-module"]
exclude = ["docs/**, data/**", "tests/**", ".pre-commit-config.yaml"]

[tool.ruff]
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
extend-include = ["*.ipynb"]

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"UP", # pyupgrade
"I", # isort
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"UP", # pyupgrade
"I", # isort
]
ignore = [
"E501", # line too long, handled by black
"B008", # do not perform function calls in argument defaults
"B905", # `zip()` without an explicit `strict=` parameter
"B018", # Found useless expression.
"F821", # Undefined name
"E501", # line too long, handled by black
"B008", # do not perform function calls in argument defaults
"B905", # `zip()` without an explicit `strict=` parameter
"B018", # Found useless expression.
"F821", # Undefined name
]

[tool.ruff.pyupgrade]
[tool.ruff.lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true

[tool.pytest.ini_options]
addopts = [
"--strict-config",
"--strict-markers",
"-m not benchmark and not slow",
"--benchmark-disable",
"--strict-config",
"--strict-markers",
"-m not benchmark and not slow",
"--benchmark-disable",
]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"benchmark: marks tests as part of benchmarking",
"multivariate: marks multivariate forecast test",
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"benchmark: marks tests as part of benchmarking",
"multivariate: marks multivariate forecast test",
]
xfail_strict = true

Expand Down
4 changes: 3 additions & 1 deletion tests/test_fourier.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import polars as pl
import pytest
from aeon.transformations.series.fourier import FourierFeatures
from polars.testing import assert_frame_equal

from functime.cross_validation import train_test_split
Expand Down Expand Up @@ -57,7 +56,10 @@ def test_fourier_with_dates(freq: str, sp: int):
)


@pytest.mark.benchmark
def test_fourier_compare_with_aeon():
from aeon.transformations.series.fourier import FourierFeatures

sp = 12
K = 4
y = pl.read_parquet("data/commodities.parquet")
Expand Down

0 comments on commit 9a9b471

Please sign in to comment.