Skip to content

Commit

Permalink
Merge ab8c8db into d47704a
Browse files Browse the repository at this point in the history
  • Loading branch information
ajduberstein committed Sep 26, 2019
2 parents d47704a + ab8c8db commit 9148842
Show file tree
Hide file tree
Showing 31 changed files with 763 additions and 706 deletions.
Expand Up @@ -154,3 +154,4 @@ $RECYCLE.BIN/
**/pydeck/nbextension/static/index.js.map
**/pydeck/nbextension/static/extensionRequires.js
**/pydeck/io/templates/requirejs_dependencies.json
**/_build
2 changes: 1 addition & 1 deletion bindings/python/pydeck/README.md
Expand Up @@ -42,7 +42,7 @@ UK_ACCIDENTS_DATA = 'https://raw.githubusercontent.com/uber-common/deck.gl-data/
layer = pdk.Layer(
'HexagonLayer',
UK_ACCIDENTS_DATA,
get_position='[lng,lat]',
get_position='[lng, lat]',
auto_highlight=True,
elevation_scale=50,
pickable=True,
Expand Down
19 changes: 19 additions & 0 deletions bindings/python/pydeck/docs/Makefile
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
19 changes: 0 additions & 19 deletions bindings/python/pydeck/docs/README.md

This file was deleted.

40 changes: 40 additions & 0 deletions bindings/python/pydeck/docs/conf.py
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# Point Sphinx autodoc at our source
import sys
import os

sys.path.insert(0, os.path.abspath('../'))

project = u'pydeck'
copyright = u'2019, Uber Technologies, Inc.'
author = u'Andrew Duberstein'
# The short X.Y version
version = u''
# The full version, including alpha/beta/rc tags
release = u'0.1.dev4'
# Extensions to generate documents from our docstrings here
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon'
]
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
language = None
exclude_patterns = [u'_build']
pygments_style = None
html_theme = 'alabaster'
html_static_path = ['_static']
htmlhelp_basename = 'pydeckdoc'
man_pages = [
(master_doc, 'pydeck', u'pydeck Documentation',
[author], 1)
]
texinfo_documents = [
(master_doc, 'pydeck', u'pydeck Documentation',
author, 'pydeck', 'One line description of project.',
'Miscellaneous'),
]
epub_title = project
epub_exclude_files = ['search.html']
autoclass_content = "both"
113 changes: 0 additions & 113 deletions bindings/python/pydeck/docs/data_utils.md

This file was deleted.

74 changes: 74 additions & 0 deletions bindings/python/pydeck/docs/data_utils.rst
@@ -0,0 +1,74 @@
Data utilities
==============

These items are convenience functions for common data processing work done for pydeck maps.

.. autofunction:: pydeck.data_utils.viewport_helpers.compute_view

For example, suppose you have 100 points, most of which are centered
around London and ten of which are distributed a few 100 kilometers away
from it. If you set ``view_proportion=0.9``, pydeck will attempt to fit
to the middle 90% of the data, aiming to exclude the points furthest
from the core of the visualization. Suppose your ten points
are in the Americas in this example--they would be excluded.

.. autofunction:: pydeck.data_utils.color_scales.assign_random_colors


Examples
--------

Below is an illustration of :func:`pydeck.data_utils.color_scales.assign_random_colors`,
using a small data set of two classes (here, 'Palace' and 'Clock Tower)
and three obervations ('Big Ben', 'Kensington Palace', and 'Buckingham Palace').
Our goal is to quickly color the data by category.

>>> import pydeck
>>> import pandas
>>> data = pandas.DataFrame([
>>> {
>>> 'site': 'Big Ben',
>>> 'attraction_type': 'Clock Tower',
>>> 'lat': 51.5006958,
>>> 'lng': -0.1266639
>>> },
>>> {
>>> 'site': 'Kensington Palace',
>>> 'attraction_type': 'Palace':
>>> 'lat': 51.5046188,
>>> 'lng': -0.1839472
>>> },
>>> {
>>> 'attraction_type': 'Palace',
>>> 'site': 'Buckingham Palace',
>>> 'lat': 51.501364,
>>> 'lng': -0.14189
>>> }
>>> ])
>>> color_lookup = pydeck.data_utils.assign_random_colors(data['attraction_type'])
>>> # Assign a color based on attraction_type
>>> data['color'] = data.apply(lambda row: color_lookup.get(row['attraction_type']), axis=1)
>>> # Data now has an RGB color by attraction type:
[
{
'site': 'Big Ben',
'attraction_type': 'Clock Tower',
'lat': 51.5006958,
'lng': -0.1266639,
'color': [0, 10, 35]
},
{
'site': 'Kensington Palace',
'attraction_type': 'Palace':
'lat': 51.5046188,
'lng': -0.1839472,
'color': [53, 243, 130]
},
{
'attraction_type': 'Palace',
'site': 'Buckingham Palace',
'lat': 51.501364,
'lng': -0.14189,
'color': [53, 243, 130]
}
]

0 comments on commit 9148842

Please sign in to comment.