-
Notifications
You must be signed in to change notification settings - Fork 81
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
"print_matrix" always print integral value of cost matrix #34
Comments
I think this can be fixed by replacing 'd' with 's' in line L#517, Edit: Instancematrix = [[5.2, 9.3, DISALLOWED],
[10.1, DISALLOWED, 2.1],
[8.4, 7.5, 4.6]] ResultHighest profit through this matrix:
[ 5.2, 9.3, <munkres.DISALLOWED_OBJ object at 0x7f424cbdab00>]
[10.1, <munkres.DISALLOWED_OBJ object at 0x7f424cbdab00>, 2.1]
[ 8.4, 7.5, 4.6]
(0, 0) -> 5.2
(1, 2) -> 2.1
(2, 1) -> 7.5
total profit=14.8 So sticking to former solution, i.e. replacing |
@bmc, sorry for directly pinging you. Can you comment something on this issue? I would like to fix this issue. |
Sorry. I haven't used this package myself in years. I'm find with the fix. I'll merge any PR and upload again to PyPI. |
When we enter float value inside cost matrix, "print_matrix" function treats those values as integer, and only prints integral part of the values. For example, if cost matrix is: matrix = [[5.1, 9.6, 1.7], [10.2, 3.5, 2.8], [8.3, 7.4, 4.9]] Then output is as follows: Lowest cost through this matrix: [ 5, 9, 1] [ 10, 3, 2] [ 8, 7, 4] (0, 0) -> 5.1 (1, 1) -> 3.5 (2, 2) -> 4.9 total cost: 13.5 We can see printed cost matrix isn't same as original cost matrix. And it's not always the case, cost matrix would have all values in integral form, cost of the assignment could be a float value. Resolves: bmc#34
Version 1.1.4 (September, 2020) - Switched from Nose to Pytest for testing. Patch courtesy @kmosiejczuk, [PR #32](bmc/munkres#32), with some additional cleanup by me. - Fix to [Issue #34](bmc/munkres#34), in which `print_matrix` wasn't handling non-integral values. Patch courtesy @finn0, via [PR #35](bmc/munkres#35). - Various changes from `http:` URLs to `https:` URLs, courtesy @finn0 via [PR #36](bmc/munkres#36). Version 1.1.3: **Nonexistent**. Accidentally published before check-in. Deleted from PyPI. Use version 1.1.4. Version 1.1.2 (February, 2019) - Removed `NoReturn` type annotations, to allow compatibility with Python 3.5 releases prior to 3.5.4. Thanks to @jackwilsdon for catching that issue. Version 1.1.1 (February, 2019) - Version bump to get past a PyPI publishing issue. (Can't republish partially published 1.1.0.) Version 1.1.0 (February, 2019) - Only supports Python 3.5 or better, from this version forward (since Python 2 is at end of life in 11 months). - Added `typing` type hints. - Updated docs to use `pdoc`, since `epydoc` is pretty much dead.
When I enter cost values in floating point form inside cost matrix,
print_matrix
function treats those values as integer and print only integral part of the values. I run this code:Output is as follows:
See matrix printed by
print_matrix
function isn't same matrix as given in code that's it only has integral part with them, although total cost calculation is correct. Is it a expected behavior ofprint_matrix
function? Because it's not always the case, cost matrix would have all value in integral form.The text was updated successfully, but these errors were encountered: