Skip to content

Commit 61e06e2

Browse files
committed
closes #171. DAG example with estimation. fixed failing tests.
1 parent 5a115ad commit 61e06e2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

elphick/mass_composition/mass_composition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ def set_data(self, data: Union[pd.DataFrame, xr.Dataset],
125125
self._data = xr_ds
126126

127127
if not self._name:
128-
self.rename(common_prefix.strip('_'))
128+
self.rename('unnamed') if not common_prefix else self.rename(common_prefix.strip('_'))
129129
else:
130-
self.rename('unnamed') if not self._name else self.rename(self._name)
130+
self.rename(self._name)
131131

132132
# explicitly define the constraints
133133
self.constraints: Dict = self.get_constraint_bounds(constraints=constraints)

tests/test_102_splitting.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import pandas as pd
44
from sklearn.dummy import DummyRegressor
5+
from sklearn.pipeline import make_pipeline
56

67
from elphick.mass_composition import MassComposition, Stream
78
from elphick.mass_composition.mc_node import MCNode
89
from elphick.mass_composition.utils.partition import perfect
10+
from elphick.mass_composition.utils.sklearn import PandasPipeline
911
from .fixtures import size_assay_data
1012

1113
from elphick.mass_composition import Flowsheet
@@ -92,7 +94,7 @@ def test_split_by_estimator(size_assay_data):
9294

9395
x = mc_size.data.to_dataframe()
9496
y = x.copy().div(2)
95-
dummy_regressor = DummyRegressor(strategy='mean').fit(X=x, y=y)
97+
dummy_regressor = PandasPipeline.from_pipeline(make_pipeline(DummyRegressor(strategy='mean'))).fit(X=x, y=y)
9698

9799
mc_1, mc_2 = mc_size.split_by_estimator(estimator=dummy_regressor, name_1='one', name_2='two')
98100

@@ -108,7 +110,7 @@ def test_split_by_estimator_stream(size_assay_data):
108110

109111
x = mc_size.data.to_dataframe()
110112
y = x.copy().div(2)
111-
dummy_regressor = DummyRegressor(strategy='mean').fit(X=x, y=y)
113+
dummy_regressor = PandasPipeline.from_pipeline(make_pipeline(DummyRegressor(strategy='mean'))).fit(X=x, y=y)
112114

113115
strm_size: Stream = Stream.from_mass_composition(mc_size)
114116
strm_1, strm_2 = strm_size.split_by_estimator(estimator=dummy_regressor, name_1='one', name_2='two')

0 commit comments

Comments
 (0)