Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
272da26
#779 At coreax.solvers.composite, changed the return statement of the…
qh681248 Sep 24, 2024
d9045a4
#779 At coreax.solvers.composite, changed the return statement of the…
qh681248 Sep 24, 2024
d87afde
Added a test in unit/test_solvers.py that checks if MapReduce's reduc…
qh681248 Sep 25, 2024
08f666a
Added an if statement on MapReduce.reduce method, it now only assigns…
qh681248 Sep 25, 2024
7d41a4b
replaced mapreduce by map_reduce in test_map_reduce_diverse_selection…
qh681248 Sep 26, 2024
48a1037
In coreax/solvers/composite.py, the reduce method updates indices onl…
qh681248 Sep 26, 2024
1bd8501
Removed the line plt.show() in examples/pounce.py
qh681248 Sep 27, 2024
082ada7
Made requested changes in the PR #790 (fixed type hints, comments etc.)
qh681248 Oct 3, 2024
e5f5122
Removed changed NoneType to None (NoneType is not compatible with pyt…
qh681248 Oct 3, 2024
da827a7
removed a folder that wasn't supposed to be added
qh681248 Oct 3, 2024
c187818
On composite.py changed return statement of _jit_tree from dataset[in…
qh681248 Oct 4, 2024
a4f762c
Added MapReduce bugfix to `CHANGELOG.md`
qh681248 Oct 8, 2024
bbae67d
Added double backticks on comments in `composite.py` when referring t…
qh681248 Oct 8, 2024
cf537ed
Removed a redundant comment on a test on `TestMapReduce` class
qh681248 Oct 8, 2024
c894e07
Added analytic test for `MapReduce`
qh681248 Oct 9, 2024
a5fb1be
docs: make suggested changes in the docstring
qh681248 Oct 14, 2024
b48bda4
docs: make suggested changes in the docstring
qh681248 Oct 17, 2024
2a9a1c4
Merge remote-tracking branch 'origin/main' into bugfix/MapReduce-inde…
qh681248 Oct 17, 2024
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
73 changes: 37 additions & 36 deletions tests/unit/test_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ def test_map_reduce_analytic(self):
r"""
Test ``MapReduce`` on an analytical example, enforcing a unique coreset.

In this example, We start with the original dataset
In this example, we start with the original dataset
:math:`[10, 20, 30, 210, 40, 60, 180, 90, 150, 70, 120,
200, 50, 140, 80, 170, 100, 190, 110, 160, 130]`.

Expand All @@ -900,11 +900,8 @@ def test_map_reduce_analytic(self):
partition size that is less than or equal to 6. Thus, we have 4 partitions
each of size 6.

We first pad the dataset by adding 3 zeros, then we arrange the
data in ascending order (Make sure to ask if this is another bug,
I don't know how exactly binary_tree manages to reorder my dataset every time)
This results in
the following 4 partitions (see how data is in ascending order):
This results in the following 4 partitions (see how
data is in ascending order):

1. :math:`[0, 0, 0, 10, 20, 30]`
2. :math:`[40, 50, 60, 70, 80, 90]`
Expand All @@ -923,9 +920,10 @@ def test_map_reduce_analytic(self):

Concatenating we obtain
:math:`[0, 30, 0, 40, 90, 50, 100, 150, 110, 160, 210, 170]`.
Now we repeat the same process, we check how many partitions
(has to be power of 2) we want to divide this new data of size 12 into,
our new options for partitioning are:
We repeat the process, checking how many partitions we want
to divide this intermediate dataset (of size 12) into.
Recall, this number of partitions must be a power of 2.
Our options are::

1. 1 partition of size 12
2. 2 partitions of size 6
Expand All @@ -951,11 +949,12 @@ def test_map_reduce_analytic(self):

1. Concatenated subset: :math:`[0, 90, 0, 100, 210, 110]`

Note that the size of the dataset is 6 so no partitioning is necessary!
Note that the size of the dataset is 6,
therefore, no more partitioning is necessary.

Applying the ``interleaved_base_solver`` one last time we obtain
the final coreset of:
:math:`[0, 110, 90]`. This is what we will test in this test
the final coreset:
:math:`[0, 110, 90]`.
"""
interleaved_base_solver = MagicMock(_ExplicitPaddingInvariantSolver)
interleaved_base_solver.coreset_size = 3
Expand All @@ -978,31 +977,33 @@ def interleaved_mock_reduce(
interleaved_base_solver.reduce = interleaved_mock_reduce

original_data = Data(
[
10,
20,
30,
210,
40,
60,
180,
90,
150,
70,
120,
200,
50,
140,
80,
170,
100,
190,
110,
160,
130,
]
jnp.array(
[
10,
20,
30,
210,
40,
60,
180,
90,
150,
70,
120,
200,
50,
140,
80,
170,
100,
190,
110,
160,
130,
]
)
)
expected_coreset_data = Data([0, 110, 90])
expected_coreset_data = Data(jnp.array([0, 110, 90]))

coreset, _ = MapReduce(base_solver=interleaved_base_solver, leaf_size=6).reduce(
original_data
Expand Down