-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
I ran into an unhelpful error message today. Here's a MWE. It has an error, which is that the well name is specified twice. This ultimately has the effect of making the well value seem to be a dictionary:
[well.A1]
A1.foo = 'bar'
When I try to visualize this layout, I get the following stack trace:
Traceback (most recent call last):
File "/home/kale/.pyenv/versions/3.10.0/bin/wellmap", line 8, in <module>
sys.exit(main())
File "/home/kale/research/software/projects/wellmap/wellmap/gui.py", line 342, in main
app = AppWindow(toml_path, color)
File "/home/kale/research/software/projects/wellmap/wellmap/gui.py", line 119, in __init__
self.reload_layout()
File "/home/kale/research/software/projects/wellmap/wellmap/gui.py", line 262, in reload_layout
fig = wellmap.plot.plot_layout(df, attr, cmap)
File "/home/kale/research/software/projects/wellmap/wellmap/plot.py", line 91, in plot_layout
fig, axes, dims = setup_axes(df, plates, attrs)
File "/home/kale/research/software/projects/wellmap/wellmap/plot.py", line 210, in setup_axes
dims = Dimensions(df)
File "/home/kale/research/software/projects/wellmap/wellmap/plot.py", line 317, in __init__
self.num_values = df.nunique()
File "/home/kale/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pandas/core/frame.py", line 10143, in nunique
return self.apply(Series.nunique, axis=axis, dropna=dropna)
File "/home/kale/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pandas/core/frame.py", line 8833, in apply
return op.apply().__finalize__(self, method="apply")
File "/home/kale/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pandas/core/apply.py", line 727, in apply
return self.apply_standard()
File "/home/kale/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pandas/core/apply.py", line 851, in apply_standard
results, res_index = self.apply_series_generator()
File "/home/kale/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pandas/core/apply.py", line 867, in apply_series_generator
results[i] = self.f(v)
File "/home/kale/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pandas/core/apply.py", line 138, in f
return func(x, *args, **kwargs)
File "/home/kale/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pandas/core/base.py", line 1027, in nunique
uniqs = self.unique()
File "/home/kale/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pandas/core/series.py", line 2088, in unique
return super().unique()
File "/home/kale/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pandas/core/base.py", line 989, in unique
result = unique1d(values)
File "/home/kale/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pandas/core/algorithms.py", line 440, in unique
uniques = table.unique(values)
File "pandas/_libs/hashtable_class_helper.pxi", line 5361, in pandas._libs.hashtable.PyObjectHashTable.unique
File "pandas/_libs/hashtable_class_helper.pxi", line 5310, in pandas._libs.hashtable.PyObjectHashTable._unique
TypeError: unhashable type: 'dict'
In short, the plotting code tries to figure out the number of unique values, and pandas chokes on the non-hashable type. The data loads without error.
Initially I wanted to raise an error in this case, but there's no way to do that without forbidding dictionary values altogether. So instead, I should probably make the plotting code robust against such inputs.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels