Skip to content
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

Simpler method names for Policy class #25

Open
21ch216 opened this issue Feb 17, 2025 · 0 comments
Open

Simpler method names for Policy class #25

21ch216 opened this issue Feb 17, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@21ch216
Copy link
Collaborator

21ch216 commented Feb 17, 2025

I propose a new interface for policies objects. While working on ReLife, I found it very cumbersome to write method names like expected_total_cost or expected_equivalent_annual_cost. The situation worsens with asymptotic_* methods, as their names are excessively long and prone to typos. I believe it would be more efficient, intuitive, and less error-prone to adopt a more concise approach, such as

policy.expected_cost(timeline) # Implicitly calculates the total cost
policy.expected_eac(timeline) # More succinct, reducing potential for errors/typos

In this approach, total cost could be treated as the default computation, as it's commonly used. If other types of costs need to be calculated, their methods would explicitly reference those types in their names, making the purpose clearer.

For asymptotic cases, I propose integrating an optional argument to simplify the method names further:

policy.expected_cost(asymptotic=True) 
policy.expected_eac(asymptotic=True)

In this case, the timeline parameter would become optional. If both timeline and asymptotic=True are provided, a warning such as "Unnecessary timeline provided. The timeline will be ignored when asymptotic=True is used." could be raised to inform the user of the redundant input.

@21ch216 21ch216 added the enhancement New feature or request label Feb 17, 2025
@21ch216 21ch216 changed the title Simpler methods for Policy class Simpler method names for Policy class Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants