Skip to content

Improve annuity calculation in economics tool #543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 20, 2019
Merged

Conversation

c-moeller
Copy link
Member

@c-moeller c-moeller commented Nov 23, 2018

@c-moeller c-moeller self-assigned this Nov 23, 2018
@c-moeller c-moeller requested review from simnh and FranziPl November 23, 2018 15:31
@simnh
Copy link
Member

simnh commented Dec 10, 2018

Nice! From the source code perspective, it does not adhere to pep8 (or our guidelines)...maybe this could be adapted?

Otherwise I am fine with the improvement

@uvchik
Copy link
Member

uvchik commented Dec 10, 2018

Thank you for improving this calculations.

  1. Could you write a short test similar to this one.
  2. I would prefer optional parameters instead of **kwargs. It is much more straightforward.
def annuity(capex, n, wacc, u=None, cost_decrease=0)
    """...."""
    if u is None:
        u = n

@c-moeller c-moeller requested a review from lmilletb December 11, 2018 11:58
also changed syntax of return formula to adhere better to style guidelines
added "tex" formulation for proper visualization in readthedocs.
modified description of input parameters
@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 86.971% when pulling b2da53b on features/economics_improv into 6c32099 on dev.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 86.971% when pulling b2da53b on features/economics_improv into 6c32099 on dev.

@coveralls
Copy link

coveralls commented Dec 19, 2018

Coverage Status

Coverage increased (+0.06%) to 86.971% when pulling 7d0c456 on features/economics_improv into 6c32099 on dev.

@lmilletb
Copy link
Contributor

within these last commits I have tried to: improve docstrings for clarity, add tests to cover additional inputs, adequate or get closer to pep8 (don't have much experience, is it now correct? how can it still be improved?), modify kwargs as suggested by @uvchik
I think it is good to merge :)

@lmilletb
Copy link
Contributor

please, could you review logging block? I have seen different criteria for logging along different files. Otherwise, any suggestion on how to improve test coverage by adding an example that checks those logging lines?

@uvchik
Copy link
Member

uvchik commented Dec 20, 2018

Thank you for the changes. Tests looks good. I just fixed a few pep8 Issues but in general everything was fine.

Sometimes we use logging warnings but the attention level is quite low. So I would rather raise a python warning or even an error if something is wrong.

Warning: The results might be unrealistic due to a strange combination of parameters but in some (rare) cases it might be okay. In that case it has to be possible to switch off the warning because a warning is annoying, if the results are okay.

Error: No chance of getting good results with this combination of input parameters.

In most cases I prefer raising an error or doing nothing.

@lluismillet Does it help?

@lmilletb
Copy link
Contributor

Thank you for the corrections and the tips.
Regarding the logging, if the condition

if ((n < 1) or (wacc < 0 or wacc > 1) or (u < 1) or
          (cost_decrease < 0 or cost_decrease > 1)):

is True, a python error will raise by itself as a division by zero will be encountered within the return clause.
The logging I added was just an additional way to track what went wrong, in case the source of this error might not trivially be understood by the user.
Anyway, in this case the error raising will probably be clear enough, as you suggested @uvchik.
For me, we could delete the logging block and is ready to merge.

@uvchik
Copy link
Member

uvchik commented Jan 11, 2019

It might help the user so you can keep the if statement but raise an error instead of a logging warning:

if ....:
    raise ValueError("Input arguments for annuity function out of bounds!")

@lmilletb
Copy link
Contributor

Trying to adopt this error raising I figured out I do not have rights to commit on this branch anymore..

@uvchik
Copy link
Member

uvchik commented Jan 11, 2019

Trying to adopt this error raising I figured out I do not have rights to commit on this branch anymore..

Sure? According to the team lists you should have writing access.

@lmilletb
Copy link
Contributor

Trying to adopt this error raising I figured out I do not have rights to commit on this branch anymore..

Sure? According to the team lists you should have writing access.

sorry, it was just a firewall problem.

@uvchik
Copy link
Member

uvchik commented Jan 13, 2019

Thanks. I added a test to test the ValueError. I think we can merge now.

@p-snft
Copy link
Member

p-snft commented Feb 27, 2019

Looks good to me.

@uvchik uvchik requested review from uvchik and p-snft and removed request for simnh, lmilletb and FranziPl May 20, 2019 08:40
Copy link
Member

@p-snft p-snft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring uses abbreviations for the formulas. I will approve this here, as it is common practice. However, I would advice symbols.

@p-snft p-snft merged commit 331968f into dev May 20, 2019
@p-snft p-snft deleted the features/economics_improv branch May 28, 2019 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants