Skip to content

Commit bf68ffc

Browse files
Merge branch 'main' into fix/onecoin_ds_fit_predict
2 parents 9b2605c + a90bdca commit bf68ffc

File tree

11 files changed

+58
-54
lines changed

11 files changed

+58
-54
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
release:
55
types: [ published ]
66

7+
env:
8+
UV_SYSTEM_PYTHON: 1
9+
710
jobs:
811
release:
912
runs-on: ubuntu-latest
@@ -14,12 +17,14 @@ jobs:
1417
- name: Set up Python
1518
uses: actions/setup-python@v5
1619
with:
17-
python-version: "3.12"
20+
python-version: "3.13"
21+
- name: Set up uv
22+
uses: astral-sh/setup-uv@v5
23+
with:
24+
enable-cache: false
1825
- name: Install dependencies
19-
run: |
20-
curl -LsSf https://astral.sh/uv/install.sh | sh
21-
uv pip install --system -e '.[dev,docs,learning]'
26+
run: uv sync --all-extras
2227
- name: Build
23-
run: python3 -m build --sdist --wheel .
28+
run: uv run python3 -m build --sdist --wheel .
2429
- name: Publish
2530
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,57 @@ name: Tests
22

33
on:
44
push:
5-
branches: [ main ]
65
pull_request:
76
branches: [ main ]
87
workflow_dispatch:
98

9+
env:
10+
UV_SYSTEM_PYTHON: 1
11+
1012
jobs:
1113
build:
1214
runs-on: ubuntu-latest
1315
strategy:
1416
fail-fast: false
1517
matrix:
16-
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
18+
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
1719
steps:
1820
- uses: actions/checkout@v4
19-
- name: Set up Python ${{ matrix.python-version }}
21+
- name: Set up Python
2022
uses: actions/setup-python@v5
2123
with:
2224
python-version: ${{ matrix.python-version }}
25+
- name: Set up uv
26+
uses: astral-sh/setup-uv@v5
27+
with:
28+
cache-dependency-glob: |
29+
**/pyproject.toml
2330
- name: Install dependencies
24-
run: |
25-
curl -LsSf https://astral.sh/uv/install.sh | sh
26-
uv pip install --system -e '.[dev,docs,learning]'
31+
run: uv sync --all-extras
2732
# NumPy 2.0 is not available for Python 3.8 and older versions, which leads to broken tests
2833
- name: Lint with Mypy (Python 3.8)
29-
run: mypy crowdkit
34+
run: uv run mypy crowdkit
3035
if: matrix.python-version == '3.8'
3136
- name: Lint with Mypy
32-
run: mypy crowdkit tests
37+
run: uv run mypy crowdkit tests
3338
if: matrix.python-version != '3.8'
3439
# pyupgrade is incompatible with Python 3.8 and older versions
3540
- name: Pre-Commit Check
3641
uses: pre-commit/action@v3.0.1
3742
if: matrix.python-version != '3.8'
3843
- name: Test with pytest
39-
run: coverage run --source crowdkit -m pytest
44+
run: uv run coverage run --source crowdkit -m pytest
4045
- name: Codecov
4146
env:
4247
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
43-
run: codecov
44-
if: matrix.python-version == '3.12'
48+
run: uv run codecov
49+
if: matrix.python-version == '3.13'
4550
- name: Run MkDocs
46-
run: mkdocs build --strict
51+
run: uv run mkdocs build --strict
4752
- name: Build wheel
4853
run: |
49-
python3 -m build --sdist --wheel .
50-
twine check --strict dist/*
54+
uv run python3 -m build --sdist --wheel .
55+
uv run twine check --strict dist/*
5156
- name: Validate CITATION.cff
5257
uses: citation-file-format/cffconvert-github-action@2.0.0
5358
with:

.pre-commit-config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
77
- id: check-yaml
88
- id: check-added-large-files
99
- repo: https://github.com/psf/black
10-
rev: 24.8.0
10+
rev: 24.10.0
1111
hooks:
1212
- id: black
1313
- repo: https://github.com/pycqa/isort
1414
rev: 5.13.2
1515
hooks:
1616
- id: isort
1717
- repo: https://github.com/pycqa/flake8
18-
rev: 7.0.0
18+
rev: 7.1.1
1919
hooks:
2020
- id: flake8
2121
- repo: https://github.com/asottile/pyupgrade
22-
rev: v3.17.0
22+
rev: v3.19.1
2323
hooks:
2424
- id: pyupgrade
2525
- repo: https://github.com/nbQA-dev/nbQA
26-
rev: 1.7.1
26+
rev: 1.9.1
2727
hooks:
2828
- id: nbqa-black
29-
additional_dependencies: [black==24.8.0]
29+
additional_dependencies: [black==24.10.0]
3030
- id: nbqa-isort
3131
additional_dependencies: [isort==5.13.2]
3232
- id: nbqa-flake8
33-
additional_dependencies: [flake8==7.0.0]
33+
additional_dependencies: [flake8==7.1.1]
3434
- id: nbqa-pyupgrade
35-
additional_dependencies: [pyupgrade==3.17.0]
35+
additional_dependencies: [pyupgrade==3.19.1]

crowdkit/aggregation/classification/mace.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,9 @@ def _initialize(self, n_workers: int, n_labels: int) -> None:
313313
self.theta_priors_[:, 0] = self.alpha
314314
self.theta_priors_[:, 1] = self.beta
315315

316-
self.strategy_priors_ = np.ones((n_workers, n_labels)) * 10.0
316+
self.strategy_priors_ = np.multiply(
317+
10.0, np.ones((n_workers, n_labels)), dtype=np.float64
318+
)
317319

318320
def _e_step(
319321
self,

crowdkit/aggregation/classification/majority_vote.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ class MajorityVote(BaseClassificationAggregator):
2323
resulting label will have the largest sum of weights.
2424
2525
26-
{% note info %}
27-
28-
If two or more labels have the largest number of votes, the resulting
29-
label will be the same for all tasks that have the same set of labels with the same number of votes.
30-
31-
{% endnote %}
26+
Note:
27+
If two or more labels have the largest number of votes, the resulting
28+
label will be the same for all tasks that have the same set of labels with the same number of votes.
3229
3330
Examples:
3431
Basic Majority Vote:

crowdkit/aggregation/classification/zero_based_skill.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@ class ZeroBasedSkill(BaseClassificationAggregator):
2020
2121
This process is repeated until the labels change or exceed the number of iterations.
2222
23-
{% note info %}
24-
25-
It is necessary that all workers in the dataset that is sent to `predict` exist in responses to
26-
the dataset that was sent to `fit`.
27-
28-
{% endnote %}
23+
Note:
24+
It is necessary that all workers in the dataset that is sent to `predict` exist in responses to
25+
the dataset that was sent to `fit`.
2926
3027
Examples:
3128
>>> from crowdkit.aggregation import ZeroBasedSkill

crowdkit/aggregation/image_segmentation/segmentation_rasa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def _aggregate_one(self, segmentations: "pd.Series[Any]") -> npt.NDArray[Any]:
105105
for _ in range(self.n_iter):
106106
weighted = self._segmentation_weighted(segmentations_np, weights)
107107
mv = weighted >= 0.5
108-
weights = self._calculate_weights(segmentations_np, mv)
108+
weights = self._calculate_weights(segmentations_np, mv) # type: ignore[assignment,unused-ignore]
109109

110110
if last_aggregated is not None:
111111
delta = weighted - last_aggregated

crowdkit/aggregation/multilabel/binary_relevance.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ class BinaryRelevance(BaseClassificationAggregator):
1919
each label is treated as a class in binary classification problem and aggregated separately using
2020
aggregation algorithms for classification, e.g. Majority Vote or Dawid Skene.
2121
22-
{% note info %}
22+
Note:
23+
If this method is used for single-label classification, the output of the BinaryRelevance method may differ
24+
from the output of the basic aggregator used for its intended purpose, since each class generates a binary
25+
classification task, and therefore it is considered separately. For example, some objects may not have labels.
2326
24-
If this method is used for single-label classification, the output of the BinaryRelevance method may differ
25-
from the output of the basic aggregator used for its intended purpose, since each class generates a binary
26-
classification task, and therefore it is considered separately. For example, some objects may not have labels.
27-
28-
{% endnote %}
2927
3028
Examples:
3129
>>> import pandas as pd

crowdkit/aggregation/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def converter(series: "pd.Series[Any]") -> "pd.Series[Any]":
191191
series.name = name
192192
return series
193193

194-
return attr.ib(init=False, converter=converter, on_setattr=attr.setters.convert) # type: ignore[no-any-return]
194+
return attr.ib(init=False, converter=converter, on_setattr=attr.setters.convert)
195195

196196

197197
def add_skills_to_data(

crowdkit/metrics/data/_classification.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"alpha_krippendorff",
55
]
66

7-
from typing import Any, Callable, Hashable, List, Optional, Tuple, Union, cast
7+
from typing import Any, Callable, Hashable, List, Optional, Union, cast
88

99
import numpy as np
1010
import pandas as pd
@@ -266,7 +266,5 @@ def alpha_krippendorff(
266266
0.4444444444444444
267267
"""
268268
_check_answers(answers)
269-
data: List[Tuple[Any, Hashable, Hashable]] = answers[
270-
["worker", "task", "label"]
271-
].values.tolist()
269+
data = answers[["worker", "task", "label"]].values.tolist()
272270
return float(AnnotationTask(data, distance).alpha())

0 commit comments

Comments
 (0)