some suggestions from prospector/pylint
This commit is contained in:
parent
ce4591fa29
commit
df96110733
|
@ -267,7 +267,7 @@ class Colormap(mpl.colors.ListedColormap):
|
|||
(bounds[0],bounds[1])
|
||||
|
||||
if abs(delta := r-l) * 1e8 <= (avg := 0.5*abs(r+l)): # delta is similar to numerical noise
|
||||
l,r = l-0.5*avg*np.sign(delta),r+0.5*avg*np.sign(delta), # extend range to have actual data centered within
|
||||
l,r = (l-0.5*avg*np.sign(delta),r+0.5*avg*np.sign(delta)) # extend range to have actual data centered within
|
||||
|
||||
return Image.fromarray(
|
||||
(np.dstack((
|
||||
|
@ -301,7 +301,7 @@ class Colormap(mpl.colors.ListedColormap):
|
|||
>>> damask.Colormap.from_predefined('stress').reversed()
|
||||
|
||||
"""
|
||||
rev = super(Colormap,self).reversed(name)
|
||||
rev = super().reversed(name)
|
||||
return Colormap(np.array(rev.colors),rev.name[:-4] if rev.name.endswith('_r_r') else rev.name)
|
||||
|
||||
|
||||
|
@ -437,7 +437,7 @@ class Colormap(mpl.colors.ListedColormap):
|
|||
"""If saturation of one of the two colors is much less than the other, hue of the less."""
|
||||
if msh_sat[0] >= msh_unsat[0]:
|
||||
return msh_sat[2]
|
||||
else:
|
||||
|
||||
hSpin = msh_sat[1]/np.sin(msh_sat[1])*np.sqrt(msh_unsat[0]**2.0-msh_sat[0]**2)/msh_sat[0]
|
||||
if msh_sat[2] < - np.pi/3.0: hSpin *= -1.0
|
||||
return msh_sat[2] + hSpin
|
||||
|
@ -453,9 +453,9 @@ class Colormap(mpl.colors.ListedColormap):
|
|||
else:
|
||||
lo = np.array([M_mid,0.0,0.0])
|
||||
frac = 2.0*frac - 1.0
|
||||
if lo[1] < 0.05 and hi[1] > 0.05:
|
||||
if lo[1] < 0.05 < hi[1]:
|
||||
lo[2] = adjust_hue(hi,lo)
|
||||
elif lo[1] > 0.05 and hi[1] < 0.05:
|
||||
elif hi[1] < 0.05 < lo[1]:
|
||||
hi[2] = adjust_hue(lo,hi)
|
||||
|
||||
return (1.0 - frac) * lo + frac * hi
|
||||
|
|
|
@ -33,7 +33,7 @@ class Grid:
|
|||
material: np.ndarray,
|
||||
size: FloatSequence,
|
||||
origin: FloatSequence = np.zeros(3),
|
||||
comments: Union[str, Sequence[str]] = []):
|
||||
comments: Union[str, Sequence[str]] = None):
|
||||
"""
|
||||
New geometry definition for grid solvers.
|
||||
|
||||
|
@ -53,7 +53,7 @@ class Grid:
|
|||
self.material = material
|
||||
self.size = size # type: ignore
|
||||
self.origin = origin # type: ignore
|
||||
self.comments = comments # type: ignore
|
||||
self.comments = [] if comments is None else comments # type: ignore
|
||||
|
||||
|
||||
def __repr__(self) -> str:
|
||||
|
@ -106,9 +106,9 @@ class Grid:
|
|||
material: np.ndarray):
|
||||
if len(material.shape) != 3:
|
||||
raise ValueError(f'invalid material shape {material.shape}')
|
||||
elif material.dtype not in np.sctypes['float'] and material.dtype not in np.sctypes['int']:
|
||||
if material.dtype not in np.sctypes['float'] and material.dtype not in np.sctypes['int']:
|
||||
raise TypeError(f'invalid material data type {material.dtype}')
|
||||
else:
|
||||
|
||||
self._material = np.copy(material)
|
||||
|
||||
if self.material.dtype in np.sctypes['float'] and \
|
||||
|
@ -126,7 +126,7 @@ class Grid:
|
|||
size: FloatSequence):
|
||||
if len(size) != 3 or any(np.array(size) < 0):
|
||||
raise ValueError(f'invalid size {size}')
|
||||
else:
|
||||
|
||||
self._size = np.array(size)
|
||||
|
||||
@property
|
||||
|
@ -139,7 +139,7 @@ class Grid:
|
|||
origin: FloatSequence):
|
||||
if len(origin) != 3:
|
||||
raise ValueError(f'invalid origin {origin}')
|
||||
else:
|
||||
|
||||
self._origin = np.array(origin)
|
||||
|
||||
@property
|
||||
|
|
|
@ -526,7 +526,7 @@ class Table:
|
|||
"""
|
||||
if self.shapes != other.shapes or not self.data.columns.equals(other.data.columns):
|
||||
raise KeyError('Labels or shapes or order do not match')
|
||||
else:
|
||||
|
||||
dup = self.copy()
|
||||
dup.data = dup.data.append(other.data,ignore_index=True)
|
||||
return dup
|
||||
|
@ -552,7 +552,7 @@ class Table:
|
|||
"""
|
||||
if set(self.shapes) & set(other.shapes) or self.data.shape[0] != other.data.shape[0]:
|
||||
raise KeyError('Duplicated keys or row count mismatch')
|
||||
else:
|
||||
|
||||
dup = self.copy()
|
||||
dup.data = dup.data.join(other.data)
|
||||
for key in other.shapes:
|
||||
|
|
|
@ -64,7 +64,7 @@ def eigenvectors(T_sym: _np.ndarray,
|
|||
associated eigenvalues.
|
||||
|
||||
"""
|
||||
(u,v) = _np.linalg.eigh(symmetric(T_sym))
|
||||
_,v = _np.linalg.eigh(symmetric(T_sym))
|
||||
|
||||
if RHS: v[_np.linalg.det(v) < 0.0,:,2] *= -1.0
|
||||
return v
|
||||
|
|
|
@ -7,7 +7,7 @@ import subprocess
|
|||
import shlex
|
||||
import re
|
||||
import fractions
|
||||
import collections.abc as abc
|
||||
from collections import abc
|
||||
from functools import reduce
|
||||
from typing import Union, Tuple, Iterable, Callable, Dict, List, Any, Literal, Optional
|
||||
from pathlib import Path
|
||||
|
@ -237,7 +237,7 @@ def show_progress(iterable: Iterable,
|
|||
else:
|
||||
if N_iter is None:
|
||||
raise ValueError('N_iter not given')
|
||||
else:
|
||||
|
||||
N = N_iter
|
||||
|
||||
if N <= 1:
|
||||
|
@ -454,7 +454,7 @@ def shapeshifter(fro: Tuple[int, ...],
|
|||
|
||||
|
||||
"""
|
||||
if not len(fro) and not len(to): return ()
|
||||
if len(fro) == 0 and len(to) == 0: return ()
|
||||
|
||||
beg = dict(left ='(^.*\\b)',
|
||||
right='(^.*?\\b)')
|
||||
|
@ -462,8 +462,8 @@ def shapeshifter(fro: Tuple[int, ...],
|
|||
right='(.*?\\b)')
|
||||
end = dict(left ='(.*?$)',
|
||||
right='(.*$)')
|
||||
fro = (1,) if not len(fro) else fro
|
||||
to = (1,) if not len(to) else to
|
||||
fro = (1,) if len(fro) == 0 else fro
|
||||
to = (1,) if len(to) == 0 else to
|
||||
try:
|
||||
match = re.match(beg[mode]
|
||||
+f',{sep[mode]}'.join(map(lambda x: f'{x}'
|
||||
|
|
Loading…
Reference in New Issue