-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(reader): convert bytes to string for h5py >= 3.0 #40
- Loading branch information
1 parent
446192d
commit f49588d
Showing
3 changed files
with
30 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
|
||
def convert_to_string(data): | ||
"""Converts extracted string data from bytes to string, as strings are handled as bytes since h5py >= 3.0. | ||
The function has been introduced as part of an `issue <https://github.com/rundherum/pymia/issues/40>`_. | ||
Args: | ||
data: The data to be converted; either :obj:`bytes` or list of :obj:`bytes`. | ||
Returns: | ||
The converted data as :obj:`str` or list of :obj:`str`. | ||
""" | ||
if isinstance(data, bytes): | ||
return data.decode('utf-8') | ||
elif isinstance(data, list): | ||
return [convert_to_string(d) for d in data] | ||
else: | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters