Fix/test and missing definition (#18)

* added missing comment on setting up matplotlib

* changed assertion description so that it makes sense

* fig definition

* new comment
This commit is contained in:
Ilenia 2022-07-25 23:11:06 +02:00 committed by GitHub
parent 331d1610dd
commit 988c0755a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -20,11 +20,16 @@ def draw_cat_plot():
# Group and reformat the data to split it by 'cardio'. Show the counts of each feature. You will have to rename one of the columns for the catplot to work correctly. # Group and reformat the data to split it by 'cardio'. Show the counts of each feature. You will have to rename one of the columns for the catplot to work correctly.
df_cat = None df_cat = None
# Draw the catplot with 'sns.catplot()' # Draw the catplot with 'sns.catplot()'
# Get the figure for the output
fig = None
# Do not modify the next two lines # Do not modify the next two lines
fig.savefig('catplot.png') fig.savefig('catplot.png')
return fig return fig

View File

@ -38,7 +38,7 @@ class HeatMapTestCase(unittest.TestCase):
for label in self.ax.get_xticklabels(): for label in self.ax.get_xticklabels():
actual.append(label.get_text()) actual.append(label.get_text())
expected = ['id', 'age', 'sex', 'height', 'weight', 'ap_hi', 'ap_lo', 'cholesterol', 'gluc', 'smoke', 'alco', 'active', 'cardio', 'overweight'] expected = ['id', 'age', 'sex', 'height', 'weight', 'ap_hi', 'ap_lo', 'cholesterol', 'gluc', 'smoke', 'alco', 'active', 'cardio', 'overweight']
self.assertEqual(actual, expected, "Expected bar plot legend labels to be months of the year.") self.assertEqual(actual, expected, "Expected heat map labels to be 'id', 'age', 'sex', 'height', 'weight', 'ap_hi', 'ap_lo', 'cholesterol', 'gluc', 'smoke', 'alco', 'active', 'cardio', 'overweight'.")
def test_heat_map_values(self): def test_heat_map_values(self):
actual = [text.get_text() for text in self.ax.get_default_bbox_extra_artists() if isinstance(text, mpl.text.Text)] actual = [text.get_text() for text in self.ax.get_default_bbox_extra_artists() if isinstance(text, mpl.text.Text)]