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.

TST: tests comparison on numpy master

See original GitHub issue

https://travis-ci.org/pandas-dev/pandas/jobs/256013691

this was working a few builds ago. I think maybe some random sorting details, IOW how exactly argsort works can make this fail with either ‘>’ or ‘<’. so ok with changing test to accept either.

________________________ TestMixedIntIndex.test_argsort ________________________
[gw1] linux -- Python 3.6.2 /home/travis/miniconda3/envs/pandas/bin/python
self = <pandas.tests.indexes.test_base.TestMixedIntIndex object at 0x7fe54ca566a0>
    def test_argsort(self):
        idx = self.create_index()
        if PY36:
            with tm.assert_raises_regex(TypeError, "'>' not supported"):
>               result = idx.argsort()
pandas/tests/indexes/test_base.py:1850: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pandas/util/testing.py:2493: in __exit__
    return self.exception_matches(exc_type, exc_value, trace_back)
pandas/util/testing.py:2528: in exception_matches
    raise_with_traceback(e, trace_back)
pandas/compat/__init__.py:343: in raise_with_traceback
    raise exc.with_traceback(traceback)
pandas/tests/indexes/test_base.py:1850: in test_argsort
    result = idx.argsort()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = Index([0, 'a', 1, 'b', 2, 'c'], dtype='object'), args = (), kwargs = {}
result = array([0, 'a', 1, 'b', 2, 'c'], dtype=object)
    def argsort(self, *args, **kwargs):
        """
            Returns the indices that would sort the index and its
            underlying data.
    
            Returns
            -------
            argsorted : numpy array
    
            See also
            --------
            numpy.ndarray.argsort
            """
        result = self.asi8
        if result is None:
            result = np.array(self)
>       return result.argsort(*args, **kwargs)
E       AssertionError: "'>' not supported" does not match "'<' not supported between instances of 'str' and 'int'"
pandas/core/indexes/base.py:2102: AssertionError

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ysaucommented, Jul 21, 2017

@gfyoung : I am looking at the documentation linked from your post. Thanks for offering guidance!

1reaction
gfyoungcommented, Jul 21, 2017

@ysau : Awesome! Thanks for taking this issue up. The problem that @jreback is raising is that the error message we’re checking for is not correct (probably a flakey test).

Thus, all you would need to do is go in and change the expected error message in that test (TestMixedIntIndex.test_argsort) in pandas.tests.indexes.test_base.py to something that would account for both us seeing ‘>’ and ‘<’ in the error message.

I think you can just replace > with >|< and everything should be fine.

Let us know if you have any other questions!

FYI: documentation for contributing can be found here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Better introspection for comparing numpy arrays #5347 - GitHub
With plain python lists I can do: a = [1, 2, 3] b = [1, 2, 4] assert a == b That does...
Read more >
Master NumPy. Here are concepts and tried-tested… - Medium
Introduction To NumPy || Master NumPy in 45min Playlist ... Here is two smart tried and tested strategies to learn very fast:.
Read more >
101 NumPy Exercises for Data Analysis (Python) - ML+
The goal of the numpy exercises is to serve as a reference as well as to get you to apply numpy beyond the...
Read more >
Test Support (numpy.testing) — NumPy v1.24 Manual
Common test support for all numpy test scripts. ... For background, see the Testing Guidelines ... Compare two arrays relatively to their spacing....
Read more >
Pure Python vs NumPy vs TensorFlow Performance Comparison
A performance comparison between pure Python, NumPy, and TensorFlow using a simple linear regression algorithm.
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