Exemplo n.º 1
0
def test_main_no_img(fast_tmpdir):
    poni_file = pyfai_poni
    dest_image_file = str(os.path.join(fast_tmpdir, 'test.tiff'))
    shutil.copy(image_file, dest_image_file)
    os.chdir(str(fast_tmpdir))
    main(poni_file)
    files = os.listdir(str(fast_tmpdir))
    for ext in expected_outputs:
        assert 'test' + ext in files
Exemplo n.º 2
0
def test_main_multi_poni(fast_tmpdir):
    poni_file = pyfai_poni
    for file, name in zip([image_file, poni_file, poni_file],
                          ['test.tiff', 'test.poni', 'test2.poni']):
        dest_image_file = str(os.path.join(fast_tmpdir, name))
        shutil.copy(file, dest_image_file)
    os.chdir(str(fast_tmpdir))
    print(os.listdir('.'))
    with pytest.raises(RuntimeError):
        main()
Exemplo n.º 3
0
def test_main_no_poni(fast_tmpdir):
    poni_file = pyfai_poni
    for file, name in zip([image_file, poni_file], ['test.tiff', 'test.poni']):
        dest_image_file = str(os.path.join(fast_tmpdir, name))
        shutil.copy(file, dest_image_file)
    os.chdir(str(fast_tmpdir))
    main()
    files = os.listdir(str(fast_tmpdir))
    for ext in expected_outputs:
        assert 'test' + ext in files
Exemplo n.º 4
0
def test_main_kwargs(fast_tmpdir, key, value):
    poni_file = pyfai_poni
    dest_image_file = str(os.path.join(fast_tmpdir, 'test.tiff'))
    shutil.copy(image_file, dest_image_file)
    os.chdir(str(fast_tmpdir))
    kwargs = {'alpha': 100, 'polarization': -.99}
    print(kwargs)
    a = main(poni_file, **kwargs)
    if value == 'mean':
        kwargs.update(alpha=5)
    kwargs.update({key: value})
    print(kwargs)
    b = main(poni_file, **kwargs)
    assert_raises(AssertionError, assert_array_equal, a[1][0], b[1][0])
Exemplo n.º 5
0
def test_main_background(fast_tmpdir):
    poni_file = pyfai_poni
    dest_image_file = str(os.path.join(fast_tmpdir, "test.tiff"))
    shutil.copy(image_file, dest_image_file)
    out = main(poni_file, dest_image_file, bg_file=dest_image_file)
    files = os.listdir(str(fast_tmpdir))
    assert_array_equal(out[1][0], np.zeros(out[1][0].shape))
    for ext in expected_outputs:
        assert "test" + ext in files
Exemplo n.º 6
0
def test_main_fit2d_mask(fast_tmpdir):
    poni_file = pyfai_poni
    # Copy the image file to the temp dir
    msk = np.random.randint(0, 2, 2048 * 2048, dtype=bool).reshape(
        (2048, 2048))
    fit2d_save(msk, 'mask_test', str(fast_tmpdir))
    dest_image_file = str(os.path.join(fast_tmpdir, 'test.tiff'))
    shutil.copy(image_file, dest_image_file)
    print(dest_image_file)
    # Copy the poni and image files to the temp dir
    main(poni_file,
         dest_image_file,
         edge=None,
         lower_thresh=None,
         alpha=None,
         mask_file=os.path.join(str(fast_tmpdir), 'mask_test.msk'),
         flip_input_mask=True)
    files = os.listdir(str(fast_tmpdir))
    for ext in expected_outputs:
        assert 'test' + ext in files
    msk2 = read_fit2d_msk(os.path.join(str(fast_tmpdir), 'test.msk'))
    assert_equal(msk, msk2)