Skip to content

Commit

Permalink
Remove pandas context manager
Browse files Browse the repository at this point in the history
  • Loading branch information
has2k1 committed May 17, 2024
1 parent fe855e3 commit aec1837
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions plotnine/_utils/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from typing import TYPE_CHECKING

import pandas as pd

if TYPE_CHECKING:
from typing_extensions import Self

Expand Down Expand Up @@ -31,22 +29,12 @@ def __init__(self, plot: ggplot, show: bool = False):

# Contexts
self.rc_context = mpl.rc_context(plot.theme.rcParams)
# Pandas deprecated is_copy, and when we create new dataframes
# from slices we do not want complaints. We always uses the
# new frames knowing that they are separate from the original.
self.pd_option_context = pd.option_context(
"mode.chained_assignment",
None,
"mode.copy_on_write",
False,
)

def __enter__(self) -> Self:
"""
Enclose in matplolib & pandas environments
"""
self.rc_context.__enter__()
self.pd_option_context.__enter__()
return self

def __exit__(self, exc_type, exc_value, exc_traceback):
Expand All @@ -66,4 +54,3 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
plt.close(self.plot.figure)

self.rc_context.__exit__(exc_type, exc_value, exc_traceback)
self.pd_option_context.__exit__(exc_type, exc_value, exc_traceback)

0 comments on commit aec1837

Please sign in to comment.