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

pydeck: Additional formatting updates #4905

Merged
merged 2 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions bindings/pydeck/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@
htmlhelp_basename = "pydeckdoc"
man_pages = [(master_doc, "pydeck", "pydeck Documentation", [author], 1)]
texinfo_documents = [
(master_doc, "pydeck", "pydeck Documentation", author, "pydeck", "Python wrapper for deck.gl", "Miscellaneous",),
(
master_doc,
"pydeck",
"pydeck Documentation",
author,
"pydeck",
"Python wrapper for deck.gl",
"Miscellaneous",
),
]
epub_title = project
epub_exclude_files = ["search.html"]
Expand All @@ -42,7 +50,8 @@ def setup(app):
master_doc = "pydeck_redirect"
if not os.environ.get("PYDECK_DEV_PORT"):
subprocess.call(
"{python} scripts/embed_examples.py".format(python=sys.executable), shell=True,
"{python} scripts/embed_examples.py".format(python=sys.executable),
shell=True,
)
else:
print("PYDECK_DEV_PORT is set, skipping layer.rst conversions")
5 changes: 4 additions & 1 deletion bindings/pydeck/docs/scripts/embed_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def create_rst(pydeck_example_file_name):
# Run the pydeck example and move the .html output
subprocess.call(
"{python} {fname}; mv {html_src} {html_dest}".format(
python=sys.executable, fname=pydeck_example_file_name, html_src=html_fname, html_dest=HTML_DIR,
python=sys.executable,
fname=pydeck_example_file_name,
html_src=html_fname,
html_dest=HTML_DIR,
),
shell=True,
)
Expand Down
10 changes: 8 additions & 2 deletions bindings/pydeck/docs/scripts/snap_thumbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ async def run(cmd):


async def snap(fname):
browser = await launch(autoClose=False, headless=False, args=["--no-sandbox", "--disable-web-security"],)
browser = await launch(
autoClose=False,
headless=False,
args=["--no-sandbox", "--disable-web-security"],
)
page = await browser.newPage()
print("[info] Converting %s to an image" % fname)
await run(" ".join(["python", fname]))
Expand All @@ -45,7 +49,9 @@ async def snap(fname):
await asyncio.sleep(10)
else:
await page.goto(
fpath, waitUntil=["load", "networkidle2", "networkidle0"], timeout=30000,
fpath,
waitUntil=["load", "networkidle2", "networkidle0"],
timeout=30000,
)
await page.screenshot({"path": png_fname})
print("[info] Sucessfully converted %s to a png at %s" % (fname, png_fname))
Expand Down
2 changes: 1 addition & 1 deletion bindings/pydeck/docs/scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def to_presentation_name(s):
"""Convert a snake_case string to a camelCase string (if a layer or view)
or just a standard title"""
or just a standard title"""
# Format deck.gl layer names from their file names
if "layer" in s or "view" in s:
return s.replace("_", " ").title().replace(" ", "").replace("json", "Json")
Expand Down
8 changes: 7 additions & 1 deletion bindings/pydeck/examples/arc_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ def in_bounding_box(point):
auto_highlight=True,
)

view_state = pdk.ViewState(latitude=37.7576171, longitude=-122.5776844, bearing=45, pitch=50, zoom=8,)
view_state = pdk.ViewState(
latitude=37.7576171,
longitude=-122.5776844,
bearing=45,
pitch=50,
zoom=8,
)


TOOLTIP_TEXT = {"html": "{S000} jobs <br /> Home of commuter in red; work location in green"}
Expand Down
9 changes: 8 additions & 1 deletion bindings/pydeck/examples/binary_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ def generate_graph_data(num_nodes, random_seed):

def make_renderer(nodes, use_binary_transport=False):
"""Creates the pydeck visualization for rendering"""
view_state = pydeck.ViewState(offset=[0, 0], latitude=None, longitude=None, bearing=None, pitch=None, zoom=10,)
view_state = pydeck.ViewState(
offset=[0, 0],
latitude=None,
longitude=None,
bearing=None,
pitch=None,
zoom=10,
)

views = [pydeck.View(type="OrbitView", controller=True)]

Expand Down
8 changes: 7 additions & 1 deletion bindings/pydeck/examples/bitmap_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@

bitmap_layer = pdk.Layer("BitmapLayer", data=None, image=IMG_URL, bounds=BOUNDS, opacity=0.7)

view_state = pdk.ViewState(latitude=37.7576171, longitude=-122.5776844, zoom=10, bearing=-45, pitch=60,)
view_state = pdk.ViewState(
latitude=37.7576171,
longitude=-122.5776844,
zoom=10,
bearing=-45,
pitch=60,
)

r = pdk.Deck(bitmap_layer, initial_view_state=view_state, map_style=pdk.map_styles.SATELLITE)

Expand Down
5 changes: 4 additions & 1 deletion bindings/pydeck/examples/column_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
}

r = pydeck.Deck(
column_layer, initial_view_state=view, tooltip=tooltip, map_style="mapbox://styles/mapbox/satellite-v9",
column_layer,
initial_view_state=view,
tooltip=tooltip,
map_style="mapbox://styles/mapbox/satellite-v9",
)

r.to_html("column_layer.html", notebook_display=False)
6 changes: 5 additions & 1 deletion bindings/pydeck/examples/geopandas_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
centroids["name"] = world.name

layers = [
pdk.Layer("GeoJsonLayer", data=world, get_fill_color=[0, 0, 0],),
pdk.Layer(
"GeoJsonLayer",
data=world,
get_fill_color=[0, 0, 0],
),
pdk.Layer(
"TextLayer",
data=centroids,
Expand Down
7 changes: 6 additions & 1 deletion bindings/pydeck/examples/globe_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ def is_green(fuel_type):

layers = [
pdk.Layer(
"GeoJsonLayer", id="base-map", data=COUNTRIES, stroked=False, filled=True, get_fill_color=[200, 200, 200],
"GeoJsonLayer",
id="base-map",
data=COUNTRIES,
stroked=False,
filled=True,
get_fill_color=[200, 200, 200],
),
pdk.Layer(
"ColumnLayer",
Expand Down
6 changes: 5 additions & 1 deletion bindings/pydeck/examples/great_circle_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
view_state = pdk.ViewState(latitude=50, longitude=-40, zoom=1, bearing=0, pitch=0)

# Render
r = pdk.Deck(layers=[layer], initial_view_state=view_state, tooltip={"text": "{from_name} to {to_name}"},)
r = pdk.Deck(
layers=[layer],
initial_view_state=view_state,
tooltip={"text": "{from_name} to {to_name}"},
)
r.picking_radius = 10

r.to_html("great_circle_layer.html")
14 changes: 12 additions & 2 deletions bindings/pydeck/examples/grid_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,21 @@
# Define a layer to display on a map

layer = pdk.Layer(
"GridLayer", df, pickable=True, extruded=True, cell_size=200, elevation_scale=4, get_position="COORDINATES",
"GridLayer",
df,
pickable=True,
extruded=True,
cell_size=200,
elevation_scale=4,
get_position="COORDINATES",
)

view_state = pdk.ViewState(latitude=37.7749295, longitude=-122.4194155, zoom=11, bearing=0, pitch=45)

# Render
r = pdk.Deck(layers=[layer], initial_view_state=view_state, tooltip={"text": "{position}\nCount: {count}"},)
r = pdk.Deck(
layers=[layer],
initial_view_state=view_state,
tooltip={"text": "{position}\nCount: {count}"},
)
r.to_html("grid_layer.html")
8 changes: 7 additions & 1 deletion bindings/pydeck/examples/hexagon_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@

# Set the viewport location
view_state = pdk.ViewState(
longitude=-1.415, latitude=52.2323, zoom=6, min_zoom=5, max_zoom=15, pitch=40.5, bearing=-27.36,
longitude=-1.415,
latitude=52.2323,
zoom=6,
min_zoom=5,
max_zoom=15,
pitch=40.5,
bearing=-27.36,
)

# Render
Expand Down
6 changes: 5 additions & 1 deletion bindings/pydeck/examples/s2_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@
view_state = pdk.ViewState(latitude=37.7749295, longitude=-122.4194155, zoom=11, bearing=0, pitch=45)

# Render
r = pdk.Deck(layers=[layer], initial_view_state=view_state, tooltip={"text": "{token} value: {value}"},)
r = pdk.Deck(
layers=[layer],
initial_view_state=view_state,
tooltip={"text": "{token} value: {value}"},
)
r.to_html("s2_layer.html", notebook_display=False)
3 changes: 2 additions & 1 deletion bindings/pydeck/pydeck/bindings/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def __init__(
self.deck_widget.map_provider = map_provider
if self.mapbox_key is None and self.map_provider == Providers.MAPBOX:
warnings.warn(
"Mapbox API key is not set. This may impact available features of pydeck.", UserWarning,
"Mapbox API key is not set. This may impact available features of pydeck.",
UserWarning,
)
self.parameters = parameters

Expand Down
14 changes: 11 additions & 3 deletions bindings/pydeck/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def has_build_utilities(self):

def copy_frontend_build(self):
"""Copy JS bundle from top-level JS module to pydeck widget's `static/` folder.
Overwrites destination files"""
Overwrites destination files"""
js_dist_dir = os.path.join(widget_dir, "dist")
nbextension_folder = os.path.join(here, "pydeck", "nbextension", "static")
js_files = [
Expand All @@ -124,12 +124,20 @@ def run(self):
if build_all:
log.info("Installing build dependencies with yarn. This may take a while...")
check_call(
["yarn", "bootstrap"], cwd=yarn_root, stdout=sys.stdout, stderr=sys.stderr, env=env,
["yarn", "bootstrap"],
cwd=yarn_root,
stdout=sys.stdout,
stderr=sys.stderr,
env=env,
)
else:
log.info("Installing build dependencies with `npm run build`.")
check_call(
["npm", "run", "build"], cwd=widget_dir, stdout=sys.stdout, stderr=sys.stderr, env=env,
["npm", "run", "build"],
cwd=widget_dir,
stdout=sys.stdout,
stderr=sys.stderr,
env=env,
)

self.clean_frontend_build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def create_heatmap_test_object():
)
# This will render
successful_heatmap_layer = Layer(
type="HeatmapLayer", id="successful-heatmap", data=data, get_position=["lon", "lat"], color_range=color_range,
type="HeatmapLayer",
id="successful-heatmap",
data=data,
get_position=["lon", "lat"],
color_range=color_range,
)

return Deck(
Expand Down
4 changes: 3 additions & 1 deletion bindings/pydeck/tests/bindings/pydeck_examples/minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

def create_minimal_test_object():
lights = LightSettings(
lights_position=[-0.144528, 49.739968, 8000, -3.807751, 54.104682, 8000], ambient_ratio=0.4, diffuse_ratio=0.6,
lights_position=[-0.144528, 49.739968, 8000, -3.807751, 54.104682, 8000],
ambient_ratio=0.4,
diffuse_ratio=0.6,
)
layer = Layer(
"HexagonLayer",
Expand Down
7 changes: 6 additions & 1 deletion bindings/pydeck/tests/bindings/pydeck_examples/stacked.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
def create_stacked_test_object():
view_state = ViewState(max_zoom=20, zoom=15)
scatterplot = Layer(
"ScatterplotLayer", data=data, get_position="position", get_radius=100, id="first", getColor="rgb",
"ScatterplotLayer",
data=data,
get_position="position",
get_radius=100,
id="first",
getColor="rgb",
)
text_layer = Layer(
"TextLayer",
Expand Down
7 changes: 6 additions & 1 deletion bindings/pydeck/tests/bindings/test_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

def test_constructor_binary_transport():
test_layer = Layer(
"ScatterplotLayer", data=df, id="test-layer", use_binary_transport=True, get_position="position", radius=10,
"ScatterplotLayer",
data=df,
id="test-layer",
use_binary_transport=True,
get_position="position",
radius=10,
)
EXPECTED_DATUM = {
"layer_id": "test-layer",
Expand Down