From b78b7fc9e9f352a4e6dccebf1296b6b72d6d60ed Mon Sep 17 00:00:00 2001 From: LeoBarreiro Date: Fri, 27 Aug 2021 18:30:07 -0300 Subject: [PATCH] refactor: Simplificado un condicional. Test comentado, hacer unit test en un futuro --- bisection.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bisection.py b/bisection.py index 26c2ae7..a3edf30 100644 --- a/bisection.py +++ b/bisection.py @@ -57,20 +57,21 @@ def logs(self, item): print("{:>4} | {:^8.4f} | {:^8.4f} | {:^8.4f} | {:_>8.4f} | {:^8.4f}". format(self.iter_n, self.xinf, self.xsup, self.xmed, self.err_rel, self.ymed)) if item == 'results': - if not (self.err_rel > self.err_obj): print("Finish by eps: {:.4e}".format(self.err_rel)) - if not (self.iter_n < self.max_iter): print("Finish by iter: {}".format(self.iter_n)) + if self.err_rel <= self.err_obj: print("Finish by eps: {:.4e}".format(self.err_rel)) + if self.iter_n >= self.max_iter: print("Finish by iter: {}".format(self.iter_n)) print("Xroot: {0}".format(self.xmed)) if item == 'exact': print ("Exact root found: {}".format(self.xmed)) -def function(tInt_perc): - frec, ampl = 1, 1 - rms_unit = (np.sqrt(2) / 2) * ampl - rms_dimmer = fun_rms_simbolic(tInt_perc, frec=frec, amp=ampl) / rms_unit - return rms_dimmer +# TEST +# def function(tInt_perc): +# frec, ampl = 1, 1 +# rms_unit = (np.sqrt(2) / 2) * ampl +# rms_dimmer = fun_rms_simbolic(tInt_perc, frec=frec, amp=ampl) / rms_unit +# return rms_dimmer -solver = bisector(function, xinf=0, xsup=100, bias=0.1, err_obj=1e-5, verbose=False) -sol = solver.run() -print("rms({:.4f}) = {:.4f}".format(sol, function(sol))) \ No newline at end of file +# solver = bisector(function, xinf=0, xsup=100, bias=0.1, err_obj=1e-5, verbose=False) +# sol = solver.run() +# print("rms({:.4f}) = {:.4f}".format(sol, function(sol))) \ No newline at end of file