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

Drop compute_ from function names? #328

Closed
niksirbi opened this issue Oct 18, 2024 · 5 comments
Closed

Drop compute_ from function names? #328

niksirbi opened this issue Oct 18, 2024 · 5 comments
Labels
enhancement New optional feature

Comments

@niksirbi
Copy link
Member

All our functions for computing metrics derived from the data take the form compute_metric, for example:

  • compute_velocity()
  • compute_path_length()
  • compute_interindividual_distances()
  • compute_norm()

Pros:

  • consistency
  • being super explicit about this function invoking the computation of some variable

Cons:

  • Verbose
  • Makes code lines long (hence more commands have to be split across lines)
  • Is somewhat redundant? Most python users understand that calling a foo() (with brackets) will trigger some computation (as apposed to object.property)

I can't think of many packages that something similar to this, happy to change my mind.

@roaldarbol
Copy link

Think it's a matter of opinion. Using verbs for method names and nouns for object names is not part of PEP 8, but some consider it best practice. In R it's very standard that function names are verbs; for the tidyverse it's by convention. Personally I like it, especially if it doesn't return a new object of the same name (e.g. get_horse returns horse, not get_horse)

@niksirbi
Copy link
Member Author

niksirbi commented Dec 5, 2024

Good points, thanks for chiming in on this!

@roaldarbol
Copy link

roaldarbol commented Dec 9, 2024

Just saw this landing page for an R package (tidyplots); try having a look at the figure by the link to the bioRxiv preprint - that's something I'd want for animovement at least - using verbs deliberately and consistently. Where it's almost possible to reason your way to the function you need next. :)

@niksirbi
Copy link
Member Author

niksirbi commented Dec 9, 2024

I like the concept of "action verbs", quite inspiring.

@niksirbi
Copy link
Member Author

niksirbi commented Dec 13, 2024

After a few discussions, and also taking into account @roaldarbol's input, I will close this as "not planned".
Starting function names with "action verbs" has its benefits, even if it's more "verbose". So we're keeping the compute_!

@github-project-automation github-project-automation bot moved this from 🤔 Triage to ✅ Done in movement progress tracker Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New optional feature
Projects
Development

No branches or pull requests

2 participants