예제 #1
0
def test_fun():
    assert (FiniteSet(
        *ImageSet(Lambda(x, sin(pi * x / 4)), Range(-10, 11))) == FiniteSet(
            -1, -sqrt(2) / 2, 0,
            sqrt(2) / 2, 1))
예제 #2
0
def test_infinitely_indexed_diophantine():
    assert (imageset(Lambda(m, 2 * pi * m), S.Integers).intersection(
        imageset(Lambda(n, 3 * pi * n),
                 S.Integers)) == ImageSet(Lambda(t, 6 * pi * t), S.Integers))
예제 #3
0
def test_ImageSet_iterator_not_injetive():
    L = Lambda(x, x - x % 2)  # produces 0, 2, 2, 4, 4, 6, 6, ...
    evens = ImageSet(L, S.Naturals)
    i = iter(evens)
    # No repeats here
    assert (next(i), next(i), next(i), next(i)) == (0, 2, 4, 6)