-
Notifications
You must be signed in to change notification settings - Fork 3
[MRG] cleaned tests #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #20 +/- ##
==========================================
+ Coverage 65.78% 86.59% +20.8%
==========================================
Files 9 6 -3
Lines 681 552 -129
==========================================
+ Hits 448 478 +30
+ Misses 233 74 -159
Continue to review full report at Codecov.
|
|
ready for merging IMO |
|
I think this is ready to merge @mathurinm |
clar/tests/test_solvers.py
Outdated
| B_mtl, _, E, gaps = solver( | ||
| X, Y, alpha, sigma_min, B0=None, | ||
| tol=tol, pb_name=pb_name, n_iter=10000) | ||
| gap = gaps[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@QB3 you can directly assert using gaps[-1]
clar/tests/test_solvers.py
Outdated
| X, Y, alpha, sigma_min, B0=B_mtl, | ||
| tol=tol, pb_name=pb_name, n_iter=10000) | ||
| np.testing.assert_equal(len(E), 2) | ||
| gap = gaps[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
clar/tests/test_solvers.py
Outdated
| tol = 1e-7 | ||
|
|
||
| X, all_epochs, _, _ = get_data_me( | ||
| dictionary_type="Gaussian", noise_type="Gaussian_iid", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe remove those which are default values
clar/tests/test_solvers.py
Outdated
| sigma_min = get_sigma_min(Y) | ||
| alpha_max = get_alpha_max(X, Y, sigma_min, "SGCL") | ||
| alpha = alpha_max * 0.9 | ||
| print("alpha = %.2e" % alpha) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm
clar/tests/test_solvers.py
Outdated
| log_gap = np.log10(gaps[-1]) | ||
| log_gap_accel = np.log10(gaps_accel[-1]) | ||
| np.testing.assert_array_less( | ||
| np.minimum(log_gap, log_gap_accel), np.log10(tol) * E[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why taking log everywhere?
| n_iter=10**4, tol=10**-4)[0] | ||
|
|
||
| old_size_supp = 0 | ||
| for supp in dict_masks.values(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are we testing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that the size of the support is growing.
what would you like to test ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it's a valid intuition, we can't say anything if the test breaks: there is no proof that support have growing sizes
clar/tests/test_solvers.py
Outdated
| tol=tol, pb_name=pb_name, n_iter=1000, | ||
| alpha_Sigma_inv=alpha_Sigma_inv)[-2] | ||
|
|
||
| assert (Es[-1] - Es[-2]) <= 1e-10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use numpy
| alpha_Sigma_inv = 0.01 | ||
|
|
||
| Y = np.mean(all_epochs, axis=0) | ||
| sigma_min = get_sigma_min(Y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you check that duality gap is 0 for alpha max and solver returns 0?
clar/data/artificial.py
Outdated
| """ | ||
| rng = check_random_state(seed) | ||
| vect = rho ** np.arange(n_sources) | ||
| covar = toeplitz(vect, vect) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can fix this too
| _, _, E, gaps = solver( | ||
| X, Y, alpha, sigma_min, B0=B_mtl, | ||
| tol=tol, pb_name=pb_name, n_iter=10000) | ||
| np.testing.assert_equal(len(E), 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it normal that convergence happens so fast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems fair since we are passing B0=B_mtl with the same arguments ?
clar/tests/test_solvers.py
Outdated
| n_sources=n_sources, n_active=3, rho_noise=rho_noise, | ||
| SNR=SNR) | ||
|
|
||
| Y = np.mean(all_epochs, axis=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid defining this variable?
clar/tests/test_solvers.py
Outdated
|
|
||
| alpha_max = get_alpha_max(X, all_epochs, sigma_min, pb_name=pb_name) | ||
|
|
||
| alpha_div = 1.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's better to test on a more difficult problem ?
clar/tests/test_solvers.py
Outdated
| alpha_max = get_alpha_max(X, all_epochs, sigma_min, pb_name=pb_name) | ||
|
|
||
| alpha_div = 1.1 | ||
| alpha = alpha_max / alpha_div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directly divide by the value you want ? (say 20 ?)
clar/tests/test_solvers.py
Outdated
| Y = all_epochs.mean(axis=0) | ||
| sigma_min = get_sigma_min(Y) | ||
| alpha_max = get_alpha_max(X, Y, sigma_min, "SGCL") | ||
| alpha = alpha_max * 0.9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again a very easy problem
|
|
||
| B_mtl, _, E, gaps = solver( | ||
| X, Y, alpha, sigma_min, B0=None, | ||
| tol=tol, pb_name=pb_name, n_iter=10000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe rm n_iter?
| alpha = alpha_max / alpha_div | ||
|
|
||
| B_mtl, _, E, gaps = solver( | ||
| X, Y, alpha, sigma_min, B0=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
B0 = None is default so not needed
| all_epochs[0] = Y | ||
|
|
||
| _, _, E, (gaps, gaps_accel) = solver( | ||
| X, Y, alpha, sigma_min, B0=None, n_iter=n_iter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm paramters having their default value
|
One last pass @QB3 :) ! |
|
Good to merge @QB3 ? |
solves #4