Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
opts[k] = None
else:
opts[k] = v
petsc_obj.setFromOptions()
obj._set_parameters = obj.parameters.copy()
def _make_reasons(reasons):
return dict([(getattr(reasons, r), r)
for r in dir(reasons) if not r.startswith('_')])
KSPReasons = _make_reasons(PETSc.KSP.ConvergedReason())
SNESReasons = _make_reasons(PETSc.SNES.ConvergedReason())
def check_snes_convergence(snes):
r = snes.getConvergedReason()
try:
reason = SNESReasons[r]
inner = False
except KeyError:
r = snes.getKSP().getConvergedReason()
try:
reason = KSPReasons[r]
inner = True
except KeyError:
reason = 'unknown reason (petsc4py enum incomplete?)'
if r < 0:
if inner: