From 484d2b920419f2ceafbdcc0edfbfa37de046cc75 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Sun, 7 Jul 2024 15:53:44 -0600 Subject: [PATCH] make use of __new__ to avoid mumps __init__ --- pymatsolver/direct/mumps.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/pymatsolver/direct/mumps.py b/pymatsolver/direct/mumps.py index b8785e5..645ef8b 100644 --- a/pymatsolver/direct/mumps.py +++ b/pymatsolver/direct/mumps.py @@ -5,19 +5,13 @@ class Mumps(Base): """ Mumps solver """ - - _factored = False _transposed = False ordering = '' - def __init__(self, A, context=None, **kwargs): + def __init__(self, A, **kwargs): self.set_kwargs(**kwargs) - if context is None: - self.solver = Context() - self._analyzed = False - self._set_A(A) - else: - self.solver = context + self.solver = Context() + self._set_A(A) self.A = A def _set_A(self, A): @@ -41,16 +35,14 @@ def _factored(self): @property def transpose(self): - trans_obect = Mumps( - self.A, - self.solver, - is_symmetric=self.is_symmetric, - is_positive_definite=self.is_positive_definite, - ordering=self.ordering, - ) - trans_obect._transposed = not self._transposed - - return trans_obect + trans_obj = Mumps.__new__(Mumps) + trans_obj.A = self.A + trans_obj.solver = self.solver + trans_obj.is_symmetric = self.is_symmetric + trans_obj.is_positive_definite = self.is_positive_definite + trans_obj.ordering = self.ordering + trans_obj._transposed = not self._transposed + return trans_obj T = transpose