2020
2121| Paper link: https://arxiv.org/abs/2103.06504
2222"""
23-
24- import string
2523from abc import ABC , abstractmethod
26- from dataclasses import dataclass
2724from logging import Logger
2825from pathlib import Path
26+ import string
2927from typing import Any , Callable , List , Tuple , Union
3028
3129import numpy as np
3230import matplotlib .pyplot as plt
3331
3432
35- @dataclass
3633class Line :
3734 """
3835 Representation of the linear function.
3936 """
4037
41- angle : float
42- bias : float
38+ def __init__ (self , angle : float , bias : float ):
39+ """
40+ :param angle: Angle in radian.
41+ :param bias: Bias of the angle.
42+ """
43+ self .angle = angle
44+ self .bias = bias
4345
4446 def __call__ (self , x : float ) -> float :
4547 return np .math .tan (self .angle ) * x + self .bias
@@ -64,14 +66,18 @@ def to_numpy(self) -> np.ndarray:
6466 return np .array ([self .angle , self .bias ])
6567
6668
67- @dataclass
6869class Range :
6970 """
7071 Representation of mathematical range concept
7172 """
7273
73- left : float
74- right : float
74+ def __init__ (self , left : float , right : float ):
75+ """
76+ :param left: Left range.
77+ :param right: Right range.
78+ """
79+ self .left = left
80+ self .right = right
7581
7682 def __contains__ (self , value ):
7783 return self .left <= value < self .right
@@ -256,14 +262,18 @@ def save_nrgb_image(image: np.ndarray, number=0, name_length=5, directory="attac
256262 plt .imsave (im_name , image )
257263
258264
259- @dataclass
260265class DebugInfo :
261266 """
262- Logs debug informations during attacking process.
267+ Logs debug information during attacking process.
263268 """
264269
265- logger : Logger
266- artifacts_directory : str
270+ def __init__ (self , logger : Logger , artifacts_directory : str ):
271+ """
272+ :param logger: Logger instance.
273+ :param artifacts_directory: Artifacts directory.
274+ """
275+ self .logger = logger
276+ self .artifacts_directory = artifacts_directory
267277
268278 def log (self , adv_object : AdversarialObject ) -> None :
269279 """
0 commit comments