Compare commits
3 commits
9e6f5a3365
...
56a99c8e58
| Author | SHA1 | Date | |
|---|---|---|---|
| 56a99c8e58 | |||
| e72b792f6f | |||
| 286f9e1949 |
3 changed files with 13 additions and 6 deletions
|
|
@ -149,7 +149,7 @@ def encode_real8(fnums: NDArray[numpy.float64]) -> NDArray[numpy.uint64]:
|
||||||
gds_exp = exp16 + 64
|
gds_exp = exp16 + 64
|
||||||
|
|
||||||
neg_biased = (gds_exp < 0)
|
neg_biased = (gds_exp < 0)
|
||||||
gds_mant[neg_biased] >>= (gds_exp[neg_biased] * 4).astype(numpy.uint16)
|
gds_mant[neg_biased] >>= (-gds_exp[neg_biased] * 4).astype(numpy.uint16)
|
||||||
gds_exp[neg_biased] = 0
|
gds_exp[neg_biased] = 0
|
||||||
|
|
||||||
too_big = (gds_exp > 0x7f) & ~(zero | subnorm)
|
too_big = (gds_exp > 0x7f) & ~(zero | subnorm)
|
||||||
|
|
@ -160,7 +160,6 @@ def encode_real8(fnums: NDArray[numpy.float64]) -> NDArray[numpy.uint64]:
|
||||||
|
|
||||||
real8 = sign | gds_exp_bits | gds_mant
|
real8 = sign | gds_exp_bits | gds_mant
|
||||||
real8[zero] = 0
|
real8[zero] = 0
|
||||||
real8[gds_exp < -14] = 0 # number is too small
|
|
||||||
|
|
||||||
return real8.astype(numpy.uint64, copy=False)
|
return real8.astype(numpy.uint64, copy=False)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
Functionality for reading/writing elements (geometry, text labels,
|
Functionality for reading/writing elements (geometry, text labels,
|
||||||
structure references) and associated properties.
|
structure references) and associated properties.
|
||||||
"""
|
"""
|
||||||
|
import io
|
||||||
from typing import IO, TypeVar
|
from typing import IO, TypeVar
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
@ -53,6 +54,8 @@ def read_properties(stream: IO[bytes]) -> dict[int, bytes]:
|
||||||
if key in properties:
|
if key in properties:
|
||||||
raise KlamathError(f'Duplicate property key: {key!r}')
|
raise KlamathError(f'Duplicate property key: {key!r}')
|
||||||
properties[key] = value
|
properties[key] = value
|
||||||
|
else:
|
||||||
|
stream.seek(size, io.SEEK_CUR)
|
||||||
size, tag = Record.read_header(stream)
|
size, tag = Record.read_header(stream)
|
||||||
return properties
|
return properties
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -220,10 +220,15 @@ def scan_hierarchy(stream: IO[bytes]) -> dict[bytes, dict[bytes, int]]:
|
||||||
colrow = COLROW.read_data(stream, size)
|
colrow = COLROW.read_data(stream, size)
|
||||||
ref_count = colrow[0] * colrow[1]
|
ref_count = colrow[0] * colrow[1]
|
||||||
elif tag == ENDEL.tag:
|
elif tag == ENDEL.tag:
|
||||||
|
if ref_name is not None:
|
||||||
if ref_count is None:
|
if ref_count is None:
|
||||||
ref_count = 1
|
ref_count = 1
|
||||||
assert ref_name is not None
|
|
||||||
cur_structure[ref_name] += ref_count
|
cur_structure[ref_name] += ref_count
|
||||||
|
ref_name = None
|
||||||
|
ref_count = None
|
||||||
|
elif tag in (SREF.tag, AREF.tag):
|
||||||
|
ref_name = None
|
||||||
|
ref_count = None
|
||||||
else:
|
else:
|
||||||
stream.seek(size, io.SEEK_CUR)
|
stream.seek(size, io.SEEK_CUR)
|
||||||
size, tag = Record.read_header(stream)
|
size, tag = Record.read_header(stream)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue