Test module seems to ignore valid answer

The test modules sometimes appear to ignore valid answers. I understand that in order for projects to be graded programmatically there needs to be certain limits on what counts as a valid answer, but the occasionally leads to cases where identical visual output is considered invalid. This is especially problematic when the output is a plot. For example, in the “data analysis with python” project “medical data visualizer”, the following code produces a bar chart that is identical to the target bar chart, but it causes errors in the code evaluation (the code itself runs without errors, it is the evaluation of the code in the test module that causes the errors). The only difference between the plot produced by this code and the target plot is the y axis, but that value isn’t checked.

def draw_cat_plot():
    # Create DataFrame for cat plot using `pd.melt` using just the values from 'cholesterol', 'gluc', 'smoke', 'alco', 'active', and 'overweight'.
    df_cat = df.melt(id_vars=["cardio"],value_vars=['active', 'alco', 'cholesterol', 'gluc', 'overweight', 'smoke'])
    # 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 = df_cat.groupby(["cardio",'variable'])

    # Draw the catplot with 'sns.catplot()'
    fig=sns.catplot(data=temp, x="variable",kind="count",hue="value", col="cardio")

    # Do not modify the next two lines
    return fig 

I suspect that the issue is that I am “supposed” to use the summary data returned by pandas functions (which I included only on a hunch that it might help fix the issue, it didn’t), instead of creating the plot whole-cloth using builtin seaborn functions, but given that the resulting plots are identical, that FreeCodeCamp doesn’t actually provide instruction on using Seaborn (the videos were on matplotlib, so there is no hint as to what the “correct” answer should look like), and that using the seaborn code makes for a more elegant solution, the provided solution really should be considered valid.

On top of that, the test_module code is clearly cut and paste from another module, and so has “vestigial” code chunks. Frankly, that’s just sloppy for public facing code.

So? If your job is produce a specific thing, you cannot stop by saying “it looks right” when you don’t produce that hing.

Also if you got feedback on the test modules or something else, please open a topic for that and actually point out something that you think might need some fixing.

Meanwhile, if you refer to a challenge, you should at least provide a link to the challenge and maybe your replit as well… that’s just sloppy complaining ;p

As for this challenge, the test module is fine. What you get is a common error which you might have figured, if you actually looked at the forum for similar topics or the error itself.
Seaborn is returning a facetgrid-object but the test want’s just the actual chart, which is located under the .figure attribute.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.