Add set values method for parameters.
parent
594ae25483
commit
d5ac4039ea
|
@ -268,6 +268,7 @@ cdef class SolverSystem:
|
||||||
cdef void free(self)
|
cdef void free(self)
|
||||||
cpdef void set_group(self, size_t g)
|
cpdef void set_group(self, size_t g)
|
||||||
cpdef int group(self)
|
cpdef int group(self)
|
||||||
|
cpdef void set_params(self, Params p, object params)
|
||||||
cpdef tuple params(self, Params p)
|
cpdef tuple params(self, Params p)
|
||||||
cpdef int dof(self)
|
cpdef int dof(self)
|
||||||
cpdef object constraints(self)
|
cpdef object constraints(self)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from typing import Tuple, List, Counter
|
from typing import Tuple, List, Sequence, Counter
|
||||||
from enum import IntEnum, auto
|
from enum import IntEnum, auto
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,6 +164,9 @@ class SolverSystem:
|
||||||
def group(self) -> int:
|
def group(self) -> int:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
def set_params(self, p: Params, params: Sequence[float]):
|
||||||
|
...
|
||||||
|
|
||||||
def params(self, p: Params) -> Tuple[float, ...]:
|
def params(self, p: Params) -> Tuple[float, ...]:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
|
@ -309,6 +309,19 @@ cdef class SolverSystem:
|
||||||
"""Return the current group by integer."""
|
"""Return the current group by integer."""
|
||||||
return <int>self.g
|
return <int>self.g
|
||||||
|
|
||||||
|
cpdef void set_params(self, Params p, object params):
|
||||||
|
"""Set the parameters by Params object and sequence object."""
|
||||||
|
params = tuple(params)
|
||||||
|
cdef int i = p.param_list.size()
|
||||||
|
if i != len(params):
|
||||||
|
raise ValueError(f"number of parameters {len(params)} are not match {i}")
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
cdef Slvs_hParam h
|
||||||
|
for h in p.param_list:
|
||||||
|
self.param_list[h].val = params[i]
|
||||||
|
i += 1
|
||||||
|
|
||||||
cpdef tuple params(self, Params p):
|
cpdef tuple params(self, Params p):
|
||||||
"""Get the parameters by Params object."""
|
"""Get the parameters by Params object."""
|
||||||
cdef list param_list = []
|
cdef list param_list = []
|
||||||
|
|
Loading…
Reference in New Issue