Changing compression parameter in python-blosc2

huangapple go评论70阅读模式
英文:

Changing compression parameter in python-blosc2

问题

我想测试[python-blosc2](https://www.blosc.org/python-blosc2/python-blosc2.html)。但是,当尝试使用用户定义的过滤器来压缩数据时,我遇到了一个对我来说无法解释的错误。

import blosc2  
import numpy as np

a = np.random.rand(1000, 1000)

blosc2.compress(a, codec='blosclz', clevel=5, filter=blosc2.Filter.SHUFFLE)

我收到一个**AttributeError: 'str' object has no attribute 'name'**错误。根据文档的说法,应该将enum blosc2.Filter`作为参数传递。但是,我尝试了多种方法,包括(但是仍然收到相同的错误):

blosc2.compress(a, codec='blosclz', clevel=5, filter=blosc2.Filter(0))

我忽略了在文档中指出的要使用枚举对象而不是字符串。

英文:

I wanted to test out python-blosc2.

When trying do compress data with a user-defined Filter however, I stumbled across a for me unexplainable error.


import blosc2  
import numpy as np

a = np.random.rand(1000, 1000)

blosc2.compress(a, codec='blosclz', clevel=5, filter=blosc2.Filter.SHUFFLE)

I receive a AttributeError: 'str' object has no attribute 'name'

as the documentation said, one should pass the `enum blosc2.Filter` as argument. However, I tried multiple ways, including (but receiving the same error):

blosc2.compress(a, codec='blosclz', clevel=5, filter=blosc2.Filter(0))

I did miss, to uses the enum objects insted of the string for as also pointed out in the documentation.

答案1

得分: 1

看起来,你的代码在这里失败。根据core.py的源代码,codec不应该是str类型。你应该传递一个blosc2.Codec的值:

blosc2.compress(a, codec=blosc2.Codec.BLOSCLZ, clevel=5, filter=blosc2.Filter.SHUFFLE)
英文:

Looks like, your code fails here. According to the source code of core.py, codec is not supposed to be str type. You should pass a value of blosc2.Codec:

blosc2.compress(a, codec=blosc2.Codec.BLOSCLZ, clevel=5, filter=blosc2.Filter.SHUFFLE)

huangapple
  • 本文由 发表于 2023年6月8日 21:38:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76432451.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定