Skip to content

WIP: Debug ResourceWarnings BufferedRandom #44877

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
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4f164f5
WIP: Debug ResourceWarnings BufferedRandom
mroeschke Dec 14, 2021
9d23ff4
Restrict to file numbers, fix match to search
mroeschke Dec 14, 2021
a59e076
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 15, 2021
9038eee
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 16, 2021
b0cc40c
Mock FT2Font object that doesn't close file
mroeschke Dec 17, 2021
580e11c
Try writing to a in memory file
mroeschke Dec 17, 2021
b925040
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 17, 2021
131369a
Only check in plotting tests
mroeschke Dec 17, 2021
113c108
Try patching without importing
mroeschke Dec 18, 2021
8236f51
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 18, 2021
c273204
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 21, 2021
83daa1b
Try clearing cache
mroeschke Dec 21, 2021
473f0f6
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 21, 2021
d56c308
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 22, 2021
8d46016
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 22, 2021
60682c8
Just run plotting tests to be sure
mroeschke Dec 22, 2021
60b2007
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 23, 2021
82efb57
Run everything again
mroeschke Dec 23, 2021
14f2f4e
Check if lsof printing stuff
mroeschke Dec 23, 2021
9fe484d
lsof check globally again
mroeschke Dec 23, 2021
9ccff0d
Clear cache in another matplotlib test
mroeschke Dec 24, 2021
5bc96ae
Found another matplotlib test in pandas/tests/io/formats/test_to_exce…
mroeschke Dec 24, 2021
ea74b7c
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 24, 2021
c7faf30
Try clearing if matplotlib in sys modules
mroeschke Dec 25, 2021
1514f18
Merge remote-tracking branch 'upstream/master' into debug/resourcewar…
mroeschke Dec 25, 2021
dcbbea2
See what command raises on windows
mroeschke Dec 26, 2021
6f6fe4a
Silence all lsof fixture
mroeschke Dec 26, 2021
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
21 changes: 21 additions & 0 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,27 @@ def pytest_collection_modifyitems(items, config):
# ----------------------------------------------------------------
# Autouse fixtures
# ----------------------------------------------------------------
# pat = re.compile(r"python")
#
#
# @pytest.fixture(autouse=True)
# def lsof_check(request):
# yield
# # https://github.com/matplotlib/matplotlib/issues/22017#issuecomment-998241017
# if "matplotlib" in sys.modules:
# import matplotlib
#
# matplotlib.font_manager._get_font.cache_clear()
# lsof = subprocess.run(["lsof", "-d", "0-25"], capture_output=True).stdout.decode(
# "utf-8"
# )
# for line in lsof.split("\n"):
# if re.search(pat, line):
# # sys.stderr for xdist
# # https://github.com/pytest-dev/pytest/issues/1693#issuecomment-233282644
# print(f"{request.node.name}: {line}", flush=True, file=sys.stderr)


@pytest.fixture(autouse=True)
def configure_tests():
"""
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/api/test_types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import subprocess

import pandas._testing as tm
from pandas.api import types
from pandas.tests.api.test_api import Base
Expand Down Expand Up @@ -57,7 +59,7 @@ def test_types(self):
self.check(types, self.allowed + self.dtypes + self.deprecated)

def test_deprecated_from_api_types(self):

subprocess.check_output(["lsof", "-d", "0-25", "-F", "n"]).decode("utf-8")
for t in self.deprecated:
with tm.assert_produces_warning(FutureWarning):
getattr(types, t)(1)
34 changes: 19 additions & 15 deletions pandas/tests/io/formats/style/test_matplotlib.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
DataFrame,
IndexSlice,
Series,
)

pytest.importorskip("matplotlib")
pytest.importorskip("jinja2")

import matplotlib as mpl

from pandas.io.formats.style import Styler


Expand Down Expand Up @@ -260,18 +259,23 @@ def test_background_gradient_gmap_wrong_series(styler_blank):
styler_blank.background_gradient(gmap=gmap, axis=None)._compute()


@pytest.mark.parametrize("cmap", ["PuBu", mpl.cm.get_cmap("PuBu")])
def test_bar_colormap(cmap):
data = DataFrame([[1, 2], [3, 4]])
ctx = data.style.bar(cmap=cmap, axis=None)._compute().ctx
pubu_colors = {
(0, 0): "#d0d1e6",
(1, 0): "#056faf",
(0, 1): "#73a9cf",
(1, 1): "#023858",
}
for k, v in pubu_colors.items():
assert v in ctx[k][1][1]
@td.skip_if_no_mpl
def test_bar_colormap():
import matplotlib as mpl

for cmap in ["PuBu", mpl.cm.get_cmap("PuBu")]:
data = DataFrame([[1, 2], [3, 4]])
ctx = data.style.bar(cmap=cmap, axis=None)._compute().ctx
pubu_colors = {
(0, 0): "#d0d1e6",
(1, 0): "#056faf",
(0, 1): "#73a9cf",
(1, 1): "#023858",
}
for k, v in pubu_colors.items():
assert v in ctx[k][1][1]
# https://github.com/matplotlib/matplotlib/issues/22017#issuecomment-998241017
mpl.font_manager._get_font.cache_clear()


def test_bar_color_raises(df):
Expand Down
6 changes: 5 additions & 1 deletion pandas/tests/io/formats/test_to_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,12 @@ def tests_css_named_colors_valid():

@td.skip_if_no_mpl
def test_css_named_colors_from_mpl_present():
from matplotlib.colors import CSS4_COLORS as mpl_colors
import matplotlib as mpl

mpl_colors = mpl.colors.CSS4_COLORS
pd_colors = CSSToExcelConverter.NAMED_COLORS
for name, color in mpl_colors.items():
assert name in pd_colors and pd_colors[name] == color[1:]

# https://github.com/matplotlib/matplotlib/issues/22017#issuecomment-998241017
mpl.font_manager._get_font.cache_clear()