glotaran / pyglotaran

A Python library for Global and Target Analysis of time-resolved spectroscopy data
GNU Lesser General Public License v3.0
53 stars 18 forks source link

In two dataset (grouped) analysis self._full_clp_labels is None #478

Closed jsnel closed 3 years ago

jsnel commented 3 years ago

Description

First patch with PR477 since otherwise another crash is observed prior to reaching the point of the traceback below. When running a (two) dataset analysis with equal_area_penalties in the model a crash is observed due clp_labels being None Two dataset so grouped, call to self.calculate_index_dependent_grouped_residual() In the call of _calculate_additional_grouped_penalty self._full_clp_labels is None

What I Did

Traceback (most recent call last):
  File "c:/src/pyglotaran_examples/examples/two_dataset/two_dataset_analysis.py", line 60, in <module>
    result = optimize(scheme)
  File "c:\src\pyglotaran\glotaran\analysis\optimize.py", line 27, in optimize
    lm_result = minimizer.minimize(method="least_squares", verbose=verbose, max_nfev=scheme.nfev)
  File ".envs\py38gta_pdev\lib\site-packages\lmfit\minimizer.py", line 2285, in minimize
    return function(**kwargs)
  File ".envs\py38gta_pdev\lib\site-packages\lmfit\minimizer.py", line 1527, in least_squares
    ret = least_squares(self.__residual, start_vals,
  File ".envs\py38gta_pdev\lib\site-packages\scipy\optimize\_lsq\least_squares.py", line 807, in least_squares
    f0 = fun_wrapped(x0)
  File ".envs\py38gta_pdev\lib\site-packages\scipy\optimize\_lsq\least_squares.py", line 802, in fun_wrapped
    return np.atleast_1d(fun(x, *args, **kwargs))
  File ".envs\py38gta_pdev\lib\site-packages\lmfit\minimizer.py", line 576, in __residual
    out = self.userfcn(params, *self.userargs, **self.userkws)
  File "c:\src\pyglotaran\glotaran\analysis\optimize.py", line 48, in _calculate_penalty
    return problem.full_penalty
  File "c:\src\pyglotaran\glotaran\analysis\problem.py", line 239, in full_penalty
    residuals = self.weighted_residuals
  File "c:\src\pyglotaran\glotaran\analysis\problem.py", line 217, in weighted_residuals
    self.calculate_residual()
  File "c:\src\pyglotaran\glotaran\analysis\problem.py", line 540, in calculate_residual
    self.calculate_index_dependent_grouped_residual()
  File "c:\src\pyglotaran\glotaran\analysis\problem.py", line 615, in calculate_index_dependent_grouped_residual
    self._calculate_additional_grouped_penalty()
  File "c:\src\pyglotaran\glotaran\analysis\problem.py", line 809, in _calculate_additional_grouped_penalty
    self._additional_penalty = self.model.additional_penalty_function(
  File "c:\src\pyglotaran\glotaran\builtin\models\kinetic_spectrum\spectral_penalties.py", line 87, in apply_spectral_penalties
    index_clp_label = clp_labels[i] if model.index_dependent() else clp_labels
TypeError: 'NoneType' object is not subscriptable
jsnel commented 3 years ago

@joernweissenborn please refer to this test case: https://github.com/glotaran/pyglotaran_examples/blob/master/examples/two_dataset/two_dataset_analysis.py

joernweissenborn commented 3 years ago

There should be nothing like _full_clp_labels, they just be the self._clp_labels. There is no full there. It might be confusing because you have _full_clp. those should be nemade just clp.

Am So., 6. Dez. 2020 um 15:34 Uhr schrieb Joris Snellenburg < notifications@github.com>:

@joernweissenborn https://github.com/joernweissenborn please refer to this test case:

https://github.com/glotaran/pyglotaran_examples/blob/master/examples/two_dataset/two_dataset_analysis.py

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/glotaran/pyglotaran/issues/478#issuecomment-739511357, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARG7QNDMSYXTUYAA5DVA6DSTOJBFANCNFSM4UPLMMTA .

jsnel commented 3 years ago

Related to #472