G-Node / G-Node/nixpy

UnicodeDecodeError when setting tag units with unit of data array

Open
#249 7 comments 0 reactions 1 assignee Claimed by @achilleas-k View on GitHub
Dominant language
Python
Stars
22
Forks
29
PR merge metrics
No merged PRs in 30d

Description

Hi

Here is an example with nixio v1.3.0

import nixio as nix
import numpy as np

nixFile = nix.File.open('test.h5')
blk = nixFile.create_block('TestBlock', 'Test')
da = blk.create_data_array('TestDA', 'Test', data=np.random.rand(50))
da.unit = 'mV'
dim = da.append_sampled_dimension(1)
dim.unit = 's'

tag = blk.create_tag('TestTag', 'Test', position=[10])
tag.extent = [10]
tag.references.append(da)
tag.units = [da.dimensions[0].unit]
nixFile.close()

Here is the Traceback,

Traceback (most recent call last):
File "tmp/nixioUnicodeBug.py", line 14, in
tag.units = [da.dimensions[0].unit]
File "/home/aj/intel/intelpython27/envs/GJEMS/lib/python2.7/site-packages/nixio/pycore/tag.py", line 51, in units
u = util.units.sanitizer(u)
File "/home/aj/intel/intelpython27/envs/GJEMS/lib/python2.7/site-packages/nixio/pycore/util/units.py", line 66, in sanitizer
replace(micro, "u").replace(mugr, "u")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)

I could get around it with

tag.units = [str(da.dimensions[0].unit)]

Is this expected behavior? Thanks.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.