Skip to content

Commit

Permalink
update pytest config for pep8 tests (keras-team#3617) (keras-team#3619)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanBE authored and fchollet committed Aug 29, 2016
1 parent 9c28d21 commit d5649da
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 32 deletions.
2 changes: 1 addition & 1 deletion keras/engine/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ def compute_mask(self, inputs, mask=None):
masks = [K.expand_dims(m, 0) for m in mask if m is not None]
return K.all(K.concatenate(masks, axis=0), axis=0, keepdims=False)
elif self.mode == 'concat':
# Make a list of masks while making sure the dimensionality of each mask
# Make a list of masks while making sure the dimensionality of each mask
# is the same as the corresponding input.
masks = []
for input_i, mask_i in zip(inputs, mask):
Expand Down
26 changes: 13 additions & 13 deletions keras/layers/convolutional.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def get_output_shape_for(self, input_shape):
raise Exception('Invalid dim_ordering: ' + self.dim_ordering)

def call(self, x, mask=None):
output = K.deconv2d(x, self.W, self.output_shape_,
output = K.deconv2d(x, self.W, self.output_shape_,
strides=self.subsample,
border_mode=self.border_mode,
dim_ordering=self.dim_ordering,
Expand Down Expand Up @@ -1544,13 +1544,13 @@ def get_output_shape_for(self, input_shape):
def call(self, x, mask=None):
input_shape = self.input_spec[0].shape
if self.dim_ordering == 'th':
return x[:,
:,
return x[:,
:,
self.cropping[0][0]:input_shape[2]-self.cropping[0][1],
self.cropping[1][0]:input_shape[3]-self.cropping[1][1]]
elif self.dim_ordering == 'tf':
return x[:,
self.cropping[0][0]:input_shape[1]-self.cropping[0][1],
return x[:,
self.cropping[0][0]:input_shape[1]-self.cropping[0][1],
self.cropping[1][0]:input_shape[2]-self.cropping[1][1],
:]

Expand Down Expand Up @@ -1624,16 +1624,16 @@ def get_output_shape_for(self, input_shape):
def call(self, x, mask=None):
input_shape = self.input_spec[0].shape
if self.dim_ordering == 'th':
return x[:,
:,
self.cropping[0][0]:input_shape[2]-self.cropping[0][1],
self.cropping[1][0]:input_shape[3]-self.cropping[1][1],
return x[:,
:,
self.cropping[0][0]:input_shape[2]-self.cropping[0][1],
self.cropping[1][0]:input_shape[3]-self.cropping[1][1],
self.cropping[2][0]:input_shape[4]-self.cropping[2][1]]
elif self.dim_ordering == 'tf':
return x[:,
self.cropping[0][0]:input_shape[1]-self.cropping[0][1],
self.cropping[1][0]:input_shape[2]-self.cropping[1][1],
self.cropping[2][0]:input_shape[3]-self.cropping[2][1],
return x[:,
self.cropping[0][0]:input_shape[1]-self.cropping[0][1],
self.cropping[1][0]:input_shape[2]-self.cropping[1][1],
self.cropping[2][0]:input_shape[3]-self.cropping[2][1],
:]

def get_config(self):
Expand Down
6 changes: 3 additions & 3 deletions keras/layers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,13 @@ def antirectifier_output_shape(input_shape):
Takes input tensor as first argument.
output_shape: Expected output shape from function.
Can be a tuple or function.
If a tuple, it only specifies the first dimension onward;
If a tuple, it only specifies the first dimension onward;
sample dimension is assumed either the same as the input:
`output_shape = (input_shape[0], ) + output_shape`
or, the input is `None` and the sample dimension is also `None`:
`output_shape = (None, ) + output_shape`
If a function, it specifies the entire shape as a function of
the input shape: `output_shape = f(input_shape)`
If a function, it specifies the entire shape as a function of the
input shape: `output_shape = f(input_shape)`
arguments: optional dictionary of keyword arguments to be passed
to the function.
Expand Down
6 changes: 3 additions & 3 deletions keras/preprocessing/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def skipgrams(sequence, vocabulary_size,
continue
couples.append([wi, wj])
if categorical:
labels.append([0,1])
labels.append([0, 1])
else:
labels.append(1)

Expand All @@ -149,12 +149,12 @@ def skipgrams(sequence, vocabulary_size,

couples += [[words[i %len(words)], random.randint(1, vocabulary_size-1)] for i in range(nb_negative_samples)]
if categorical:
labels += [[1,0]]*nb_negative_samples
labels += [[1, 0]]*nb_negative_samples
else:
labels += [0]*nb_negative_samples

if shuffle:
seed = random.randint(0,10e6)
seed = random.randint(0, 10e6)
random.seed(seed)
random.shuffle(couples)
random.seed(seed)
Expand Down
2 changes: 1 addition & 1 deletion keras/utils/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def get_file(fname, origin, untar=False,
download = True

if download:
print('Downloading data from', origin)
print('Downloading data from', origin)
global progbar
progbar = None

Expand Down
6 changes: 0 additions & 6 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,20 @@ norecursedirs= build
# E251 unexpected spaces around keyword / parameter equals
# E225 missing whitespace around operator
# E226 missing whitespace around arithmetic operator
# W291 trailing whitespace
# W293 blank line contains whitespace
# E501 line too long (82 > 79 characters)
# E402 module level import not at top of file - temporary measure to coninue adding ros python packaged in sys.path
# E731 do not assign a lambda expression, use a def
# E302 two blank lines between the functions
# E231 missing whitespace after ,
# E241 multiple spaces after ','
# E261 at least two spaces before inline comment


pep8ignore=* E251 \
* E225 \
* E226 \
* W291 \
* W293 \
* E501 \
* E402 \
* E731 \
* E302 \
* E231 \
* E241 \
* E261
2 changes: 1 addition & 1 deletion tests/keras/preprocessing/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_pad_sequences_vector():

def test_make_sampling_table():
a = make_sampling_table(3)
assert_allclose(a, np.asarray([0.00315225, 0.00315225, 0.00547597]),
assert_allclose(a, np.asarray([0.00315225, 0.00315225, 0.00547597]),
rtol=.1)


Expand Down
8 changes: 4 additions & 4 deletions tests/keras/test_activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def softplus(x):
return np.log(np.ones_like(x) + np.exp(x))

x = K.placeholder(ndim=2)
f = K.function([x], [activations.softplus(x)])
f = K.function([x], [activations.softplus(x)])
test_values = get_standard_values()

result = f([test_values])[0]
Expand All @@ -64,7 +64,7 @@ def softsign(x):
return np.divide(x, np.ones_like(x) + np.absolute(x))

x = K.placeholder(ndim=2)
f = K.function([x], [activations.softsign(x)])
f = K.function([x], [activations.softsign(x)])
test_values = get_standard_values()

result = f([test_values])[0]
Expand All @@ -85,7 +85,7 @@ def ref_sigmoid(x):
sigmoid = np.vectorize(ref_sigmoid)

x = K.placeholder(ndim=2)
f = K.function([x], [activations.sigmoid(x)])
f = K.function([x], [activations.sigmoid(x)])
test_values = get_standard_values()

result = f([test_values])[0]
Expand All @@ -108,7 +108,7 @@ def ref_hard_sigmoid(x):
hard_sigmoid = np.vectorize(ref_hard_sigmoid)

x = K.placeholder(ndim=2)
f = K.function([x], [activations.hard_sigmoid(x)])
f = K.function([x], [activations.hard_sigmoid(x)])
test_values = get_standard_values()

result = f([test_values])[0]
Expand Down

0 comments on commit d5649da

Please sign in to comment.