Lab 4_3 Python Pandas ChipWhisperer Analyzer

When trying to run the commands under Plot Data in Lab 4.3, I get the following error:

WARNING:param.dynamic_operation: Callable raised "TypeError('cannot do slice indexing on RangeIndex with these indexers [0.0] of type float64')".
Invoked as dynamic_operation(x_range=None, y_range=None)
WARNING:param.dynamic_operation:Callable raised "TypeError('cannot do slice indexing on RangeIndex with these indexers [0.0] of type float64')".
Invoked as dynamic_operation(x_range=None, y_range=None)

In order to run anything at all I had to install dask dataframe with the following:

pip install "dask[dataframe]"

I suspect that there might have been updates to some dependencies which broke the script. Any ideas? I’m using Python 3.12.7 (installed with brew) on a Mac.

Thanks,
Andreas

Full stack trace:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/python/chipwhisperer/lib/python3.12/site-packages/IPython/core/formatters.py:977, in MimeBundleFormatter.__call__(self, obj, include, exclude)
    974     method = get_real_method(obj, self.print_method)
    976     if method is not None:
--> 977         return method(include=include, exclude=exclude)
    978     return None
    979 else:

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/dimension.py:1275, in Dimensioned._repr_mimebundle_(self, include, exclude)
   1268 def _repr_mimebundle_(self, include=None, exclude=None):
   1269     """
   1270     Resolves the class hierarchy for the class rendering the
   1271     object using any display hooks registered on Store.display
   1272     hooks.  The output of all registered display_hooks is then
   1273     combined and returned.
   1274     """
-> 1275     return Store.render(self)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/options.py:1428, in Store.render(cls, obj)
   1426 data, metadata = {}, {}
   1427 for hook in hooks:
-> 1428     ret = hook(obj)
   1429     if ret is None:
   1430         continue

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/ipython/display_hooks.py:287, in pprint_display(obj)
    285 if not ip.display_formatter.formatters['text/plain'].pprint:
    286     return None
--> 287 return display(obj, raw_output=True)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/ipython/display_hooks.py:255, in display(obj, raw_output, **kwargs)
    253 elif isinstance(obj, (CompositeOverlay, ViewableElement)):
    254     with option_state(obj):
--> 255         output = element_display(obj)
    256 elif isinstance(obj, (Layout, NdLayout, AdjointLayout)):
    257     with option_state(obj):

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/ipython/display_hooks.py:149, in display_hook.<locals>.wrapped(element)
    147 try:
    148     max_frames = OutputSettings.options['max_frames']
--> 149     mimebundle = fn(element, max_frames=max_frames)
    150     if mimebundle is None:
    151         return {}, {}

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/ipython/display_hooks.py:195, in element_display(element, max_frames)
    192 if type(element) not in Store.registry[backend]:
    193     return None
--> 195 return render(element)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/ipython/display_hooks.py:76, in render(obj, **kwargs)
     73 if renderer.fig == 'pdf':
     74     renderer = renderer.instance(fig='png')
---> 76 return renderer.components(obj, **kwargs)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/plotting/renderer.py:396, in Renderer.components(self, obj, fmt, comm, **kwargs)
    394 embed = (not (dynamic or streams or self.widget_mode == 'live') or config.embed)
    395 if embed or config.comms == 'default':
--> 396     return self._render_panel(plot, embed, comm)
    397 return self._render_ipywidget(plot)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/plotting/renderer.py:403, in Renderer._render_panel(self, plot, embed, comm)
    401 doc = Document()
    402 with config.set(embed=embed):
--> 403     model = plot.layout._render_model(doc, comm)
    404 if embed:
    405     return render_model(model, comm)

File ~/python/chipwhisperer/lib/python3.12/site-packages/panel/viewable.py:740, in Viewable._render_model(self, doc, comm)
    738 if comm is None:
    739     comm = state._comm_manager.get_server_comm()
--> 740 model = self.get_root(doc, comm)
    742 if self._design and self._design.theme.bokeh_theme:
    743     doc.theme = self._design.theme.bokeh_theme

File ~/python/chipwhisperer/lib/python3.12/site-packages/panel/layout/base.py:317, in Panel.get_root(self, doc, comm, preprocess)
    313 def get_root(
    314     self, doc: Optional[Document] = None, comm: Optional[Comm] = None,
    315     preprocess: bool = True
    316 ) -> Model:
--> 317     root = super().get_root(doc, comm, preprocess)
    318     # ALERT: Find a better way to handle this
    319     if hasattr(root, 'styles') and 'overflow-x' in root.styles:

File ~/python/chipwhisperer/lib/python3.12/site-packages/panel/viewable.py:671, in Renderable.get_root(self, doc, comm, preprocess)
    669 wrapper = self._design._wrapper(self)
    670 if wrapper is self:
--> 671     root = self._get_model(doc, comm=comm)
    672     if preprocess:
    673         self._preprocess(root)

File ~/python/chipwhisperer/lib/python3.12/site-packages/panel/layout/base.py:183, in Panel._get_model(self, doc, root, parent, comm)
    181 root = root or model
    182 self._models[root.ref['id']] = (model, parent)
--> 183 objects, _ = self._get_objects(model, [], doc, root, comm)
    184 props = self._get_properties(doc)
    185 props[self._property_mapping['objects']] = objects

File ~/python/chipwhisperer/lib/python3.12/site-packages/panel/layout/base.py:165, in Panel._get_objects(self, model, old_objects, doc, root, comm)
    163 else:
    164     try:
--> 165         child = pane._get_model(doc, root, model, comm)
    166     except RerenderError as e:
    167         if e.layout is not None and e.layout is not self:

File ~/python/chipwhisperer/lib/python3.12/site-packages/panel/pane/holoviews.py:438, in HoloViews._get_model(self, doc, root, parent, comm)
    436     plot = self.object
    437 else:
--> 438     plot = self._render(doc, comm, root)
    440 plot.pane = self
    441 backend = plot.renderer.backend

File ~/python/chipwhisperer/lib/python3.12/site-packages/panel/pane/holoviews.py:532, in HoloViews._render(self, doc, comm, root)
    529     if comm:
    530         kwargs['comm'] = comm
--> 532 return renderer.get_plot(self.object, **kwargs)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/plotting/bokeh/renderer.py:68, in BokehRenderer.get_plot(self_or_cls, obj, doc, renderer, **kwargs)
     61 @bothmethod
     62 def get_plot(self_or_cls, obj, doc=None, renderer=None, **kwargs):
     63     """
     64     Given a HoloViews Viewable return a corresponding plot instance.
     65     Allows supplying a document attach the plot to, useful when
     66     combining the bokeh model with another plot.
     67     """
---> 68     plot = super().get_plot(obj, doc, renderer, **kwargs)
     69     if plot.document is None:
     70         plot.document = Document() if self_or_cls.notebook_context else curdoc()

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/plotting/renderer.py:216, in Renderer.get_plot(self_or_cls, obj, doc, renderer, comm, **kwargs)
    213     raise SkipRendering(msg.format(dims=dims))
    215 # Initialize DynamicMaps with first data item
--> 216 initialize_dynamic(obj)
    218 if not renderer:
    219     renderer = self_or_cls

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/plotting/util.py:270, in initialize_dynamic(obj)
    268     continue
    269 if not len(dmap):
--> 270     dmap[dmap._initial_key()]

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/spaces.py:1216, in DynamicMap.__getitem__(self, key)
   1214 # Not a cross product and nothing cached so compute element.
   1215 if cache is not None: return cache
-> 1216 val = self._execute_callback(*tuple_key)
   1217 if data_slice:
   1218     val = self._dataslice(val, data_slice)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/spaces.py:983, in DynamicMap._execute_callback(self, *args)
    980     kwargs['_memoization_hash_'] = hash_items
    982 with dynamicmap_memoization(self.callback, self.streams):
--> 983     retval = self.callback(*args, **kwargs)
    984 return self._style(retval)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/spaces.py:581, in Callable.__call__(self, *args, **kwargs)
    578     args, kwargs = (), dict(pos_kwargs, **kwargs)
    580 try:
--> 581     ret = self.callable(*args, **kwargs)
    582 except KeyError:
    583     # KeyError is caught separately because it is used to signal
    584     # invalid keys on DynamicMap and should not warn
    585     raise

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/util/__init__.py:1039, in Dynamic._dynamic_operation.<locals>.dynamic_operation(*key, **kwargs)
   1037 def dynamic_operation(*key, **kwargs):
   1038     key, obj = resolve(key, kwargs)
-> 1039     return apply(obj, *key, **kwargs)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/util/__init__.py:1031, in Dynamic._dynamic_operation.<locals>.apply(element, *key, **kwargs)
   1029 def apply(element, *key, **kwargs):
   1030     kwargs = dict(util.resolve_dependent_kwargs(self.p.kwargs), **kwargs)
-> 1031     processed = self._process(element, key, kwargs)
   1032     if (self.p.link_dataset and isinstance(element, Dataset) and
   1033         isinstance(processed, Dataset) and processed._dataset is None):
   1034         processed._dataset = element.dataset

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/util/__init__.py:1013, in Dynamic._process(self, element, key, kwargs)
   1011 elif isinstance(self.p.operation, Operation):
   1012     kwargs = {k: v for k, v in kwargs.items() if k in self.p.operation.param}
-> 1013     return self.p.operation.process_element(element, key, **kwargs)
   1014 else:
   1015     return self.p.operation(element, **kwargs)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/operation.py:194, in Operation.process_element(self, element, key, **params)
    191 else:
    192     self.p = param.ParamOverrides(self, params,
    193                                   allow_extra_keywords=self._allow_extra_keywords)
--> 194 return self._apply(element, key)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/operation.py:141, in Operation._apply(self, element, key)
    139     if not in_method:
    140         element._in_method = True
--> 141 ret = self._process(element, key)
    142 if hasattr(element, '_in_method') and not in_method:
    143     element._in_method = in_method

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/operation/element.py:1017, in decimate._process(self, element, key)
   1016 def _process(self, element, key=None):
-> 1017     return element.map(self._process_layer, Element)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/data/__init__.py:196, in PipelineMeta.pipelined.<locals>.pipelined_fn(*args, **kwargs)
    193     inst._in_method = True
    195 try:
--> 196     result = method_fn(*args, **kwargs)
    197     if PipelineMeta.disable:
    198         return result

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/data/__init__.py:1213, in Dataset.map(self, *args, **kwargs)
   1211 @wraps(LabelledData.map)
   1212 def map(self, *args, **kwargs):
-> 1213     return super().map(*args, **kwargs)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/dimension.py:695, in LabelledData.map(self, map_fn, specs, clone)
    693     return deep_mapped
    694 else:
--> 695     return map_fn(self) if applies else self

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/operation/element.py:1007, in decimate._process_layer(self, element, key)
   1005 # Slice element to current ranges
   1006 xdim, ydim = element.dimensions(label=True)[0:2]
-> 1007 sliced = element.select(**{xdim: (xstart, xend),
   1008                            ydim: (ystart, yend)})
   1010 if len(sliced) > self.p.max_samples:
   1011     prng = np.random.RandomState(self.p.random_seed)

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/data/__init__.py:196, in PipelineMeta.pipelined.<locals>.pipelined_fn(*args, **kwargs)
    193     inst._in_method = True
    195 try:
--> 196     result = method_fn(*args, **kwargs)
    197     if PipelineMeta.disable:
    198         return result

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/data/__init__.py:623, in Dataset.select(self, selection_expr, selection_specs, **selection)
    621 # Handle selection kwargs
    622 if selection:
--> 623     data = self.interface.select(self, **selection)
    624 else:
    625     data = self.data

File ~/python/chipwhisperer/lib/python3.12/site-packages/holoviews/core/data/pandas.py:403, in PandasInterface.select(cls, dataset, selection_mask, **selection)
    401 try:
    402     if len(index_sel) == 1:
--> 403         df = df[next(iter(index_sel.values()))]
    404     else:
    405         df = df.loc[tuple(index_sel.values()), :]

File ~/python/chipwhisperer/lib/python3.12/site-packages/pandas/core/frame.py:4085, in DataFrame.__getitem__(self, key)
   4083 # Do we have a slicer (on rows)?
   4084 if isinstance(key, slice):
-> 4085     return self._getitem_slice(key)
   4087 # Do we have a (boolean) DataFrame?
   4088 if isinstance(key, DataFrame):

File ~/python/chipwhisperer/lib/python3.12/site-packages/pandas/core/generic.py:4349, in NDFrame._getitem_slice(self, key)
   4344 """
   4345 __getitem__ for the case where the key is a slice object.
   4346 """
   4347 # _convert_slice_indexer to determine if this slice is positional
   4348 #  or label based, and if the latter, convert to positional
-> 4349 slobj = self.index._convert_slice_indexer(key, kind="getitem")
   4350 if isinstance(slobj, np.ndarray):
   4351     # reachable with DatetimeIndex
   4352     indexer = lib.maybe_indices_to_slice(
   4353         slobj.astype(np.intp, copy=False), len(self)
   4354     )

File ~/python/chipwhisperer/lib/python3.12/site-packages/pandas/core/indexes/base.py:4248, in Index._convert_slice_indexer(self, key, kind)
   4245     return key
   4246 elif self.dtype.kind in "iu":
   4247     # Note: these checks are redundant if we know is_index_slice
-> 4248     self._validate_indexer("slice", key.start, "getitem")
   4249     self._validate_indexer("slice", key.stop, "getitem")
   4250     self._validate_indexer("slice", key.step, "getitem")

File ~/python/chipwhisperer/lib/python3.12/site-packages/pandas/core/indexes/base.py:6697, in Index._validate_indexer(self, form, key, kind)
   6692 """
   6693 If we are positional indexer, validate that we have appropriate
   6694 typed bounds must be an integer.
   6695 """
   6696 if not lib.is_int_or_none(key):
-> 6697     self._raise_invalid_indexer(form, key)

File ~/python/chipwhisperer/lib/python3.12/site-packages/pandas/core/indexes/base.py:4301, in Index._raise_invalid_indexer(self, form, key, reraise)
   4299 if reraise is not lib.no_default:
   4300     raise TypeError(msg) from reraise
-> 4301 raise TypeError(msg)

TypeError: cannot do slice indexing on RangeIndex with these indexers [0.0] of type float64

It seems the hv.Curve function needs a string, so if I change:

for i in range(1, 16):
    curve *= hv.Curve(pdb[str(i)]).options(color='black')
    
for i in range(0, 16):
    curve *= hv.Curve(pda[str(i)]).options(color=byte_to_color(i))

to (strings pda and pdb chosen arbitrarily):

for i in range(1, 16):
    curve *= hv.Curve(pdb[str(i)], "pdb").options(color='black')
    
for i in range(0, 16):
    curve *= hv.Curve(pda[str(i)], "pda").options(color=byte_to_color(i))

it seems to work. But I’m not sure why, and if it’s correct.