question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Date Analysis with Python: demographic-data-analyzer has incorrect `assertAlmostEqual` function calls

See original GitHub issue

Describe 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 msg fixes 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_occupation appears to be incorrect, I get Private but expected in test is Prof-specialty even 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
naomi-lgbtcommented, Jul 15, 2020

expected top_IN_occupation appears to be incorrect, I get Private but expected in test is Prof-specialty even though there are none of this profession (in India and salary >50K) in the dataset. Apologies if I’m incorrect here.

On this test, I think the comment in the demographic_data_analyser.py file might be incorrect? I mistakenly looked for the top occupation in India overall, and that returned the expected Prof-specialty.

1reaction
naomi-lgbtcommented, Jul 15, 2020

To add on to this:

def test_highest_earning_country(self):
        actual = self.data['highest_earning_country']
        expected = 'Iran'
        self.assertAlmostEqual(actual, expected, "Expected different value for highest earning country.")  

This test will not pass, because using the assertAlmostEqual method 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-std project? 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with Demographic Data Analyzer test module
Hi all, I'm done with the Demographic Data Analyzer test except for one ... has incorrect assertAlmostEqual function calls · Issue #39243 ......
Read more >
readme - Tai Le
In this challenge you must analyze demographic data using Pandas. You are given a dataset of demographic data that was extracted from the...
Read more >
Demographic Data Analyzer | FreeCodeCamp - YouTube
I go through how I did the Demographic Data Analyzer on FreeCodeCamp. It is part of the data analysis with python certification.
Read more >
Bountysource
Date Analysis with Python: demographic-data-analyzer has incorrect `assertAlmostEqual` function calls.
Read more >
History - Collection of Repositories - Python.org
Fix warnings reported by Klocwork's static analysis tool. - Bug #1512814, Fix incorrect lineno's when code within a function had more than 255...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found