Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
Signed-off-by: Beat Buesser <[email protected]>
  • Loading branch information
beat-buesser committed Aug 26, 2024
1 parent 1145d2f commit d75ec05
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 36 deletions.
10 changes: 5 additions & 5 deletions tests/attacks/evasion/test_laser_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@pytest.fixture(name="close")
def fixture_close() -> Callable:
"""
Comparison function
Comparison function.
:returns: function that checks if two float arrays are close.
"""

Expand All @@ -51,7 +51,7 @@ def close(x: np.ndarray, y: np.ndarray):
@pytest.fixture(name="not_close")
def fixture_not_close(close):
"""
Comparison function
Comparison function.
:returns: function that checks if values of two float arrays are not close.
"""

Expand All @@ -75,7 +75,7 @@ def not_close(x: np.ndarray, y: np.ndarray) -> bool:
@pytest.fixture(name="less_or_equal")
def fixture_less_or_equal():
"""
Comparison function
Comparison function.
:returns: function that checks if first array is less or equal than the second.
"""

Expand Down Expand Up @@ -126,7 +126,7 @@ def fixture_max_laser_beam() -> LaserBeam:
@pytest.fixture(name="laser_generator_fixture")
def fixture_laser_generator_fixture(min_laser_beam, max_laser_beam) -> Callable:
"""
Return a function that returns geneartor of the LaserBeam objects.
Return a function that returns generator of the LaserBeam objects.
:param min_laser_beam: LaserBeam object with minimal acceptable properties.
:param max_laser_beam: LaserBeam object with maximal acceptable properties.
Expand All @@ -138,7 +138,7 @@ def fixture_laser_generator_fixture(min_laser_beam, max_laser_beam) -> Callable:
@pytest.fixture(name="laser_generator")
def fixture_laser_generator(min_laser_beam, max_laser_beam) -> LaserBeamGenerator:
"""
Geneartor of the LaserBeam objects.
Generator of the LaserBeam objects.
:param min_laser_beam: LaserBeam object with minimal acceptable properties.
:param max_laser_beam: LaserBeam object with maximal acceptable properties.
Expand Down
2 changes: 1 addition & 1 deletion tests/attacks/evasion/test_lowprofool.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def test_clipping(iris_dataset):
top_custom = 3
clf_slr_custom = ScikitlearnLogisticRegression(model=lr_clf, clip_values=(bottom_custom, top_custom))

# Setting up LowProFool classes with different hyper-parameters
# Setting up LowProFool classes with different hyperparameters
lpf_min_max_default = LowProFool(classifier=clf_slr_min_max, n_steps=45, eta=0.02, lambd=1.5)
lpf_min_max_high_eta = LowProFool(classifier=clf_slr_min_max, n_steps=45, eta=100000, lambd=1.5)
lpf_custom_default = LowProFool(classifier=clf_slr_custom, n_steps=45, eta=0.02, lambd=1.5)
Expand Down
8 changes: 4 additions & 4 deletions tests/attacks/evasion/test_pe_malware_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def fix_make_dummy_model():

def get_prediction_model(param_dic):
"""
Model going from embeddings to predictions so we can easily optimise the embedding malware embedding.
Model going from embeddings to predictions, so we can easily optimise the embedding malware embedding.
Needs to have the same structure as the target model.
Populated here with "standard" parameters.
"""
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_append_attack(art_warning, fix_get_synthetic_data, fix_make_dummy_model

# We should only have 2 files as the following cannot be converted to valid adv samples:
# 2nd datapoint (file too large to support any modifications)
# 4th datapoint (file to large to support append attacks)
# 4th datapoint (file too large to support append attacks)
# 5th datapoint (benign file)

assert len(adv_x) == 2
Expand Down Expand Up @@ -360,7 +360,7 @@ def test_dos_header_attack(art_warning, fix_get_synthetic_data, fix_make_dummy_m
)

# should have 3 files. Samples which are excluded are:
# 2nd datapoint (file to large to support any modifications)
# 2nd datapoint (file too large to support any modifications)
# 5th datapoint (benign file)

assert len(adv_x) == 3
Expand Down Expand Up @@ -511,7 +511,7 @@ def test_do_not_check_for_valid(art_warning, fix_get_synthetic_data, fix_make_du

# We expect 2 files to have been made adversarial the following cannot be converted to valid adv samples:
# 2nd datapoint (file too large to support any modifications)
# 4th datapoint (file to large to support append attacks)
# 4th datapoint (file too large to support append attacks)
# 5th datapoint (benign file)
for i, size in enumerate(size_of_files):
if i in [0, 2]:
Expand Down
4 changes: 2 additions & 2 deletions tests/attacks/poison/test_audio_perturbations.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_insert_tone_trigger(art_warning):
assert np.max(audio) != 0
assert np.max(np.abs(audio)) <= 1.0

# test single example with differet duration, frequency, and scale
# test single example with different duration, frequency, and scale
trigger = CacheToneTrigger(sampling_rate=16000, frequency=16000, duration=0.2, scale=0.5)
audio = trigger.insert(x=np.zeros(3200))
assert audio.shape == (3200,)
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_insert_audio_trigger(art_warning):
assert np.max(audio) != 0
assert np.max(np.abs(audio)) <= 1.0

# test single example with differet duration and scale
# test single example with different duration and scale
trigger = CacheAudioTrigger(
sampling_rate=16000,
backdoor_path=file_path,
Expand Down
12 changes: 6 additions & 6 deletions tests/attacks/test_adversarial_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_2_tensorflow_numpy(self):
x_out = attack_ap.insert_transformed_patch(
self.x_train_mnist[0], np.ones((14, 14, 1)), np.asarray([[2, 13], [2, 18], [12, 22], [8, 13]])
)
x_out_expexted = np.array(
x_out_expected = np.array(
[
0.0,
0.0,
Expand Down Expand Up @@ -130,7 +130,7 @@ def test_2_tensorflow_numpy(self):
],
dtype=np.float32,
)
np.testing.assert_almost_equal(x_out[15, :, 0], x_out_expexted, decimal=3)
np.testing.assert_almost_equal(x_out[15, :, 0], x_out_expected, decimal=3)

if sess is not None:
sess.close()
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_3_tensorflow_v2_framework(self):
x_out = attack_ap.insert_transformed_patch(
self.x_train_mnist[0], np.ones((14, 14, 1)), np.asarray([[2, 13], [2, 18], [12, 22], [8, 13]])
)
x_out_expexted = np.array(
x_out_expected = np.array(
[
0.0,
0.0,
Expand Down Expand Up @@ -199,7 +199,7 @@ def test_3_tensorflow_v2_framework(self):
],
dtype=np.float32,
)
np.testing.assert_almost_equal(x_out[15, :, 0], x_out_expexted, decimal=3)
np.testing.assert_almost_equal(x_out[15, :, 0], x_out_expected, decimal=3)

mask = np.ones((1, 28, 28)).astype(bool)
attack_ap.apply_patch(x=self.x_train_mnist, scale=0.1, mask=mask)
Expand Down Expand Up @@ -240,7 +240,7 @@ def test_6_keras(self):
x_out = attack_ap.insert_transformed_patch(
self.x_train_mnist[0], np.ones((14, 14, 1)), np.asarray([[2, 13], [2, 18], [12, 22], [8, 13]])
)
x_out_expexted = np.array(
x_out_expected = np.array(
[
0.0,
0.0,
Expand Down Expand Up @@ -273,7 +273,7 @@ def test_6_keras(self):
],
dtype=np.float32,
)
np.testing.assert_almost_equal(x_out[15, :, 0], x_out_expexted, decimal=3)
np.testing.assert_almost_equal(x_out[15, :, 0], x_out_expected, decimal=3)

def test_4_pytorch(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/attacks/test_backdoor_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_backdoor_pixel(self):

def test_backdoor_image(self):
"""
Test the backdoor attack with a image-based perturbation can be trained on classifier
Test the backdoor attack with an image-based perturbation can be trained on classifier
"""
krc = get_image_classifier_kr()
(is_poison_train, x_poisoned_raw, y_poisoned_raw) = self.poison_dataset(
Expand Down
2 changes: 1 addition & 1 deletion tests/attacks/test_targeted_universal_perturbation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TestTargetedUniversalPerturbation(TestBase):
This module tests the Targeted Universal Perturbation.
| Paper link: https://arxiv.org/abs/1911.06502)
| Paper link: https://arxiv.org/abs/1911.06502
"""

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions tests/defences/preprocessor/test_mp3_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_non_temporal_data_error(art_warning, image_batch_small):

@pytest.mark.parametrize("channels_first", [True, False])
@pytest.mark.skip_framework("keras", "pytorch", "scikitlearn", "mxnet")
def test_mp3_compresssion(art_warning, audio_batch, channels_first):
def test_mp3_compression(art_warning, audio_batch, channels_first):
try:
test_input, test_output, sample_rate = audio_batch
mp3compression = Mp3Compression(sample_rate=sample_rate, channels_first=channels_first)
Expand All @@ -96,7 +96,7 @@ def test_mp3_compresssion(art_warning, audio_batch, channels_first):

@pytest.mark.parametrize("channels_first", [True, False])
@pytest.mark.skip_framework("keras", "pytorch", "scikitlearn", "mxnet")
def test_mp3_compresssion_object(art_warning, audio_batch, channels_first):
def test_mp3_compression_object(art_warning, audio_batch, channels_first):
try:
test_input, test_output, sample_rate = audio_batch
test_input_object = np.array([x for x in test_input], dtype=object)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_non_temporal_data_error(art_warning, image_batch_small):

@pytest.mark.parametrize("channels_first", [True, False])
@pytest.mark.skip_framework("tensorflow", "keras", "scikitlearn", "mxnet", "kerastf")
def test_mp3_compresssion(art_warning, audio_batch, channels_first):
def test_mp3_compression(art_warning, audio_batch, channels_first):
try:
test_input, test_output, sample_rate = audio_batch
mp3compression = Mp3CompressionPyTorch(sample_rate=sample_rate, channels_first=channels_first)
Expand Down
2 changes: 1 addition & 1 deletion tests/defences/preprocessor/test_video_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def video_batch(channels_first):

@pytest.mark.parametrize("channels_first", [True, False])
@pytest.mark.skip_framework("keras", "pytorch", "scikitlearn", "mxnet")
def test_video_compresssion(art_warning, video_batch, channels_first):
def test_video_compression(art_warning, video_batch, channels_first):
try:
test_input, test_output = video_batch
video_compression = VideoCompression(video_format="mp4", constant_rate_factor=0, channels_first=channels_first)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def video_batch(channels_first):

@pytest.mark.parametrize("channels_first", [True, False])
@pytest.mark.skip_framework("tensorflow", "keras", "scikitlearn", "mxnet", "kerastf")
def test_video_compresssion(art_warning, video_batch, channels_first):
def test_video_compression(art_warning, video_batch, channels_first):
try:
test_input, test_output = video_batch
video_compression = VideoCompressionPyTorch(
Expand Down
2 changes: 1 addition & 1 deletion tests/defences/test_adversarial_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_classifier_match(self):
self.assertEqual(len(adv_trainer.attacks), 1)
self.assertEqual(adv_trainer.attacks[0].estimator, adv_trainer.get_classifier())

def test_excpetions(self):
def test_exceptions(self):
with self.assertRaises(ValueError):
_ = AdversarialTrainer(self.classifier, "attack")

Expand Down
2 changes: 1 addition & 1 deletion tests/estimators/certification/test_deepz.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@pytest.fixture()
def fix_get_mnist_data():
"""
Get the first 100 samples of the mnist test set with channels first format
Get the first 100 samples of the mnist test set with channels first format.
:return: First 100 sample/label pairs of the MNIST test dataset.
"""
nb_test = 100
Expand Down
4 changes: 2 additions & 2 deletions tests/estimators/certification/test_derandomized_smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def build_model(input_shape):
img_inputs = tf.keras.Input(shape=(input_shape[0], input_shape[1], input_shape[2] * 2))
x = tf.keras.layers.Conv2D(filters=32, kernel_size=(4, 4), strides=(2, 2), activation="relu")(img_inputs)
x = tf.keras.layers.MaxPool2D(pool_size=(2, 2), strides=2)(x)
# tensorflow uses channels last and we are loading weights from an originally trained pytorch model
# tensorflow uses channels last, and we are loading weights from an originally trained pytorch model
x = tf.transpose(x, (0, 3, 1, 2))
x = tf.keras.layers.Flatten()(x)
x = tf.keras.layers.Dense(100, activation="relu")(x)
Expand Down Expand Up @@ -295,7 +295,7 @@ def build_model(input_shape):
img_inputs = tf.keras.Input(shape=(input_shape[0], input_shape[1], input_shape[2] * 2))
x = tf.keras.layers.Conv2D(filters=32, kernel_size=(4, 4), strides=(2, 2), activation="relu")(img_inputs)
x = tf.keras.layers.MaxPool2D(pool_size=(2, 2), strides=2)(x)
# tensorflow uses channels last and we are loading weights from an originally trained pytorch model
# tensorflow uses channels last, and we are loading weights from an originally trained pytorch model
x = tf.transpose(x, (0, 3, 1, 2))
x = tf.keras.layers.Flatten()(x)
x = tf.keras.layers.Dense(100, activation="relu")(x)
Expand Down
2 changes: 1 addition & 1 deletion tests/estimators/certification/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def forward(self, x):
@pytest.fixture()
def fix_get_mnist_data():
"""
Get the first 100 samples of the mnist test set with channels first format
Get the first 100 samples of the mnist test set with channels first format.
:return: First 100 sample/label pairs of the MNIST test dataset.
"""
nb_test = 100
Expand Down
2 changes: 1 addition & 1 deletion tests/metrics/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_loss_sensitivity(self):
# (x_train, y_train), (_, _), _, _ = load_mnist()
# x_train, y_train = x_train[:NB_TRAIN], y_train[:NB_TRAIN]
#
# # Get classifier
# # Get classifier.
# classifier = self._cnn_mnist_k([28, 28, 1])
# classifier.fit(x_train, y_train, batch_size=BATCH_SIZE, nb_epochs=2)
#
Expand Down
10 changes: 5 additions & 5 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def get_image_classifier_tf_v1(from_logits=False, load_init=True, sess=None):
"""
Standard TensorFlow classifier for unit testing.
The following hyper-parameters were used to obtain the weights and biases:
The following hyperparameters were used to obtain the weights and biases:
learning_rate: 0.01
batch size: 10
number of epochs: 2
Expand Down Expand Up @@ -413,7 +413,7 @@ def discriminator_loss_fct(real_output, generated_output):
zeros (since these are the fake images).
3. Calculate the total_loss as the sum of real_loss and generated_loss.
"""
# [1,1,...,1] with real output since it is true and we want our generated examples to look like it
# [1,1,...,1] with real output since it is true, and we want our generated examples to look like it
real_loss = tf.compat.v1.losses.sigmoid_cross_entropy(
multi_class_labels=tf.ones_like(real_output), logits=real_output
)
Expand Down Expand Up @@ -442,7 +442,7 @@ def get_image_classifier_tf_v2(from_logits=False):
"""
Standard TensorFlow v2 classifier for unit testing.
The following hyper-parameters were used to obtain the weights and biases:
The following hyperparameters were used to obtain the weights and biases:
learning_rate: 0.01
batch size: 10
number of epochs: 2
Expand Down Expand Up @@ -1576,7 +1576,7 @@ def get_tabular_classifier_tf_v1(load_init=True, sess=None):
"""
Standard TensorFlow classifier for unit testing.
The following hyper-parameters were used to obtain the weights and biases:
The following hyperparameters were used to obtain the weights and biases:
* learning_rate: 0.01
* batch size: 5
Expand Down Expand Up @@ -1663,7 +1663,7 @@ def get_tabular_classifier_tf_v2():
"""
Standard TensorFlow v2 classifier for unit testing.
The following hyper-parameters were used to obtain the weights and biases:
The following hyperparameters were used to obtain the weights and biases:
* learning_rate: 0.01
* batch size: 5
Expand Down

0 comments on commit d75ec05

Please sign in to comment.