-
Notifications
You must be signed in to change notification settings - Fork 190
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
Documentation Proposals #2046
Comments
Hi Zach. I do not like this submodule with alias in documentation in general. In spikeinterface there is 3 ways: import spikeinterface.full as si
si.bandpass_filter()
from spikeinterface.preprocessing import bandpass_filter
bandpass_filter()
import spikeinterface.preprocessing as pre
pre.bandpass_filter() My feeling is that this is good to have a bit of the 3 situations in the documentations and not impose a unique way of writting. Also I am not totally convince that a beginner should need to remember from which module a function come from. This is my very personnal point of view! On point 2. |
Importing modules and aliases makes everything easier to understand and tidier. Especially for the documentation, we should use this approach. So I vote for submodule imports + aliases
|
I agree on point 2. Keywords are better than positional. I also would like to use that within the library and not just in the documentation. For the first point. I share the aesthethics of Sam:
I also don't have an explanation for this. I am willing to change my mind based on usability / design arguments for this. If somebody has a good sourrce where that is discussed that would be great. I am glad Sam enumerated the options we have here currently:
I always use 2 personally. I think that 1 is error prone and I don't trust it I would prefer to drop it. My biggest problem with 3 is that we are using acronmys there instead of full names ( My feelings about something being tidy. For me just importing the specific functions that I will use -and as I use them- seems like the tydiest approach. It also provides the benefit of making it explict where does the function comes from. The only problem is when people chose some function name that shadows another function in another library (.e.g That said, I would like to have consistency in the documentation. If we managed to get consensus about something I would go behind that. Just a majority and not a super-majority would do it for me. |
Cool. This is why I figured this one needed a proposal. People have their styles. But it sounds like like for point 2 we all agree so I can start on that as a PR as the debate rages on point 1. I (personally) do not like importing individual functions because it pollutes the name space (the I also find the knowing where a function came from (for me at least) is clearer with an acronym. If I see a function came from spre then I know it is preprocessing, whereas if I write a script or get down to the bottom of a page of documentation I will just see a function On the level of acronyms most of them are just first letters so if I want widgets I need [s]pikeinterface.[w]idgets-> sw. I think people catch onto that pretty quick. Put I agree For point 1 then, I will await consensus should it ever arrive, but I think we need to at least add some additional import statements because currently the docs use functions from other modules without 'importing' them and so the user has no way to connect a function being used in the current docs to other sections of the docs within the examples. So something needs to be added (even if we choose to still retain all three styles). |
@h-mayorquin : happy to be your friend on point 1. |
I agree with the one way only, at least on the docs.
The difficulty is on the reverse inference, all abbreviations makes sense when you see them next to the full word. But if I see Concerning the pollution of the namespace: very short stuff like a See examples: Namespace clashing becomes less of a problem the more specific you are like using a function, having a more specific module name or reflecting the nesting structure of your library in the alias:
Plus, the latter follows the logic that explicit is better tha implicit kind of thing. The argument against of course is verbosity. |
I actually find it interesting that this "branded short import alias" (for lack of a better name) is some kind of scientific library pattern (numpy -> np, pandas -> pd, seaborn -> sns). Probably because people work a lot in notebooks and it somehow convenient (not clear to me)? Or it could be just an historical accident As a counter example, scikit-learn just does not have this type of branded imports in their documentation (they just import full functions) and they seem to be doing well. On the other hand, people do feel like having this type of brand is really important, check out this guy feeling the pull to fill the pattern: Why compete for namespace as a brand like that? The only suggestion the PEP 8 is that you juse alises to avoid namespace clash. Edit: Scipy started importing submodules because of heavy import costs. I have the memory than scipy is older than most other modules, maybe it comes from there. |
I have to run in a minute, (so I'll be back with fuller thoughts later), but I agree. (And to be honest a few of spikeinterface abbreviations have other well known meanings in US English--for example si-> is the abbreviation for sports illustrated a well known magazine). I would never argue for branded namespace, I just argue for namespace in general to reduce potential for clash. And people follow the recommended namespace (I don't know why seaborn is sns, but I definitely use it).
I find this to be the most compelling point. I would say look to the top of the script to see the import, but then you could argue that also works for the pure function import. The current problem is the docs don't do either for some functions, so I think that needs to be fixed separate from style. I guess for my I prefer an alias.function and I as the user control the alias whereas you and Sam (but correct me if I'm wrong), prefer the user to control the function important and keep track of not importing clashing functions. Just to address one more point before I run (but not a fully formed thought yet)
I agree doing the full is better for a script. I at least don't do that because I usually test something in the terminal see that I like it and then once I know my flow save it into a script for later. So I alias so I don't have to type as much, but then when I copy that into a script I save the alias function rather than the full function. I think better practice for a script would be to save full name to be as explicit as possible, but (mostly from laziness), I don't do that. Not to say it is the right thing, but it is just common. People want to do less and get the same results. But unfortunately with 4 people in this debate (2-2) I don't think a majority is currently possible. Haha. |
That's how I work but I will be fine with using We can wait for @DradeAW to break the tie but I also think that the person who volunteers to do the unification should have a double vote : ) |
Interesting discussion!
|
Is it a tiebreaker? :) |
Maybe we can get more opinions, like in #1989 |
Although I do have a preference, I would support whatever the community wants in end (similarly to @h-mayorquin). So the more votes the merrier in my opinion. |
Me too! Again, I vote for module aliases (this is what we also use "internally"). We will need to disambiguate comparison and curation, so maybe we could go with @JoeZiminski @TomBugnon @bendichter @yger what do you guys think? |
@alejoe91 your link is death for me. |
Wrong one, fixed |
Good discussion! I typically prefer importing the module e.g. As mentioned above there is no consensus between the main packages. (e.g.
The only solution that solves all of these problems is to use very explicit module import names and fix these somewhere in the documentation. e.g. from It is also worth considering if this is just for documentation / tutorials, or as general practice in SI itself. If it is just for documentation / tutorials, then I think constraint 1) can be relaxed. I don't think it is so important for new users to worry about what module a function has come from, and a search of the documentation will indicate this. For documentation only, I would consider the So, overall I think fixing a set of explicit module names used for imports is the best of available solutions for all use-cases (documentation, tutorials, day-to-day programming), albeit not perfect. |
Related to point 2: https://discuss.python.org/t/syntactic-sugar-to-encourage-use-of-named-arguments/36217/15 EDIT (And to @DradeAW comments!) Apparently the verbosity of long keyword arguments annoys people enough that Guido is willing to sponsor a PEP for adding syntactic suggar for this. I am weird in how little this verbosity annoys me in this regard then and should change my beliefs to be more aware of this. I think is becaus black just collapses everything into: def(
long_argument_1 = long_argument_1,
long_argument_2 = long_argument_2,
...
long_argumnet_n = long_argumnet_n
) Which does not bother me. But I guess in non-blacked code bases it is harder to look for the argument as they look like
And then I guess is more difficult to get comas or typos. |
I agree the verbosity doesn't annoy me. I think black helps a lot with that. As far as point 1, which has been left unresolved (although I think submodule imports are slightly in the lead :) ), maybe going forward I will just make sure there is at least some import at the top of a documentation page. I think the worst thing would be to have documents where people have no clue where a function is coming from, so at least adding explicit import statements in the docs is something I think we can all agree on? |
FWIW for 1- I vote for module-level aliases as well, and I don't think it's a big deal if they are not so explicit (ie For 2- I think lengthy & explicit is good as well |
I think that everyeon agreed with the full keywords and with @TomBugnon we also have a vote for the aliases now, right? |
Yeah it looks like aliases have won based on pure democracy. @samuelgarcia and @alejoe91 (but mostly Sam), any final comments or can I officially put that on my docs todo list? |
Here we have a weird style of democracy. the voted are ponderated by the age. I am really not sure that unify the way we import is a good stuff. |
omg what have I done |
traitre. |
I think at the beginning of the docs we still say there are three ways so users can always choose to do the |
Agree it cannot hurt to let the user know about the different ways of importing, and also to keep this as a distinct section (e.g. 'ways to import functions in spikeinterface') in only one place in the docs. For the rest of the docs, I would keep the imports consistent, so the reader can focus on the specific content that is aimed to be taught in that part section of the docs. The website diataxis is a great resource that tries to take a systematic approach to documentation writing. In their tutorials page they have a section 'Ignore options and alternatives, which I think is relevant for this dicsussion. |
I beg of you that we don't start a tutorial by saying:
|
No, no. There will be a whole tutorial that explains how to import:
|
Something like this : https://spikeinterface.readthedocs.io/en/latest/modules/core.html#import-rules |
Although that is missing the |
This is looking very nice! I would still advocate for more explicit import names recommended in the documentation. At the moment the list is quite long (as it must be) but it means there are lots of random abbreviations there that I think are: a) confusing / intimidating to new users If I am reading someone's code and they have followed the docs, I'm going to have no idea what is going on with all of these module names and will keep having to refer back to the documentation to decode. I would suggest recommending import names such as |
I just reread the thread and realised how I forgot this has already been discussed to death and resolved in a PR. Please ignore my last comment 😅. Maybe this can be closed with the merging of #2168? |
I agree @JoeZiminski , we can close this now and move to your new issue #2800 for further docs work :) |
As I was looking over the docs I was thinking of two changes that I think would be beneficial, but since they would be a bit of work to implement (I'm happy to do 1 or 2 PRs for this), I wanted to make sure no one was absolutely against them.
I would propose instead to use
Although an advanced user can import whatever they want, I think helping beginners to use the namespace would be beneficial. And in the docs seeing that
run_sorter
is part ofss
which is the alias ofsorters
will help them find their way around the documentation by knowing which module to go to if they aren't sure where a function came from.This is a bit more verbose, but it encourages good function practices and if something goes wrong it will help them generate issues on the tracker/ search through the source code to see what is going on.
But do let me know if anyone is completely against adding these features to the docs. Otherwise I'll get started working on some of those updates when I have some free time.
The text was updated successfully, but these errors were encountered: