def test_vmobject_same_points_become():
    a = Square()
    b = Circle()
    a.become(b)
    np.testing.assert_array_equal(a.points, b.points)
    assert len(a.submobjects) == len(b.submobjects)
Beispiel #2
0
def test_shift_family():
    """Check that each member of the family is shifted along with the parent.

    Importantly, here we add a common grandchild to each of the children.  So
    this test will fail if the grandchild moves twice as much as it should.

    """
    # Note shift() needs the mobject to have a non-empty `points` attribute, so
    # we cannot use a plain Mobject or VMobject.  We use Circle instead.
    mob, child1, child2, = Circle(), Circle(), Circle(),
    gchild1, gchild2, gchild_common = Circle(), Circle(), Circle()

    child1.add(gchild1, gchild_common)
    child2.add(gchild2, gchild_common)
    mob.add(child1, child2)
    family = mob.get_family()

    positions_before = {m: m.get_center() for m in family}
    mob.shift(RIGHT)
    positions_after = {m: m.get_center() for m in family}

    for m in family:
        assert np.allclose(positions_before[m] + RIGHT, positions_after[m])