Skip to content

renamed line_flip to flip_ab #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ other objects.

scale_ip: Scales the line by the given amount in place.

flip: Switches the endpoints of the line.
flip_ab: Switches the endpoints of the line.

flip_ip: Switches the endpoints of the line in place.
flip_ab_ip: Switches the endpoints of the line in place.

update: Updates the line's attributes.

Expand Down
12 changes: 6 additions & 6 deletions docs/line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,25 +237,25 @@ Line Methods

.. ## Line.scale_ip ##

.. method:: flip
.. method:: flip_ab

| :sl:`flips the line a and b points`
| :sg:`flip() -> Line`
| :sg:`flip_ab() -> Line`

Returns a new `Line` that has the `a` and `b` points flipped.
The original `Line` is not modified.

.. ## Line.flip ##
.. ## Line.flip_ab ##

.. method:: flip_ip
.. method:: flip_ab_ip

| :sl:`flips the line a and b points, in place`
| :sg:`flip_ip() -> None`
| :sg:`flip_ab_ip() -> None`

Flips the `Line`'s `b` and `b` points. The original `Line` is modified.
Always returns None.

.. ## Line.flip_ip ##
.. ## Line.flip_ab_ip ##

.. method:: is_parallel

Expand Down
4 changes: 2 additions & 2 deletions geometry.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ class Line(Sequence[float]):
def scale(self, factor_and_origin: Sequence[float, float]) -> Line: ...
@overload
def scale_ip(self, factor_and_origin: Sequence[float, float]) -> None: ...
def flip(self) -> Line: ...
def flip_ip(self) -> None: ...
def flip_ab(self) -> Line: ...
def flip_ab_ip(self) -> None: ...
def is_parallel(self, line: LineValue) -> bool: ...
def is_perpendicular(self, line: LineValue) -> bool: ...
def as_points(self, n_points: int) -> List[Tuple[float, float]]: ...
Expand Down
6 changes: 3 additions & 3 deletions src_c/line.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ pg_line_flip(pgLineObject *self, PyObject *_null)
}

static PyObject *
pg_line_flip_ip(pgLineObject *self, PyObject *_null)
pg_line_flip_ab_ip(pgLineObject *self, PyObject *_null)
{
double tx = self->line.x2;
double ty = self->line.y2;
Expand Down Expand Up @@ -754,8 +754,8 @@ static struct PyMethodDef pg_line_methods[] = {
{"move", (PyCFunction)pg_line_move, METH_FASTCALL, NULL},
{"move_ip", (PyCFunction)pg_line_move_ip, METH_FASTCALL, NULL},
{"at", (PyCFunction)pg_line_at, METH_O, NULL},
{"flip", (PyCFunction)pg_line_flip, METH_NOARGS, NULL},
{"flip_ip", (PyCFunction)pg_line_flip_ip, METH_NOARGS, NULL},
{"flip_ab", (PyCFunction)pg_line_flip, METH_NOARGS, NULL},
{"flip_ab_ip", (PyCFunction)pg_line_flip_ab_ip, METH_NOARGS, NULL},
{"as_points", (PyCFunction)pg_line_as_points, METH_O, NULL},
{"as_segments", (PyCFunction)pg_line_as_segments, METH_O, NULL},
{"scale", (PyCFunction)pg_line_scale, METH_FASTCALL, NULL},
Expand Down
10 changes: 5 additions & 5 deletions test/test_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ def test_meth_scale_ip(self):
def test_meth_flip(self):
line = Line(1.1, 2.2, 3.3, 4.4)

ret = line.flip()
ret = line.flip_ab()

self.assertIsInstance(ret, Line)
self.assertEqual(ret.x1, 3.3)
Expand All @@ -734,20 +734,20 @@ def test_meth_flip(self):
self.assertEqual(ret.y2, 2.2)

with self.assertRaises(TypeError):
line.flip(1)
line.flip_ab(1)

def test_meth_flip_ip(self):
def test_meth_flip_ab_ip(self):
line = Line(1.1, 2.2, 3.3, 4.4)

line.flip_ip()
line.flip_ab_ip()

self.assertEqual(line.x1, 3.3)
self.assertEqual(line.y1, 4.4)
self.assertEqual(line.x2, 1.1)
self.assertEqual(line.y2, 2.2)

with self.assertRaises(TypeError):
line.flip_ip(1)
line.flip_ab_ip(1)

def test_meth_collidepoint(self):
A = Line(0, 0, 1, 1)
Expand Down