Dessia-tech / dessia_common

GNU Lesser General Public License v2.1
1 stars 2 forks source link

Cycles in jsonpointers when check_plaform #644

Closed younesdessia closed 10 months ago

younesdessia commented 11 months ago

**Note: for support questions, please use https://nextcloud.dessia.tech/call/hr9z9bif

from dessia_common.core import DessiaObject import volmdlr as vm

class Module(DessiaObject): _standalone_in_db = True

def __init__(self, direction: vm.Vector3D, origin: vm.Point3D, name: str = ''):
    DessiaObject.__init__(self, name=name)
    self.origin = origin
    self.direction = direction

class Vessel(DessiaObject): _standalone_in_db = True

def __init__(self, module: List[Module], name: str = ''):
    self.module = module
    DessiaObject.__init__(self, name=name)

class Layout(DessiaObject): _standalone_in_db = True

def __init__(self, vessel: Vessel, name: str = ''):
    self.vessel = vessel
    DessiaObject.__init__(self, name=name)

```py
from class_check import Module, Vessel, Layout
import volmdlr as vm

v_1 = vm.Vector3D(-1.0, 0.0, 6.123233995736766e-17)
v_2 = vm.Vector3D(-1.0, 0.0, 6.123233995736766e-17)
v_3 = vm.Vector3D(-1.0, 0.0, 6.123233995736766e-17)
v_4 = vm.Vector3D(-1.0, 0.0, 6.123233995736766e-17)

vectors = [v_1, v_2] # , v_3, v_4

pt_1 = vm.Point3D(1.039, -0.9850000001020002, 0.26500000000000007)
pt_2 = vm.Point3D(1.039, -0.45500000010200015, 0.26500000000000007)
pt_3 = vm.Point3D(1.039, 0.07499999989799988, 0.26500000000000007)
pt_4 = vm.Point3D(1.039, 0.6049999998979999, 0.26500000000000007)

points = [pt_1, pt_2] # , pt_3, pt_4

list_module_pos = []
for i in range(len(vectors)):
    module_pos = Module(origin=points[i], direction=vectors[i])
    list_module_pos.append(module_pos)

vessel = Vessel(module=list_module_pos)
layout_result = Layout(vessel=vessel)
layout_result._check_platform()
GhislainJ commented 10 months ago

I cannot reproduce without using volmdlr objects

younesdessia commented 10 months ago

yes, me too I can't do it. maybe it's problem with compiled class (I'm not sur !). I will investigate this

GhislainJ commented 10 months ago

Repro case without using volmdlr :

class Point:

    def to_dict(self):
        return {}

class Vector:

    def to_dict(self):
        return {}

    def __eq__(self, other):
        return True

    def __hash__(self):
        return 0

class Module(DessiaObject):
    _standalone_in_db = True

    def __init__(self, direction: Vector, origin: Point, name: str = ''):
        self.origin = origin
        self.direction = direction

        DessiaObject.__init__(self, name=name)

class Vessel(DessiaObject):
    _standalone_in_db = True

    def __init__(self, module: List[Module], name: str = ''):
        self.module = module

        DessiaObject.__init__(self, name=name)

class Layout(DessiaObject):
    _standalone_in_db = True

    def __init__(self, vessel: Vessel, name: str = ''):
        self.vessel = vessel
        DessiaObject.__init__(self, name=name)
vectors = [Vector(), Vector()]
points = [Point(), Point()]

vessel = Vessel(module=[Module(origin=p, direction=v) for p, v in zip(points, vectors)])
dict_ = Layout(vessel=vessel).to_dict()
obj = Layout.dict_to_object(dict_)