Skip to content

BUG/DEPR: the deprecation of util.testing fails for direct imports #30735

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

Closed
jorisvandenbossche opened this issue Jan 6, 2020 · 4 comments · Fixed by #30745
Closed

BUG/DEPR: the deprecation of util.testing fails for direct imports #30735

jorisvandenbossche opened this issue Jan 6, 2020 · 4 comments · Fixed by #30745
Labels
Deprecate Functionality to remove in pandas Testing pandas testing functions or related to the test suite
Milestone

Comments

@jorisvandenbossche
Copy link
Member

In [1]: from pandas.util.testing import assert_frame_equal  
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-79d99d902fdd> in <module>
----> 1 from pandas.util.testing import assert_frame_equal

ImportError: cannot import name 'assert_frame_equal' from 'pandas.util.testing' (/home/joris/scipy/pandas/pandas/util/testing/__init__.py)

It works when accessing from top-level import:

In [3]: pd.util.testing.assert_frame_equal
/home/joris/miniconda3/envs/dev/bin/ipython:1: FutureWarning: pandas._testing.assert_frame_equal is deprecated. Please use pandas.testing.assert_frame_equal instead.
  #!/home/joris/miniconda3/envs/dev/bin/python
Out[3]: <function pandas._testing.assert_frame_equal(left, right, check_dtype=True, check_index_type='equiv', check_column_type='equiv', check_frame_type=True, check_less_precise=False, check_names=True, by_blocks=False, check_exact=False, check_datetimelike_compat=False, check_categorical=True, check_like=False, obj='DataFrame')>
@jorisvandenbossche jorisvandenbossche added this to the 1.0 milestone Jan 6, 2020
@jorisvandenbossche
Copy link
Member Author

cc @TomAugspurger

@TomAugspurger
Copy link
Contributor

Thanks, looking into it.

@TomAugspurger
Copy link
Contributor

I think the easiest way to restore these is as references to the _DeprecatedModule items. Something like

# pandas/util/testing/__init__.py
testing = _DeprecatedModule("pandas._testing", "pandas.testing", _removals)

with warnings.catch_warnings():
    assert_frame_equal = testing.assert_frame_equal
    ...

@TomAugspurger
Copy link
Contributor

Actually that doesn't work since the user doesn't see the warning...

TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Jan 6, 2020
Closes pandas-dev#30735

This avoids using _DeprecatedModule, which doesn't work for
direct imports from a module.
@jreback jreback added Deprecate Functionality to remove in pandas Testing pandas testing functions or related to the test suite labels Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants