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

Skip to content

Commit ce4274a

Browse files
committed
💄
1 parent ce90bc8 commit ce4274a

File tree

4 files changed

+103
-97
lines changed

4 files changed

+103
-97
lines changed

gridspec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ c1 = Column('first column', [1, 2, 3, 4])
216216
grid = Grid([c1])
217217
grid_url = py.grid_ops.upload(grid, unique_filename, auto_open=False)
218218

219-
# Add some meta data to that grid
219+
# Add some Metadata to that grid
220220
meta = {"settings": {"scope1": {"model": "Unicorn Finder", "voltage": 4}}}
221221
meta_url = py.meta_ops.upload(
222222
meta,

plotly/grid_objs/grid_objs.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313

1414
__all__ = None
1515

16+
1617
class Column(object):
17-
'''
18+
"""
1819
Columns make up Plotly Grids and can be the source of
1920
data for Plotly Graphs.
2021
They have a name and an array of data.
21-
They can be uploaded to Plotly with the `plotly.plotly.plotly.grid_ops`
22+
They can be uploaded to Plotly with the `plotly.plotly.grid_ops`
2223
class.
2324
2425
Usage example 1: Upload a set of columns as a grid to Plotly
@@ -48,14 +49,14 @@ class Column(object):
4849
trace = Scatter(xsrc=grid[0], ysrc=grid[1])
4950
py.plot([trace], filename='graph from grid')
5051
```
51-
'''
52+
"""
5253
def __init__(self, data, name):
53-
'''
54+
"""
5455
Initialize a Plotly column with `data` and `name`.
5556
`data` is an array of strings, numbers, or dates.
5657
`name` is the name of the column as it will apppear
57-
in the Plotly grid.
58-
'''
58+
in the Plotly grid. Names must be unique to a grid.
59+
"""
5960

6061
# TODO: data type checking
6162
self.data = data
@@ -82,13 +83,13 @@ def to_json(self):
8283

8384

8485
class Grid(MutableSequence):
85-
'''
86+
"""
8687
Grid is Plotly's Python representation of Plotly Grids.
87-
Plotly Grids tabular data made up of columns. They can be
88+
Plotly Grids are tabular data made up of columns. They can be
8889
uploaded, appended to, and can source the data for Plotly
8990
graphs.
9091
91-
This plotly.grid_objs.Grid object is essentially a list.
92+
A plotly.grid_objs.Grid object is essentially a list.
9293
9394
Usage example 1: Upload a set of columns as a grid to Plotly
9495
```
@@ -117,9 +118,9 @@ class Grid(MutableSequence):
117118
trace = Scatter(xsrc=grid[0], ysrc=grid[1])
118119
py.plot([trace], filename='graph from grid')
119120
```
120-
'''
121+
"""
121122
def __init__(self, iterable_of_columns):
122-
'''
123+
"""
123124
Initialize a grid with an iterable of
124125
`plotly.grid_objs.Column objects
125126
@@ -129,7 +130,7 @@ def __init__(self, iterable_of_columns):
129130
column_2 = Column([4, 2, 5], 'voltage')
130131
grid = Grid([column_1, column_2])
131132
```
132-
'''
133+
"""
133134

134135
# TODO: verify that columns are actually columns
135136

plotly/plotly/plotly.py

Lines changed: 88 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,9 @@ def mkdirs(cls, folder_path):
698698
class grid_ops:
699699
""" Interface to Plotly's Grid API.
700700
Plotly Grids are Plotly's tabular data object, rendered
701-
in a online spreadsheet. Plotly graphs can be made from
701+
in an online spreadsheet. Plotly graphs can be made from
702702
references of columns of Plotly grid objects. Free-form
703-
JSON Meta data can be saved with Plotly grids.
703+
JSON Metadata can be saved with Plotly grids.
704704
705705
To create a Plotly grid in your Plotly account from Python,
706706
see `grid_ops.upload`.
@@ -724,57 +724,62 @@ def _fill_in_response_column_ids(cls, request_columns,
724724
@classmethod
725725
def upload(cls, grid, filename,
726726
world_readable=True, auto_open=True, meta=None):
727-
""" Upload a grid to your Plotly account with the specified filename.
728-
729-
Positional arguments:
730-
- grid: A plotly.grid_objs.Grid object,
731-
call `help(plotly.grid_ops.Grid)` for more info.
732-
- filename: Name of the grid to be saved in your Plotly account.
733-
To save a grid in a folder in your Plotly account,
734-
separate specify a filename with folders and filename
735-
separated by backslashes (`/`).
736-
If a grid, plot, or folder already exists with the same
737-
filename, a `plotly.exceptions.RequestError` will be thrown
738-
with status_code 409
739-
740-
Optional keyword arguments:
741-
- world_readable (default=True): make this grid publically (True)
742-
or privately (False) viewable.
743-
- auto_open (default=True): Automatically open this grid in
744-
the browser (True)
745-
- meta (default=None): Optional meta data to associate with
746-
this grid.
747-
Meta data is any arbitrary
748-
JSON-encodable object, for example:
749-
`{"experiment name": "GaAs"}`
750-
751-
Usage example 1: Upload a plotly grid
752-
```
753-
from plotly.grid_objs import Grid, Column
754-
import plotly.plotly as py
755-
column_1 = Column([1, 2, 3], 'time')
756-
column_2 = Column([4, 2, 5], 'voltage')
757-
grid = Grid([column_1, column_2])
758-
py.grid_ops.upload(grid, 'time vs voltage')
759-
```
727+
"""
728+
Upload a grid to your Plotly account with the specified filename.
729+
730+
Positional arguments:
731+
- grid: A plotly.grid_objs.Grid object,
732+
call `help(plotly.grid_ops.Grid)` for more info.
733+
- filename: Name of the grid to be saved in your Plotly account.
734+
To save a grid in a folder in your Plotly account,
735+
separate specify a filename with folders and filename
736+
separated by backslashes (`/`).
737+
If a grid, plot, or folder already exists with the same
738+
filename, a `plotly.exceptions.RequestError` will be thrown
739+
with status_code 409
740+
741+
Optional keyword arguments:
742+
- world_readable (default=True): make this grid publically (True)
743+
or privately (False) viewable.
744+
- auto_open (default=True): Automatically open this grid in
745+
the browser (True)
746+
- meta (default=None): Optional Metadata to associate with
747+
this grid.
748+
Metadata is any arbitrary
749+
JSON-encodable object, for example:
750+
`{"experiment name": "GaAs"}`
751+
752+
Filenames must be unique. To overwrite a grid with the same filename,
753+
you'll first have to delete the grid with the blocking name. See
754+
`plotly.plotly.grid_ops.delete`.
755+
756+
Usage example 1: Upload a plotly grid
757+
```
758+
from plotly.grid_objs import Grid, Column
759+
import plotly.plotly as py
760+
column_1 = Column([1, 2, 3], 'time')
761+
column_2 = Column([4, 2, 5], 'voltage')
762+
grid = Grid([column_1, column_2])
763+
py.grid_ops.upload(grid, 'time vs voltage')
764+
```
760765
761-
Usage example 2: Make a graph based with data that is sourced
762-
from a newly uploaded Plotly grid
763-
```
764-
import plotly.plotly as py
765-
from plotly.grid_objs import Grid, Column
766-
from plotly.graph_objs import Scatter
767-
# Upload a grid
768-
column_1 = Column([1, 2, 3], 'time')
769-
column_2 = Column([4, 2, 5], 'voltage')
770-
grid = Grid([column_1, column_2])
771-
py.grid_ops.upload(grid, 'time vs voltage')
766+
Usage example 2: Make a graph based with data that is sourced
767+
from a newly uploaded Plotly grid
768+
```
769+
import plotly.plotly as py
770+
from plotly.grid_objs import Grid, Column
771+
from plotly.graph_objs import Scatter
772+
# Upload a grid
773+
column_1 = Column([1, 2, 3], 'time')
774+
column_2 = Column([4, 2, 5], 'voltage')
775+
grid = Grid([column_1, column_2])
776+
py.grid_ops.upload(grid, 'time vs voltage')
772777
773-
# Build a Plotly graph object sourced from the
774-
# grid's columns
775-
trace = Scatter(xsrc=grid[0], ysrc=grid[1])
776-
py.plot([trace], filename='graph from grid')
777-
```
778+
# Build a Plotly graph object sourced from the
779+
# grid's columns
780+
trace = Scatter(xsrc=grid[0], ysrc=grid[1])
781+
py.plot([trace], filename='graph from grid')
782+
```
778783
"""
779784

780785
# Make a folder path
@@ -974,35 +979,35 @@ def append_rows(cls, rows, grid=None, grid_url=None):
974979
@classmethod
975980
def delete(cls, grid=None, grid_url=None):
976981
'''
977-
Delete a grid from your Plotly account.
982+
Delete a grid from your Plotly account.
978983
979-
Only one of `grid` or `grid_url` needs to be specified.
984+
Only one of `grid` or `grid_url` needs to be specified.
980985
981-
`grid` is a plotly.grid_objs.Grid object that has already
982-
been uploaded to Plotly.
986+
`grid` is a plotly.grid_objs.Grid object that has already
987+
been uploaded to Plotly.
983988
984-
`grid_url` is the URL of the Plotly grid to delete
989+
`grid_url` is the URL of the Plotly grid to delete
985990
986-
Usage example 1: Upload a grid to plotly, then delete it
987-
```
988-
from plotly.grid_objs import Grid, Column
989-
import plotly.plotly as py
990-
column_1 = Column([1, 2, 3], 'time')
991-
column_2 = Column([4, 2, 5], 'voltage')
992-
grid = Grid([column_1, column_2])
993-
py.grid_ops.upload(grid, 'time vs voltage')
991+
Usage example 1: Upload a grid to plotly, then delete it
992+
```
993+
from plotly.grid_objs import Grid, Column
994+
import plotly.plotly as py
995+
column_1 = Column([1, 2, 3], 'time')
996+
column_2 = Column([4, 2, 5], 'voltage')
997+
grid = Grid([column_1, column_2])
998+
py.grid_ops.upload(grid, 'time vs voltage')
994999
995-
# now delete it, and free up that filename
996-
py.grid_ops.delete(grid)
997-
```
1000+
# now delete it, and free up that filename
1001+
py.grid_ops.delete(grid)
1002+
```
9981003
999-
Usage example 2: Delete a plotly grid by url
1000-
```
1001-
import plotly.plotly as py
1004+
Usage example 2: Delete a plotly grid by url
1005+
```
1006+
import plotly.plotly as py
10021007
1003-
grid_url = 'https://plot.ly/~chris/3'
1004-
py.grid_ops.delete(grid_url=grid_url)
1005-
```
1008+
grid_url = 'https://plot.ly/~chris/3'
1009+
py.grid_ops.delete(grid_url=grid_url)
1010+
```
10061011
'''
10071012

10081013
grid_id = _api_v2.parse_grid_id_args(grid, grid_url)
@@ -1014,32 +1019,32 @@ def delete(cls, grid=None, grid_url=None):
10141019
class meta_ops:
10151020
""" Interface to Plotly's Metadata API.
10161021
1017-
In Plotly, meta data is arbitrary, free-form JSON data that is
1018-
associated with Plotly grids. Meta data is viewable with any grid
1022+
In Plotly, Metadata is arbitrary, free-form JSON data that is
1023+
associated with Plotly grids. Metadata is viewable with any grid
10191024
that is shared and grids are searchable by key value pairs in
1020-
the meta data. Meta data is any JSON-encodable object.
1025+
the Metadata. Metadata is any JSON-encodable object.
10211026
1022-
To upload meta data, either use the optional keyword argument `meta`
1027+
To upload Metadata, either use the optional keyword argument `meta`
10231028
in the `py.grid_ops.upload` method, or use `py.meta_ops.upload`.
10241029
10251030
"""
10261031

10271032
@classmethod
10281033
def upload(cls, meta, grid=None, grid_url=None):
10291034
'''
1030-
Upload meta data to a Plotly grid.
1035+
Upload Metadata to a Plotly grid.
10311036
1032-
Meta data is any JSON-encodable object. For example,
1037+
Metadata is any JSON-encodable object. For example,
10331038
a dictionary, string, or list.
10341039
10351040
Only one of `grid` or `grid_url` needs to be specified.
10361041
10371042
`grid` is a plotly.grid_objs.Grid object that has already
10381043
been uploaded to Plotly.
10391044
1040-
`grid_url` is the URL of the Plotly grid to attach meta data to.
1045+
`grid_url` is the URL of the Plotly grid to attach Metadata to.
10411046
1042-
Usage example 1: Upload a grid to Plotly, then attach meta data to it
1047+
Usage example 1: Upload a grid to Plotly, then attach Metadata to it
10431048
```
10441049
from plotly.grid_objs import Grid, Column
10451050
import plotly.plotly as py
@@ -1048,12 +1053,12 @@ def upload(cls, meta, grid=None, grid_url=None):
10481053
grid = Grid([column_1, column_2])
10491054
py.grid_ops.upload(grid, 'time vs voltage')
10501055
1051-
# now attach meta data to the grid
1056+
# now attach Metadata to the grid
10521057
meta = {'experment': 'GaAs'}
10531058
py.meta_ops.upload(meta, grid=grid)
10541059
```
10551060
1056-
Usage example 2: Upload meta data to an existing Plotly grid
1061+
Usage example 2: Upload Metadata to an existing Plotly grid
10571062
```
10581063
import plotly.plotly as py
10591064

plotly/tests/test_core/test_meta/test_meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_upload_meta():
3737
unique_filename = _random_filename()
3838
grid_url = py.grid_ops.upload(_grid, unique_filename, auto_open=False)
3939

40-
# Add some meta data to that grid
40+
# Add some Metadata to that grid
4141
meta_url = py.meta_ops.upload(
4242
_meta,
4343
grid_url=grid_url)

0 commit comments

Comments
 (0)