From 2e8876fe1814a19b732cd2cabdf95c1343a16698 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 3 Aug 2023 12:16:36 +0800 Subject: [PATCH 1/3] add multiple bpy versions to test suite --- .github/workflows/tests.yml | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6d7e4888..5fbc501d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: max-parallel: 4 fail-fast: false matrix: - blender-version: ["3.5.0"] + blender-version: ["3.5.0", "3.6.0"] os: [ubuntu-latest, windows-latest] # os: [ubuntu-latest] steps: @@ -24,7 +24,7 @@ jobs: with: python-version: '3.10' cache: 'pip' - # - run: pip install bpy==${{ matrix.blender-version }} + - run: pip install bpy==${{ matrix.blender-version }} # - run: pip install -r requirements.txt - name: Install MolecularNodes + Dependencies run: pip install . diff --git a/pyproject.toml b/pyproject.toml index 837958b5..bc1d563f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ authors = [ description = "Toolbox for molecular animations with Blender and Geometry Nodes." requires-python = ">=3.10.0" dependencies = [ - "bpy", + "bpy>=3.5.0", "MDAnalysis==2.5.0", "biotite==0.37.0", "mrcfile", From e4118ca8e2f8b741405ab3e83bc496a6e7cf7522 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 3 Aug 2023 12:24:10 +0800 Subject: [PATCH 2/3] tweak imports for c-contiguos --- MolecularNodes/assembly/cif.py | 6 +++--- MolecularNodes/assembly/pdb.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MolecularNodes/assembly/cif.py b/MolecularNodes/assembly/cif.py index e858cb2b..2aac84a1 100644 --- a/MolecularNodes/assembly/cif.py +++ b/MolecularNodes/assembly/cif.py @@ -66,9 +66,9 @@ def get_transformations(self, assembly_id): rotations, translations ) transformations.append(( - np.array(affected_chain_ids, dtype="U4"), - total_rotation, - total_translation + np.array(affected_chain_ids, dtype="U4").tolist(), + total_rotation.tolist(), + total_translation.tolist() )) return transformations diff --git a/MolecularNodes/assembly/pdb.py b/MolecularNodes/assembly/pdb.py index d29639c4..e4a3d99d 100644 --- a/MolecularNodes/assembly/pdb.py +++ b/MolecularNodes/assembly/pdb.py @@ -81,9 +81,9 @@ def get_transformations(self, assembly_id): ) for rotation, translation in zip(rotations, translations): transformations.append(( - np.array(affected_chain_ids, dtype="U4"), - rotation, - translation + np.array(affected_chain_ids, dtype="U4").tolist(), + rotation.tolist(), + translation.tolist() )) return transformations From 3ba0a6dd85a5af73348dddcc5d8e29cfe6152405 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 3 Aug 2023 12:46:01 +0800 Subject: [PATCH 3/3] fix c-contigous problem --- MolecularNodes/assembly/mmtf.py | 2 +- MolecularNodes/obj.py | 4 ++-- tests/test_load.py | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/MolecularNodes/assembly/mmtf.py b/MolecularNodes/assembly/mmtf.py index 790405e6..fa7ce726 100644 --- a/MolecularNodes/assembly/mmtf.py +++ b/MolecularNodes/assembly/mmtf.py @@ -41,7 +41,7 @@ def get_transformations(self, assembly_id): chain_ids = np.array(self._file["chainNameList"], dtype="U4") affected_chain_ids = chain_ids[transform["chainIndexList"]] transformations.append(( - affected_chain_ids, + affected_chain_ids.tolist(), matrix[:3, :3].tolist(), matrix[:3, 3].tolist() )) diff --git a/MolecularNodes/obj.py b/MolecularNodes/obj.py index f3d6e377..005551aa 100644 --- a/MolecularNodes/obj.py +++ b/MolecularNodes/obj.py @@ -84,11 +84,11 @@ def add_attribute(object: bpy.types.Object, name: str, data, type="FLOAT", domai att = object.data.attributes.new(name, type, domain) # currently vectors have to be added as a 1d array. may change in the future # but currently must be reshaped then added as a 'vector' but supplying a 1d array - vec_1d = data.reshape(len(data) * 3) + vec_1d = data.reshape(len(data) * 3).copy(order = 'c') att.data.foreach_set('vector', vec_1d) else: att = object.data.attributes.new(name, type, domain) - att.data.foreach_set('value', data) + att.data.foreach_set('value', data.copy(order = 'c')) return att diff --git a/tests/test_load.py b/tests/test_load.py index d079716b..ea8b3f85 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -172,7 +172,6 @@ def test_1cd3_bio_assembly(snapshot): # Results shows the same number of atoms and atom positions are resulting from the # different import methods so it still works positions = [np.sort(mn.obj.get_attribute(obj, 'position'), axis = 0, kind = 'quicksort')[::-1] for obj in objects] - print(positions) assert np.allclose(positions[0], positions[1], atol = 1e-4) # TODO: for some reason when opening from .CIF files, we are ending up with double the