Data Analysis with Python Projects - Medical Data Visualizer-Heatmap-values

Hi,

A number of campers have run into this problem:

when I run it on replit the heatmap does not show the annot values , even when the test module retrieves those values, the output just shows [‘–’ , ‘–’].

To fix this, I have been recommending to fork the code from this replit: https://replit.com/@freeCodeCamp/fcc-medical-data-visualizer

And it seems to have been working. But now another camper has noticed that the test suite contains some extra blank elements at the end:

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)]
        print(actual)
        expected = ['0.0', '0.0', '-0.0', '0.0', '-0.1', '0.5', '0.0', '0.1', '0.1', '0.3', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.2', '0.1', '0.0', '0.2', '0.1', '0.0', '0.1', '-0.0', '-0.1', '0.1', '0.0', '0.2', '0.0', '0.1', '-0.0', '-0.0', '0.1', '0.0', '0.1', '0.4', '-0.0', '-0.0', '0.3', '0.2', '0.1', '-0.0', '0.0', '0.0', '-0.0', '-0.0', '-0.0', '0.2', '0.1', '0.1', '0.0', '0.0', '0.0', '0.0', '0.3', '0.0', '-0.0', '0.0', '-0.0', '-0.0', '-0.0', '0.0', '0.0', '-0.0', '0.0', '0.0', '0.0', '0.2', '0.0', '-0.0', '0.2', '0.1', '0.3', '0.2', '0.1', '-0.0', '-0.0', '-0.0', '-0.0', '0.1', '-0.1', '-0.1', '0.7', '0.0', '0.2', '0.1', '0.1', '-0.0', '0.0', '-0.0', '0.1', '', '', '']

Which causes an error and does not match what’s on github https://github.com/freeCodeCamp/boilerplate-medical-data-visualizer/blob/main/test_module.py:

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)]
        print(actual)
        expected = ['0.0', '0.0', '-0.0', '0.0', '-0.1', '0.5', '0.0', '0.1', '0.1', '0.3', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.2', '0.1', '0.0', '0.2', '0.1', '0.0', '0.1', '-0.0', '-0.1', '0.1', '0.0', '0.2', '0.0', '0.1', '-0.0', '-0.0', '0.1', '0.0', '0.1', '0.4', '-0.0', '-0.0', '0.3', '0.2', '0.1', '-0.0', '0.0', '0.0', '-0.0', '-0.0', '-0.0', '0.2', '0.1', '0.1', '0.0', '0.0', '0.0', '0.0', '0.3', '0.0', '-0.0', '0.0', '-0.0', '-0.0', '-0.0', '0.0', '0.0', '-0.0', '0.0', '0.0', '0.0', '0.2', '0.0', '-0.0', '0.2', '0.1', '0.3', '0.2', '0.1', '-0.0', '-0.0', '-0.0', '-0.0', '0.1', '-0.1', '-0.1', '0.7', '0.0', '0.2', '0.1', '0.1', '-0.0', '0.0', '-0.0', '0.1']

So maybe the Replit version can be fixed.

I’m not sure what was causing the original problem, I thought maybe corrupt Replit.

Continuing the discussion from Data Analysis with Python Projects - Medical Data Visualizer-Heatmap-values:

1 Like

Same problem again:

I don’t remember right now which one, but that’s caused by one of the dependencies, it might have been pandas. With one version there will be empty elements at the end, with other there will not.

Well, there’s two problems:

  1. At some point the heatmap data is all blank. The code was 100% correct, (I copied in known working code) the only fix I could find is simply fork the boilerplate replit (not import it from github) and it seemed to work until:

  2. In the test script test_module.py located here: https://replit.com/@freeCodeCamp/fcc-medical-data-visualizer the heatmap test array ends like this: '-0.0', '0.1', '', '', ''] which does not match the github version

So maybe problem 1 is caused by the pandas verion? I’ll test that out, thanks!

For reference here is the error and Pandas version:

AssertionError: Lists differ: ['--', '--', '--', '--', '--', '--', '--', [36 chars]'--'] != ['0.0', '0.0', '-0.0', '0.0', '-0.1', '0.5'[615 chars]0.1']

Pandas 2.1.0

Testing this: https://replit.com/@pkdvalis/martintokman-medical-data-visualizer-2#medical_data_visualizer.py

I’ll try different versions of Pandas

Same error with Pandas 1.5.3 and 2.1.1

I’m having hard time to test this on replit myself, just spend half an hour waiting for poetry to change the pandas version, to result in an error.

I’ve found couple my old posts suggesting it’s matplotlib who’s the culprit of empty elements at the end. The change was then at the versions 3.2.2/3.3.0.

Same, it seemed to hang when trying to remove Pandas using the packages module. I had better luck using the shell command prompt pip install pandas==2.1.1 or whatever version/dependency.

When you say “empty elements at the end” are you referring to the test_module.py which has 3 blank elements at the end ? Because the error shows the entire heatmap, all elements, are blank.

same error
https://forum.freecodecamp.org/t/data-analysis-with-python-projects-medical-data-visualizer-figure-settings/641051/7

Sorry, I meant the 3 blank elements, that sometimes appear in the result and/or test module.

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