mirror of
https://github.com/lancedb/lancedb.git
synced 2026-08-31 02:18:27 +00:00
fix: retain unordered take semantics
This commit is contained in:
@@ -1489,9 +1489,9 @@ class Table(ABC):
|
||||
Offsets are mostly useful for sampling as the set of all valid offsets is easily
|
||||
known in advance to be [0, len(table)).
|
||||
|
||||
Results are returned in the same order as the given offsets. Repeated offsets
|
||||
produce repeated rows, which makes this method suitable for sampling with
|
||||
replacement.
|
||||
No guarantees are made regarding the order in which results are returned.
|
||||
Repeated offsets produce repeated rows, which makes this method suitable for
|
||||
sampling with replacement.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -6291,8 +6291,8 @@ class AsyncTable:
|
||||
Offsets are mostly useful for sampling as the set of all valid offsets is easily
|
||||
known in advance to be [0, len(table)).
|
||||
|
||||
Results are returned in the same order as the given offsets, including repeated
|
||||
occurrences.
|
||||
No guarantees are made regarding the order in which results are returned.
|
||||
Repeated offsets produce repeated rows.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
@@ -1891,13 +1891,10 @@ def test_take_queries(tmp_path):
|
||||
17,
|
||||
]
|
||||
|
||||
# Duplicate offsets are occurrences, not set members, and preserve input order.
|
||||
assert table.take_offsets([5, 2, 5, 17]).to_pandas()["idx"].to_list() == [
|
||||
5,
|
||||
2,
|
||||
5,
|
||||
17,
|
||||
]
|
||||
# Duplicate offsets are occurrences, not set members. Ordering is unspecified.
|
||||
assert sorted(
|
||||
table.take_offsets([5, 2, 5, 17]).to_pandas()["idx"].to_list()
|
||||
) == [2, 5, 5, 17]
|
||||
|
||||
# Take by row id
|
||||
assert list(
|
||||
|
||||
@@ -510,8 +510,8 @@ def test_remote_permutation_is_picklable():
|
||||
table = db.open_table("test")
|
||||
assert table.take_offsets([0, 2, 0, 4]).to_list() == [
|
||||
{"a": 0},
|
||||
{"a": 2},
|
||||
{"a": 0},
|
||||
{"a": 2},
|
||||
{"a": 4},
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user