Skip to content
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

[Fix] print_matrix #35

Merged
merged 4 commits into from
Sep 15, 2020
Merged

[Fix] print_matrix #35

merged 4 commits into from
Sep 15, 2020

Conversation

etanot
Copy link
Contributor

@etanot etanot commented Aug 13, 2020

@bmc can you take a look into this PR?

Closes: #34

Vipul Kumar and others added 4 commits August 13, 2020 09:48
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
Add some examples of cost matrix with float values and their
corresponding total cost of assignment, in main.
To compare two float values, "assert_almost_equal"[1] method has been
used. If "places" argument isn't set, its value will be "7" (default).

[1]: https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertAlmostEqual
@bmc
Copy link
Owner

bmc commented Sep 15, 2020

Merged, with conflicts resolved.. Publishing shortly. Sorry for the delay.

@bmc bmc merged commit c7ae115 into bmc:master Sep 15, 2020
@bmc
Copy link
Owner

bmc commented Sep 15, 2020

Pushed to PyPI in version 1.1.4.

@etanot etanot deleted the fix/print_matrix branch September 15, 2020 23:34
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jan 5, 2022
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.
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.

"print_matrix" always print integral value of cost matrix
2 participants