-
Notifications
You must be signed in to change notification settings - Fork 6
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
Remove cvxpy for weight minimization, fix test values and refactor tests codes #120
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6a0b55d
Add pyproject.toml
bobleesj b20f1be
Remove cvxpy dep
bobleesj 1ed7094
Use scipy L-BFGS-B for matrix optimization, remove cvxpy
bobleesj 534f621
Correclty set the bounds for example set in optimization
bobleesj 675ee69
Remove abs tolerance of 0.5
bobleesj debc7bc
Add news
bobleesj 4407df7
Fix tests for computing real root
bobleesj 1c590a4
Refactor test_contianers test
bobleesj 47bb88a
Refactor test for test factorizers
bobleesj c8258de
Refactor test optimizers
bobleesj 81c402e
Refactor test polynomial
bobleesj 71c017f
Refactor subroutines test
bobleesj da7dda1
Fix typo in news
bobleesj a5e2eae
Remove usage of input in test_containers.py
bobleesj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**Added:** | ||
|
||
* L-BFGS-B method in scipy for weight optimization in def get_weights | ||
* Support for Python 3.13 | ||
|
||
**Changed:** | ||
|
||
* <news item> | ||
|
||
**Deprecated:** | ||
|
||
* <news item> | ||
|
||
**Removed:** | ||
|
||
* cvxpy dependency for linear weight optimization in def get_weights | ||
* Support for Python 3.10 | ||
|
||
**Fixed:** | ||
|
||
* Absolute tolerance for updated weighted matrix from 0.5 to 1e-05 in test_subroutines.py | ||
|
||
**Security:** | ||
|
||
* <news item> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
numpy | ||
scipy | ||
cvxpy | ||
diffpy.utils | ||
numdifftools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
numpy | ||
scipy | ||
cvxpy | ||
diffpy.utils | ||
numdifftools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,19 +2,19 @@ | |
|
||
from diffpy.snmf.optimizers import get_weights | ||
|
||
tm = [ | ||
([[[1, 0], [0, 1]], [1, 1], [0, 0], [1, 1]], [0, 0]), | ||
([[[1, 0], [0, 1]], [1, 1], -1, 1], [-1, -1]), | ||
([[[1.75, 0], [0, 1.5]], [1, 1.2], -1, 1], [-0.571428571428571, -0.8]), | ||
([[[0.75, 0.2], [0.2, 0.75]], [-0.1, -0.2], -1, 1], [0.066985645933014, 0.248803827751196]), | ||
([[[2, -1, 0], [-1, 2, -1], [0, -1, 2]], [1, 1, 1], -10, 12], [-1.5, -2, -1.5]), | ||
([[[2, -1, 0], [-1, 2, -1], [0, -1, 2]], [1, -1, -1], -10, 12], [0, 1, 1]), | ||
([[[4, 0, 0, 0], [0, 3, 0, 0], [0, 0, 2, 0], [0, 0, 0, 1]], [-2, -3, -4, -1], 0, 1000], [0.5, 1, 2, 1]), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("tm", tm) | ||
def test_get_weights(tm): | ||
expected = tm[1] | ||
actual = get_weights(tm[0][0], tm[0][1], tm[0][2], tm[0][3]) | ||
@pytest.mark.parametrize( | ||
"stretched_component_gram_matrix, linear_coefficient, lower_bound, upper_bound, expected", | ||
[ | ||
([[1, 0], [0, 1]], [1, 1], 0, 0, [0, 0]), | ||
([[1, 0], [0, 1]], [1, 1], -1, 1, [-1, -1]), | ||
([[1.75, 0], [0, 1.5]], [1, 1.2], -1, 1, [-0.571428571428571, -0.8]), | ||
([[0.75, 0.2], [0.2, 0.75]], [-0.1, -0.2], -1, 1, [0.066985645933014, 0.248803827751196]), | ||
([[2, -1, 0], [-1, 2, -1], [0, -1, 2]], [1, 1, 1], -10, 12, [-1.5, -2, -1.5]), | ||
([[2, -1, 0], [-1, 2, -1], [0, -1, 2]], [1, -1, -1], -10, 12, [0, 1, 1]), | ||
([[4, 0, 0, 0], [0, 3, 0, 0], [0, 0, 2, 0], [0, 0, 0, 1]], [-2, -3, -4, -1], 0, 1000, [0.5, 1, 2, 1]), | ||
], | ||
) | ||
def test_get_weights(stretched_component_gram_matrix, linear_coefficient, lower_bound, upper_bound, expected): | ||
actual = get_weights(stretched_component_gram_matrix, linear_coefficient, lower_bound, upper_bound) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pass variables instead of |
||
assert actual == pytest.approx(expected, rel=1e-4, abs=1e-6) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As intended