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

Draft: REF: Rename ar variables #766

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

juanmpga
Copy link
Contributor

@juanmpga juanmpga commented Jan 15, 2025

Hi all,

going through Time_Series_Generative_Graph I found the naming of the variable ar_innov slightly confusing as innovations usually refers to the forecast error (the term pm.Normal.dist(sigma=sigma) within ar_step in this case) and following @jessegrabowski 's suggestion I'm proposing a renaming.

  • ar_innov -> ar_steps

I've also renamed the ar function names to give them verb-like structure:

  • ar_step -> get_next_step
  • ar_dist -> get_ar_steps. In the cases of pm.CustomDist("ar_dist"...) I've replaced by "ar_steps" for consistency.
  • conditional_ar_dist -> get_conditional_ar_steps
  • ar_dist_forecasting -> get_ar_steps_forecast (I could've used forecast_ar_steps but it could introduce potential confusing given how adjacent variables are named)

and similarly some variables to give them noun-like strucutre:

  • forecast_inital_state -> initial_state_forecast

I sometimes name ar_init as ar_0 and ar_steps as ar_t for compactness.

I haven't created an issue because I felt this was too trivial but I have no trouble creating one.

Disclaimer: this is my first potential contribution to an OS project (at all!), I've read the guides and hope I haven't missed anything important.


📚 Documentation preview 📚: https://pymc-examples--766.org.readthedocs.build/en/766/

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@ricardoV94
Copy link
Member

ricardoV94 commented Jan 16, 2025

I don't like the get_ prefix. Doesn't really add more info? The _dist name was a conscious choice, because it's the function passed into the dist argument of CustomDist. It's the function that defines the generative graph of the distribution.

innovations -> steps sounds fine

@juanmpga
Copy link
Contributor Author

Yes I sometimes get the same feeling with the get_ prefix although I also find it a convenient (short) way to turn nouns into verbs which can be useful to distinguish functions from variables. Perhaps this distinction is not relevant to you?
In that case I can revert to the original variable names except for the "innovations -> steps" change.
Otherwise some alternatives could be: calc_next_step, regress_next_step, autoregress_next_step, define_ar_dist, define_ar_forecast_dist. It's also true that these names can get quite long which can be quite annoying when trying to stay below 80 characters.

@ricardoV94
Copy link
Member

In that case I can revert to the original variable names except for the "innovations -> steps" change.

That would be my suggestion

@juanmpga
Copy link
Contributor Author

Done!

With respect to optimal naming conventions I love this quote: "There are only two hard things in Computer Science: cache invalidation and naming things". Do you have any references (or things you've written) that you like particularly on the topic?

@ricardoV94
Copy link
Member

ricardoV94 commented Jan 17, 2025

I agree it's hard. The other issue in an OSS is that it's subjective. So someone may come next and decide they don't like the current names, and propose a change. Then someone says they like something like the original ones, and so on...

So if we are not adding anything extra to the codebase/documentation I would generally suggest not changing anything unless it's clearly needed.

That's why tools like black are right to be opinionated: "Here is an automatically-enforced default, no more discussions about how to format code/etc".

@ricardoV94 ricardoV94 merged commit c73b785 into pymc-devs:main Jan 17, 2025
2 checks passed
fonnesbeck pushed a commit to fonnesbeck/pymc-examples that referenced this pull request Jan 19, 2025
fonnesbeck pushed a commit to fonnesbeck/pymc-examples that referenced this pull request Jan 19, 2025
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

Successfully merging this pull request may close these issues.

2 participants