Skip to content

Commit 06bfbb3

Browse files
committed
close gaps in diff and importance
1 parent e1ecc49 commit 06bfbb3

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

sentience/tracing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class TraceEvent:
2929
run_id: str # UUID for the run
3030
seq: int # Sequence number
3131
data: dict[str, Any] # Event payload
32-
step_id: Optional[str] = None # UUID for the step (if step-scoped)
33-
ts_ms: Optional[int] = None # Unix timestamp in milliseconds
32+
step_id: str | None = None # UUID for the step (if step-scoped)
33+
ts_ms: int | None = None # Unix timestamp in milliseconds
3434

3535
def to_dict(self) -> dict[str, Any]:
3636
"""Convert to dictionary for JSON serialization."""

tests/test_importance_score.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def create_snapshot(elements: list[Element]) -> Snapshot:
3333
def test_importance_score_normalization_basic():
3434
"""Test basic importance score normalization to [0, 1] range."""
3535
elements = [
36-
create_element(1, importance=0), # Min -> 0.0
36+
create_element(1, importance=0), # Min -> 0.0
3737
create_element(2, importance=500), # Mid -> 0.5
38-
create_element(3, importance=1000), # Max -> 1.0
38+
create_element(3, importance=1000), # Max -> 1.0
3939
]
4040
snapshot = create_snapshot(elements)
4141

@@ -52,16 +52,16 @@ def test_importance_score_normalization_basic():
5252
assert "importance_score" in el2
5353
assert "importance_score" in el3
5454

55-
assert el1["importance_score"] == 0.0 # (0 - 0) / (1000 - 0) = 0.0
56-
assert el2["importance_score"] == 0.5 # (500 - 0) / (1000 - 0) = 0.5
57-
assert el3["importance_score"] == 1.0 # (1000 - 0) / (1000 - 0) = 1.0
55+
assert el1["importance_score"] == 0.0 # (0 - 0) / (1000 - 0) = 0.0
56+
assert el2["importance_score"] == 0.5 # (500 - 0) / (1000 - 0) = 0.5
57+
assert el3["importance_score"] == 1.0 # (1000 - 0) / (1000 - 0) = 1.0
5858

5959

6060
def test_importance_score_with_negative_values():
6161
"""Test normalization with negative importance values."""
6262
elements = [
6363
create_element(1, importance=-300), # Min -> 0.0
64-
create_element(2, importance=500), # Mid -> ~0.44
64+
create_element(2, importance=500), # Mid -> ~0.44
6565
create_element(3, importance=1800), # Max -> 1.0
6666
]
6767
snapshot = create_snapshot(elements)
@@ -137,10 +137,7 @@ def test_importance_score_preserves_original_importance():
137137
def test_importance_score_in_range_0_to_1():
138138
"""Test that all normalized scores are in [0, 1] range."""
139139
# Create elements with various importance values
140-
elements = [
141-
create_element(i, importance=i * 100 - 300)
142-
for i in range(20)
143-
]
140+
elements = [create_element(i, importance=i * 100 - 300) for i in range(20)]
144141
snapshot = create_snapshot(elements)
145142

146143
event_data = TraceEventBuilder.build_snapshot_event(snapshot)

0 commit comments

Comments
 (0)