Skip to content

Commit

Permalink
pydeck: Update documentation for 0.2.0 (#4102)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajduberstein committed Jan 6, 2020
1 parent 4578dcb commit c482053
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .readthedocs.yml
Expand Up @@ -7,9 +7,9 @@ version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: bindings/python/pydeck/docs/conf.py
configuration: bindings/pydeck/docs/conf.py

# Optionally set the version of Python and requirements required to build your docs
python:
install:
- requirements: bindings/python/pydeck/requirements-dev.txt
- requirements: bindings/pydeck/requirements-dev.txt
2 changes: 1 addition & 1 deletion bindings/pydeck/LICENSE.txt
@@ -1,4 +1,4 @@
Copyright (c) 2019 Uber Technologies Inc.
Copyright (c) 2020 Uber Technologies Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
4 changes: 2 additions & 2 deletions bindings/pydeck/docs/conf.py
Expand Up @@ -6,7 +6,7 @@
sys.path.insert(0, os.path.abspath('../'))

project = u'pydeck'
copyright = u'2019, Uber Technologies, Inc.'
copyright = u'2020, Uber Technologies, Inc.'
author = u'Andrew Duberstein'
# The short X.Y version
version = u''
Expand All @@ -32,7 +32,7 @@
]
texinfo_documents = [
(master_doc, 'pydeck', u'pydeck Documentation',
author, 'pydeck', 'One line description of project.',
author, 'pydeck', 'Python wrapper for deck.gl',
'Miscellaneous'),
]
epub_title = project
Expand Down
4 changes: 2 additions & 2 deletions bindings/pydeck/docs/layer.rst
Expand Up @@ -57,7 +57,7 @@ HexagonLayer <https://deck.gl/#/examples/core-layers/hexagon-layer>`__:
layer = pdk.Layer(
'HexagonLayer', # `type` positional argument is here
UK_ACCIDENTS_DATA,
get_position='[lng, lat]',
get_position=['lng', 'lat'],
auto_highlight=True,
elevation_scale=50,
pickable=True,
Expand Down Expand Up @@ -91,7 +91,7 @@ Try changing ``type`` above to ``ScatterplotLayer`` and add some
layer = pdk.Layer(
'ScatterplotLayer', # Change the `type` positional argument here
UK_ACCIDENTS_DATA,
get_position='[lng, lat]',
get_position=['lng', 'lat'],
auto_highlight=True,
get_radius=1000, # Radius is given in meters
get_fill_color=[180, 0, 200, 140], # Set an RGBA value for fill
Expand Down
4 changes: 3 additions & 1 deletion bindings/pydeck/pydeck/bindings/deck.py
Expand Up @@ -55,6 +55,7 @@ def __init__(
For more advanced usage, the user can pass a dict to configure more custom tooltip features.
Documentation on this is available `in the hosted pydeck documentation <tooltip.html>`_.
.. _Deck:
https://deck.gl/#/documentation/deckgl-api-reference/deck
.. _gallery:
Expand Down Expand Up @@ -129,7 +130,8 @@ def to_html(
Returns
-------
str : Returns absolute path of the file
str
Returns absolute path of the file
"""
json_blob = self.to_json()
f = deck_to_html(
Expand Down
5 changes: 5 additions & 0 deletions bindings/pydeck/pydeck/bindings/json_tools.py
Expand Up @@ -14,6 +14,11 @@ def to_camel_case(snake_case):
-----------
snake_case : str
Snake-cased string (e.g., "snake_cased") to be converted to camel-case (e.g., "camelCase")
Returns
-------
str
Camel-cased (e.g., "camelCased") version of input string
"""
output_str = ''
should_upper_case = False
Expand Down
4 changes: 2 additions & 2 deletions bindings/pydeck/pydeck/bindings/layer.py
Expand Up @@ -50,7 +50,7 @@ def __init__(
>>> layer = pydeck.Layer(
>>> 'HexagonLayer',
>>> UK_ACCIDENTS_DATA,
>>> get_position='[lng, lat]',
>>> get_position=['lng', 'lat'],
>>> auto_highlight=True,
>>> elevation_scale=50,
>>> pickable=True,
Expand All @@ -65,7 +65,7 @@ def __init__(
>>> layer = pydeck.Layer(
>>> 'HexagonLayer',
>>> df,
>>> get_position='[lng, lat]',
>>> get_position=['lng', 'lat'],
>>> auto_highlight=True,
>>> elevation_scale=50,
>>> pickable=True,
Expand Down
6 changes: 4 additions & 2 deletions bindings/pydeck/pydeck/data_utils/color_scales.py
Expand Up @@ -7,7 +7,8 @@ def get_random_rgb():
Returns
-------
list of float : Random RGB array
list of float
Random RGB array
"""
return [round(random.random()*255) for _ in range(0, 3)]

Expand All @@ -22,7 +23,8 @@ def assign_random_colors(data_vector):
Returns
-------
collections.OrderedDict : Dictionary of random RGBA value per class, keyed on class
collections.OrderedDict
Dictionary of random RGBA value per class, keyed on class
"""
deduped_classes = list(set(data_vector))
classes = sorted([str(x) for x in deduped_classes])
Expand Down
7 changes: 6 additions & 1 deletion bindings/pydeck/pydeck/data_utils/type_checking.py
@@ -1,9 +1,14 @@
def is_pandas_df(obj):
"""Check if an object is a Pandas dataframe
"""Check if an object is a Pandas DataFrame
The benefit here is that Pandas doesn't have to be included
in the dependencies for pydeck
The drawback of course is that the Pandas API might change and break this function
Returns
-------
bool
Returns True if object is a Pandas DataFrame and False otherwise
"""
return obj.__class__.__module__ == 'pandas.core.frame' and obj.to_records and obj.to_dict
18 changes: 12 additions & 6 deletions bindings/pydeck/pydeck/data_utils/viewport_helpers.py
Expand Up @@ -41,7 +41,8 @@ def geometric_mean(points):
Returns
-------
tuple : The centroid of a list of points
tuple
The centroid of a list of points
"""
avg_x = sum([float(p[0]) for p in points]) / len(points)
avg_y = sum([float(p[1]) for p in points]) / len(points)
Expand All @@ -58,7 +59,8 @@ def get_bbox(points):
Returns
-------
dict: Dictionary containing the top left and bottom right points of a bounding box
dict
Dictionary containing the top left and bottom right points of a bounding box
"""
xs = [p[0] for p in points]
ys = [p[1] for p in points]
Expand All @@ -83,7 +85,8 @@ def k_nearest_neighbors(points, center, k):
Returns
-------
list: Index of the k furthest points
list
Index of the k furthest points
Todo
---
Expand All @@ -106,7 +109,8 @@ def get_n_pct(points, proportion=1):
Returns
-------
list: k nearest data points
list
k nearest data points
"""
if proportion == 1:
return points
Expand All @@ -127,7 +131,8 @@ def bbox_to_zoom_level(bbox):
Returns
-------
int : Zoom level of map in a WGS84 Mercator projection (e.g., like that of Google Maps)
int
Zoom level of map in a WGS84 Mercator projection (e.g., like that of Google Maps)
"""
lat_diff = max(bbox[0][0], bbox[1][0]) - min(bbox[0][0], bbox[1][0])
lng_diff = max(bbox[0][1], bbox[1][1]) - min(bbox[0][1], bbox[1][1])
Expand Down Expand Up @@ -158,7 +163,8 @@ def compute_view(points, view_proportion=1, view_type=ViewState):
Returns
-------
pydeck.Viewport : Viewport fitted to the data
pydeck.Viewport
Viewport fitted to the data
"""
if is_pandas_df(points):
points = points.to_records(index=False)
Expand Down
2 changes: 1 addition & 1 deletion scripts/bindings-precommit-hook.sh
@@ -1,5 +1,5 @@
#!/bin/bash
IS_PYTHON=$(git diff --cached --name-only | grep "bindings/python/")
IS_PYTHON=$(git diff --cached --name-only | grep "python/pydeck")
HAS_PYTEST=$(command -v pytest)

if [[ -n "$IS_PYTHON" ]]; then
Expand Down

0 comments on commit c482053

Please sign in to comment.