Add conversion to list before padding, extend length of result #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, I've been using this repository for some time now and I found two things that did not work for me.
First, when passing a non-square numpy ndarray to the Munkres.compute() function, an error occurs because numpy arrays are not extendable. However, this only happens when there are more rows than columns because the column extension does not modify the original array.
So with this code we get:
because the array has not been padded correctly.
The solution to this is changing line 103 from
new_row = row[:]
tonew_row = list(row[:])
, which is then extendable and can be padded correctly. Moreover, ifrow[:]
is a list already, then nothing will happen.The second thing is the output solution. The output of the above program is:
However, since there is an additional row, we would like to also have the assignment for that row. This can be fixed by changing line 166 from
self.original_length
toself.n
and line 167 fromself.original_width
toself.n
. Then we obtain:Edit about this second part: I checked the tests and they fail for this second part because the
_get_cost
definition. I'm not sure if this is a feature that people need, but it's definitely something I personally needed.