test_resampling.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:uncover-ml 作者: GeoscienceAustralia 项目源码 文件源码
def test_resampling_value(shapefile, bins, samples):
    samples = (samples//bins) * bins
    lonlats, filename = shapefile
    random_filename = tempfile.mktemp() + ".shp"
    resampling.resample_by_magnitude(filename,
                                     random_filename,
                                     target_field='lat',
                                     bins=bins,
                                     output_samples=samples,
                                     bootstrap=True
                                     )
    resampled_sf = shp.Reader(random_filename)
    resampled_shapefields = [f[0] for f in resampled_sf.fields[1:]]

    new_coords, new_val, new_othervals = \
        geoio.load_shapefile(random_filename, 'lat')

    assert 'lat' in resampled_shapefields
    assert 'lon' not in resampled_shapefields
    assert np.all((samples, 2) == new_coords.shape)
    assert new_othervals == {}  # only the target is retained after resampling
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号