Skip to content

Commit a889461

Browse files
committed
pep-8
1 parent 0c26f86 commit a889461

File tree

10 files changed

+16
-15
lines changed

10 files changed

+16
-15
lines changed

.editorconfig

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ multi_line_output = 5
1414
order_by_type = true
1515
known_third_party=numpy,scipy,matplotlib,sklearn,joblib,theano,gensim,lasagne
1616
not_skip=__init__.py
17+
skip=/senti/score.py

senti/data/twitter.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import html
44
import json
5-
import logging
65
import os
76
import re
87
from contextlib import ExitStack, closing

senti/models/base/nn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def fit(
100100
params = lasagne.layers.get_all_params(self.network)
101101
best_perf, best_params = None, None
102102
epoch_iter = EpochIterator(
103-
self.gen_batches, (docs, y), (epoch_size + self.batch_size - 1)//self.batch_size
103+
self.gen_batches, (docs, y), (epoch_size + self.batch_size - 1) // self.batch_size
104104
if epoch_size else None
105105
)
106106
for i, batches, update_params in zip(range(max_epochs), epoch_iter, update_params_iter):

senti/preprocess/twokenize.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ def regex_or(*items):
189189
edge_punct = "[" + edge_punct_chars + "]"
190190
not_edge_punct = "[a-zA-Z0-9]" # content characters
191191
off_edge = r"(^|$|:|;|\s|\.|,)" # colon here gets "(hello):" ==> "( hello ):"
192-
edge_punct_left = re.compile(off_edge + "("+edge_punct+"+)("+not_edge_punct+")", re.UNICODE)
193-
edge_punct_Right = re.compile("("+not_edge_punct+")("+edge_punct+"+)" + off_edge, re.UNICODE)
192+
edge_punct_left = re.compile(off_edge + "(" + edge_punct + "+)(" + not_edge_punct + ")", re.UNICODE)
193+
edge_punct_Right = re.compile("(" + not_edge_punct + ")(" + edge_punct + "+)" + off_edge, re.UNICODE)
194194

195195

196196
def split_edge_punct(input_):
@@ -236,7 +236,7 @@ def simple_tokenize(text):
236236
# Group the indices and map them to their respective portion of the string
237237
split_goods = []
238238
for i in range(0, len(indices), 2):
239-
good_str = split_punct_text[indices[i]:indices[i+1]]
239+
good_str = split_punct_text[indices[i]:indices[i + 1]]
240240
split_str = good_str.strip().split(" ")
241241
split_goods.append(split_str)
242242

senti/score.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
import matplotlib; matplotlib.use('Agg')
2+
import matplotlib
3+
matplotlib.use('Agg')
34
from contextlib import closing
45

56
import matplotlib.pyplot as plt

senti/senti_models.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
import itertools
32
import logging
43
import re
54
from types import SimpleNamespace
@@ -73,9 +72,9 @@ def fit_voting(self):
7372
# assume w_0=1 as w is invariant to scaling
7473
w = basinhopping(
7574
lambda w_: -(dev_label_indexes == np.argmax((
76-
all_probs_first + all_probs_rest*w_.reshape((len(w_), 1, 1))
75+
all_probs_first + all_probs_rest * w_.reshape((len(w_), 1, 1))
7776
).sum(axis=0), axis=1)).sum(), get_rng().uniform(0, 1, len(classifiers) - 1), niter=1000,
78-
minimizer_kwargs=dict(method='L-BFGS-B', bounds=[(0, None)]*(len(classifiers) - 1))
77+
minimizer_kwargs=dict(method='L-BFGS-B', bounds=[(0, None)] * (len(classifiers) - 1))
7978
).x
8079
w = np.hstack([[1], w])
8180
w /= w.sum()
@@ -366,7 +365,7 @@ def _fit_rnn_embedding(self):
366365
batch_size=128, emb_X=emb_char.X, lstm_params=(300, 300), output_size=emb_char.X.shape[1]
367366
)
368367
cf_char.fit(
369-
ft_char.transform(emb_word.vocab), emb_word.syn0, epoch_size=10**3, max_epochs=2*300,
368+
ft_char.transform(emb_word.vocab), emb_word.syn0, epoch_size=10**3, max_epochs=2 * 300,
370369
update_params_iter=geometric_learning_rates(0.01, 0.5, 10)
371370
)
372371
return cf_char

senti/transforms/transforms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ def transform(docs):
5656
class Proportion(BaseEstimator, EmptyFitMixin):
5757
@staticmethod
5858
def transform(docs):
59-
return vstack(sparse_sum(doc, axis=0)/doc.shape[0] for doc in docs)
59+
return vstack(sparse_sum(doc, axis=0) / doc.shape[0] for doc in docs)

senti/utils/cache.py

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def _cached_fit(self, cls, params, X, X_hash, *args, **kwargs):
4242
self.__wrapped__.fit(X, *args, **kwargs)
4343
return self.__wrapped__
4444

45+
# noinspection PyAttributeOutsideInit
4546
@skip_empty_fit
4647
def fit(self, X, *args, **kwargs):
4748
params = self.__wrapped__.get_params(deep=True)

senti/utils/numpy_.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
def sparse_sum(X, axis):
1111
if axis == 0:
1212
n = X.shape[0]
13-
return sparse.csr_matrix((np.ones(n), np.arange(n), (0, n)))*X
13+
return sparse.csr_matrix((np.ones(n), np.arange(n), (0, n))) * X
1414
elif axis == 1:
1515
n = X.shape[1]
16-
return X*sparse.csr_matrix((np.ones(n), np.arange(n), (0, n)))
16+
return X * sparse.csr_matrix((np.ones(n), np.arange(n), (0, n)))
1717

1818

1919
def vstack(Xs):

senti/utils/sr.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def __init__(self, srs, n=None):
5555

5656
def __iter__(self):
5757
with reset_sr(*self.srs):
58-
m = None if self.n is None else round(self.n/len(self.srs))
59-
m_last = None if self.n is None else self.n - m*(len(self.srs) - 1)
58+
m = None if self.n is None else round(self.n / len(self.srs))
59+
m_last = None if self.n is None else self.n - m * (len(self.srs) - 1)
6060
for i, sr in enumerate(self.srs):
6161
if m is None:
6262
yield from sr

0 commit comments

Comments
 (0)