TST: add test for getting array from series
State: closed

- [x] closes #38543 
- [ x] tests added / passed
- [x ] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them
- [ ] whatsnew entry


Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Constructors
description: Series/DataFrame/Index/pd.array Constructors
name: Upstream issue
description: Issue related to pandas dependency

Comments:
Mind investigating the failures @horaceklai? 
> Mind investigating the failures @horaceklai?

Do you mean investigating the bug that the issue initially described?

The failure has to do with the bug reoccurring. I thought it was fixed from the comments written before I took this issue, but it is here now.
can you merge master and ping on green.
> You need to skip this test on old numpy. I believe 1.19 is the first version it works on but haven't checked.

Hi Thomas,

I am not sure how to skip certain tests for old numpy. Mind giving me a tip?

Thanks,
Horace
Have a look at the ``pytest.mark.skipif`` decorator(https://docs.pytest.org/en/latest/reference/reference.html#pytest-mark-skipif-ref). 

You'll also need https://github.com/pandas-dev/pandas/blob/35d52ff2d50ebbf24514407d5986ccf89f56b296/pandas/compat/numpy/__init__.py#L12 from ``pandas.compat.numpy``.
This variable is a boolean that tells you if the numpy version is under 1.19

So you'll have something like 
```
from pandas.compat.numpy import np_version_under1p19
...
...
...
@pytest.mark.skipif(np_version_under1p19, reason="fails on numpy below 1.19")
[your test code]
```

Let me know if you have more questions.
> Have a look at the `pytest.mark.skipif` decorator(https://docs.pytest.org/en/latest/reference/reference.html#pytest-mark-skipif-ref).
> 
> You'll also need
> 
> https://github.com/pandas-dev/pandas/blob/35d52ff2d50ebbf24514407d5986ccf89f56b296/pandas/compat/numpy/__init__.py#L12
> 
> from `pandas.compat.numpy`.
> This variable is a boolean that tells you if the numpy version is under 1.19
> So you'll have something like
> 
> ```
> from pandas.compat.numpy import np_version_under1p19
> ...
> ...
> ...
> @pytest.mark.skipif(np_version_under1p19, reason="fails on numpy below 1.19")
> [your test code]
> ```
> 
> Let me know if you have more questions.

Thanks! You pretty much did all the work for me and I learned something new!
Yes, good idea.

On Mon, Sep 6, 2021, 5:25 PM Jeff Reback ***@***.***> wrote:

> ***@***.**** commented on this pull request.
> ------------------------------
>
> In pandas/tests/series/test_constructors.py
> <https://github.com/pandas-dev/pandas/pull/42939#discussion_r702974630>:
>
> > @@ -1840,3 +1841,17 @@ def test_constructor(rand_series_with_duplicate_datetimeindex):
>      dups = rand_series_with_duplicate_datetimeindex
>      assert isinstance(dups, Series)
>      assert isinstance(dups.index, DatetimeIndex)
> +
> +
> ***@***.***(
> +    "input_dict,expected",
> +    [
> +        ({0: 0}, np.array([[0]], dtype=np.int64)),
> +        ({"a": "a"}, np.array([["a"]], dtype=object)),
> +        ({1: 1}, np.array([[1]], dtype=np.int64)),
> +    ],
> +)
> ***@***.***(np_version_under1p19, reason="fails on numpy below 1.19")
>
> can you write a tests that specifically tests < numpy 1.19. e.g. an
> asserts the error that happens (OT I wonder if this is fixable on the
> pandas side).
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/42939#pullrequestreview-747317050>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AKTQNIYUAY6N3G6P42VDOQTUATMQHANCNFSM5BY3FVMA>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
>

@horaceklai Can you fix the test failures?
> @horaceklai Can you fix the test failures?

I think I fixed it now with the error message not matching, but now I'm having another error that I don't know if it is related. The test is taking too much time (> 1hr)
Thanks @horaceklai