Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
brilee committed Jan 31, 2024
1 parent 41fb93a commit a48af85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lilac/data/dataset_duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,6 @@ def select_groups(
if not leaf.categorical and (leaf_is_float or leaf_is_integer):
if named_bins is None:
# Auto-bin.
print(stats)
named_bins = _auto_bins(stats, NUM_AUTO_BINS)

sql_bounds = []
Expand Down Expand Up @@ -1933,7 +1932,6 @@ def select_groups(
ORDER BY {sort_by.value} {sort_order.value}, {value_column}
{limit_query}
"""
print(query)
df = self._query_df(query)
counts = list(df.itertuples(index=False, name=None))
if is_temporal(leaf.dtype):
Expand Down
20 changes: 20 additions & 0 deletions lilac/data/dataset_select_groups_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,26 @@ def test_auto_bins_for_missing_float(make_test_data: TestDataMaker) -> None:
assert res.too_many_distinct is False
assert res.bins == [('0', None, None)]

# Confirm that SQL compliation works for 1 bin.
stats = dataset.stats('feature')
assert stats.min_val is None
assert stats.max_val is None


def test_auto_bins_for_constant_float(make_test_data: TestDataMaker) -> None:
items: list[Item] = [{'feature': 1.0}] * 5
dataset = make_test_data(items)

res = dataset.select_groups('feature')
assert res.counts == [('0', 5)]
assert res.too_many_distinct is False
assert res.bins == [('0', 1.0, None)]

# Confirm that SQL compliation works for 1 bin.
stats = dataset.stats('feature')
assert stats.min_val == 1.0
assert stats.max_val == 1.0


def test_map_dtype(make_test_data: TestDataMaker) -> None:
items = [
Expand Down

0 comments on commit a48af85

Please sign in to comment.