Skip to content

Commit

Permalink
only use hidden height factor attr in default height method
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjonesBSU committed Sep 18, 2023
1 parent 509cda7 commit acb3545
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions cmeutils/tests/test_visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ def test_box_radius(self, p3ht_fresnel):
assert p3ht_fresnel.box_radius == 0.1

def test_default_height(self, p3ht_fresnel):
assert p3ht_fresnel.height == np.linalg.norm(
p3ht_fresnel.box_length[:3] * p3ht_fresnel.view_axis
assert (
p3ht_fresnel.height
== np.linalg.norm(
p3ht_fresnel.box_length[:3] * p3ht_fresnel.view_axis
)
* p3ht_fresnel._height_factor
)

def test_reset_height(self, p3ht_fresnel):
Expand Down
7 changes: 4 additions & 3 deletions cmeutils/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(
self.gsd_file = gsd_file
with gsd.hoomd.open(gsd_file) as traj:
self._n_frames = len(traj)
self._height_factor = 1.25
self._unwrap_positions = unwrap_positions
self._snapshot = None
self._view_axis = np.asarray(view_axis)
Expand All @@ -92,7 +93,6 @@ def __init__(
self._up = np.asarray(up)
self._show_box = show_box
self._box_radius = box_radius
self._height_factor = 1.25

@property
def frame(self):
Expand Down Expand Up @@ -321,7 +321,8 @@ def box_length(self):

def _default_height(self):
"""Set the height based on box dimensions and view axis"""
return np.linalg.norm(self.view_axis * self.box_length[:3])
height = np.linalg.norm(self.view_axis * self.box_length[:3])
return height * self._height_factor

def reset_height(self):
"""Reset the height of the camera to the default."""
Expand Down Expand Up @@ -379,7 +380,7 @@ def camera(self):
position=self.camera_position,
look_at=self.look_at,
up=self.up,
height=self.height * self._height_factor,
height=self.height,
)
return camera

Expand Down

0 comments on commit acb3545

Please sign in to comment.