Repository navigation
Changes intended to assist with investigation of issue #28 (possibly also issue #23) - #29
Closed
tim-littlefair wants to merge 3 commits into
Closed
tim-littlefair wants to merge 3 commits into
tim-littlefair wants to merge 3 commits into
Conversation
…ws an exception under Python3.5 (both on macOS). As well as adding the test class, this commit turns on DEBUG level logging, which makes it easier to spot the point at which the behaviour of the two versions diverge.
… to the logic linkage.py. This change ensures that the tests which have been written in this file can be run from the CLI. The tests presently run successfully under both Python2.7 and Python3.5.
…on call, which is intended to be identical in effect, but provides an informative log message. With this commit, the behaviour of the test_hierarchical.py test set remains identical to python-cluster 1.4.1 under both Python2.7 (which passes)_and Python3.5 (which fails with a KeyError thrown).
Contributor
Author
|
I am cancelling this pull request as I intend to submit a better one, which I believe resolves issue #28 (at least in relation to the specific problem I am having, where the list of items to be clustered contains keys of type str). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I have added an extra test class to hierarchical_test.py which includes a set of data which illustrates the difference in behaviour between Python2.7 and Python3.5 which caused me to raise this issue.
From analysis of log files, I believe the point at which the behaviour of this test under the two Python versions begins to diverge in the python-cluster 1.4.1 code is the following four lines in matrix.py:
I've replaced these four lines with a single function, invoked twice, which logs the name of type of the original item and the name of the type it is converted two. From these log messages, I'm fairly certain that the problem is caused by the fact that Python2.7 (which works) encapsulates any item which is of type str as a list containing that str, whereas Python3.5 (which does not work) passes the str object on unchanged, with the result that later logic unpacks the string one character at a time instead of handling it as a whole.
I think the change in behaviour here may also be related to issue #23 (based on exhuma's comment on that issue dated 15 May 2017.
I will continue to investigate this issue when I get time and will cancel this PR and issue a new one if I feel I have a robust fix.