Mentions légales du service

Skip to content
Snippets Groups Projects
Commit aced5639 authored by hhakim's avatar hhakim
Browse files

Add matfaust.ParamsFact.get_constraints (equivalent to pyfaust get_constraints).

parent 1cfba84a
Branches
Tags
No related merge requests found
...@@ -262,5 +262,35 @@ classdef (Abstract) ParamsFact ...@@ -262,5 +262,35 @@ classdef (Abstract) ParamsFact
end end
end end
% =========================================================
%> @brief Returns a cell array of constraints from constraints which is a ConstraintList or cell array that can be a
%> mix of pyfaust.factparams.ConstraintGeneric or pyfaust.proj.proj_gen.
%> If projs is a ConstraintList then the function just returns the same
%> object as is.
%>
%> The function purpose is to make the list uniform as ConstraintGeneric
%> objects.
% =========================================================
function clist = get_constraints(constraints)
if(isa(constraints, 'matfaust.factparams.ConstraintList'))
clist = constraints.clist;
elseif(isa(constraints, 'cell'))
clist = cell(1, length(constraints));
for i=1:length(constraints)
c = constraints{i};
if(isa(c, 'matfaust.proj.proj_gen'))
clist{i} = c.constraint;
elseif(isa(c, 'matfaust.factparams.ConstraintGeneric'))
clist{i} = c;
else
error('constraints items must be of type ConstraintGeneric or proj_gen')
end
end
else
error('constraints must be of type ConstraintList or cell array')
end
end
end end
end end
...@@ -957,7 +957,8 @@ class ParamsFact(ABC): ...@@ -957,7 +957,8 @@ class ParamsFact(ABC):
@staticmethod @staticmethod
def get_constraints(projs): def get_constraints(projs):
""" """
Returns a python list of constraints from the projs list/tuple that can be a Returns a python list of constraints from the projs which is a
ConstralintList or a list/tuple that can be a
mix of pyfaust.factparams.ConstraintGeneric or pyfaust.proj.proj_gen. mix of pyfaust.factparams.ConstraintGeneric or pyfaust.proj.proj_gen.
If projs is a ConstraintList then the function just returns the same If projs is a ConstraintList then the function just returns the same
object as is. object as is.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment