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

Type hints generally incorrect #55

Open
mikesmit opened this issue Dec 5, 2024 · 3 comments
Open

Type hints generally incorrect #55

mikesmit opened this issue Dec 5, 2024 · 3 comments

Comments

@mikesmit
Copy link
Collaborator

mikesmit commented Dec 5, 2024

Many type hints are incorrect in the current version of the source code (mostly in simulation.py). This makes it harder to identify and fix issues like #53

@mikesmit
Copy link
Collaborator Author

mikesmit commented Dec 5, 2024

I'm using this comment to track "bug or feature" questions I run into trying to correctly assign types

  • I'm confused by the "baseline" input
    • What is this actually for? it's optional and the example doesn't set it and the object we build with it is called "Reform" but also there is an actual reform....
    • Also later... we call _apply_region_to_simulation on both the reform and the baseline, but we only ever use the reform in that method (confusingly this has now be reassigned to a Reform object although it was originally the dict | None from input).
    • I think this is a bug and it should be baseline for baseline and reform for reform, but not clear. either way we
  • baseline refers to three things and at times appears to have three different types of values (reform has two only because we also have "reformed" instead of "reform")
  • "selected"
    • Why do we only set "selected" if this is a reform (also need to fix to be "| None" to reflect this). Surely if there is no reform we just make selected the baseline?
    • Similarly, why it is typed as the microsimulations instead of simulation... but it can be either right? (I can have a reform comparison for a household sim)
  • the "time_period" attribute
  • _apply_region_to_simulation silently does nothing unless you are in the US (and some other constraints) - is that right? It seems like it should fail if it can't apply the region (but maybe I misunderstand how the region stuff works)

@mikesmit
Copy link
Collaborator Author

mikesmit commented Dec 6, 2024

Sleeping on it, I believe the actual clear bugs are the following:

  1. baseline overloaded - baseline is defined twice to mean two things. the second eclipses the first.
    2. the baseline country simulation
    3. the reform used to build the baseline country simulation4
  2. _apply_region_to_simulation applies the wrong reform to baseline - instead of applying the baseline reform (as when it initializes the simulation first) it applies the reform reform
  3. "selected" should default to baseline if there is no reform

@mikesmit
Copy link
Collaborator Author

mikesmit commented Dec 6, 2024

@nikhilwoodruff I pushed a branch with the update I have (commit log discusses the limitations) here: https://github.com/PolicyEngine/policyengine.py/tree/55_fix_type_hints

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant