Skip to content

Commit 575e3c1

Browse files
authored
Merge pull request #103 from ladisk/wrong_dataset_separator_in_58b
resolved wrong dataset separator
2 parents 8f184f9 + 8789920 commit 575e3c1

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed
24.8 MB
Binary file not shown.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "pyuff"
7-
version = "2.5.0"
7+
version = "2.5.1"
88
authors = [{name = "Primož Čermelj, Janko Slavič", email = "[email protected]"}]
99
maintainers = [{name = "Janko Slavič et al.", email = "[email protected]"}]
1010
license = "MIT"

pyuff/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.5.0"
1+
__version__ = "2.5.1"
22
from .pyuff import *
33
from .datasets import *
44

pyuff/datasets/dataset_58.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1090,11 +1090,13 @@ def _extract58(block_data, header_only=False):
10901090
else:
10911091
bo = '>'
10921092
if (dset['ord_data_type'] == 2) or (dset['ord_data_type'] == 5):
1093-
# single precision - 4 bytes
1094-
values = np.asarray(struct.unpack('%c%sf' % (bo, int(len(split_data) / 4)), split_data), 'd')
1093+
# single precision - 4 bytes, note: sometimes split_data wrongly contains CR/LF and
1094+
# therefore the length of split_data is not divisible by 4
1095+
values = np.asarray(struct.unpack('%c%sf' % (bo, int(len(split_data) / 4)), split_data[:(len(split_data) // 4)*4]), 'd')
10951096
else:
1096-
# double precision - 8 bytes
1097-
values = np.asarray(struct.unpack('%c%sd' % (bo, int(len(split_data) / 8)), split_data), 'd')
1097+
# double precision - 8 bytes, note: sometimes split_data wrongly contains CR/LF and
1098+
# therefore the length of split_data is not divisible by 8
1099+
values = np.asarray(struct.unpack('%c%sd' % (bo, int(len(split_data) / 8)), split_data[:(len(split_data) // 8)*8]), 'd')
10981100
except:
10991101
raise Exception('Potentially wrong data format (common with binary files from some commercial softwares). Try using pyuff.fix_58b() to fix your file. For more information, see https://github.com/ladisk/pyuff/issues/61')
11001102
else:

0 commit comments

Comments
 (0)