spacetelescope / style-guides

An opinionated guide on how we work.
Creative Commons Attribution 4.0 International
55 stars 33 forks source link

Notebook guide enhancements #39

Closed eteq closed 6 years ago

eteq commented 6 years ago

This makes a substantial set of changes to the notebook style guide. Aside from modification of text to inject @eteq's Opinions in a variety of places, there are a couple substantive structural changes, including:

I tried to keep these pieces as fairly atomic commits so can revert them if anyone disagrees with one of them...

cc @arfon @ivastar

pllim commented 6 years ago

Haven't had the chance to catch up on all the reading, so perhaps my two questions below are already answered...

  1. Are all imports at the beginning really ideal? I was told by a different source that it is better to import when used.
  2. Is it better to add notebooks to repo with outputs cleared or pre-populated?
arfon commented 6 years ago

Responding to @pllim:

Are all imports at the beginning really ideal? I was told by a different source that it is better to import when used.

IMO having them at the top makes it clearer what packages are being used within the notebook so it's preferable from a usability standpoint?

Is it better to add notebooks to repo with outputs cleared or pre-populated?

As mentioned in the guide (but not yet reality), we're planning on compiling these as the Astropy tutorials repo does which means we'd encourage people to read the compiled/executed versions on Readthedocs.

pllim commented 6 years ago

IMO having them at the top makes it clearer what packages are being used within the notebook so it's preferable from a usability standpoint?

Perhaps for static ones. In my experience, when I update a notebook, if all the imports are on top, and I have to add a new import, then I have to scroll all the way up to add it. If I remove a cell, I have to remember to scroll all the way up to delete the import. 🤷‍♀️

eteq commented 6 years ago

Re: @pllim's

Perhaps for static ones. In my experience, when I update a notebook, if all the imports are on top, and I have to add a new import, then I have to scroll all the way up to add it. If I remove a cell, I have to remember to scroll all the way up to delete the import.

I see this point. This guide is generally for "notebooks that are meant to be presented", but it's a valid point that there's a use case of "notebooks that capture an actual real analysis workflow". In that case, it's often a practical choice to do just what @pllim says.

eteq commented 6 years ago

Because I think what's in here is still true for the "presented" case, I think I'm going to merge this - some other folks looking at the guide for some imminent work I think will want to see this content.

But @pllim, do you think you can either make an issue, or better yet a PR, that adds some words along the lines of what you suggested? That way we can have this discussion but not have it hold up the other stuff.

pllim commented 6 years ago

@eteq , I barely do any "real analysis" nowadays. I don't have motivation to follow up on it. Whatever is here is fine. 😄