Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ jobs:
sudo apt-get install -y pandoc
python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
python -m pip install ".[dev,doc]"
- name: Documentation Coverage Report
run: invoke docs.coverage

- name: Build Documentation
run: invoke docs.build

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/code_review.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This document describes the code review process for CapyMOA. It is intended for
2. Download the built documentation [pull request
artifact](./docs.rst#pull-request-artifact) and check it renders nicely.
3. If the PR adds new methods these should be cited in the documentation.
4. Does the PR test added code?
4. Does the PR test add code?
5. Manually review the code changes.
6. If everything is good **squash and merge** the PR using the GitHub interface and add
a meaningful commit message. See [commit messages](#commit-messages) below for more
Expand Down
15 changes: 0 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ doc=[
"myst-parser",
# Adds design elements to the documentation
"sphinx_design",
"interrogate",
"sphinxcontrib-programoutput"
]

Expand Down Expand Up @@ -196,20 +195,6 @@ insecure = false
dist_glob_patterns = ["dist/*"]
upload_to_vcs_release = true


[tool.interrogate]
# Interrogate is used to check the documentation coverage of the codebase.
# https://interrogate.readthedocs.io/en/latest/
ignore-semiprivate = true
ignore-private = true
ignore-overloaded-functions = true
ignore-magic = true
exclude=["docs", "tests", "notebooks"]
style = "sphinx"
fail-under = 80
omit-covered-files = true
ignore-module = true

# Configuration for the formatter
[tool.ruff]
target-version = "py310"
3 changes: 2 additions & 1 deletion src/capymoa/evaluation/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ def update(self, y, y_pred: Optional[float]):

# The learner did not produce a prediction for this instance, thus y_pred is None
if y_pred is None:
warnings.warn("The learner did not produce a prediction for this instance")
# We used to produce a warning here, but since `None` predictions are common
# at the beginning of training, most warnings that were not useful.
y_pred = 0.0

# Different from classification, there is no need to copy the prediction array, just override the value.
Expand Down
37 changes: 0 additions & 37 deletions src/capymoa/misc.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
from capymoa._pickle import (
JPickler as DeprecatedJPickler,
JUnpickler as DeprecatedJUnpickler,
)
from jpype.pickle import JPickler, JUnpickler
from deprecated import deprecated
from jpype import JException
from typing import BinaryIO, TextIO
from pathlib import Path
Expand All @@ -12,35 +7,6 @@
import tqdm


# TODO: Remove this and capymoa._pickle in a future release
@deprecated(version="v0.8.2", reason="Use ``save_model(...)`` instead.")
def legacy_save_model(model, filename):
"""Save a model to a file.

Use :func:`save_model` if possible.

:param model: The model to save.
:param filename: The file to save the model to.
"""

with open(filename, "wb") as fd:
DeprecatedJPickler(fd).dump(model)


# TODO: Remove this and capymoa._pickle in a future release
@deprecated(version="v0.8.2", reason="Use ``load_model(...)`` instead.")
def legacy_load_model(filename):
"""Load a model from a file.

Use :func:`load_model` if possible.

:param filename: The file to load the model from.
"""

with open(filename, "rb") as fd:
return DeprecatedJUnpickler(fd).load()


def save_model(model: object, file: BinaryIO) -> None:
"""Save a model to a jpype pickle file.

Expand All @@ -66,9 +32,6 @@ def save_model(model: object, file: BinaryIO) -> None:
def load_model(file: BinaryIO) -> object:
"""Load a model from a jpype pickle file.

If you are trying to load a model saved with a version of CapyMOA < 0.8.2,
use :func:`legacy_load_model` and :func:`save_model` to reformat the model.

See also: :func:`save_model`.

:param file: The file-like object to load the model from.
Expand Down
4 changes: 2 additions & 2 deletions src/capymoa/ocl/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ def _accuracy_all(t: int) -> float:

tasks = np.arange(self.task_count, dtype=int)

accuracy_seen = np.vectorize(_accuracy_seen)(tasks)
accuracy_all = np.vectorize(_accuracy_all)(tasks)
accuracy_seen = np.array([_accuracy_seen(t) for t in tasks])
accuracy_all = np.array([_accuracy_all(t) for t in tasks])
boundaries = boundary_instances.numpy()

ttt_windowed_task_index = None
Expand Down
4 changes: 2 additions & 2 deletions src/capymoa/ocl/strategy/_rar.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class RAR(BatchClassifier, TrainTaskAware, TestTaskAware):
... scenario.train_loaders(32),
... scenario.test_loaders(32),
... )
>>> print(f"{results.accuracy_final*100:.1f}%")
41.5%
>>> results.accuracy_final*100 > 41.5 # PyTorch is nondeterministic across versions
True

Usually more complex augmentations are used such as random crops and
rotations.
Expand Down
10 changes: 0 additions & 10 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ def docs_build(ctx: Context, ignore_warnings: bool = False):
raise SystemExit(err.result.return_code)


@task
def docs_coverage(ctx: Context):
"""Check the coverage of the documentation.

Requires the `interrogate` package.
"""
ctx.run("python -m interrogate -vv -c pyproject.toml || true")


@task
def docs_clean(ctx: Context):
"""Remove the built documentation."""
Expand Down Expand Up @@ -313,7 +304,6 @@ def format(ctx: Context):
docs = Collection("docs")
docs.add_task(docs_build, "build", default=True)
docs.add_task(docs_clean, "clean")
docs.add_task(docs_coverage, "coverage")

build = Collection("build")
build.add_task(download_moa)
Expand Down
4 changes: 3 additions & 1 deletion tests/ocl/test_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import torch
from torch import nn

approx = partial(pytest.approx, abs=0.1)
# PyTorch is notorious for non-deterministic behavior between versions and platforms.
# Here we set a fixed absolute tolerance of +-1.5 for percentage-based metrics.
approx = partial(pytest.approx, abs=1.5)


@dataclass(frozen=True)
Expand Down
27 changes: 0 additions & 27 deletions tests/test_misc.py

This file was deleted.

Loading