Skip to content

VMobject: get_anchors() and get_anchors_and_handles() different behavior #3185

Closed
@ubaldot

Description

@ubaldot

Description of bug / unexpected behavior

It seems that get_anchors() returns a new object whereas get_anchors_and_handles() returns a reference.
get_start_anchors() and get_end_anchors() also return a reference.

Expected behavior

Consistency between the methods would be desirable.

How to reproduce the issue

The following snippet produce

c = Circle()

print("get_anchors = ", c.get_anchors()[-1])
print("get_anchors_and_handles = ", c.get_anchors_and_handles()[-1][-1])
c.get_anchors_and_handles()[-1][-1] += 2 * mn.RIGHT
print("get_anchors = ", c.get_anchors()[-1])
print("get_anchors_and_handles = ", c.get_anchors_and_handles()[-1][-1])

produces

get_anchors =  [ 1.0000000e+00 -2.4492936e-16  0.0000000e+00]
get_anchors_and_handles =  [ 1.0000000e+00 -2.4492936e-16  0.0000000e+00]
get_anchors =  [ 3.0000000e+00 -2.4492936e-16  0.0000000e+00]
get_anchors_and_handles =  [ 3.0000000e+00 -2.4492936e-16  0.0000000e+00]

whereas the following snippet

c =  Circle()

print("get_anchors = ", c.get_anchors()[-1])
print("get_anchors_and_handles = ", c.get_anchors_and_handles()[-1][-1])
c.get_anchors()[-1] += 2 * mn.RIGHT
print("get_anchors = ", c.get_anchors()[-1])
print("get_anchors_and_handles = ", c.get_anchors_and_handles()[-1][-1])

produces

get_anchors =  [ 1.0000000e+00 -2.4492936e-16  0.0000000e+00]
get_anchors_and_handles =  [ 1.0000000e+00 -2.4492936e-16  0.0000000e+00]
get_anchors =  [ 1.0000000e+00 -2.4492936e-16  0.0000000e+00]
get_anchors_and_handles =  [ 1.0000000e+00 -2.4492936e-16  0.0000000e+00]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions