Skip to content
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

function reconstruct_signal_hess #52

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
8 changes: 7 additions & 1 deletion diffpy/snmf/subroutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,13 @@ def reconstruct_signal_hess(components, signal_idx):
1d array like
The reconstruction of a signal's hessian from calculated weights, stretching factors, and iq values
"""
return 0
signal_length = len(components[0].grid)
reconstruction = np.zeros(signal_length)
for component in components:
stretched = component.apply_stretch(signal_idx)[2]
stretched_and_weighted = component.apply_weight(signal_idx, stretched)
reconstruction += stretched_and_weighted
return reconstruction
def initialize_arrays(number_of_components, number_of_moments, signal_length):
"""Generates the initial guesses for the weight, stretching, and component matrices

Expand Down
15 changes: 12 additions & 3 deletions diffpy/snmf/tests/test_subroutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,16 @@ def test_reconstruct_signal(trs):
actual = reconstruct_signal(trs[0], trs[1])
assert len(actual) == len(trs[0][0].grid)

trsh = []
trsh = [([ComponentSignal([0, .25, .5, .75, 1], 2, 0), ComponentSignal([0, .25, .5, .75, 1], 2, 1),
ComponentSignal([0, .25, .5, .75, 1], 2, 2)], 1),
([ComponentSignal([0, .25, .5, .75, 1], 2, 0), ComponentSignal([0, .25, .5, .75, 1], 2, 1),
ComponentSignal([0, .25, .5, .75, 1], 2, 2)], 0),
([ComponentSignal([0, .25, .5, .75, 1], 3, 0), ComponentSignal([0, .25, .5, .75, 1], 3, 1),
ComponentSignal([0, .25, .5, .75, 1], 3, 2)], 2),
# ([ComponentSignal([0, .25, .5, .75, 1], 2, 0), ComponentSignal([0, .25, .5, .75, 1], 2, 1),
# ComponentSignal([0, .25, .5, .75, 1], 2, 2)], -1),
]
@pytest.mark.parametrize('trsh', trsh)
def test_reconstruct_signal_hessian():
assert False
def test_reconstruct_signal_hess(trsh):
actual = reconstruct_signal(trsh[0], trsh[1])
assert len(actual) == len(trsh[0][0].grid)
Copy link
Contributor

@sbillinge sbillinge Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be just testing the shape of the array handed back. Is that your intention?

Let's have a quick conversation about what you want to test here and then how best to do it.