Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(57)  |  Call(57)  |  Derive(0)  |  Import(0)

src/n/i/nibabel-1.3.0/nibabel/tests/test_trackvis.py   nibabel(Download)
    tv.write(out_f, [], {})
    assert_equal(out_f.getvalue(), tv.empty_header().tostring())
    out_f.truncate(0); out_f.seek(0)
    # Write something not-default
    tv.write(out_f, [], {'id_string':'TRACKb'})
    # read it back
    out_f.seek(0)
    assert_equal(hdr['id_string'], asbytes('TRACKb'))
    # check that we can pass none for the header
    out_f.truncate(0); out_f.seek(0)
    tv.write(out_f, [])
    out_f.truncate(0); out_f.seek(0)
    tv.write(out_f, [], None)
    # check that we check input values
    out_f.truncate(0); out_f.seek(0)

src/n/i/nibabel-1.3.0/nibabel/tests/test_utils.py   nibabel(Download)
    # And that offset=None respected
    str_io.truncate(22)
    str_io.seek(22)
    array_to_file(arr, str_io, np.float, None)
    data_back = array_from_file(arr.shape, np.float, str_io, 22)
    assert_array_equal(data_back, [-128, 0, 127])
    # Scales also if mx, mn specified?
    str_io.seek(0)
    array_to_file(arr, str_io, np.int8, mn=info['min'], mx=info['max'],
                  intercept=np.float32(2**120))
    data_back = array_from_file(arr.shape, np.int8, str_io)
    assert_array_equal(data_back, [-128, 0, 127])
    # And if slope causes overflow?
    str_io.seek(0)
    assert_array_equal(data_back, [-128, 0, 127])
    # with mn, mx specified?
    str_io.seek(0)
    array_to_file(arr, str_io, np.int8, mn=info['min'], mx=info['max'],
                  divslope=np.float32(0.5))
def test_write_zeros():
    bio = BytesIO()
    write_zeros(bio, 10000)
    assert_equal(bio.getvalue(), ZEROB*10000)
    bio.seek(0)

src/n/i/nibabel-1.3.0/nibabel/tests/test_scaling.py   nibabel(Download)
        slope, inter, mn, mx = calculate_scale(arr, out_dtype, True)
        array_to_file(arr, bio, out_type, 0, inter, slope, mn, mx)
        bio.seek(0)
        arr2 = array_from_file(arr.shape, out_dtype, bio)
        arr3 = apply_read_scaling(arr2, slope, inter)
        # Max rounding error for integer type
        max_miss = slope / 2.
        assert_true(np.all(np.abs(arr - arr3) <= max_miss))
        bio.truncate(0)
        bio.seek(0)

src/n/i/nibabel-1.3.0/nibabel/tests/test_arraywriters.py   nibabel(Download)
        aw.calc_scale()
        aw.to_fileobj(bio)
        bio.seek(0)
        arr2 = array_from_file(arr.shape, out_dtype, bio)
        arr3 = apply_read_scaling(arr2, aw.slope, aw.inter)
        # Max rounding error for integer type
        max_miss = aw.slope / 2.
        assert_true(np.all(np.abs(arr - arr3) <= max_miss))
        bio.truncate(0)
        bio.seek(0)

src/n/i/nibabel-1.3.0/nibabel/tests/test_spatialimages.py   nibabel(Download)
    assert_equal(fobj.getvalue(),
                       data.astype(np.int32).tostring(order='F'))
    fobj.seek(0)
    data2 = hdr.data_from_fileobj(fobj)
    assert_array_equal(data, data2)

src/n/i/nibabel-1.3.0/nibabel/tests/test_wrapstruct.py   nibabel(Download)
        str_io = BytesIO()
        hdr.write_to(str_io)
        str_io.seek(0)
        hdr2 = self.header_class.from_fileobj(str_io)
        assert_equal(hdr2.endianness, native_code)

src/n/i/nibabel-1.3.0/nibabel/tests/test_nifti1.py   nibabel(Download)
    nim.file_map['image'].fileobj = stio
    nim.to_file_map()
    stio.seek(0)
    # reload
    lnim = Nifti1Image.from_file_map(nim.file_map)
    wnim.file_map['image'].fileobj = stio
    wnim.to_file_map()
    stio.seek(0)
    lnim = Nifti1Image.from_file_map(wnim.file_map)
    assert_equal(lnim.get_data_dtype(), np.int16)

src/n/i/nibabel-1.3.0/nibabel/tests/test_image_load_save.py   nibabel(Download)
    img.file_map['image'].fileobj = str_io
    img.to_file_map()
    str_io.seek(0)
    re_img = Nifti1Image.from_file_map(img.file_map)
    assert_array_almost_equal(re_img.get_data(), data, 4)