Skip to content

DOC: updates documentations Closes #21749 #42979

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

Merged
merged 5 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions pandas/_testing/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,18 @@ def network(
Tests decorated with @network will fail if it's possible to make a network
connection to another URL (defaults to google.com)::

>>> from pandas._testing import network
>>> from pandas.io.common import urlopen
>>> @network
>>> from pandas import _testing as ts
>>> @ts.network
... def test_network():
... with urlopen("rabbit://bonanza.com"):
... with pd.io.common.urlopen("rabbit://bonanza.com"):
... pass
Traceback
...
URLError: <urlopen error unknown url type: rabit>

You can specify alternative URLs::

>>> @network("https://www.yahoo.com")
>>> @ts.network("https://www.yahoo.com")
... def test_something_with_yahoo():
... raise IOError("Failure Message")
>>> test_something_with_yahoo()
Expand All @@ -183,7 +182,7 @@ def network(
If you set check_before_test, it will check the url first and not run the
test on failure::

>>> @network("failing://url.blaher", check_before_test=True)
>>> @ts.network("failing://url.blaher", check_before_test=True)
... def test_something():
... print("I ran!")
... raise ValueError("Failure")
Expand Down
12 changes: 6 additions & 6 deletions pandas/_testing/asserters.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ def assert_index_equal(

Examples
--------
>>> from pandas.testing import assert_index_equal
>>> from pandas import testing as tm
>>> a = pd.Index([1, 2, 3])
>>> b = pd.Index([1, 2, 3])
>>> assert_index_equal(a, b)
>>> tm.assert_index_equal(a, b)
"""
__tracebackhide__ = True

Expand Down Expand Up @@ -794,10 +794,10 @@ def assert_extension_array_equal(

Examples
--------
>>> from pandas.testing import assert_extension_array_equal
>>> from pandas import testing as tm
>>> a = pd.Series([1, 2, 3, 4])
>>> b, c = a.array, a.array
>>> assert_extension_array_equal(b, c)
>>> tm.assert_extension_array_equal(b, c)
"""
if check_less_precise is not no_default:
warnings.warn(
Expand Down Expand Up @@ -938,10 +938,10 @@ def assert_series_equal(

Examples
--------
>>> from pandas.testing import assert_series_equal
>>> from pandas import testing as tm
>>> a = pd.Series([1, 2, 3, 4])
>>> b = pd.Series([1, 2, 3, 4])
>>> assert_series_equal(a, b)
>>> tm.assert_series_equal(a, b)
"""
__tracebackhide__ = True

Expand Down
3 changes: 1 addition & 2 deletions pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ def register_extension_dtype(cls: type_t[ExtensionDtypeT]) -> type_t[ExtensionDt

Examples
--------
>>> from pandas.api.extensions import register_extension_dtype
>>> from pandas.api.extensions import ExtensionDtype
>>> from pandas.api.extensions import register_extension_dtype, ExtensionDtype
>>> @register_extension_dtype
... class MyExtensionDtype(ExtensionDtype):
... name = "myextension"
Expand Down
9 changes: 3 additions & 6 deletions pandas/io/formats/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,8 @@ def _select_iterator(self, over: str) -> type[RowStringIterator]:
class LongTableBuilder(GenericTableBuilder):
"""Concrete table builder for longtable.

>>> from pandas import DataFrame
>>> from pandas.io.formats import format as fmt
>>> df = DataFrame({"a": [1, 2], "b": ["b1", "b2"]})
>>> df = pd.DataFrame({"a": [1, 2], "b": ["b1", "b2"]})
>>> formatter = fmt.DataFrameFormatter(df)
>>> builder = LongTableBuilder(formatter, caption='a long table',
... label='tab:long', column_format='lrl')
Expand Down Expand Up @@ -578,9 +577,8 @@ def env_end(self) -> str:
class RegularTableBuilder(GenericTableBuilder):
"""Concrete table builder for regular table.

>>> from pandas import DataFrame
>>> from pandas.io.formats import format as fmt
>>> df = DataFrame({"a": [1, 2], "b": ["b1", "b2"]})
>>> df = pd.DataFrame({"a": [1, 2], "b": ["b1", "b2"]})
>>> formatter = fmt.DataFrameFormatter(df)
>>> builder = RegularTableBuilder(formatter, caption='caption', label='lab',
... column_format='lrc')
Expand Down Expand Up @@ -625,9 +623,8 @@ def env_end(self) -> str:
class TabularBuilder(GenericTableBuilder):
"""Concrete table builder for tabular environment.

>>> from pandas import DataFrame
>>> from pandas.io.formats import format as fmt
>>> df = DataFrame({"a": [1, 2], "b": ["b1", "b2"]})
>>> df = pd.DataFrame({"a": [1, 2], "b": ["b1", "b2"]})
>>> formatter = fmt.DataFrameFormatter(df)
>>> builder = TabularBuilder(formatter, column_format='lrc')
>>> table = builder.get_result()
Expand Down
3 changes: 2 additions & 1 deletion pandas/tseries/holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ class from pandas.tseries.offsets
Holiday: July 3rd (month=7, day=3, )

>>> NewYears = Holiday(
... "New Years Day", month=1, day=1, observance=nearest_workday
... "New Years Day", month=1, day=1,
... observance=nearest_workday
... )
>>> NewYears # doctest: +SKIP
Holiday: New Years Day (
Expand Down