diff --git a/fury/animation/animation.py b/fury/animation/animation.py index afc2775f2..8e2d78b63 100644 --- a/fury/animation/animation.py +++ b/fury/animation/animation.py @@ -42,7 +42,10 @@ class Animation: """ - def __init__(self, actors=None, length=None, loop=True, motion_path_res=None): + def __init__(self, actors=None, + length=None, + loop=True, + motion_path_res=None): super().__init__() self._data = defaultdict(dict) @@ -81,7 +84,8 @@ def update_duration(self): else: self._duration = max( self._max_timestamp, - max([0] + [anim.update_duration() for anim in self.child_animations]), + max([0] + [anim.update_duration() + for anim in self.child_animations]), ) return self.duration @@ -184,7 +188,8 @@ def _get_attribute_data(self, attrib): data[attrib] = { 'keyframes': defaultdict(dict), 'interpolator': { - 'base': linear_interpolator if attrib != 'rotation' else slerp, + 'base': (linear_interpolator + if attrib != 'rotation' else slerp), 'func': None, 'args': defaultdict(), }, @@ -206,7 +211,8 @@ def get_keyframes(self, attrib=None): if attrib is None: attribs = data.keys() return { - attrib: data.get(attrib, {}).get('keyframes', {}) for attrib in attribs + attrib: data.get(attrib, + {}).get('keyframes', {}) for attrib in attribs } return data.get(attrib, {}).get('keyframes', {}) @@ -315,7 +321,8 @@ def is_inside_scene_at(self, timestamp): parent_in_scene = parent._added_to_scene if self.is_interpolatable('in_scene'): - in_scene = parent_in_scene and self.get_value('in_scene', timestamp) + in_scene = parent_in_scene and self.get_value('in_scene', + timestamp) else: in_scene = parent_in_scene return in_scene @@ -360,7 +367,8 @@ def _handle_scene_event(self, timestamp): self._scene.rm(*self._actors) self._added_to_scene = False - def set_interpolator(self, attrib, interpolator, is_evaluator=False, **kwargs): + def set_interpolator(self, attrib, interpolator, + is_evaluator=False, **kwargs): """Set keyframes interpolator for a certain property Parameters @@ -438,7 +446,8 @@ def is_interpolatable(self, attrib): data = self._data return bool(data.get(attrib, {}).get('interpolator', {}).get('func')) - def set_position_interpolator(self, interpolator, is_evaluator=False, **kwargs): + def set_position_interpolator(self, interpolator, + is_evaluator=False, **kwargs): """Set the position interpolator. Parameters @@ -501,7 +510,8 @@ def set_rotation_interpolator(self, interpolator, is_evaluator=False): >>> Animation.set_rotation_interpolator(slerp) """ - self.set_interpolator('rotation', interpolator, is_evaluator=is_evaluator) + self.set_interpolator('rotation', interpolator, + is_evaluator=is_evaluator) def set_color_interpolator(self, interpolator, is_evaluator=False): """Set the color interpolator. @@ -539,7 +549,9 @@ def set_opacity_interpolator(self, interpolator, is_evaluator=False): >>> Animation.set_opacity_interpolator(step_interpolator) """ - self.set_interpolator('opacity', interpolator, is_evaluator=is_evaluator) + self.set_interpolator('opacity', + interpolator, + is_evaluator=is_evaluator) def get_value(self, attrib, timestamp): """Return the value of an attribute at any given timestamp. @@ -553,7 +565,8 @@ def get_value(self, attrib, timestamp): """ value = ( - self._data.get(attrib, {}).get('interpolator', {}).get('func')(timestamp) + self._data.get(attrib, + {}).get('interpolator', {}).get('func')(timestamp) ) return value @@ -1217,7 +1230,11 @@ class CameraAnimation(Animation): """ - def __init__(self, camera=None, length=None, loop=True, motion_path_res=None): + def __init__(self, + camera=None, + length=None, + loop=True, + motion_path_res=None): super(CameraAnimation, self).__init__( length=length, loop=loop, motion_path_res=motion_path_res ) @@ -1381,7 +1398,8 @@ def set_view_up_interpolator(self, interpolator, is_evaluator=False): function that does not depend on keyframes. """ - self.set_interpolator('view_up', interpolator, is_evaluator=is_evaluator) + self.set_interpolator('view_up', interpolator, + is_evaluator=is_evaluator) def update_animation(self, time=None): """Update the camera animation. @@ -1406,7 +1424,10 @@ def update_animation(self, time=None): # camera axis is reverted rot = -self.get_rotation(time, as_quat=True) rot = transform.Rotation.from_quat(rot).as_matrix() - rot = np.array([[*rot[0], 0], [*rot[1], 0], [*rot[2], 0], [0, 0, 0, 1]]) + rot = np.array([[*rot[0], 0], + [*rot[1], 0], + [*rot[2], 0], + [0, 0, 0, 1]]) rot = translation @ rot @ np.linalg.inv(translation) self._camera.SetModelTransformMatrix(rot.flatten()) diff --git a/fury/animation/helpers.py b/fury/animation/helpers.py index 1b553d36c..eb4d01f25 100644 --- a/fury/animation/helpers.py +++ b/fury/animation/helpers.py @@ -83,7 +83,8 @@ def get_values_from_keyframes(keyframes): """ return np.asarray( - [keyframes.get(t, {}).get('value', None) for t in sorted(keyframes.keys())] + [keyframes.get(t, {}).get('value', None) + for t in sorted(keyframes.keys())] ) diff --git a/fury/animation/tests/fares b/fury/animation/tests/fares index 22d4b906a..b0bb73da9 100644 --- a/fury/animation/tests/fares +++ b/fury/animation/tests/fares @@ -19,13 +19,13 @@ class myclass(): myclass.usren+=1 def __str__(self): return f'collage name is {self.pname} , dof = {self.ccname}' - + def print(self): if self.pname in myclass.notallow: print('not allowed') else: print(f'{self.pname} , {self.ccname}') - + def allinfo(): print(f'the end of the class') @classmethod @@ -37,7 +37,7 @@ class student(myclass): def __init__(self,name,cname,age): super().__init__(name,cname) self.age=age - + def __str__(self): return f'your name is {self.pname} ,course name = {self.ccname}, your age is {self.age}' diff --git a/fury/animation/tests/test_timeline.py b/fury/animation/tests/test_timeline.py index 8897ad0fe..41350eccf 100644 --- a/fury/animation/tests/test_timeline.py +++ b/fury/animation/tests/test_timeline.py @@ -3,10 +3,10 @@ import numpy as np import numpy.testing as npt -from fury.animation import Animation, Timeline import fury.testing as ft +from fury.animation import Animation, Timeline from fury.ui import PlaybackPanel -from fury.window import Scene, ShowManager +from fury.window import ShowManager, Scene def assert_not_equal(x, y): diff --git a/fury/animation/timeline.py b/fury/animation/timeline.py index 710d08e89..f9216a344 100644 --- a/fury/animation/timeline.py +++ b/fury/animation/timeline.py @@ -1,8 +1,8 @@ import os from time import perf_counter -from PIL import Image import numpy as np +from PIL import Image from fury import window from fury.animation.animation import Animation @@ -33,7 +33,9 @@ class Timeline: """ - def __init__(self, animations=None, playback_panel=False, loop=True, length=None): + def __init__(self, animations=None, + playback_panel=False, + loop=True, length=None): self._scene = None self.playback_panel = None @@ -365,7 +367,11 @@ def record(self, fname=None, fps=30, speed=1.0, size=(900, 768), render_window.SetSize(*size) if order_transparent: - window.antialiasing(scene, render_window, multi_samples, max_peels, 0) + window.antialiasing(scene, + render_window, + multi_samples, + max_peels, + 0) window_to_image_filter = WindowToImageFilter()