Make some ruff fixes (#8154)

* Make some ruff fixes

* Undo manual fix

* Undo manual fix

* Updates from ruff=0.0.251
This commit is contained in:
Christian Clauss
2023-03-01 17:23:33 +01:00
committed by GitHub
parent 1c15cdff70
commit 64543faa98
73 changed files with 151 additions and 203 deletions

View File

@ -129,7 +129,7 @@ class SmoSVM:
# error
self._unbound = [i for i in self._all_samples if self._is_unbound(i)]
for s in self.unbound:
if s == i1 or s == i2:
if s in (i1, i2):
continue
self._error[s] += (
y1 * (a1_new - a1) * k(i1, s)
@ -225,7 +225,7 @@ class SmoSVM:
def _choose_alphas(self):
locis = yield from self._choose_a1()
if not locis:
return
return None
return locis
def _choose_a1(self):
@ -423,9 +423,8 @@ class Kernel:
return np.exp(-1 * (self.gamma * np.linalg.norm(v1 - v2) ** 2))
def _check(self):
if self._kernel == self._rbf:
if self.gamma < 0:
raise ValueError("gamma value must greater than 0")
if self._kernel == self._rbf and self.gamma < 0:
raise ValueError("gamma value must greater than 0")
def _get_kernel(self, kernel_name):
maps = {"linear": self._linear, "poly": self._polynomial, "rbf": self._rbf}