Skip to content

Commit

Permalink
move PlotAccessor stuff from samples into weighted_pandas, where it s…
Browse files Browse the repository at this point in the history
…hould have arguably been in the first place
  • Loading branch information
lukashergt committed Sep 13, 2023
1 parent 735f4bd commit 43c5be5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 0 additions & 7 deletions anesthetic/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@
from anesthetic.gui.plot import RunPlotter
from anesthetic.weighted_pandas import WeightedDataFrame, WeightedSeries
from anesthetic.labelled_pandas import LabelledDataFrame, LabelledSeries
from pandas.core.accessor import CachedAccessor
from anesthetic.plot import (make_1d_axes, make_2d_axes,
AxesSeries, AxesDataFrame)
from anesthetic.utils import adjust_docstrings
import anesthetic.weighted_pandas
from anesthetic.plotting import PlotAccessor
anesthetic.weighted_pandas._WeightedObject.plot =\
CachedAccessor("plot", PlotAccessor)


class WeightedLabelledDataFrame(WeightedDataFrame, LabelledDataFrame):
Expand Down Expand Up @@ -172,8 +167,6 @@ def __init__(self, *args, **kwargs):
def _constructor(self):
return Samples

plot = CachedAccessor("plot", PlotAccessor)

def plot_1d(self, axes=None, *args, **kwargs):
"""Create an array of 1D plots.
Expand Down
5 changes: 5 additions & 0 deletions anesthetic/weighted_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from anesthetic.utils import (compress_weights, neff, quantile,
temporary_seed, adjust_docstrings)
from pandas.core.dtypes.missing import notna
from pandas.core.accessor import CachedAccessor
from anesthetic.plotting import PlotAccessor


class WeightedGroupBy(GroupBy):
Expand Down Expand Up @@ -141,6 +143,9 @@ def __init__(self, *args, **kwargs):
if weights is not None:
self.set_weights(weights, inplace=True)

plot = CachedAccessor("plot", PlotAccessor)
""":meta private:"""

def isweighted(self, axis=0):
"""Determine if weights are actually present."""
return 'weights' in self._get_axis(axis).names
Expand Down

0 comments on commit 43c5be5

Please sign in to comment.