tests.py 文件源码

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

项目:higlass-server 作者: hms-dbmi 项目源码 文件源码
def check_tile(self, z, x, y):
        returned = json.loads(
            self.client.get(
                '/api/v1/tiles/?d={uuid}.{z}.{x}.{y}'.format(
                    uuid=self.cooler.uuid, x=x, y=y, z=z
                )
            ).content.decode('utf-8')
        )

        r = base64.decodestring(returned[list(returned.keys())[0]]['dense'].encode('utf-8'))
        q = np.frombuffer(r, dtype=np.float16)

        with h5py.File(self.cooler.datafile.url) as f:
            tileset_info = cch.get_info(self.cooler.datafile.url)
            tileset_file = f

            mat = [tileset_file, tileset_info]

            zoom_level = z
            BINS_PER_TILE = 256

            hdf_for_resolution = tileset_file[str(zoom_level)]
            resolution = (tileset_info['max_width'] / 2**zoom_level) / BINS_PER_TILE

            t = tt.make_tiles(hdf_for_resolution, resolution, x, y)[(x,y)]

            # test the base64 encoding
            self.assertTrue(np.isclose(sum(q), sum(t), rtol=1e-3))

            # make sure we're returning actual data
            self.assertGreater(sum(q), 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号