Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Animations/Frames in Python API #584

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

Merged
merged 27 commits into from
Nov 26, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cb4552c
iplot in offline works with frames
Kully Oct 18, 2016
b4c3953
updated js version in plotly offline
Kully Oct 19, 2016
54c1386
added Andrew's #586 PR
Kully Oct 20, 2016
d19c6ca
added some print statements to check progresses
Kully Oct 21, 2016
efa390e
__init__.py now accepts create_animations which lives in plotly.py --…
Kully Oct 28, 2016
eb57218
rewrote create_animations to take frames - still beta
Kully Nov 3, 2016
5482b53
merged master offline.py to local - changed call signature in one func
Kully Nov 3, 2016
b2b8451
tests
Kully Nov 3, 2016
a156503
added create_animations so v2 is hit if frames is in fig
Kully Nov 4, 2016
d173cbb
create_animations to bad_create_animations
Kully Nov 8, 2016
d17a222
added function to spit out uids from column names
Kully Nov 14, 2016
49bdc97
made get_grid() to pull grid from cloud and added method in Grid clas…
Kully Nov 15, 2016
4fbdc99
cleaned up url parsing + moved json_to_grid functionality to __init__…
Kully Nov 16, 2016
dbb386f
fixed order upon creating Grid
Kully Nov 17, 2016
bd2132b
accounted for orders with jump discontinuities
Kully Nov 18, 2016
26c3714
moved all_columns list where appropriate - above code block that uses it
Kully Nov 19, 2016
0c7bb1c
...
Kully Nov 24, 2016
4acc146
commented out fid stuff
Kully Nov 24, 2016
c195e78
merged master into branch
Kully Nov 24, 2016
6f12ba8
delete print lines from debugging
Kully Nov 24, 2016
253228f
grid_id is set to grids created via get_grid
Kully Nov 24, 2016
405e71d
add 'Frames' to grid_objs_test
Kully Nov 24, 2016
c1727d8
removed commented out code for old get_uid code
Kully Nov 24, 2016
fca8fed
added animations function
Kully Nov 24, 2016
587dfa5
Chris' comments sans tests
Kully Nov 25, 2016
495b015
changed some terminology around
Kully Nov 26, 2016
dd20177
last of non-blocking
Kully Nov 26, 2016
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
Prev Previous commit
Next Next commit
grid_id is set to grids created via get_grid
  • Loading branch information
Kully committed Nov 24, 2016
commit 253228fe9f8b64f80c65bf4d795ca701cd1fa2d1
26 changes: 20 additions & 6 deletions plotly/grid_objs/grid_objs.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,17 @@ class Grid(MutableSequence):
py.plot([trace], filename='graph from grid')
```
"""
def __init__(self, columns_or_json):
def __init__(self, columns_or_json, grid_id=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, can we call this fid?

"""
Initialize a grid with an iterable of `plotly.grid_objs.Column`
objects or a json/dict describing a grid. See second usage example
below for the necessary structure of the dict.

:param (str|bool) grid_id: should not be accessible to users. Default
is 'None' but if a grid is retrieved via `py.get_grid()` then the
retrieved grid response will contain the grid_id which will be
necessary to set `self.id` and `self._columns.id` below.

Example from iterable of columns:
```
column_1 = Column([1, 2, 3], 'time')
Expand All @@ -141,9 +146,19 @@ def __init__(self, columns_or_json):
grid = Grid(grid_json)
Copy link
Contributor

Choose a reason for hiding this comment

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

💥 🎎 :)

```
"""

# TODO: verify that columns are actually columns
if isinstance(columns_or_json, dict):
# check that grid_id is entered
if grid_id is None:
raise exceptions.PlotlyError(
"If you are manually converting a raw json/dict grid "
"into a Grid instance, you must ensure that make "
Copy link
Contributor

Choose a reason for hiding this comment

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

🐐 ensure that make

"'grid_id' is set to your file ID. This looks like "
"'username:187'."
)
# TODO: verify that grid_id is a correct fid if a string
self.id = grid_id
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, can we call this self.fid?


# check if 'cols' is a root key
if 'cols' not in columns_or_json:
raise exceptions.PlotlyError(
Expand Down Expand Up @@ -182,7 +197,8 @@ def __init__(self, columns_or_json):

# fill in uids
Copy link
Contributor

Choose a reason for hiding this comment

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

🎎 uids --> column_ids.

for column in self:
column.id = columns_or_json['cols'][column.name]['uid']
column.id = self.id + ':' + columns_or_json['cols'][column.name]['uid']
Copy link
Contributor

Choose a reason for hiding this comment

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

🐄 we typically use format i think. non-blocking


else:
column_names = [column.name for column in columns_or_json]
duplicate_name = utils.get_first_duplicate(column_names)
Expand All @@ -193,8 +209,6 @@ def __init__(self, columns_or_json):
self._columns = list(columns_or_json)
self.id = ''

#self._fid = ''

def __repr__(self):
return self._columns.__repr__()

Expand Down Expand Up @@ -241,7 +255,7 @@ def get_column(self, column_name):
if column.name == column_name:
return column

def get_uid(self, column_name):
def get_fid_uid(self, column_name):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it called get_fid_uid? Maybe just get_uid? Also, are users supposed to use this? They shouldn't need to know about uids or srcs. If it's something users are playing with, I'd suggest get_column_reference or something (which should return the fid:uid pair (and could potentially handle 2d references).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, users are supposed to use this. And it does return the fid:uid pair

"""
Return uid of given column name in the grid by column name.

Expand Down
14 changes: 10 additions & 4 deletions plotly/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,6 @@ def upload(cls, grid, filename,
cls._fill_in_response_column_ids(grid, response_columns, grid_id)

grid.id = grid_id
#grid._fid = res['file']['fid']

if meta is not None:
meta_ops.upload(meta, grid=grid)
Expand Down Expand Up @@ -1476,13 +1475,20 @@ def get_grid(grid_url, raw=False):
if url_path[-1] == '/':
url_path = url_path[0: -1]
url_path = url_path.replace('/', ':')
get_url = upload_url + '/' + url_path + '/content'
print url_path

meta_get_url = upload_url + '/' + url_path
get_url = meta_get_url + '/content'

r = requests.get(get_url, headers=headers)
json_res = json.loads(r.text)

# make request to grab the grid id (fid)
r_meta = requests.get(meta_get_url, headers=headers)
json_res_meta = json.loads(r_meta.text)
retrieved_grid_id = json_res_meta['fid']

if raw is False:
return Grid(json_res)
return Grid(json_res, retrieved_grid_id)
else:
return json_res

Expand Down