Compare commits

..

No commits in common. "56a99c8e58a6cd0cb729454c618fc164815b7427" and "9e6f5a336578558a2aa9c0414826d4bba594fbaa" have entirely different histories.

3 changed files with 6 additions and 13 deletions

View file

@ -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,6 +160,7 @@ 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)

View file

@ -2,7 +2,6 @@
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
@ -54,8 +53,6 @@ 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

View file

@ -220,15 +220,10 @@ 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)