Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 18, 2023
1 parent ca00946 commit a203eb1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
30 changes: 17 additions & 13 deletions cmeutils/tests/test_visualize.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np
import pytest

from cmeutils.visualize import FresnelGSD
from cmeutils.tests.base_test import BaseTest
from cmeutils.visualize import FresnelGSD


class TestFresnelGSD(BaseTest):
Expand All @@ -18,7 +18,9 @@ def test_frace(self, p3ht_fresnel):
def test_scale_diameter(self, p3ht_fresnel):
p3ht_fresnel.diameter_scale = 0.6
assert p3ht_fresnel.diameter_scale == 0.6
assert np.array_equal(p3ht_fresnel.radius, np.ones_like(p3ht_fresnel.radius)*0.60)
assert np.array_equal(
p3ht_fresnel.radius, np.ones_like(p3ht_fresnel.radius) * 0.60
)

def test_update_snapshot(self, gsdfile):
test_fresnel = FresnelGSD(gsd_file=gsdfile)
Expand All @@ -32,16 +34,18 @@ def test_update_snapshot(self, gsdfile):

def test_color_dict(self, p3ht_fresnel):
p3ht_fresnel.color_dict = {
"c3": np.array([0.5, 0.5, 0.5]),
"cc": np.array([0.5, 0.5, 0.5]),
"cd": np.array([0.5, 0.5, 0.5]),
"h4": np.array([0.5, 0.5, 0.5]),
"ha": np.array([0.5, 0.5, 0.5]),
"hc": np.array([0.5, 0.5, 0.5]),
"ss": np.array([0.5, 0.5, 0.5]),
"c3": np.array([0.5, 0.5, 0.5]),
"cc": np.array([0.5, 0.5, 0.5]),
"cd": np.array([0.5, 0.5, 0.5]),
"h4": np.array([0.5, 0.5, 0.5]),
"ha": np.array([0.5, 0.5, 0.5]),
"hc": np.array([0.5, 0.5, 0.5]),
"ss": np.array([0.5, 0.5, 0.5]),
}
p3ht_fresnel.set_type_color(particle_type="c3", color=(0.1, 0.1, 0.1))
assert np.array_equal(p3ht_fresnel.color_dict["c3"], np.array([0.1, 0.1, 0.1]))
assert np.array_equal(
p3ht_fresnel.color_dict["c3"], np.array([0.1, 0.1, 0.1])
)

def test_set_color_no_type(self, p3ht_fresnel):
with pytest.raises(ValueError):
Expand All @@ -68,19 +72,19 @@ def test_specular(self, p3ht_fresnel):
assert p3ht_fresnel.specular == 0.5
material = p3ht_fresnel.material()
assert material.specular == 0.5

def test_specular_trans(self, p3ht_fresnel):
p3ht_fresnel.specular_trans = 0.5
assert p3ht_fresnel.specular_trans == 0.5
material = p3ht_fresnel.material()
assert material.spec_trans == 0.5

def test_metal(self, p3ht_fresnel):
p3ht_fresnel.metal = 0.5
assert p3ht_fresnel.metal == 0.5
material = p3ht_fresnel.material()
assert material.metal == 0.5

def test_geometry(self, p3ht_fresnel):
geometry = p3ht_fresnel.geometry()
for i, j in zip(p3ht_fresnel.positions, geometry.position):
Expand Down
6 changes: 3 additions & 3 deletions cmeutils/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def __init__(
height=10,
up=(0, 0, 1),
unwrap_positions=False,
device=fresnel.Device()
device=fresnel.Device(),
):
self.scene = fresnel.Scene()
self.gsd_file = gsd_file
with gsd.hoomd.open(gsd_file) as traj:
self._n_frames = len(traj)
self._unwrap_positions = unwrap_positions
self._unwrap_positions = unwrap_positions
self._snapshot = None
self._frame = 0
self.frame = frame
Expand All @@ -39,7 +39,7 @@ def __init__(
self._specular_trans = specular_trans
self._metal = metal
self._view_axis = np.asarray(view_axis)
self._up = np.asarray(up)
self._up = np.asarray(up)

@property
def frame(self):
Expand Down

0 comments on commit a203eb1

Please sign in to comment.