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

Updated various notebooks to use opts #3315

Merged
merged 24 commits into from Dec 21, 2018
Merged

Updated various notebooks to use opts #3315

merged 24 commits into from Dec 21, 2018

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented Dec 18, 2018

User guides

  • 04 - Style Mapping
  • 05 - Building Composite objects
  • 06 - Live Data
  • 07 - Tabular Data
  • 08 - Gridded Data
  • 09 - Indexing and Selecting
  • 10 - Transforming Elements
  • 12 - Custom Interactivity
  • 13 - Data Pipelines
  • 14 - Large Data
  • 15 - Streaming Data
  • 16 - Dashboards
  • Network Graphs
  • Plotting with Bokeh
  • Plotting with Matplotlib
  • Colormaps
  • Continuous Coordinates
  • Geometry data
  • Styling Plots
  • Linking Plots

@philippjfr philippjfr added the type: docs Related to the documentation and examples label Dec 18, 2018
"sample_style = dict(edgecolors='k', alpha=1)\n",
"all_samples = obs_hmap.collapse().to.scatter3d().options(alpha=0.15, xticks=4)\n",
"sampled = obs_hmap.sample((3,3))\n",
"subsamples = sampled.to.scatter3d().options(**sample_style)\n",
"subsamples = sampled.to.scatter3d().opts(**sample_style)\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dict should be made into keywords and should be split onto a separate line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're reused at least twice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case make a single options object with an options builder and reuse that.

"sampled = obs_hmap.sample((3,3), bounds=(2,5,5,10))\n",
"subsamples = sampled.to.scatter3d().options(**dict(sample_style, xticks=4))\n",
"subsamples = sampled.to.scatter3d().opts(**dict(sample_style, xticks=4))\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**dict seems unnecessary...

" streams.Stream.define('Time', time=1.0)(),\n",
" streams.PointerX().rename(x='limit')]\n",
"\n",
"integral_dmap = hv.DynamicMap(integral, streams=integral_streams)\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to call the dynamicmap integral and the callback something else...e.g integral_X or X_integral where X is descriptive..

"%%opts RGB [width=300] {+axiswise}\n",
"\n",
"datashade(hv.HoloMap(gaussians, kdims='k')) + datashade(hv.HoloMap(lines, 'k'))"
"(datashade(hv.HoloMap(gaussians, kdims='k')) + datashade(hv.HoloMap(lines, 'k'))).opts(opts.RGB(framewise=True))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be given a handle with .opts on another line.

@@ -72,9 +72,9 @@
" n = len(cms)*1.0\n",
" c=ceil(n/cols) if n>cols else cols\n",
" bars = [hv.Image(spacing, ydensity=1, label=\"{0} ({1})\".format(r.name,r.provider))\\\n",
" .options(cmap=process_cmap(r.name,provider=r.provider), **opts)\n",
" .opts(cmap=process_cmap(r.name,provider=r.provider), **opt_kwargs)\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would prefer to inline those options instead of using **.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems way too long in this case.

"\n",
"np.set_printoptions(precision=2, linewidth=80)\n",
"hv.Dimension.type_formatters[np.float64] = '%.2f'\n",
"%opts HeatMap (cmap=\"hot\")"
"opts.defaults(opts.HeatMap(cmap='fire'), opts.Layout(shared_axes=False))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opts.defaults should general be formatted like .opts with entries on newlines (when you have more than one)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's sensible for one or two keywords defaults.

"hv.extension('bokeh')"
"hv.extension('bokeh')\n",
"\n",
"opts.defaults(opts.Path(padding=0.1), opts.Polygons(padding=0.1))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment.

"%%opts Graph [color_index='circle']\n",
"%%opts Graph (node_size=10 edge_line_width=1)\n",
"kwargs = dict(width=800, height=800, xaxis=None, yaxis=None)\n",
"opts.defaults(opts.Nodes(**kwargs), opts.Graph(**kwargs))\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either the keywords should be inlined here, or in this case make explicit options objects with the builders (assuming there are lots of kwargs).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't agree with inlining, this avoids duplication. Don't quite follow the second suggestion.

@@ -186,9 +180,9 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Image [xaxis='bare', yaxis='bare' show_title=False, colorbar=True] (cmap='fire')\n",
"%%output holomap='mp4'\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%%output can be removed.

@jlstevens
Copy link
Contributor

@philippjfr Thanks for updating all these!

I'm happy to see all the magics removed. Most of my comments are about following the guidelines we are recommending people use when using options. In the customization user guide we state that we are following these guidelines so my comments are trying to make sure that is true...

@jlstevens
Copy link
Contributor

Thanks for updating these guides and implementing the suggestions. There may always be some minor tweaks in subsequent PRs but the main thing is to get rid of the magics. Merging.

@jlstevens jlstevens merged commit 7bde402 into master Dec 21, 2018
@philippjfr philippjfr deleted the doc_updates branch April 29, 2019 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: docs Related to the documentation and examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants