def test_pnmimage_to_val(): img = PNMImage(1, 1) assert img.to_val(-0.5) == 0 assert img.to_val(0.0) == 0 assert img.to_val(0.5) == 128 assert img.to_val(1.0) == 255 assert img.to_val(2.0) == 255
def test_pnmimage_from_val(): img = PNMImage(1, 1) assert img.from_val(0) == 0.0 assert img.to_val(img.from_val(128)) == 128 assert img.from_val(255) == 1.0