Skip to content

Commit

Permalink
refactor: Simplificado un condicional. Test comentado, hacer unit tes…
Browse files Browse the repository at this point in the history
…t en un futuro
  • Loading branch information
barreiroleo committed Aug 27, 2021
1 parent 189d521 commit b78b7fc
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions bisection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
# 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)))

0 comments on commit b78b7fc

Please sign in to comment.