Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST/API: Simplify testing functions API #10788

Closed
sinhrks opened this issue Aug 10, 2015 · 4 comments
Closed

TST/API: Simplify testing functions API #10788

sinhrks opened this issue Aug 10, 2015 · 4 comments
Labels
API Design Clean Testing pandas testing functions or related to the test suite

Comments

@sinhrks
Copy link
Member

sinhrks commented Aug 10, 2015

Derived from #10507. Consider better API for testing functions.

1. How to specify comparison tolerance

Current assert functions have check_less_precise and check_exact flags to specify how to compare values:

  • check_exact=True: Use assert_equal, comparison using ==.
  • check_exact=False and check_less_precise=False: Use assert_almost_equal, comparing 5 digits after decimal points (default)
  • check_exact=False and check_less_precise=True: Use assert_almost_equal, comparing 3 digits after decimal points

There can be single kw to specify above behaviors?

2. Make integrated assert function

I think it's nice to have test functions which supports all pandas objects for users who is starting contribution / using pandas as their dependencies. Changing assertEquals and assertAlmostEquals to internally use current assert_index/series/frame_equal is one idea.

3. Remove assert_almost_equal

Remove assert_almost_equal and use class-based validation method. Also add input type validation to numpy_assert_array_equal.

xref #9895.

@sinhrks sinhrks added Testing pandas testing functions or related to the test suite API Design labels Aug 10, 2015
@kawochen
Copy link
Contributor

I've seen multiple versions of 2 scattered across different test scripts, such as this. They might be good building blocks.

@jorisvandenbossche
Copy link
Member

Regarding the How to specify comparison tolerance, I have two problems with the current interface:

  • It is a bit clumsy, as you have two keywords that could perfectly fit into one keyword, making it a bit confusing.
  • It is also not very flexible, as it only gives you the option to check all, 5 or 3 digits. For example, if you have values of different order in one frame (eg 0.0001 to 100), then the absolute number of digits cannot be used to check this but you need something relative. Therefore, you have to fall back to checking the .values with numpy.

Specifically for that last point, I think it is nice to look at np.testing.assert_allclose (which is now the recommended way in numpy according to the assert_array_almost_equal docstring), which uses both relative and absolute tolerance.

@sinhrks
Copy link
Member Author

sinhrks commented May 5, 2016

Added 3rd item, I think we should replace assert_almost_equal to precise functions as much.

@sinhrks sinhrks added this to the 0.19.0 milestone May 5, 2016
@jreback jreback modified the milestones: 0.20.0, Next Major Release Mar 23, 2017
@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
@mroeschke
Copy link
Member

I think a lot of these have addressed in a meantime so closing

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Clean Testing pandas testing functions or related to the test suite
Projects
None yet
Development

No branches or pull requests

5 participants