-
Notifications
You must be signed in to change notification settings - Fork 10
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
Py35 #29
Py35 #29
Conversation
@@ -108,7 +108,12 @@ def get_consensus_stats(consensus_map): | |||
cons = consensus_map.values() | |||
total_cons = len(cons) | |||
|
|||
rank_names = [c[0] for c in cons[0]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wasade please double check if this change still results in the intended logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did this need to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because dict values are not indexable
t2t/nlevel.py
Outdated
@@ -564,7 +563,7 @@ def make_consensus_tree(cons_split, check_for_rank=True, tips=None): | |||
god_node = TreeNode(name=None) | |||
god_node.Rank = None | |||
|
|||
base = cons_split[0] | |||
base = next(iter(cons_split)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wasade also here, I am not totally sure if the syntax change preserves your logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure but i think that's safe as long as the change works if cons_split
is list
or tuple
or a generator
obs = hash_cons(input, ['a', 'd', 'c', 'b'], 7) | ||
self.assertTrue(array_equal(obs, exp)) | ||
self.assertTrue(array_equal(obs.flatten(), exp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a better way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems fine?
@sjanssen2 Looks okay to me. Wait for @wasade 's more expertised review. |
@@ -108,7 +108,12 @@ def get_consensus_stats(consensus_map): | |||
cons = consensus_map.values() | |||
total_cons = len(cons) | |||
|
|||
rank_names = [c[0] for c in cons[0]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did this need to change?
t2t/nlevel.py
Outdated
@@ -564,7 +563,7 @@ def make_consensus_tree(cons_split, check_for_rank=True, tips=None): | |||
god_node = TreeNode(name=None) | |||
god_node.Rank = None | |||
|
|||
base = cons_split[0] | |||
base = next(iter(cons_split)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure but i think that's safe as long as the change works if cons_split
is list
or tuple
or a generator
obs = hash_cons(input, ['a', 'd', 'c', 'b'], 7) | ||
self.assertTrue(array_equal(obs, exp)) | ||
self.assertTrue(array_equal(obs.flatten(), exp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems fine?
tests/test_consensus.py
Outdated
@@ -178,8 +178,8 @@ def test_get_consensus_stats(self): | |||
's': set(['s__s1', 's__s2', 's__s3'])} | |||
#exp_names = {'k':2,'p':1,'c':2,'o':1,'f':2,'g':2,'s':3} | |||
obs_nseqs, obs_names = get_consensus_stats(input) | |||
self.assertEqual(obs_nseqs, exp_nseqs) | |||
self.assertEqual(obs_names, exp_names) | |||
#self.assertEqual(obs_nseqs, exp_nseqs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can these tests executed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wasade very good catch! because this test points out a conceptional problem.
In py35 the order of the dict key,value pairs seems to be different from the order in py27, i.e. they might come as:
['k__k2', '', 'c__c1', 'f__f2', 'f__f2', 'g__g2', 's__s3']
[None, None, None, None, None, None, None]
['k__k1', 'p__p1', 'c__c1', 'o__o1', 'f__f1', 'g__g1', 's__s1']
['k__k1', 'p__p1', 'c__c2', None, 'f__f2', 'g__g1', 's__s2']
which would result in ranks [k, "", c, f, f, g, s]
. Do we have to assume this input is correct, even with 'f__f2', 'f__f2'
? If yes, we need to change and maybe use a constant to define rank names? I don't see a schema to infer correct rank names from the above input :-/
Save fmeasures
Thanks!!! Do you think this is good to merge? |
With this PR the codebase gets migrated to python 3.x