pysdic.check_same_problem#

check_same_problem(objects)[source]#

Check that the objects of a pysolvegn problem (terms and parametrizations) work on the same analysis and the same unknowns, before giving them to pysolvegn.solve.

The objects are compared two by two, by identity: for each pair, a.analysis is b.analysis and a.unknowns is b.unknowns, with an analysis of type pysdic.SDICAnalysis and unknowns of type pysdic.SDICUnknowns. Two different (even equivalent) objects are rejected: build all the objects of a problem with the same analysis object and the same unknowns object.

pysolvegn only sees functions: two terms built on different unknowns of the same size (e.g. the frame 1 and the frame 2) would be added without any error. This check makes this mistake explicit.

Parameters:

objects (Sequence) – The objects of the problem, each one with the properties analysis and unknowns: pysdic.SDICCorrelationTerm, pysdic.SDICTemporalRegularizationTerm, pysdic.SDICFixedParametrization.

Raises:
  • TypeError – If objects is not a sequence, an object has no analysis or unknowns, or they have a wrong type.

  • ValueError – If objects is empty, or two objects have different analyses or different unknowns.

Return type:

None

Examples

from pysdic import check_same_problem

check_same_problem([correlation, regularization, parametrization])
result = pysolvegn.solve([correlation.term, regularization.term], parametrization.reparametrized_pack(),
                         parametrization=parametrization.parametrization)