Skip to content

Commit

Permalink
fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkamm committed Nov 5, 2018
1 parent 2f0ef55 commit 1df9c50
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions momi/compute_sfs.py
Expand Up @@ -455,7 +455,7 @@ def sum_trailing_antidiagonals(self):
def convolve_trailing_axes(self, other):
def within_pop_sfs(a, b):
return a.sfs * b.liks[
[slice(None)] + [0] * len(b.pop_labels)]
tuple([slice(None)] + [0] * len(b.pop_labels))]
self.sfs = within_pop_sfs(
self, other) + within_pop_sfs(other, self)

Expand Down Expand Up @@ -506,9 +506,10 @@ def make_last_axis(self, pop):

def add_last_axis_sfs(self, truncated_sfs):
self.sfs = self.sfs + np.dot(
self.liks[[slice(None)] +
[0] * (self.n_pops - 1) +
[slice(None)]],
self.liks[tuple(
[slice(None)] +
[0] * (self.n_pops - 1) +
[slice(None)])],
truncated_sfs)

def get_last_axis_n(self):
Expand Down
4 changes: 2 additions & 2 deletions momi/data/sfs.py
Expand Up @@ -152,8 +152,8 @@ def __init__(self, loci, configs, folded, length):
self.loc_counts.append(np.array(cnts, dtype=float))

if len(self.loc_idxs) > 1:
self._total_freqs = np.array(np.squeeze(np.asarray(
self.freqs_matrix.sum(axis=1))), ndmin=1)
self._total_freqs = self.freqs_matrix.dot(np.ones(self.n_loci))
assert self._total_freqs.shape == (self.freqs_matrix.shape[0],)
else:
# avoid costly building of frequency matrix, when there are many
# Sfs's of a single locus (e.g. in many stochastic minibatches)
Expand Down
6 changes: 3 additions & 3 deletions momi/demography.py
Expand Up @@ -127,9 +127,9 @@ def sampled_n(self):

@memoize_instance
def _n_at_node(self, node):
return np.sum(self._G.node[(pop, idx)]['lineages']
for pop, idx in nx.dfs_preorder_nodes(self._G, node)
if idx == 0)
return sum(self._G.node[(pop, idx)]['lineages']
for pop, idx in nx.dfs_preorder_nodes(self._G, node)
if idx == 0)

@property
def _root(self):
Expand Down
2 changes: 1 addition & 1 deletion momi/moran_model.py
Expand Up @@ -38,6 +38,6 @@ def rate_matrix(n, sparse_format="csr"):

@memoize
def moran_eigensystem(n):
M = np.asarray(rate_matrix(n).todense())
M = rate_matrix(n).toarray()
d, P = np.linalg.eig(M)
return P, d, np.linalg.inv(P)

0 comments on commit 1df9c50

Please sign in to comment.