Skip to content

Commit

Permalink
fix starfile tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyAJohnston committed Apr 6, 2024
1 parent 04c36de commit 05ae0e1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/test_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_starfile_attributes(type):
# Activate the rotation debug mode in the nodetreee and get the quaternion attribute
debugnode = mn.blender.nodes.star_node(
ensemble.node_group).node_tree.nodes['Switch.001']
debugnode.inputs[1].default_value = True
debugnode.inputs['Switch'].default_value = True
quat_attribute = ensemble.get_attribute('MNDEBUGEuler', evaluate=True)

# Convert from blender to scipy conventions and then into Scipy rotation
Expand All @@ -42,6 +42,7 @@ def test_starfile_attributes(type):
# To compare the two rotation with multiply one with the inverse of the other
assert (rot_from_euler * rot_from_geo_nodes.inv()).magnitude().max() < 1e-5


def test_categorical_attributes():
file = data_dir / "cistem.star"
ensemble = mn.io.star.load(file)
Expand All @@ -50,14 +51,15 @@ def test_categorical_attributes():

def test_micrograph_conversion():
from pathlib import Path

file = data_dir / "cistem.star"
ensemble = mn.io.star.load(file)
tiff_path = data_dir / "montage.tiff"
tiff_path.unlink(missing_ok=True)
ensemble._convert_mrc_to_tiff()
assert tiff_path.exists()


def test_micrograph_loading():
import bpy
file = data_dir / "cistem.star"
Expand All @@ -69,11 +71,13 @@ def test_micrograph_loading():
ensemble.star_node.inputs['Show Micrograph'].default_value = True
bpy.context.evaluated_depsgraph_get().update()
assert tiff_path.exists()
# Ensure montage get only loaded once
assert sum(1 for image in bpy.data.images.keys() if 'montage' in image) == 1
# Ensure montage get only loaded once
assert sum(1 for image in bpy.data.images.keys()
if 'montage' in image) == 1
assert ensemble.micrograph_material.node_tree.nodes['Image Texture'].image.name == 'montage.tiff'
assert ensemble.star_node.inputs['Micrograph'].default_value.name == 'montage.tiff'


def test_rehydration(tmp_path):
import bpy
bpy.ops.wm.read_homefile()
Expand Down

0 comments on commit 05ae0e1

Please sign in to comment.