@@ -118,15 +118,15 @@ class Grid(MutableSequence):
118118 py.plot([trace], filename='graph from grid')
119119 ```
120120 """
121- def __init__ (self , columns_or_json , grid_id = None ):
121+ def __init__ (self , columns_or_json , fid = None ):
122122 """
123123 Initialize a grid with an iterable of `plotly.grid_objs.Column`
124124 objects or a json/dict describing a grid. See second usage example
125125 below for the necessary structure of the dict.
126126
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
128128 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
130130 necessary to set `self.id` and `self._columns.id` below.
131131
132132 Example from iterable of columns:
@@ -148,16 +148,16 @@ def __init__(self, columns_or_json, grid_id=None):
148148 """
149149 # TODO: verify that columns are actually columns
150150 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 :
153153 raise exceptions .PlotlyError (
154154 "If you are manually converting a raw json/dict grid "
155155 "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 "
157157 "'username:187'."
158158 )
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
161161
162162 # check if 'cols' is a root key
163163 if 'cols' not in columns_or_json :
@@ -255,16 +255,26 @@ def get_column(self, column_name):
255255 if column .name == column_name :
256256 return column
257257
258- def get_fid_uid (self , column_name ):
258+ def get_column_reference (self , column_name ):
259259 """
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.
261261
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.
264264 """
265- uid = ''
265+ col_names = []
266+ for column in self ._columns :
267+ col_names .append (column .name )
268+
269+ column_id = None
266270 for column in self ._columns :
267271 if column .name == column_name :
268- uid = column .id
272+ column_id = column .id
269273 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