Skip to content

v0.18.1 weird behavior of Axes().coords_to_point / Axes().c2p #4073

@uwezi

Description

@uwezi

Description of bug / unexpected behavior

According to the documentation, the argument of .c2p() may be individual values for x, y (and z), as well as lists, lists of lists and numpy.arrays. However, when using just lists [x,y,z] or 1D np.arrays the returned coordinates are wrong.

Expected behavior

How to reproduce the issue

Code for reproducing the problem
class testc2p(Scene):
    def construct(self):
        ax = Axes()
        print("ax.c2p(1,2) = ",ax.c2p(1,2))
        print("ax.c2p(1,2,1) = ",ax.c2p(1,2,1))
        print("ax.c2p(np.array([1,2])) = ",ax.c2p(np.array([1,2])))
        print("ax.c2p(np.array([1,2,1])) = ",ax.c2p(np.array([1,2,1])))
        print("ax.c2p([1,2,1]) = ",ax.c2p([1,2,1]))
        print("ax.c2p([1,2]) = ",ax.c2p([1,2]))
        print("ax.c2p([[1,2],[2,3]]) = ",ax.c2p([[1,2],[2,3]]))

returns

Manim Community v0.18.1

ax.c2p(1,2)   =  [0.85714286 1.5        0.        ]
ax.c2p(1,2,1) =  [0.85714286 1.5        0.        ]
ax.c2p(np.array([1,2])) =  [[0.85714286 1.71428571]
                            [0.         0.        ]
                            [0.         0.        ]]
ax.c2p(np.array([1,2,1])) =  [[0.85714286 1.71428571 0.85714286]
                              [0.         0.         0.        ]
                              [0.         0.         0.        ]]
ax.c2p([1,2,1]) =  [[0.85714286 1.71428571 0.85714286]
                    [0.         0.         0.        ]
                    [0.         0.         0.        ]]
ax.c2p([1,2]) =  [[0.85714286 1.71428571]
                  [0.         0.        ]
                  [0.         0.        ]]
ax.c2p([[1,2],[2,3]]) =  [[0.85714286 1.5        0.        ]
                          [1.71428571 2.25       0.        ]]
  • ax.c2p(1,2) and ax.c2p(1,2,1) return reasonable values
  • ax.c2p(np.array([1,2])) appears to be treated as two "points" with x=1 and x=2 respectively, returning [[x1, x2],[y1, y2],[z1, z2]] rather than [[x1 y1 z1],[x2, y2, z2]], similar for all other 1D-lists
  • ax.c2p([[1,2],[2,3]]) appears to correctly return two points

System specifications

System Details
  • OS : Windows 10
  • RAM: enough
  • Python version (python/py/python3 --version): 3.11.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedWe would appreciate help on this issue/PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions