Skip to content

Commit 376c5e6

Browse files
committed
.
1 parent a9e8270 commit 376c5e6

File tree

2 files changed

+32
-40
lines changed

2 files changed

+32
-40
lines changed

Diff for: skfda/preprocessing/binning.py

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Data Binning Module with CommonGridBinner class."""
1+
"""Data Binning Module with GridBinner class."""
22

33
import itertools
44
from typing import Any, List, Optional, Tuple, Union, cast
@@ -35,15 +35,7 @@
3535
TupleOutputGrid = Tuple[None, Tuple[NDArray[np.float64], ...]]
3636

3737

38-
class CommonGridBinner( # noqa: WPS230
39-
# class DomainBinner(
40-
# class Binner(
41-
# class FunctionalDataBinningTransformer(
42-
# class CommonGridTransformer(
43-
# class DataBinner(
44-
# class Discretizer(
45-
# class FunctionalDataDiscretizer(
46-
# class CommonGridDiscretizer(
38+
class GridBinner( # noqa: WPS230
4739
BaseEstimator,
4840
TransformerMixin[FDataGrid, FDataGrid, object],
4941
):
@@ -111,7 +103,7 @@ class CommonGridBinner( # noqa: WPS230
111103
Given an FDataIrregular with 2 samples representing a function
112104
:math:`f : \mathbb{R}\longmapsto\mathbb{R}^2`.
113105
114-
>>> from skfda.preprocessing.binning import CommonGridBinner
106+
>>> from skfda.preprocessing.binning import GridBinner
115107
>>> from skfda.representation import FDataIrregular
116108
>>> indices=[0,2]
117109
>>> points=[[1.0],[4.0],[1.0],[3.0],[5.0]]
@@ -127,14 +119,14 @@ class CommonGridBinner( # noqa: WPS230
127119
... points=points,
128120
... values=values,
129121
... )
130-
>>> binner = CommonGridBinner(bins=2)
122+
>>> binner = GridBinner(bins=2)
131123
>>> binner.fit_transform(fd)
132124
133125
Given a FDataGrid with 2 samples representing a function
134126
:math:`f : \mathbb{R}^2\longmapsto\mathbb{R}`.
135127
136128
>>> import numpy as np
137-
>>> from skfda.preprocessing.binning import CommonGridBinner
129+
>>> from skfda.preprocessing.binning import GridBinner
138130
>>> from skfda.representation import FDataGrid
139131
>>> grid_points=[
140132
... [1., 2.],
@@ -156,7 +148,7 @@ class CommonGridBinner( # noqa: WPS230
156148
... grid_points=grid_points,
157149
... data_matrix=values
158150
... )
159-
>>> binner = CommonGridBinner(bins=(2, 1))
151+
>>> binner = GridBinner(bins=(2, 1))
160152
>>> binner.fit_transform(fd)
161153
"""
162154

@@ -432,7 +424,7 @@ def fit(
432424
self,
433425
X: Union[FDataGrid, FDataIrregular],
434426
y: object = None,
435-
) -> "CommonGridBinner":
427+
) -> "GridBinner":
436428
"""
437429
Prepare the binning parameters based on the domain range.
438430

Diff for: skfda/tests/test_commongridbinner.py renamed to skfda/tests/test_gridbinner.py

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Tests for CommonGridBinner module."""
1+
"""Tests for GridBinner module."""
22

33
import re
44
from typing import Any, Tuple, Union
@@ -7,7 +7,7 @@
77
import pytest
88
from numpy.typing import NDArray
99

10-
from skfda.preprocessing.binning import CommonGridBinner
10+
from skfda.preprocessing.binning import GridBinner
1111
from skfda.representation import FData, FDataGrid, FDataIrregular
1212

1313
RaisesFixture = Tuple[
@@ -19,7 +19,7 @@
1919
str,
2020
str,
2121
]
22-
ParamFixture = Tuple[FData, CommonGridBinner, Tuple[NDArray[np.float64], ...]]
22+
ParamFixture = Tuple[FData, GridBinner, Tuple[NDArray[np.float64], ...]]
2323

2424

2525
##############################################################################
@@ -82,27 +82,27 @@
8282
],
8383
],
8484
)
85-
def commongridbinner_raises_fixture(request: Any) -> RaisesFixture:
86-
"""Fixture for getting a CommonGridBinner that raises a ValueError."""
85+
def gridbinner_raises_fixture(request: Any) -> RaisesFixture:
86+
"""Fixture for getting a GridBinner that raises a ValueError."""
8787
return tuple(request.param)
8888

8989

9090
@pytest.fixture(
9191
params=[
9292
[
93-
CommonGridBinner(bins=(1, 1)),
93+
GridBinner(bins=(1, 1)),
9494
fd.domain_range,
9595
],
9696
[
97-
CommonGridBinner(bins=(1, 1), domain_range=((0, 2), (0, 2))),
97+
GridBinner(bins=(1, 1), domain_range=((0, 2), (0, 2))),
9898
((0, 2), (0, 2)),
9999
],
100100
[
101-
CommonGridBinner(bins=(np.array([-1, 1]), np.array([-1, 1]))),
101+
GridBinner(bins=(np.array([-1, 1]), np.array([-1, 1]))),
102102
((-1, 1), (-1, 1)),
103103
],
104104
[
105-
CommonGridBinner(
105+
GridBinner(
106106
bins=(np.array([-1, 1]), np.array([-1, 1])),
107107
domain_range=((0, 2), (0, 2)),
108108
),
@@ -120,22 +120,22 @@ def domain_range_interactions_fixture(
120120
@pytest.fixture(
121121
params=[
122122
[
123-
CommonGridBinner(
123+
GridBinner(
124124
bins=(2, 2),
125125
output_grid=(np.array([0, 1]), np.array([0, 1])),
126126
),
127127
(np.array([0, 1]), np.array([0, 1])),
128128
],
129129
[
130-
CommonGridBinner(bins=(2, 2), output_grid="left"),
130+
GridBinner(bins=(2, 2), output_grid="left"),
131131
(np.array([0, 0.5]), np.array([0, 0.5])),
132132
],
133133
[
134-
CommonGridBinner(bins=(2, 2), output_grid="right"),
134+
GridBinner(bins=(2, 2), output_grid="right"),
135135
(np.array([0.5, 1]), np.array([0.5, 1])),
136136
],
137137
[
138-
CommonGridBinner(bins=(2, 2), output_grid="middle"),
138+
GridBinner(bins=(2, 2), output_grid="middle"),
139139
(np.array([0.25, 0.75]), np.array([0.25, 0.75])),
140140
],
141141
],
@@ -150,11 +150,11 @@ def output_grid_interactions_fixture(
150150
@pytest.fixture(
151151
params=[
152152
[
153-
CommonGridBinner(bins=2),
153+
GridBinner(bins=2),
154154
"Input FData must have 1 domain dimensions.",
155155
],
156156
[
157-
CommonGridBinner(
157+
GridBinner(
158158
bins=(2, 2),
159159
output_grid=(np.array([0.6, 1]), np.array([0, 1])),
160160
),
@@ -166,7 +166,7 @@ def output_grid_interactions_fixture(
166166
)
167167
def fitting_raises_fixture(
168168
request: Any,
169-
) -> Tuple[FDataGrid, CommonGridBinner, str]:
169+
) -> Tuple[FDataGrid, GridBinner, str]:
170170
"""Fixture for checking mismatch between binner and FData."""
171171
return fd, *request.param
172172

@@ -444,17 +444,17 @@ def precalc_example_data_domain_3(
444444
##############################################################################
445445

446446

447-
def test_raises(commongridbinner_raises_fixture: RaisesFixture) -> None:
447+
def test_raises(gridbinner_raises_fixture: RaisesFixture) -> None:
448448
"""
449449
Check raises ValueError.
450450
451-
Check that CommonGridBinners raise a ValueError exception.
451+
Check that GridBinners raise a ValueError exception.
452452
"""
453-
bins, domain_range_, output_grid, *rest = commongridbinner_raises_fixture
453+
bins, domain_range_, output_grid, *rest = gridbinner_raises_fixture
454454
bin_aggregation, error_msg = rest
455455

456456
with pytest.raises(ValueError, match=error_msg):
457-
CommonGridBinner(
457+
GridBinner(
458458
bins=bins,
459459
domain_range=domain_range_,
460460
output_grid=output_grid,
@@ -499,7 +499,7 @@ def test_output_grid_interactions(
499499

500500

501501
def test_fitting_raises(
502-
fitting_raises_fixture: Tuple[FDataGrid, CommonGridBinner, str],
502+
fitting_raises_fixture: Tuple[FDataGrid, GridBinner, str],
503503
) -> None:
504504
"""
505505
Check the domain parameter behaviour in fitting.
@@ -519,12 +519,12 @@ def test_precalc_example_domain_1(
519519
Check the precalculated example for binned FData.
520520
521521
Compare the theoretical precalculated results against the binned data
522-
with CommonGridBinner implementation, for different FData.
522+
with GridBinner implementation, for different FData.
523523
524524
Dimensions interacting are 1->n.
525525
"""
526526
fd, precalc_result = precalc_example_data_domain_1
527-
binner = CommonGridBinner(bins=2)
527+
binner = GridBinner(bins=2)
528528
computed_result = binner.fit_transform(fd)
529529

530530
np.testing.assert_array_equal(
@@ -545,12 +545,12 @@ def test_precalc_example_domain_3(
545545
Check the precalculated example for binned FData.
546546
547547
Compare the theoretical precalculated results against the binned data
548-
with CommonGridBinner implementation, for different FData.
548+
with GridBinner implementation, for different FData.
549549
550550
Dimensions interacting are 3->n.
551551
"""
552552
fd, precalc_result = precalc_example_data_domain_3
553-
binner = CommonGridBinner(bins=(2, 2, 2))
553+
binner = GridBinner(bins=(2, 2, 2))
554554
computed_result = binner.fit_transform(fd)
555555

556556
np.testing.assert_allclose(

0 commit comments

Comments
 (0)