Giter Site home page Giter Site logo

Do not use `except Exception` about opem HOT 5 CLOSED

ecsim avatar ecsim commented on July 19, 2024
Do not use `except Exception`

from opem.

Comments (5)

katyhuff avatar katyhuff commented on July 19, 2024 1

@sepandhaghighi : I agree with @nnadeau . This is very bad practice and should be strongly reconsidered or given a reason.

from opem.

sepandhaghighi avatar sepandhaghighi commented on July 19, 2024

Hi @nnadeau

It's true, using of general exception is not a good point but in OPEM we don't want to handle different exceptions in different ways so I think it's okay.

Thanks

from opem.

sepandhaghighi avatar sepandhaghighi commented on July 19, 2024

@katyhuff

As I mentioned before, in OPEM we don't want to handle different exceptions in different ways, and there is a single response to all of exceptions so I think general exception is not a problem in this case.

Thanks

from opem.

engnadeau avatar engnadeau commented on July 19, 2024

@sepandhaghighi, unfortunately I disagree. The vast majority of the package's functions have a try-except at their returns, catching everything and anything, even for functions that are simply multiplying several floats...

E.g.,

def Power_Thermal_Calc(VStack,N,i):
'''
This function calculate thermal power
:param VStack: VStack [V]
:type VStack : float
:param N: number of single cells
:type N : int
:param i: Cell load current [A]
:type i : float
:return: Thermal power [W]
'''
try:
return i*((N*Eth)-VStack)
except Exception:
return None

The function is a simple/trivial: float * ((int * const float) - float)

There should literally never be an exception...

from opem.

sepandhaghighi avatar sepandhaghighi commented on July 19, 2024

@nnadeau
These functions run in a cascade mode and if prev function return None this exception raised.
Type of exception is not important for us
For example if VStack =None from previous calculation.

from opem.

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.