英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论