Skip to content

Added Murty-based k-best partial assignment#1738

Open
FlorianPfaff wants to merge 6 commits intomainfrom
murty
Open

Added Murty-based k-best partial assignment#1738
FlorianPfaff wants to merge 6 commits intomainfrom
murty

Conversation

@FlorianPfaff
Copy link
Copy Markdown
Owner

No description provided.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 19, 2026

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 12.64s
✅ JSON prettier 2 0 0 0 0.49s
✅ JSON v8r 2 0 0 2.56s
✅ MARKDOWN markdownlint 1 0 0 0 0.66s
✅ MARKDOWN markdown-table-formatter 1 0 0 0 0.27s
✅ PYTHON bandit 334 0 0 4.96s
✅ PYTHON black 334 10 0 0 8.46s
✅ PYTHON flake8 334 0 0 2.77s
✅ PYTHON isort 334 12 0 0 0.67s
✅ PYTHON mypy 334 0 0 4.84s
✅ PYTHON pylint 334 0 0 105.1s
✅ PYTHON ruff 334 12 0 0 0.07s
✅ REPOSITORY checkov yes no no 22.99s
✅ REPOSITORY gitleaks yes no no 6.16s
✅ REPOSITORY git_diff yes no no 0.05s
✅ REPOSITORY secretlint yes no no 6.32s
✅ REPOSITORY syft yes no no 2.98s
✅ REPOSITORY trivy-sbom yes no no 2.85s
✅ REPOSITORY trufflehog yes no no 18.87s
✅ YAML prettier 4 0 0 0 0.47s
✅ YAML v8r 4 0 0 5.08s
✅ YAML yamllint 4 0 0 0.4s

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.4.0 --custom-flavor-setup --custom-flavor-linters PYTHON_PYLINT,PYTHON_BLACK,PYTHON_FLAKE8,PYTHON_ISORT,PYTHON_BANDIT,PYTHON_MYPY,PYTHON_RUFF,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 19, 2026

Test Results

    12 files  ±  0     12 suites  ±0   4h 26m 33s ⏱️ - 21m 36s
   990 tests + 45    990 ✅ + 45      0 💤 ±  0  0 ❌ ±0 
12 164 runs  +540  9 416 ✅ +332  2 748 💤 +208  0 ❌ ±0 

Results for commit 7e934b6. ± Comparison against base commit b4815e8.

♻️ This comment has been updated with latest results.

@FlorianPfaff
Copy link
Copy Markdown
Owner Author

@copilot Suppress the too-many-locals and fix the others

pyrecest/utils/assignment.py:207: error: Need type annotation for "solution_heap" (hint: "solution_heap: list[] = ...") [var-annotated]
pyrecest/utils/assignment.py:215: error: Need type annotation for "ranked_solutions" (hint: "ranked_solutions: list[] = ...") [var-annotated]
Found 2 errors in 1 file (checked 334 source files)
❌ PYTHON / pylint - 5 errors
************* Module pyrecest.filters.multi_hypothesis_tracker
pyrecest/filters/multi_hypothesis_tracker.py:474:4: R0914: Too many local variables (16/15) (too-many-locals)
************* Module pyrecest.tests.filters.test_multi_hypothesis_tracker
pyrecest/tests/filters/test_multi_hypothesis_tracker.py:64:17: W0212: Access to a protected member _enumerate_candidate_assignments of a client class (protected-access)
pyrecest/tests/filters/test_multi_hypothesis_tracker.py:79:17: W0212: Access to a protected member _enumerate_candidate_assignments of a client class (protected-access)
************* Module pyrecest.utils.assignment
pyrecest/utils/assignment.py:66:0: R0914: Too many local variables (19/15) (too-many-locals)
pyrecest/utils/assignment.py:124:0: R0914: Too many local variables (19/15) (too-many-locals)


@FlorianPfaff
Copy link
Copy Markdown
Owner Author

@copilot Do not use numpy (except numpy.testing), only use pyrecest.backend

…gnment.py

Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/44825912-e64b-4f73-a35d-56c3791cb99a

Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

@copilot Suppress the too-many-locals and fix the others

pyrecest/utils/assignment.py:207: error: Need type annotation for "solution_heap" (hint: "solution_heap: list[] = ...") [var-annotate...

Fixed in 6c69d17:

  • Added # pylint: disable=too-many-locals to murty_k_best_assignments
  • Added type annotation solution_heap: list[tuple[float, int, _MurtySubproblem, dict]]
  • Added type annotation ranked_solutions: list[dict]

@FlorianPfaff
Copy link
Copy Markdown
Owner Author

@copilot Ignore too-many-locals, fix the rest

************* Module pyrecest.filters.multi_hypothesis_tracker
pyrecest/filters/multi_hypothesis_tracker.py:474:4: R0914: Too many local variables (16/15) (too-many-locals)
************* Module pyrecest.tests.filters.test_multi_hypothesis_tracker
pyrecest/tests/filters/test_multi_hypothesis_tracker.py:64:17: W0212: Access to a protected member _enumerate_candidate_assignments of a client class (protected-access)
pyrecest/tests/filters/test_multi_hypothesis_tracker.py:79:17: W0212: Access to a protected member _enumerate_candidate_assignments of a client class (protected-access)
************* Module pyrecest.utils.assignment
pyrecest/utils/assignment.py:66:0: R0914: Too many local variables (19/15) (too-many-locals)


…ny-locals; fix protected-access warnings

Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/bd8f9d4b-e2a9-4a7d-9c85-2d29e0be37df

Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

@copilot Do not use numpy (except numpy.testing), only use pyrecest.backend

Done in bbc3b52. Replaced import numpy as _np with individual imports from pyrecest.backend (abs, any, asarray, concatenate, full, isfinite, sum, where, zeros) throughout assignment.py.

@copilot Ignore too-many-locals, fix the rest

************* Module pyrecest.filters.multi_hypothesis_tracker
...

Fixed in bbc3b52:

  • Added # pylint: disable=too-many-locals to _solve_subproblem in assignment.py and _enumerate_candidate_assignments in multi_hypothesis_tracker.py
  • Added inline # pylint: disable=protected-access on the two test lines accessing _enumerate_candidate_assignments

@FlorianPfaff
Copy link
Copy Markdown
Owner Author

@copilot Make the respectdive functions fail for jax backend and skip test cases with skipif (as in other files).

=========================== short test summary info ============================
FAILED pyrecest/tests/filters/test_multi_hypothesis_tracker.py::MultiHypothesisTrackerEnumerationTest::test_enumeration_matches_bruteforce - TypeError: JAX arrays are immutable and do not support in-place item assignment. Instead of x[idx] = y, use x = x.at[idx].set(y) or another .at[] method: https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html
FAILED pyrecest/tests/utils/test_assignment.py::MurtyAssignmentTest::test_empty_column_case_returns_all_rows_unassigned - TypeError: JAX arrays are immutable and do not support in-place item assignment. Instead of x[idx] = y, use x = x.at[idx].set(y) or another .at[] method: https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html
FAILED pyrecest/tests/utils/test_assignment.py::MurtyAssignmentTest::test_matches_bruteforce_for_small_random_problems - TypeError: JAX arrays are immutable and do not support in-place item assignment. Instead of x[idx] = y, use x = x.at[idx].set(y) or another .at[] method: https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html
= 3 failed, 475 passed, 472 skipped, 15 warnings, 9 subtests passed in 981.00s (0:16:20) =

…; add skipIf decorators in tests

Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/a6374baf-ebe6-4629-9fa6-baf8f4fbb0e4

Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

@copilot Make the respectdive functions fail for jax backend and skip test cases with skipif (as in other files).

=========================== short test summary info ============================
...

Done in 1419db9. murty_k_best_assignments now raises NotImplementedError when the JAX backend is active, and the three affected tests in test_assignment.py and test_multi_hypothesis_tracker.py are decorated with @unittest.skipIf(pyrecest.backend.__backend_name__ == "jax", ...) following the pattern used in other test files.

@FlorianPfaff
Copy link
Copy Markdown
Owner Author

@copilot Use from copy import copy

=========================== short test summary info ============================
FAILED pyrecest/tests/filters/test_multi_hypothesis_tracker.py::MultiHypothesisTrackerEnumerationTest::test_enumeration_matches_bruteforce - AttributeError: 'Tensor' object has no attribute 'copy'
FAILED pyrecest/tests/utils/test_assignment.py::MurtyAssignmentTest::test_empty_column_case_returns_all_rows_unassigned - AttributeError: 'Tensor' object has no attribute 'copy'
FAILED pyrecest/tests/utils/test_assignment.py::MurtyAssignmentTest::test_matches_bruteforce_for_small_random_problems - AttributeError: 'Tensor' object has no attribute 'copy'
= 3 failed, 804 passed, 177 skipped, 5585436 warnings, 18 subtests

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

@copilot Use from copy import copy

=========================== short test summary info ============================
...

Fixed in c054500. Added from copy import copy and replaced both x.copy() calls (cost_matrix.copy() and augmented_cost_matrix.copy()) with copy(x) in assignment.py.

@FlorianPfaff
Copy link
Copy Markdown
Owner Author

@copilot The error below only happens for the pytorch interface. Can you fix it?

=========================== short test summary info ============================
FAILED pyrecest/tests/filters/test_multi_hypothesis_tracker.py::MultiHypothesisTrackerEnumerationTest::test_enumeration_matches_bruteforce - TypeError: full() received an invalid combination of arguments - got (int, int, dtype=type), but expected one of:

  • (tuple of ints size, Number fill_value, *, tuple of names names, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
  • (tuple of ints size, Number fill_value, *, Tensor out = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
    FAILED pyrecest/tests/utils/test_assignment.py::MurtyAssignmentTest::test_empty_column_case_returns_all_rows_unassigned - TypeError: full() received an invalid combination of arguments - got (int, int, dtype=type), but expected one of:
  • (tuple of ints size, Number fill_value, *, tuple of names names, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
  • (tuple of ints size, Number fill_value, *, Tensor out = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
    FAILED pyrecest/tests/utils/test_assignment.py::MurtyAssignmentTest::test_matches_bruteforce_for_small_random_problems - TypeError: full() received an invalid combination of arguments - got (int, int, dtype=type), but expected one of:
  • (tuple of ints size, Number fill_value, *, tuple of names names, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
  • (tuple of ints size, Number fill_value, *, Tensor out = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
    = 3 failed, 808 passed, 179 skipped, 5585436 warnings, 18 subtests passed in 2027.54s (0:33:47) =

…tuple shape, int64 dtype

Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/f699ff14-0aa5-40e1-93a1-b9f8b7ff6876

Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

@copilot The error below only happens for the pytorch interface. Can you fix it?

=========================== short test summary info ============================
...

Fixed in 7e934b6. Three PyTorch-specific issues were addressed in assignment.py:

  1. _full(n_rows, -1, dtype=int)_full((n_rows,), -1, dtype=_int64) — PyTorch requires a tuple for the shape argument and a proper dtype (imported int64 from pyrecest.backend).
  2. .astype(int)_asarray(..., dtype=_int64) — cross-backend int casting.
  3. copy(matrix)_array(matrix)copy.copy() creates a shallow alias for PyTorch tensors (shared storage), causing the original augmented_cost_matrix to be corrupted when modified_cost_matrix was written to. Using array() from pyrecest.backend creates a true independent copy on both numpy and PyTorch.

@FlorianPfaff FlorianPfaff force-pushed the main branch 3 times, most recently from 7b21428 to 429a157 Compare April 21, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants