Skip to content

Commit

Permalink
Fix linter suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Oct 13, 2021
1 parent f9ea821 commit e42a0eb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion galois/_fields/_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def _formatter(cls, array):
return formatter

def _print_int(cls, element): # pylint: disable=no-self-use
return "{:d}".format(int(element))
return f"{int(element)}"

def _print_poly(cls, element):
poly = integer_to_poly(element, cls.characteristic)
Expand Down
2 changes: 1 addition & 1 deletion galois/_fields/_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _lapack_linalg(a, b, function, out=None, n_sum=None):
characteristic = field.characteristic

# Determine the return data-type which is the minimum of the two inputs' data-types
if a.dtype == np.object_ or b.dtype == np.object_:
if np.object_ in [a.dtype, b.dtype]:
return_dtype = np.object_
else:
return_dtype = a.dtype if np.iinfo(a.dtype).max < np.iinfo(b.dtype).max else b.dtype
Expand Down
4 changes: 2 additions & 2 deletions galois/_fields/_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def __init__(cls, name, bases, namespace, **kwargs):
cls._display_mode = "int"

if cls.degree == 1:
cls._order_str = "order={}".format(cls.order)
cls._order_str = f"order={cls.order}"
else:
cls._order_str = "order={}^{}".format(cls.characteristic, cls.degree)
cls._order_str = f"order={cls.characteristic}^{cls.degree}"

###############################################################################
# Class attributes
Expand Down
12 changes: 6 additions & 6 deletions galois/_poly_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ def poly_to_str(coeffs, poly_var="x"):

x = []
if degree >= 0 and coeffs[0] != 0:
x += ["{}".format(coeffs[0])]
x += [f"{coeffs[0]}"]
if degree >= 1 and coeffs[1] != 0:
x += ["{}{}".format(coeffs[1] if coeffs[1] != 1 else "", poly_var)]
x += [f"{coeffs[1] if coeffs[1] != 1 else ''}{poly_var}"]
if degree >= 2:
idxs = np.nonzero(coeffs[2:])[0] # Indices with non-zeros coefficients
x += ["{}{}^{}".format(coeffs[2+i] if coeffs[2+i] != 1 else "", poly_var, 2+i) for i in idxs]
x += [f"{coeffs[2 + i] if coeffs[2 + i] != 1 else ''}{poly_var}^{2 + i}" for i in idxs]

poly_str = " + ".join(x[::-1]) if x else "0"

Expand Down Expand Up @@ -160,11 +160,11 @@ def sparse_poly_to_str(degrees, coeffs, poly_var="x"):
coeff_repr = coeff

if degree > 1:
s = "{}{}^{}".format(coeff_repr if coeff != 1 else "", poly_var, degree)
s = f"{coeff_repr if coeff != 1 else ''}{poly_var}^{degree}"
elif degree == 1:
s = "{}{}".format(coeff_repr if coeff != 1 else "", poly_var)
s = f"{coeff_repr if coeff != 1 else ''}{poly_var}"
elif coeff != 0:
s = "{}".format(coeff_repr)
s = f"{coeff_repr}"
else:
continue
x.append(s)
Expand Down

0 comments on commit e42a0eb

Please sign in to comment.