Repository: sympy/sympy
File: sympy/assumptions/tests/test_refine.py (Python)

Code before:
    assert refine(cos(x + n*pi + m*pi / 2), Q.integer(n) & Q.odd(m)) == \
        (-1)**(n + (m + 1)/2) * sin(x)
    assert refine(cos(x + n*pi + m*pi / 2), Q.integer(n) & Q.integer(m)) == \
        (-1)**(n) * cos(x + m*pi / 2)
    assert refine(cos(x + (2*n + 1)*pi + m*pi / 2), \
        Q.integer(n) & Q.integer(m)) == \
        - cos(x + m*pi / 2)
    assert refine(sin(x - (2*n)*pi + m*pi/2), \
        Q.integer(n) & Q.integer(m)) == \
        sin(x + m*pi / 2)
    k = Symbol('k')
    assert refine(cos(x + n*pi + k*pi/2 + m*pi/2), \
                  Q.integer(n) & Q.odd(k) & Q.integer(m)) == \
        (-1)**(n + (k + 1)/2) * sin(x + m*pi/2)
    assert refine(sin(x + n*pi + k*pi/2 + m*pi/2), \
                  Q.integer(n) & Q.odd(k) & Q.integer(m)) == \
        (-1)**(n + (k + 3)/2) * cos(x + m*pi/2)
    assert refine(cos(x + n*pi/2 + k*pi/2 + m*pi/2), \
                  Q.odd(n) & Q.odd(k) & Q.integer(m)) == \
        (-1)**((n + k)/2) * cos(x + m*pi/2)


def test_floor_ceiling():
    x = Symbol('x')
    y = Symbol('y')
    assert refine(floor(x), Q.integer(x)) == x
    assert refine(ceiling(x), Q.integer(x)) == x
    assert refine(floor(x), Q.infinite(x)) == x

    assert refine(floor(y), Q.real(y)) == floor(y)
    assert refine(ceiling(y), Q.real(y)) == ceiling(y)

    assert refine(floor(x + y), Q.integer(x)) == x + floor(y)
    assert refine(ceiling(x + y), Q.integer(x)) == x + ceiling(y)

    assert refine(floor(x), Q.imaginary(x) & ~Q.integer(x)) == I * floor(-I * x)


Review comment (suggestion):
You should add the same test for `ceiling`. Generally, you should err on the side of having too many tests. I know I gave you feedback about having some unnecessary tests before, but it's generally a lot worse to miss a test than include a redundant test. That being said including redundant tests does create extra work for me since I have more lines of code to review. 

Code after:
    assert refine(cos(x + n*pi + m*pi / 2), Q.integer(n) & Q.odd(m)) == \
        (-1)**(n + (m + 1)/2) * sin(x)
    assert refine(cos(x + n*pi + m*pi / 2), Q.integer(n) & Q.integer(m)) == \
        (-1)**(n) * cos(x + m*pi / 2)
    assert refine(cos(x + (2*n + 1)*pi + m*pi / 2), \
        Q.integer(n) & Q.integer(m)) == \
        - cos(x + m*pi / 2)
    assert refine(sin(x - (2*n)*pi + m*pi/2), \
        Q.integer(n) & Q.integer(m)) == \
        sin(x + m*pi / 2)
    k = Symbol('k')
    assert refine(cos(x + n*pi + k*pi/2 + m*pi/2), \
                  Q.integer(n) & Q.odd(k) & Q.integer(m)) == \
        (-1)**(n + (k + 1)/2) * sin(x + m*pi/2)
    assert refine(sin(x + n*pi + k*pi/2 + m*pi/2), \
                  Q.integer(n) & Q.odd(k) & Q.integer(m)) == \
        (-1)**(n + (k + 3)/2) * cos(x + m*pi/2)
    assert refine(cos(x + n*pi/2 + k*pi/2 + m*pi/2), \
                  Q.odd(n) & Q.odd(k) & Q.integer(m)) == \
        (-1)**((n + k)/2) * cos(x + m*pi/2)


def test_floor_ceiling():
    assert refine(floor(x), Q.integer(x)) == x
    assert refine(ceiling(x), Q.integer(x)) == x
    assert refine(floor(x), Q.infinite(x)) == x
    assert refine(ceiling(x), Q.infinite(x)) == x

    assert refine(floor(y), Q.real(y)) == floor(y)
    assert refine(ceiling(y), Q.real(y)) == ceiling(y)

    assert refine(floor(x + y), Q.integer(x)) == x + floor(y)
    assert refine(ceiling(x + y), Q.integer(x)) == x + ceiling(y)
    assert refine(floor(x + y + z), Q.integer(x) & Q.integer(y)) == x + y + floor(z)
    assert refine(ceiling(x + y + z), Q.integer(x) & Q.integer(z)) == x + z + ceiling(y)
    assert refine(floor(x + y - z)) == floor (x + y - z)
    assert refine(ceiling(ceiling(x) + y + floor(z))) == ceiling(x) + ceiling(y) + floor(z)

    assert refine(floor(floor(x)+ floor(y))) == floor(x) + floor(y)
    assert refine(ceiling(ceiling(x) - ceiling(y))) == ceiling(x) - ceiling(y)