diff --git a/.github/.dependabot.yaml b/.github/.dependabot.yaml index 94ef9b9..ae6e8f1 100644 --- a/.github/.dependabot.yaml +++ b/.github/.dependabot.yaml @@ -15,4 +15,4 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "daily" \ No newline at end of file + interval: "daily" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 9c786d6..9d0f405 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -21,4 +21,4 @@ jobs: - name: Test with pytest run: pytest -v --cov=src tests/ - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v3 \ No newline at end of file + uses: codecov/codecov-action@v3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 07b1942..8f7c4ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,8 @@ ---- # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: check-added-large-files @@ -13,57 +12,23 @@ repos: - id: check-symlinks - id: check-toml - id: check-yaml + args: ['--unsafe'] - id: debug-statements - id: end-of-file-fixer - id: mixed-line-ending - - repo: https://github.com/python-poetry/poetry - rev: '1.5.1' - hooks: - - id: poetry-check - - id: poetry-lock - - id: poetry-export - args: ["-f", "requirements.txt", "-o", "requirements.txt"] - - repo: https://github.com/PyCQA/autoflake - rev: v1.7.7 - hooks: - - id: autoflake - args: - - "--ignore-init-module-imports" - - "--remove-all-unused-imports" - - "--remove-unused-variables" - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - name: isort (python) + - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.4.1 + rev: v1.7.0 hooks: - id: mypy # yaml requires additional stubs. # Similar to: https://stackoverflow.com/a/73603491/5755604 additional_dependencies: ['types-PyYAML'] - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 - hooks: - - id: python-use-type-annotations - - repo: https://github.com/psf/black.git - rev: 23.7.0 - hooks: - - id: black - language_version: python3 - exclude: ^(tests\/hooks-abort-render\/hooks|docs) - - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 - hooks: - - id: flake8 - additional_dependencies: - - flake8-absolute-import - - flake8-black - - flake8-docstrings - - flake8-bugbear - - repo: https://github.com/asottile/pyupgrade - rev: v3.9.0 - hooks: - - id: pyupgrade -exclude: "^(doc)" + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.6 + hooks: + - id: ruff + args: + - --fix + - id: ruff-format +exclude: "^(references|reports)" diff --git a/.vscode/settings.json b/.vscode/settings.json index a7d0fc7..070cfda 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { "esbonio.sphinx.confDir": "" -} \ No newline at end of file +} diff --git a/README.md b/README.md index 0c7a7fb..ce08738 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,4 @@ Documentation is available [here](https://KarelZe.github.io/tclf/).
Lee, C., & Ready, M. J. (1991). Inferring trade direction from intraday data. The Journal of Finance, 46(2), 733–746. https://doi.org/10.1111/j.1540-6261.1991.tb02683.x
- \ No newline at end of file + diff --git a/docs/index.md b/docs/index.md index 0d84151..6188886 100644 --- a/docs/index.md +++ b/docs/index.md @@ -27,4 +27,4 @@
Lee, C., & Ready, M. J. (1991). Inferring trade direction from intraday data. The Journal of Finance, 46(2), 733–746. https://doi.org/10.1111/j.1540-6261.1991.tb02683.x
- \ No newline at end of file + diff --git a/docs/reference.md b/docs/reference.md index 9c01596..7b0cf4c 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -1,4 +1,4 @@ Welcome to the reference. -::: tclf.classical_classifier.ClassicalClassifier \ No newline at end of file +::: tclf.classical_classifier.ClassicalClassifier diff --git a/environment.yml b/environment.yml deleted file mode 100644 index fcb0d29..0000000 --- a/environment.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: project-template -dependencies: - - numpy - - scipy - - scikit-learn diff --git a/mkdocs.yml b/mkdocs.yml index ff7732a..549ac60 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -52,4 +52,4 @@ extra: link: https://www.linkedin.com/in/markus-bilz/ extra_javascript: - - https://unpkg.com/mermaid@8.4.6/dist/mermaid.min.js \ No newline at end of file + - https://unpkg.com/mermaid@8.4.6/dist/mermaid.min.js diff --git a/pyproject.toml b/pyproject.toml index ce5c5f8..1754b8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -129,4 +129,4 @@ section-order = ["future", "standard-library", "third-party", "first-party", "lo "__init__.py" = ["D104", "F401"] # disable missing docstrings in __init__, unused imports [tool.ruff.pydocstyle] -convention = "google" \ No newline at end of file +convention = "google" diff --git a/src/tclf/classical_classifier.py b/src/tclf/classical_classifier.py index e2060ba..ca681fd 100644 --- a/src/tclf/classical_classifier.py +++ b/src/tclf/classical_classifier.py @@ -71,6 +71,12 @@ def __init__( ): """Initialize a ClassicalClassifier. + Examples: + >>> clf = ClassicalClassifier(layers=[("lr", "all")], strategy="const") + + Or equivalent: + >>> clf = ClassicalClassifier(layers=[("quote", "all"), ("tick", "all")], strategy="const") + Args: layers (List[ tuple[ str, str, ] ]): Layers of classical rule. features (List[str] | None, optional): List of feature names in order of columns. Required to match columns in feature matrix with label. Can be `None`, if `pd.DataFrame` is passed. Defaults to None. @@ -477,7 +483,7 @@ def predict(self, X: npt.NDArray | pd.DataFrame) -> npt.NDArray: func = self.func_mapping_[func_str] pred = np.where( np.isnan(pred), - func(subset), + func(subset), # type: ignore [operator] pred, )