diff --git a/setup.py b/setup.py index b3b77f4..2f9a5ad 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setuptools.setup( name="spyrograph", - version="0.25.3", + version="0.26.0", author="Chris Greening", author_email="chris@christophergreening.com", description="Library for drawing spirographs in Python", diff --git a/spyrograph/core/_trochoid.py b/spyrograph/core/_trochoid.py index 7ddfdbc..402d7bd 100644 --- a/spyrograph/core/_trochoid.py +++ b/spyrograph/core/_trochoid.py @@ -90,7 +90,7 @@ def __init__( self.coords = list(zip(self.x, self.y, self.thetas)) - def transform(self, x: Number = 0, y: Number = 0) -> "_Trochoid": + def translate(self, x: Number = 0, y: Number = 0) -> "_Trochoid": """ Return a new shape translated by the given x and y offsets. @@ -113,7 +113,7 @@ def transform(self, x: Number = 0, y: Number = 0) -> "_Trochoid": """ # pylint: disable=no-value-for-parameter try: - transformed_shape = self.__class__( + translated_shape = self.__class__( R=self.R, r=self.r, d=self.d, @@ -121,13 +121,13 @@ def transform(self, x: Number = 0, y: Number = 0) -> "_Trochoid": origin=(self.origin[0]+x, self.origin[1]+y) ) except TypeError: - transformed_shape = self.__class__( + translated_shape = self.__class__( R=self.R, r=self.r, thetas=self.thetas, origin=(self.origin[0]+x, self.origin[1]+y) ) - return transformed_shape + return translated_shape def scale(self, factor: Number) -> Union["_Trochoid", "_Cycloid"]: """Return shape with input parameters scaled by a given input factor. diff --git a/tests/_trochoid.py b/tests/_trochoid.py index 1b43da8..eac80b0 100644 --- a/tests/_trochoid.py +++ b/tests/_trochoid.py @@ -45,28 +45,28 @@ def test_dunder_repr_doesnt_break_on_repr_call(self, instance): repr_val = repr(instance) assert isinstance(repr_val, str) - def test_transform_float_offset(self, instance): - up_and_left_transform_instance = instance.transform(x=100.33, y=-100.69) - assert instance.origin[0] + 100.33 == up_and_left_transform_instance.origin[0] - assert instance.origin[1] - 100.69 == up_and_left_transform_instance.origin[1] + def test_translate_float_offset(self, instance): + up_and_left_translate_instance = instance.translate(x=100.33, y=-100.69) + assert instance.origin[0] + 100.33 == up_and_left_translate_instance.origin[0] + assert instance.origin[1] - 100.69 == up_and_left_translate_instance.origin[1] - def test_transform_zero_offset(self, instance): - zero_transformed_instance = instance.transform(x=0, y=0) - assert instance.origin[0] == zero_transformed_instance.origin[0] - assert instance.origin[1] == zero_transformed_instance.origin[1] + def test_translate_zero_offset(self, instance): + zero_translateed_instance = instance.translate(x=0, y=0) + assert instance.origin[0] == zero_translateed_instance.origin[0] + assert instance.origin[1] == zero_translateed_instance.origin[1] - def test_transform_shape_x_direction(self, instance): - left_transformed_instance = instance.transform(x=-100) - assert instance.origin[0] - 100 == left_transformed_instance.origin[0] + def test_translate_shape_x_direction(self, instance): + left_translateed_instance = instance.translate(x=-100) + assert instance.origin[0] - 100 == left_translateed_instance.origin[0] - def test_transform_shape_y_direction(self, instance): - up_transformed_instance = instance.transform(y=100) - assert instance.origin[1] + 100 == up_transformed_instance.origin[1] + def test_translate_shape_y_direction(self, instance): + up_translateed_instance = instance.translate(y=100) + assert instance.origin[1] + 100 == up_translateed_instance.origin[1] - def test_transform_shape_x_and_y_same_transform_call(self, instance): - up_and_left_transform_instance = instance.transform(x=100, y=-100) - assert instance.origin[0] + 100 == up_and_left_transform_instance.origin[0] - assert instance.origin[1] - 100 == up_and_left_transform_instance.origin[1] + def test_translate_shape_x_and_y_same_translate_call(self, instance): + up_and_left_translate_instance = instance.translate(x=100, y=-100) + assert instance.origin[0] + 100 == up_and_left_translate_instance.origin[0] + assert instance.origin[1] - 100 == up_and_left_translate_instance.origin[1] def test_dunder_repr_values(self, instance): repr_val = repr(instance)