@@ -118,15 +118,15 @@ class Grid(MutableSequence):
118
118
py.plot([trace], filename='graph from grid')
119
119
```
120
120
"""
121
- def __init__ (self , columns_or_json , grid_id = None ):
121
+ def __init__ (self , columns_or_json , fid = None ):
122
122
"""
123
123
Initialize a grid with an iterable of `plotly.grid_objs.Column`
124
124
objects or a json/dict describing a grid. See second usage example
125
125
below for the necessary structure of the dict.
126
126
127
- :param (str|bool) grid_id : should not be accessible to users. Default
127
+ :param (str|bool) fid : should not be accessible to users. Default
128
128
is 'None' but if a grid is retrieved via `py.get_grid()` then the
129
- retrieved grid response will contain the grid_id which will be
129
+ retrieved grid response will contain the fid which will be
130
130
necessary to set `self.id` and `self._columns.id` below.
131
131
132
132
Example from iterable of columns:
@@ -148,16 +148,16 @@ def __init__(self, columns_or_json, grid_id=None):
148
148
"""
149
149
# TODO: verify that columns are actually columns
150
150
if isinstance (columns_or_json , dict ):
151
- # check that grid_id is entered
152
- if grid_id is None :
151
+ # check that fid is entered
152
+ if fid is None :
153
153
raise exceptions .PlotlyError (
154
154
"If you are manually converting a raw json/dict grid "
155
155
"into a Grid instance, you must ensure that make "
156
- "'grid_id ' is set to your file ID. This looks like "
156
+ "'fid ' is set to your file ID. This looks like "
157
157
"'username:187'."
158
158
)
159
- # TODO: verify that grid_id is a correct fid if a string
160
- self .id = grid_id
159
+ # TODO: verify that fid is a correct fid if a string
160
+ self .id = fid
161
161
162
162
# check if 'cols' is a root key
163
163
if 'cols' not in columns_or_json :
@@ -255,16 +255,26 @@ def get_column(self, column_name):
255
255
if column .name == column_name :
256
256
return column
257
257
258
- def get_fid_uid (self , column_name ):
258
+ def get_column_reference (self , column_name ):
259
259
"""
260
- Return uid of given column name in the grid by column name.
260
+ Returns the column reference of given column in the grid by its name.
261
261
262
- Returns an empty string if either the column name does not exist in
263
- the grid or if the id of the specified column has the empty string id .
262
+ Raises an error if the column name is not in the grid. Otherwise,
263
+ returns the fid:uid pair, which may be the empty string.
264
264
"""
265
- uid = ''
265
+ col_names = []
266
+ for column in self ._columns :
267
+ col_names .append (column .name )
268
+
269
+ column_id = None
266
270
for column in self ._columns :
267
271
if column .name == column_name :
268
- uid = column .id
272
+ column_id = column .id
269
273
break
270
- return uid
274
+
275
+ if column_id is None :
276
+ raise exceptions .PlotlyError (
277
+ "Whoops, that column name doesn't match any of the column "
278
+ "names in your grid. You must pick from {cols}" .format (col_names )
279
+ )
280
+ return column_id
0 commit comments