Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Duberstein committed Jan 17, 2020
1 parent 6440fbf commit c886eb5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
38 changes: 1 addition & 37 deletions bindings/pydeck/pydeck/data_utils/binary_transfer.py
@@ -1,7 +1,5 @@
import numpy as np

from .type_checking import is_pandas_df

# Grafted from
# https://github.com/maartenbreddels/ipyvolume/blob/d13828dfd8b57739004d5daf7a1d93ad0839ed0f/ipyvolume/serialize.py#L219
def array_to_binary(ar, obj=None, force_contiguous=True):
Expand Down Expand Up @@ -36,40 +34,6 @@ def serialize_columns(data_set_cols, obj=None):
return payload


def deserialize_columns(value, obj=None):
pass


def binary_to_array(value, obj=None):
return np.frombuffer(value["data"], dtype=value["dtype"]).reshape(value["shape"])


def convert_df_to_matrix(df, obj=None, force_contiguous=True):
"""
Flattens a pandas.DataFrame into a row-major format array
In this implementation, `position` | `color`
lng | lat | r | g | b
----+-----+---+---+---
0.0 0.0 140 5 5
-1.0 1.0 100 10 10
becomes
[[0.0, 0.0, 140, 5, 5], [-1.0, 1.0, 100, 10, 10]]
"""
if df is None or not is_pandas_df(df):
return None
matrix = df.values
try:
return array_to_binary(matrix)
except ValueError as e:
raise Exception("Binary conversion failed with message:", e)


array_seralization = dict(to_json=array_to_binary, from_json=None)
data_buffer_serialization = dict(
to_json=serialize_columns, from_json=deserialize_columns
to_json=serialize_columns, from_json=None
)
11 changes: 0 additions & 11 deletions bindings/pydeck/pydeck/data_utils/type_checking.py
Expand Up @@ -12,14 +12,3 @@ def is_pandas_df(obj):
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


def is_numpy_array(obj):
"""Check if an object is a numpy array
Returns
-------
bool
Returns True if object is a numpy array, False otherwise
"""
return 'numpy.ndarray' in str(obj.__class__) and obj.to_list

0 comments on commit c886eb5

Please sign in to comment.