# Buggy code
def wordcloud_viz(
    word_cnts: pd.Series,
    plot_width: int,
    plot_height: int,
) -> Panel:
    """
    Visualize the word cloud
    """  # pylint: disable=unsubscriptable-object
    ellipse_mask = np.array(
        Image.open(f"{Path(__file__).parent.parent.parent}/assets/ellipse.jpg")
    )
    wordcloud = WordCloud(
        background_color="white", mask=ellipse_mask, width=800, height=400
    )
    wordcloud.generate_from_frequencies(word_cnts)
    wcimg = wordcloud.to_array().astype(np.uint8)
    alpha = np.full([*wcimg.shape[:2], 1], 255, dtype=np.uint8)
    wcimg = np.concatenate([wcimg, alpha], axis=2)[::-1, :]

    fig = figure(
        plot_width=plot_width,
        plot_height=plot_height,
        title="Word Cloud",
        x_range=(0, 1),
        y_range=(0, 1),
        toolbar_location=None,
    )
    fig.image_rgba(image=[wcimg], x=0, y=0, dh=1, dw=1)

    fig.axis.visible = False
    fig.grid.visible = False
    return Panel(child=row(fig), title="Word Cloud")


# Traceback (ValueError)
nan_value = float("NaN")
df = pd.DataFrame(5 * [[1, nan_value]]
... )
df
0   1
0  1 NaN
1  1 NaN
2  1 NaN
3  1 NaN
4  1 NaN
rep = plot(df)
C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\lib\histograms.py:433: RuntimeWarning: invalid value encountered in greater
if np.any(bin_edges[:-1] > bin_edges[1:]):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\dataprep\eda\distribution\__init__.py", line 165, in plot
figure = render(intermediate, yscale=yscale, tile_size=tile_size)
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\dataprep\eda\distribution\render.py", line 1920, in render
visual_elem = render_distribution_grid(
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\dataprep\eda\distribution\render.py", line 1565, in render_distribution_grid
fig = hist_viz(data, nrows, col, yscale, plot_width, plot_height, False)
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\dataprep\eda\distribution\render.py", line 441, in hist_viz
fig = Figure(
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\bokeh\plotting\figure.py", line 155, in __init__
super().__init__(*arg, **kw)
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\bokeh\model.py", line 234, in __init__
super().__init__(**kwargs)
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\bokeh\core\has_props.py", line 247, in __init__
setattr(self, name, value)
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\bokeh\core\has_props.py", line 274, in __setattr__
super().__setattr__(name, value)
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\bokeh\core\property\descriptors.py", line 539, in __set__
self._internal_set(obj, value, setter=setter)
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\bokeh\core\property\descriptors.py", line 760, in _internal_set
value = self.property.prepare_value(obj, self.name, value)
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\bokeh\core\property\bases.py", line 331, in prepare_value
raise e
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\bokeh\core\property\bases.py", line 324, in prepare_value
self.validate(value)
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\bokeh\core\property\instance.py", line 112, in validate
raise ValueError(msg)
ValueError: expected an instance of type Title, got 0 of type int

# Fixed code
def wordcloud_viz(
    word_cnts: pd.Series,
    plot_width: int,
    plot_height: int,
) -> Panel:
    """
    Visualize the word cloud
    """  # pylint: disable=unsubscriptable-object
    ellipse_mask = np.array(
        Image.open(f"{Path(__file__).parent.parent.parent}/assets/ellipse.jpg")
    )
    wordcloud = WordCloud(background_color="white", mask=ellipse_mask)
    wordcloud.generate_from_frequencies(word_cnts)
    wcarr = wordcloud.to_array().astype(np.uint8)

    # use image_rgba following this example
    # https://docs.bokeh.org/en/latest/docs/gallery/image_rgba.html
    img = np.empty(wcarr.shape[:2], dtype=np.uint32)
    view = img.view(dtype=np.uint8).reshape((*wcarr.shape[:2], 4))
    alpha = np.full((*wcarr.shape[:2], 1), 255, dtype=np.uint8)
    view[:] = np.concatenate([wcarr, alpha], axis=2)[::-1]

    fig = figure(
        plot_width=plot_width,
        plot_height=plot_height,
        title="Word Cloud",
        x_range=(0, 1),
        y_range=(0, 1),
        toolbar_location=None,
    )
    fig.image_rgba(image=[img], x=0, y=0, dw=1, dh=1)

    fig.axis.visible = False
    fig.grid.visible = False
    return Panel(child=row(fig), title="Word Cloud")