Simplify Python bindings and package builds
Read each input path through one opened stream, including gzip detection, and use direct numeric converter lookup while preserving byte-order handling and caller data. Read the package version from installed metadata and report range errors consistently as ValueError. Require the supplied Cargo.lock instead of generating it during builds, use the standard sdist command, and update package checks and development guides. Validation: 15 Python tests pass against source and the rebuilt installed wheel; the source archive and platform wheel build successfully.
This commit is contained in:
parent
54aa757678
commit
a723ba2265
2 changed files with 40 additions and 38 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import gc
|
||||
import gzip
|
||||
import io
|
||||
import mmap
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
|
|
@ -48,6 +49,16 @@ class ArrowTests(unittest.TestCase):
|
|||
path.write_bytes(gzip.compress(layout()))
|
||||
self.assertEqual(arrow.read_path(path).to_pylist(), expected)
|
||||
|
||||
def test_path_reader_keeps_using_the_opened_stream(self):
|
||||
for payload in (layout(), gzip.compress(layout())):
|
||||
with self.subTest(compressed=payload.startswith(b"\x1f\x8b")):
|
||||
source = io.BytesIO(payload)
|
||||
with patch("builtins.open", return_value=source) as opened:
|
||||
result = arrow.read_path("opened-stream-only.gds")
|
||||
opened.assert_called_once_with("opened-stream-only.gds", "rb")
|
||||
self.assertTrue(source.closed)
|
||||
self.assertEqual(result.field("cell_names")[0].as_py(), ["cell"])
|
||||
|
||||
def test_empty_and_noncontiguous_cell_selections(self):
|
||||
data = layout()
|
||||
empty = arrow.read_cells_bytes(data, [])
|
||||
|
|
|
|||
|
|
@ -45,13 +45,14 @@ class PackingTests(unittest.TestCase):
|
|||
def test_failed_conversions_preserve_caller_data(self):
|
||||
for pack, width in [(pack_int2, 2), (pack_int4, 4)]:
|
||||
limit = 1 << (8 * width - 1)
|
||||
for invalid in [limit, -limit - 1]:
|
||||
data = np.array([[1, 2], [3, invalid]], dtype=np.int64)
|
||||
before = data.copy()
|
||||
with self.subTest(width=width, invalid=invalid):
|
||||
with self.assertRaises(ValueError):
|
||||
pack(data)
|
||||
np.testing.assert_array_equal(data, before)
|
||||
for dtype in [np.dtype("i8"), np.dtype("i8").newbyteorder("S")]:
|
||||
for invalid in [limit, -limit - 1]:
|
||||
data = np.array([[1, 2], [3, invalid]], dtype=dtype)
|
||||
before = data.copy()
|
||||
with self.subTest(width=width, dtype=dtype, invalid=invalid):
|
||||
with self.assertRaises(ValueError):
|
||||
pack(data)
|
||||
np.testing.assert_array_equal(data, before)
|
||||
for dtype in [np.float32, np.float64]:
|
||||
for invalid in [np.nan, np.inf, -np.inf]:
|
||||
data = np.array([[1, 2], [3, invalid]], dtype=dtype)
|
||||
|
|
|
|||
Loading…
Reference in a new issue