Code Duplication    Length = 20-22 lines in 2 locations

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.