-
Notifications
You must be signed in to change notification settings - Fork 3
Update to be compatible with Python 3 #5
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
Open
burntyellow
wants to merge
1
commit into
ADicksonLab:master
Choose a base branch
from
burntyellow:kimwong
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| build/lib.linux-x86_64-2.7/wex_utils.so | ||
| build/lib.linux-x86_64-3.7/wex_utils.cpython-37m-x86_64-linux-gnu.so | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,8 @@ | |
| import networkx as nx | ||
| import pandas as pd | ||
| import heapq | ||
| import cPickle as pickle | ||
| #KFW import cPickle as pickle | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could probably be better handled by: try:
import cPickle as pickle
except ImportError:
import pickleI guess this depends on whether we want to maintain python 2/3 compatibility or if we're dropping python2 completely. |
||
| import pickle | ||
| import hashlib | ||
| import logging | ||
| import itertools | ||
|
|
@@ -30,7 +31,8 @@ def __init__(self, n_regions, d_cut, dfunc, dfargs=None, dfkwargs=None): | |
| self.centers = [] | ||
|
|
||
| # List of bin indices for each level | ||
| self.level_indices = [[] for k in xrange(self.n_levels)] | ||
| #KFW self.level_indices = [[] for k in xrange(self.n_levels)] | ||
| self.level_indices = [[] for k in range(self.n_levels)] | ||
|
|
||
| # Directed graph containing that defines the connectivity | ||
| # of the hierarchical bin space. | ||
|
|
@@ -102,11 +104,14 @@ def _assign_level(self, coords, centers, mask, output, min_dist): | |
| return output | ||
|
|
||
| def dump_graph(self): | ||
| print '' | ||
| #KFW print '' | ||
| print('') | ||
| for li, nodes in enumerate(self.level_indices): | ||
| print 'Level: ', li | ||
| #KFW print 'Level: ', li | ||
| print('Level: ', li) | ||
| for nix in nodes: | ||
| print nix, self.bin_graph.node[nix] | ||
| #KFW print nix, self.bin_graph.node[nix] | ||
| print(nix, self.bin_graph.node[nix]) | ||
|
|
||
| def _distribute_to_children(self, G, output, coord_indices, node_indices): | ||
| s = pd.Series(output, copy=False) | ||
|
|
@@ -144,15 +149,17 @@ def _prune_violations(self): | |
|
|
||
| self._assign_level(centers, pcenters, mask, output, min_dist) | ||
|
|
||
| for k in xrange(ncenters): | ||
| #KFW for k in xrange(ncenters): | ||
| for k in range(ncenters): | ||
| if output[k] != prev_level_nodes.index(parent_nodes[k]): | ||
| nix = level_indices[k] | ||
| succ = nx.algorithms.traversal.dfs_successors(G, nix).values() | ||
| nodes_remove.extend(list(itertools.chain.from_iterable(succ)) + [nix]) | ||
|
|
||
| if len(nodes_remove): | ||
| G.remove_nodes_from(nodes_remove) | ||
| for k in xrange(self.n_levels): | ||
| #KFW for k in xrange(self.n_levels): | ||
| for k in range(self.n_levels): | ||
| self.level_indices[k] = [nix for nix in self.level_indices[k] if nix not in nodes_remove] | ||
|
|
||
| def assign(self, coords, mask=None, output=None, add_bins=False): | ||
|
|
@@ -211,7 +218,8 @@ def assign(self, coords, mask=None, output=None, add_bins=False): | |
| if coord_ix >= 0: | ||
| new_bins.append((0, None, coord_ix)) | ||
|
|
||
| for lid in xrange(1, self.n_levels): | ||
| #KFW for lid in xrange(1, self.n_levels): | ||
| for lid in range(1, self.n_levels): | ||
| next_obs_nodes = [] | ||
| for nix in obs_nodes: | ||
| successors = list(G.successors(nix)) | ||
|
|
@@ -360,7 +368,8 @@ def balance_replicas(self, max_replicas, assignments): | |
| for top_node in self.level_indices[0]: | ||
| for nix in nx.algorithms.traversal.dfs_postorder_nodes(G, top_node): | ||
| try: | ||
| pred = G.pred[nix].keys()[0] # parent node | ||
| #KFW pred = G.pred[nix].keys()[0] # parent node | ||
| pred = list(G.pred[nix].keys())[0] # parent node | ||
| G.node[pred]['nreplicas'] += G.node[nix]['nreplicas'] | ||
| except IndexError: | ||
| pass | ||
|
|
||
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.
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.
I'm not sure if there should be a
.sofile included in the repo since this could cause compatibility issues.