Hide copy API.
parent
3d498223f5
commit
a4652f0324
|
@ -44,9 +44,6 @@ import pickle
|
||||||
print(pickle.dumps(sys))
|
print(pickle.dumps(sys))
|
||||||
|
|
||||||
sys_new = sys.copy()
|
sys_new = sys.copy()
|
||||||
# equivalent to
|
|
||||||
func, args = sys.__reduce__()
|
|
||||||
sys_new = func(*args)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The entity and parameter handles should have the same lifetime to the solver.
|
The entity and parameter handles should have the same lifetime to the solver.
|
||||||
|
|
|
@ -95,11 +95,8 @@ class Entity:
|
||||||
|
|
||||||
class SolverSystem:
|
class SolverSystem:
|
||||||
|
|
||||||
def __init__(self, g: int = 0, param_list=None, entity_list=None, cons_list=None) -> None:
|
def __init__(self) -> None:
|
||||||
"""Create a solver system.
|
"""Create a solver system."""
|
||||||
|
|
||||||
The current group, parameters, entities, constraints can be set from an existing solver.
|
|
||||||
"""
|
|
||||||
...
|
...
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
|
|
|
@ -13,6 +13,16 @@ from cpython.object cimport Py_EQ, Py_NE
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
|
|
||||||
|
def _create_sys(dof_v, g, param_list, entity_list, cons_list):
|
||||||
|
cdef SolverSystem s = SolverSystem.__new__(SolverSystem)
|
||||||
|
s.dof_v = dof_v
|
||||||
|
s.g = g
|
||||||
|
s.param_list = param_list
|
||||||
|
s.entity_list = entity_list
|
||||||
|
s.cons_list = cons_list
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
||||||
cpdef tuple quaternion_u(double qw, double qx, double qy, double qz):
|
cpdef tuple quaternion_u(double qw, double qx, double qy, double qz):
|
||||||
"""Input quaternion, return unit vector of U axis.
|
"""Input quaternion, return unit vector of U axis.
|
||||||
|
|
||||||
|
@ -290,17 +300,11 @@ cdef class SolverSystem:
|
||||||
The operation of entities and constraints are using the methods of this class.
|
The operation of entities and constraints are using the methods of this class.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __cinit__(self, int g = 0, param_list=None, entity_list=None, cons_list=None):
|
def __cinit__(self):
|
||||||
self.g = g
|
self.g = 0
|
||||||
if param_list is not None:
|
|
||||||
self.param_list = param_list
|
|
||||||
if entity_list is not None:
|
|
||||||
self.entity_list = entity_list
|
|
||||||
if cons_list is not None:
|
|
||||||
self.cons_list = cons_list
|
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
return (self.__class__, (self.g, self.param_list, self.entity_list, self.cons_list))
|
return (_create_sys, (self.dof_v, self.g, self.param_list, self.entity_list, self.cons_list))
|
||||||
|
|
||||||
def entity(self, int i) -> Entity:
|
def entity(self, int i) -> Entity:
|
||||||
"""Generate entity handle, it can only be used with this system.
|
"""Generate entity handle, it can only be used with this system.
|
||||||
|
@ -316,7 +320,7 @@ cdef class SolverSystem:
|
||||||
|
|
||||||
cpdef SolverSystem copy(self):
|
cpdef SolverSystem copy(self):
|
||||||
"""Copy the solver."""
|
"""Copy the solver."""
|
||||||
return SolverSystem.__new__(SolverSystem, self.g, self.param_list, self.entity_list, self.cons_list)
|
return _create_sys(self.dof_v, self.g, self.param_list, self.entity_list, self.cons_list)
|
||||||
|
|
||||||
cpdef void clear(self):
|
cpdef void clear(self):
|
||||||
"""Clear the system."""
|
"""Clear the system."""
|
||||||
|
|
Loading…
Reference in New Issue