Skip to content

Can't use reader.get_project(uids) multiple times #128

Description

@WesleyTheGeolien

Calling get_project with uids mutates the project_elments in fileio.get_project on v1.0.1 this line is the culprit as copy is a shallow copy and not a deepcopy project_json = self._project_json.copy() proposed solution would be to:

import copy
copy.deepcopy(self.project_json)

MRE:

import omf

pts = omf.PointSetElement(
            name=f'Points',
            geometry=omf.PointSetGeometry(
                vertices=np.array([0,0,0])
            ),
        )

pts1 = omf.PointSetElement(
            name=f'Points',
            geometry=omf.PointSetGeometry(
                vertices=np.array([1,1,1])
            ),
        )

proj = omf.Project()
proj.elements = [pts, pts1]

omf.OMFWriter(proj, "test.omf")

reader = omf.OMFReader("test.omf")
print(reader._project_json[reader._uid]['elements'])

first_element_uid = str(reader.get_project_overview().elements[0].uid)
print(first_element_uid)
reader.get_project([first_element_uid])
print(reader._project_json[reader._uid]['elements'])

Happy to put in a PR just not sure how it works seeing it is on v1.0.1 is v1.0.2 (bug fix) on the road map or only v2.X in dev?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions