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

Use pythonic names #8

Closed
cthoyt opened this issue Oct 25, 2024 · 3 comments
Closed

Use pythonic names #8

cthoyt opened this issue Oct 25, 2024 · 3 comments

Comments

@cthoyt
Copy link
Contributor

cthoyt commented Oct 25, 2024

The repository uses very java-flavored names, which makes it less approachable for python programmers. You can read PEP-8's naming conventions guide to get familiar with https://peps.python.org/pep-0008/#naming-conventions

for example, step = lvmod.stepGillespie() feels very java. Python conventions would be to write it as step = lvmod.step_gillespie()

similarly, using the number 2 instead of to is also not very pythonic

def mod2Spn(filename, verb=False):

should be mod_to_spn, or ideally, something that is not an abbreviation

I understand that this might be because you're trying to mimic the interface of smfsb, but this is irrelevant in terms of reviewing this repo

@darrenjw
Copy link
Owner

darrenjw commented Nov 3, 2024

OK, I've had a go at this. I don't like unnecessary breaking changes, but I do get your point. I've tried to make consistent changes to both this library and smfsb. Of course they are now both somewhat inconsistent with the R library and the Scala library, but I guess that's inevitable.

@darrenjw darrenjw closed this as completed Nov 3, 2024
@cthoyt
Copy link
Contributor Author

cthoyt commented Nov 3, 2024

I'd highly suggest running the following in the root of your repo before considering this issue closed:

ruff check --select N

More information about how PEP-8 naming checks works here: https://docs.astral.sh/ruff/rules/#pep8-naming-n. I guess it might be initially frustrating to get errors like

tests/test_spatial.py:65:5: N806 Variable `N` in function should be lowercase
   |
63 | def test_step_cle_2d():
64 |     M=16
65 |     N=20
   |     ^ N806
66 |     x0 = jnp.zeros((2,M,N))
67 |     lv = jsmfsb.models.lv()

but, people who read your code will highly appreciate not having cryptic variable names everywhere

@darrenjw darrenjw reopened this Nov 3, 2024
@darrenjw
Copy link
Owner

Have had a good go at cleaning up ruff suggestions

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

2 participants