-
Notifications
You must be signed in to change notification settings - Fork 188
refactor: add py3.12 and py3.13 to tests #1212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 11 commits
8e60bff
9cab92c
23b158f
ae1dc4b
91a4a24
8caaba8
7766077
1cc50b5
11454a3
20320cd
f1305c6
ae11f3b
004ce6c
a9b83cb
f5a238b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,12 +14,12 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.10", "3.11"] | ||
| python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v4.3.1 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C1 requires commit sha? was denied v4 and v5 on first commit |
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v5.6.0 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,10 +40,12 @@ repos: | |
| # Mypy: Optional static type checking | ||
| # https://github.com/pre-commit/mirrors-mypy | ||
| - repo: https://github.com/pre-commit/mirrors-mypy | ||
| rev: v0.982 | ||
| rev: v1.11.2 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated mypy |
||
| hooks: | ||
| - id: mypy | ||
| exclude: (^dataprofiler/tests/|^resources/|^examples|venv*/|versioneer.py|dataprofiler/_version.py|_docs/) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this exclude is for pre-commit, but mypy doesn't utilize it hence the updates here |
||
| # Let mypy own target selection and exclusions via setup.cfg. | ||
| args: [--config-file=setup.cfg, dataprofiler] | ||
| pass_filenames: false | ||
| language_version: python3 | ||
| additional_dependencies: # Keep up-to-date with the respective requirement files | ||
| [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,25 +32,27 @@ def convert_confusion_matrix_to_MCM(conf_matrix: list | np.ndarray) -> np.ndarra | |
| """ | ||
| if not isinstance(conf_matrix, np.ndarray): | ||
| conf_matrix = np.array(conf_matrix) | ||
| conf_matrix = cast(np.ndarray, conf_matrix) | ||
| num_labels = len(conf_matrix) | ||
| num_samples: int = int(np.sum(conf_matrix)) | ||
| MCM = np.zeros((num_labels, 2, 2), dtype=np.int64) | ||
| MCM = cast(np.ndarray, np.zeros((num_labels, 2, 2), dtype=np.int64)) | ||
|
|
||
| # True Positives | ||
| MCM[:, 1, 1] = np.sum(conf_matrix * np.eye(num_labels), axis=1) | ||
|
|
||
| # False Negatives | ||
| MCM[:, 1, 0] = np.sum( | ||
| conf_matrix * (np.ones(num_labels) - np.eye(num_labels)), axis=1 | ||
| non_diagonal_mask = cast( | ||
| np.ndarray, np.logical_not(np.eye(num_labels, dtype=bool)).astype(np.int64) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small change here |
||
| ) | ||
| MCM[:, 1, 0] = np.sum(conf_matrix * non_diagonal_mask, axis=1) | ||
|
|
||
| # False Positives | ||
| MCM[:, 0, 1] = np.sum( | ||
| conf_matrix.T * (np.ones(num_labels) - np.eye(num_labels)), axis=1 | ||
| ) | ||
| MCM[:, 0, 1] = np.sum(conf_matrix.T * non_diagonal_mask, axis=1) | ||
|
|
||
| # True Negatives | ||
| MCM[:, 0, 0] = num_samples - MCM[:, 1, 0] - MCM[:, 0, 1] - MCM[:, 1, 1] | ||
| MCM[:, 0, 0] = cast( | ||
| np.ndarray, num_samples - MCM[:, 1, 0] - MCM[:, 0, 1] - MCM[:, 1, 1] | ||
| ) | ||
|
|
||
| return MCM | ||
|
|
||
|
|
@@ -210,6 +212,7 @@ def precision_recall_fscore_support( | |
| support: np.ndarray | None = true_sum | ||
| if average == "weighted": | ||
| weights = true_sum | ||
| assert weights is not None | ||
| if weights.sum() == 0: | ||
| return np.array([0.0]), np.array([0.0]), np.array([0.0]), None | ||
| elif average == "samples": | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
|
|
||
| import json | ||
| import os | ||
| from typing import Any, Callable | ||
| from typing import Any, Callable, cast | ||
|
|
||
| import numpy as np | ||
|
|
||
|
|
@@ -176,7 +176,7 @@ def _reconstruct_model(self) -> None: | |
| pass | ||
|
|
||
| def _need_to_reconstruct_model(self) -> bool: | ||
| pass | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a change, but should be inconsequential and matches the typing previously would return |
||
| return False | ||
|
|
||
| def reset_weights(self) -> None: | ||
| """Reset weights function.""" | ||
|
|
@@ -191,15 +191,17 @@ def _model( | |
| scorer: Callable, | ||
| include_label: bool = False, | ||
| ) -> list: | ||
| scores = [] | ||
| scores: list[list[float | int]] = [] | ||
|
|
||
| check_values_list = [dict["attribute"] for dict in check_values_dict] | ||
|
|
||
| model_outputs = rapidfuzz.process.cdist( | ||
| list_of_column_names, check_values_list, processor=processor, scorer=scorer | ||
| ) | ||
| model_outputs = cast(np.ndarray, model_outputs) | ||
|
|
||
| for iter_value, ngram_match_results in enumerate(model_outputs): | ||
| for i in range(len(model_outputs)): | ||
| ngram_match_results: np.ndarray = cast(np.ndarray, model_outputs[i]) | ||
| column_result = [np.max(ngram_match_results)] | ||
| if include_label: | ||
| index_max_result = ngram_match_results.argmax(axis=0) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added newest python