There are 3 errors here, but regarding the first two:
======================================================================
ERROR: test_bar_plot_number_of_bars (test_module.CatPlotTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/boilerplate-medical-data-visualizer-1/test_module.py", line 26, in test_bar_plot_number_of_bars
actual = len([rect for rect in self.ax.get_children() if isinstance(rect, mpl.patches.Rectangle)])
AttributeError: 'numpy.ndarray' object has no attribute 'get_children'
======================================================================
ERROR: test_line_plot_labels (test_module.CatPlotTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/boilerplate-medical-data-visualizer-1/test_module.py", line 13, in test_line_plot_labels
actual = self.ax.get_xlabel()
AttributeError: 'numpy.ndarray' object has no attribute 'get_xlabel'
You can find a bit more info here:
https://forum.freecodecamp.org/t/draw-bar-plot-test-failure/424240/2?u=pkdvalis
I find this problem poorly documented and not clear at all tbh. I’ve solved it by putting fig = fig.figure before the save, like this:
fig = fig.figure
# Do not modify the next two lines
fig.savefig('catplot.png')
return fig
This converts the seaborn facet grid into a figure that the tests can read. This will clear the first two errors. I’m providing the solution here because I can’t find good documentation that actually explains this, and it seems to only be needed for this test. The image is still generated. All I can find is this:
http://seaborn.pydata.org/generated/seaborn.FacetGrid.html
figure
Access the matplotlib.figure.Figure object underlying the grid.