Date Analysis with Python: demographic-data-analyzer has incorrect `assertAlmostEqual` function calls
See original GitHub issueDescribe your problem and how to reproduce it:
The three issues with the assertAlmostEqual function calls are as follows:
-
an assertion error message is passed as a positional argument, resulting in the assertion not being called correctly. Changing this to pass as a keyword argument with keyword
msgfixes this. -
the expected values in the assertion are rounded to one decimal place, but actual values outputted in (correct) program is many decimal places so the assertion fails. Manually rounding each result in the function before sending to test fixes this. But rounding seems unneccessary burden to the user, especially as you would only know to do it if you looked at the tests very carefully.
-
expected
top_IN_occupationappears to be incorrect, I getPrivatebut expected in test isProf-specialtyeven though there are none of this profession (in India and salary >50K) in the dataset. Apologies if I’m incorrect here.
Add a Link to the page with the problem: https://repl.it/@freeCodeCamp/fcc-demographic-data-analyzer#README.md
Tell us about your browser and operating system:
- Browser Name: Mozilla Firefox
- Browser Version: 78.02
- Operating System: Windows 7
If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box): n/a
======================================================== I’m happy to create a PR for this but it would be good to have other opinions to make sure I’m not mistaken about anything before I go ahead.
In case it is of any use, my modified version is here: https://repl.it/@moustachiobelve/fcc-demographic-data-analyze
Update: corrected link, thanks for spotting the mistake @nhcarrigan
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
On this test, I think the comment in the
demographic_data_analyser.pyfile might be incorrect? I mistakenly looked for the top occupation in India overall, and that returned the expectedProf-specialty.To add on to this:
This test will not pass, because using the
assertAlmostEqualmethod expects an integer to round, while this test is called on a string value.@moustachio-belvedere - as an aside, did you mean to provide the link to the
mean-var-stdproject? 🤔