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

Implement LArray.reverse(axis) #631

Closed
gdementen opened this issue May 4, 2018 · 2 comments
Closed

Implement LArray.reverse(axis) #631

gdementen opened this issue May 4, 2018 · 2 comments

Comments

@gdementen
Copy link
Contributor

So that we can write:

(agei * dx).reverse(AGE).cumsum(AGE).reverse(AGE)

instead of the much less readable:

(agei * dx)[AGE[::-1]].cumsum(AGE)[AGE[::-1]]
@alixdamman
Copy link
Collaborator

My biggest fear with small methods like that is to run into the same pitfall as pandas: having a too wide API and then make users to use only (less than) 10% of it.
I wonder if we shouln't encourage users to have an utils.py module in their models instead.

@gdementen
Copy link
Contributor Author

Pandas has indeed a very wide API, but I think it is part of the reason it is so successful. Yes, each user only ever uses 10% of Pandas, but not the same 10% and the long tail of features is important.

Pro arguments

  • the slice step is very seldom meaningful in the context of labelled arrays so (non Python developers) users do not really know this syntax.
  • the number one priority of LArray is to make code readable and reverse is IMO much more readable than [::-1].
  • reverse is probably more easily discoverable than [::-1] for our typical user base. If one of our current users is looking for a way to reverse an axis, there are chances he finds the method. The inverse slice? I don't think so.

Con arguments

  • it adds more code to maintain. That's a true problem, but I think there are other places where we have more to gain in this regard: e.g. think about how to have less ways to call the functions which accept 23 different types as arguments.
  • that is two ways to do the same thing and we would promote the one which is not builtin/idiomatic Python.

All in all, I would say the benefits far outweigh the disadvantages for our non-Python expert users. For seasoned Python users, the status quo is clearly better IMO, but this is not our target audience at the moment.

@alixdamman alixdamman modified the milestones: 0.30, 0.31 Jul 18, 2018
alixdamman added a commit to alixdamman/larray that referenced this issue Apr 12, 2019
@gdementen gdementen modified the milestones: 0.31, 0.30 Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants