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

PEP 8 compliant notation/names #907

Closed
sbenthall opened this issue Jan 12, 2021 · 12 comments
Closed

PEP 8 compliant notation/names #907

sbenthall opened this issue Jan 12, 2021 · 12 comments
Assignees
Milestone

Comments

@sbenthall
Copy link
Contributor

Originally in #857

The current standard for notation has been defined by NARK, which specifies the translation of mathematical notation into strings. This has complicated the adherence to Python notational conventions because these notational strings have been used as Python variable names. This is changing as of 0.10.8: now these strings are being used as keys in namespaces for model variable values and so on.

That creates an opportunity to streamline the 'mathematical notation' elements of HARK, with a couple of possibilities:

  • Removing Now and Prev from model variable names
  • reconsider the use of mattNwhiteCase for math variable names
@sbenthall sbenthall added this to the 1.0.0 milestone Jan 12, 2021
@sbenthall sbenthall self-assigned this Jan 12, 2021
@sbenthall
Copy link
Contributor Author

EndOfPrdvPP -> end_of_prd_vpp ?

@sbenthall
Copy link
Contributor Author

The first step on this which is:

  • turn Python code to PEP 8 style
  • except for the explicit mathematical terms, which are in NARK

@MridulS
Copy link
Member

MridulS commented Feb 12, 2021 via email

@sbenthall
Copy link
Contributor Author

We did. The main thing that is out of compliance is the use of CamelCase instead of snake_case in a lot of places.

@sbenthall
Copy link
Contributor Author

black does not check for that.

@MridulS
Copy link
Member

MridulS commented Feb 12, 2021

Ah yeah! But I remember Matt/Chris having strong opinions against it?

@sbenthall
Copy link
Contributor Author

I believe Matt original objected but has changed his mind since.

I was just on a call with Chris where I confirmed with him this plan.

This has been discussed in this EEP:

https://github.com/econ-ark/governance/issues

@llorracc
Copy link
Collaborator

llorracc commented Feb 12, 2021 via email

@sbenthall
Copy link
Contributor Author

In particular, does this proposal involve renaming all of the model classes?

No it does not.

Please see the discussion of this in the EEP.

https://github.com/econ-ark/governance/issues/5#issuecomment-656888010

@llorracc
Copy link
Collaborator

I'm confused.

I looked in the EEP. It says:

PEP8 is opinionated. The format of the names should match the programming role of the object.

Class names: CapWordsStyle aka CamelCase
Function and variable names: lower_case_with_internal_underscores
Class method names: same as functions

OK, so ConsIndShockModel.py is a package, and not any of these things.

But could you clarify whether when you said that we were going to leave alone "mathematical objects" did you mean for example ConsumerSolution etc? And the function defValueFuncs?

If not, what ARE some specific examples of things you'd like to change and about which you think there might be some controversy?

@sbenthall
Copy link
Contributor Author

ConsumerSolution and IndShockConsumerType are the names of class names. As they are in CapWordsStyle, they would be unchanged in my proposal.

The function defValueFuncs is a function name. To be compliant with PEP 8, this would need to be changed to lower_case_with_underscores. For example, it could become def_value_funcs.

I am certainly not trying to make a controversial proposal. I am trying to make a proposal that will move us closer to PEP 8 compliance while acknowledging the limited time available before the 1.0 release.

An example of something that might be "left alone" is updateRiskyDstn. RiskyDstn is a term for a mathematical entity.
I could see a case for making it update_RiskyDstn, but would not insist on it at all.

@sbenthall
Copy link
Contributor Author

Is ValueFuncs a mathematical name, i.e specified in NARK?
In that case it is a bad example of a function that would be changed.

A better example: prepareToSolve -> prepare_to_solve

@sbenthall sbenthall mentioned this issue Feb 16, 2021
3 tasks
sbenthall added a commit to sbenthall/HARK that referenced this issue Feb 23, 2021
sbenthall added a commit to sbenthall/HARK that referenced this issue Feb 23, 2021
sbenthall added a commit to sbenthall/HARK that referenced this issue Feb 23, 2021
sbenthall added a commit to sbenthall/HARK that referenced this issue Feb 23, 2021
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

3 participants