Skip to content

Commit 0348510

Browse files
committed
initial commit
created construct_stretching_matrix, test, and docstring
1 parent 6f6bda8 commit 0348510

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

diffpy/snmf/subroutines.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def initialize_components(number_of_components, number_of_signals, grid_vector):
2525
raise ValueError(f"Number of components = {number_of_components}. Number_of_components must be >= 1.")
2626
components = list()
2727
for component in range(number_of_components):
28-
component = ComponentSignal(grid_vector,number_of_signals,component)
28+
component = ComponentSignal(grid_vector, number_of_signals, component)
2929
components.append(component)
3030
return tuple(components)
3131

@@ -54,6 +54,27 @@ def lift_data(data_input, lift=1):
5454
return data_input + np.abs(np.min(data_input) * lift)
5555

5656

57+
def construct_stretching_matrix(components, number_of_components, number_of_signals):
58+
"""Constructs the stretching factor matrix
59+
60+
Parameters
61+
----------
62+
components: tuple of ComponentSignal objects
63+
The tuple containing the component signals in ComponentSignal objects.
64+
number_of_components: int
65+
The number of component signals in the NMF decomposition
66+
number_of_signals: int
67+
The number of signals in the data provided by the user.
68+
69+
Returns
70+
-------
71+
2d array
72+
The matrix containing the stretching factors for the component signals for each of the signals in the raw data.
73+
Has dimensions `component_signal` x `number_of_signals`
74+
75+
"""
76+
77+
5778
def initialize_arrays(number_of_components, number_of_moments, signal_length):
5879
"""Generates the initial guesses for the weight, stretching, and component matrices
5980

diffpy/snmf/tests/test_subroutines.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,7 @@ def test_initialize_components(tcc):
161161
assert len(actual) == tcc[0]
162162
assert len(actual[0].weights) == tcc[1]
163163
assert (actual[0].grid == np.array(tcc[2])).all()
164+
165+
tcso =[]
166+
def test_construct_stretching_matrix():
167+
assert False

0 commit comments

Comments
 (0)