vector_of_kll_floats_sketches.get_quantiles() returns wrong values with float32
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu với bản tái hiện Python được cung cấp bằng cách sử dụng vector_of_kll_floats_sketches.get_quantiles(), so sánh các mảng thứ hạng float32 và float64. Theo dõi cách xử lý các thứ hạng float32 và thêm một bài kiểm thử hồi quy bao quát các thứ hạng gần 0 và 1; được xem là hoàn thành khi float32 và float64 trả về các phân vị tương đương cho ví dụ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
#!/usr/bin/env python3
"""
Minimal example: vector_of_kll_floats_sketches.get_quantiles() returns WRONG VALUES with float32
"""
import numpy as np
from datasketches import vector_of_kll_floats_sketches
# Create test data: 1000 samples between -100 and -10
np.random.seed(42)
test_data = np.random.uniform(-100, -10, size=(1000, 1)).astype(np.float32)
print("Test data: 1000 samples between -100 and -10")
print(f"True min: {test_data.min():.2f}, True max: {test_data.max():.2f}")
# Create sketch and add data
kll = vector_of_kll_floats_sketches(200, 1)
kll.update(test_data)
# Request p0.0001 (should be ~-100) and p0.9999 (should be ~-10)
ranks_list = [0.0001, 0.9999]
ranks_array32 = np.array(ranks_list, dtype=np.float32)
ranks_array64 = np.array(ranks_list, dtype=np.float64)
print("\n" + "="*60)
print("BUG: numpy array with dtype=np.float32 returns WRONG quantiles")
print("="*60)
quants_array = kll.get_quantiles(ranks_array32)
print(f"\nWith numpy array with dtype=np.float32: {ranks_array32}")
print(f" p0.0001 = {quants_array[0][0]:.2f} (expected: ~-100)")
print(f" p0.9999 = {quants_array[0][1]:.2f} (expected: ~-10)")
print(f" ✗ WRONG: Both values near minimum!")
quants_array64 = kll.get_quantiles(ranks_array64)
print(f"\nWith numpy array with dtype=np.float64: {ranks_array64}")
print(f" p0.0001 = {quants_array64[0][0]:.2f} (expected: ~-100)")
print(f" p0.9999 = {quants_array64[0][1]:.2f} (expected: ~-10)")
print(f" ✓ CORRECT")
Test data: 1000 samples between -100 and -10
True min: -99.58, True max: -10.03
============================================================
BUG: numpy array with dtype=np.float32 returns WRONG quantiles
============================================================
With numpy array with dtype=np.float32: [1.000e-04 9.999e-01]
p0.0001 = -98.69 (expected: ~-100)
p0.9999 = -99.50 (expected: ~-10)
✗ WRONG: Both values near minimum!
With numpy array with dtype=np.float64: [1.000e-04 9.999e-01]
p0.0001 = -99.50 (expected: ~-100)
p0.9999 = -10.28 (expected: ~-10)
✓ CORRECT
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 46
- Fork
- 9
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/datasketches-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
apache/datasketches-python#65 · 3 reaction ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 55/100
apache/datasketches-python#46 · 2 bình luận ·
-
Vectorize update() Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
apache/datasketches-python#21 · 2 bình luận ·
Tất cả issue của apache/datasketches-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
robjhyndman/forecast#1220 ·
-
Add: New Channel Đang mởchannels:add check:passed
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
good first issue help wanted NLnet
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
collective/icalendar#1819 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
confluentinc/dbt-confluent#160 ·
-
inceleme-kuyrugu
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Greater-Turkiye/platform#107 ·