Giter Club home page Giter Club logo

Comments (4)

TTitscher avatar TTitscher commented on June 10, 2024

Excellent idea! One the one hand, we must avoid the "catch everything" pitfall. On the other hand, we do not know what exactly to catch. So my preferred solution is to have a tuple of allowed exceptions in VBOptions, essentially:

def f_with_value_error(x):
   return int("I am not a number")

result = bayem.vba(f_with_value_error, ...) # fails
result = bayem.vba(f_with_value_error, ..., allowed_exceptions=(ValueError,)) # result.success = False, but you get some values
result = bayem.vba(f_with_value_error, ..., allowed_exceptions=(IndexError,)) # fails (which is important to find bugs!)

internally, this then simply

...
try:
   k, J = self.p(self.m)
except self.options.allowed_exceptions as e:
   self.result.success = False
   self.result.exception = e  # or logger.error(e)
   # ... whatever cleanup
   return self.result

from bayem.

ajafarihub avatar ajafarihub commented on June 10, 2024

I think, at this point we are not going to uncover the reason behind any exception. That would be the duty of the user, I suppose. I would say, the VB can stop iterating due to ANY exception emerging in the evaluation of the model error and its jacobian, however, the VB must return proper WARNING messages to the user; e.g. hey :) , something has gone wrong in the model evaluation and therefore I stopped iterations. Makes sense?

from bayem.

TTitscher avatar TTitscher commented on June 10, 2024

For me, it is very important to know how the code fails (and it also should for you). So if you expect VB to fail because of convergence issues in FEniCS, but it actually fails because of a typo (likely to result in an AttributeError), you should get a real, severe error. Not just a printed message that is likely lost in some logs.

But if you still want this behavior, you could always pass allowed_exceptions=RuntimeError and catch everything...

from bayem.

TTitscher avatar TTitscher commented on June 10, 2024

Solved via #88

from bayem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.