예제 #1
0
def test_validation(lt_ctx):
    """
    Test that the ValidationUDF works as designed
    """
    data = _mk_random(size=(16, 16, 16, 16), dtype="float32")
    dataset = MemoryDataSet(data=data,
                            tileshape=(1, 16, 16),
                            num_partitions=2,
                            sig_dims=2)

    udf = ValidationUDF(reference=data.reshape((-1, 16, 16)))
    res = lt_ctx.run_udf(dataset=dataset, udf=udf)
    assert res['nav_shape'].data.shape == (16, 16)

    with pytest.raises(AssertionError):
        data2 = data.copy()
        data2[7, 9, 13, 11] += 0.1
        udf = ValidationUDF(reference=data2.reshape((-1, 16, 16)))
        res = lt_ctx.run_udf(dataset=dataset, udf=udf)

    with pytest.raises(AssertionError):

        def badcompare(a, b):
            return False

        udf = ValidationUDF(reference=data.reshape((-1, 16, 16)),
                            validation_function=badcompare)
        res = lt_ctx.run_udf(dataset=dataset, udf=udf)
예제 #2
0
def test_comparison(default_k2is, default_k2is_raw, lt_ctx_fast):
    udf = ValidationUDF(
        reference=reshaped_view(default_k2is_raw,
                                (-1, *tuple(default_k2is.shape.sig))),
        validation_function=lambda a, b: np.all(a == b),
    )
    lt_ctx_fast.run_udf(udf=udf, dataset=default_k2is)
예제 #3
0
def test_comparison_roi(default_blo, default_blo_raw, lt_ctx_fast):
    roi = np.random.choice(
        [True, False],
        size=tuple(default_blo.shape.nav),
        p=[0.5, 0.5]
    )
    udf = ValidationUDF(reference=default_blo_raw[roi])
    lt_ctx_fast.run_udf(udf=udf, dataset=default_blo, roi=roi)
예제 #4
0
def test_comparison_roi(default_k2is, default_k2is_raw, lt_ctx_fast):
    roi = np.random.choice([True, False],
                           size=tuple(default_k2is.shape.nav),
                           p=[0.5, 0.5])
    udf = ValidationUDF(
        reference=default_k2is_raw[roi],
        validation_function=lambda a, b: np.all(a == b),
    )
    lt_ctx_fast.run_udf(udf=udf, dataset=default_k2is, roi=roi)
예제 #5
0
def test_comparison_roi(default_seq, default_seq_raw, lt_ctx_fast):
    corrset = CorrectionSet()
    roi = np.random.choice([True, False],
                           size=tuple(default_seq.shape.nav),
                           p=[0.5, 0.5])
    udf = ValidationUDF(reference=default_seq_raw[roi])
    lt_ctx_fast.run_udf(udf=udf,
                        dataset=default_seq,
                        roi=roi,
                        corrections=corrset)
예제 #6
0
def test_comparison(default_seq, default_seq_raw, lt_ctx_fast):
    corrset = CorrectionSet()
    udf = ValidationUDF(reference=reshaped_view(default_seq_raw, (
        -1, *tuple(default_seq.shape.sig))))
    lt_ctx_fast.run_udf(udf=udf, dataset=default_seq, corrections=corrset)
예제 #7
0
def test_comparison(default_blo, default_blo_raw, lt_ctx_fast):
    udf = ValidationUDF(
        reference=reshaped_view(default_blo_raw, (-1, *tuple(default_blo.shape.sig)))
    )
    lt_ctx_fast.run_udf(udf=udf, dataset=default_blo)
예제 #8
0
def test_comparison_roi(default_frms6_uncorr, default_frms6_raw, lt_ctx_fast):
    roi = np.random.choice([True, False],
                           size=tuple(default_frms6_uncorr.shape.nav),
                           p=[0.001, 0.999])
    udf = ValidationUDF(reference=default_frms6_raw[roi])
    lt_ctx_fast.run_udf(udf=udf, dataset=default_frms6_uncorr, roi=roi)
예제 #9
0
def test_comparison_3d(dm_stack_of_3d, default_dm_3d_raw, lt_ctx_fast):
    udf = ValidationUDF(reference=default_dm_3d_raw)
    lt_ctx_fast.run_udf(udf=udf, dataset=dm_stack_of_3d)
예제 #10
0
def test_comparison(default_dm, default_dm_raw, lt_ctx_fast):
    udf = ValidationUDF(reference=default_dm_raw)
    lt_ctx_fast.run_udf(udf=udf, dataset=default_dm)