Code Duplication    Length = 20-22 lines in 3 locations

NiaPy/algorithms/other/nmm.py 1 location

@@ 57-78 (lines=22) @@
54
		"""
55
		return r"""No info"""
56
57
	@staticmethod
58
	def typeParameters():
59
		r"""Get dictionary with function for testing correctness of parameters.
60
61
		Returns:
62
			Dict[str, Callable]:
63
				* alpha (Callable[[Union[int, float]], bool])
64
				* gamma (Callable[[Union[int, float]], bool])
65
				* rho (Callable[[Union[int, float]], bool])
66
				* sigma (Callable[[Union[int, float]], bool])
67
68
		See Also
69
			* :func:`NiaPy.algorithms.Algorithm.typeParameters`
70
		"""
71
		d = Algorithm.typeParameters()
72
		d.update({
73
			'alpha': lambda x: isinstance(x, (int, float)) and x >= 0,
74
			'gamma': lambda x: isinstance(x, (int, float)) and x >= 0,
75
			'rho': lambda x: isinstance(x, (int, float)),
76
			'sigma': lambda x: isinstance(x, (int, float))
77
		})
78
		return d
79
80
	def setParameters(self, NP=None, alpha=0.1, gamma=0.3, rho=-0.2, sigma=-0.2, **ukwargs):
81
		r"""Set the arguments of an algorithm.

NiaPy/algorithms/basic/ba.py 1 location

@@ 43-64 (lines=22) @@
40
	"""
41
	Name = ['BatAlgorithm', 'BA']
42
43
	@staticmethod
44
	def typeParameters():
45
		r"""Return dict with where key of dict represents parameter name and values represent checking functions for selected parameter.
46
47
		Returns:
48
			Dict[str, Callable]:
49
				* A (Callable[[Union[float, int]], bool]): Loudness.
50
				* r (Callable[[Union[float, int]], bool]): Pulse rate.
51
				* Qmin (Callable[[Union[float, int]], bool]): Minimum frequency.
52
				* Qmax (Callable[[Union[float, int]], bool]): Maximum frequency.
53
54
		See Also:
55
			* :func:`NiaPy.algorithms.Algorithm.typeParameters`
56
		"""
57
		d = Algorithm.typeParameters()
58
		d.update({
59
			'A': lambda x: isinstance(x, (float, int)) and x > 0,
60
			'r': lambda x: isinstance(x, (float, int)) and x > 0,
61
			'Qmin': lambda x: isinstance(x, (float, int)),
62
			'Qmax': lambda x: isinstance(x, (float, int))
63
		})
64
		return d
65
66
	def setParameters(self, NP=40, A=0.5, r=0.5, Qmin=0.0, Qmax=2.0, **ukwargs):
67
		r"""Set the parameters of the algorithm.

NiaPy/algorithms/basic/fa.py 1 location

@@ 53-72 (lines=20) @@
50
       	Main reference: Yang, Xin-She. Nature-Inspired Metaheuristic Algorithms,  Luniver Press, 2008.
51
        """
52
53
	@staticmethod
54
	def typeParameters():
55
		r"""TODO.
56
57
		Returns:
58
			Dict[str, Callable]:
59
				* alpha (Callable[[Union[float, int]], bool]): TODO.
60
				* betamin (Callable[[Union[float, int]], bool]): TODO.
61
				* gamma (Callable[[Union[float, int]], bool]): TODO.
62
63
		See Also:
64
			* :func:`NiaPy.algorithms.Algorithm.typeParameters`
65
		"""
66
		d = Algorithm.typeParameters()
67
		d.update({
68
			'alpha': lambda x: isinstance(x, (float, int)) and x > 0,
69
			'betamin': lambda x: isinstance(x, (float, int)) and x > 0,
70
			'gamma': lambda x: isinstance(x, (float, int)) and x > 0,
71
		})
72
		return d
73
74
	def setParameters(self, NP=20, alpha=1, betamin=1, gamma=2, **ukwargs):
75
		r"""Set the parameters of the algorithm.