diff --git a/westpa_wexplore/wex_utils.so b/westpa_wexplore/wex_utils.so index 8218d85..dfab6cd 120000 --- a/westpa_wexplore/wex_utils.so +++ b/westpa_wexplore/wex_utils.so @@ -1 +1 @@ -build/lib.linux-x86_64-2.7/wex_utils.so \ No newline at end of file +build/lib.linux-x86_64-3.7/wex_utils.cpython-37m-x86_64-linux-gnu.so \ No newline at end of file diff --git a/westpa_wexplore/wexplore.py b/westpa_wexplore/wexplore.py index f22936d..b25efa0 100644 --- a/westpa_wexplore/wexplore.py +++ b/westpa_wexplore/wexplore.py @@ -2,7 +2,8 @@ import networkx as nx import pandas as pd import heapq -import cPickle as pickle +#KFW import cPickle as pickle +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,7 +149,8 @@ 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() @@ -152,7 +158,8 @@ def _prune_violations(self): 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