From 5cfd60ca0f3e956e9f7809ebed9f796c7b60d42d Mon Sep 17 00:00:00 2001 From: QuantumGhost Date: Mon, 26 May 2025 14:04:30 +0800 Subject: [PATCH] docs(api): Add a documentation about equality of `FloatSegment` --- api/core/variables/segments.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/api/core/variables/segments.py b/api/core/variables/segments.py index 64ba16c367..5a470c0d2d 100644 --- a/api/core/variables/segments.py +++ b/api/core/variables/segments.py @@ -1,12 +1,11 @@ import json -import sys from collections.abc import Mapping, Sequence from typing import Any +import sys from pydantic import BaseModel, ConfigDict, field_validator from core.file import File - from .types import SegmentType @@ -75,6 +74,20 @@ class StringSegment(Segment): class FloatSegment(Segment): value_type: SegmentType = SegmentType.NUMBER value: float + # NOTE(QuantumGhost): seems that the equality for FloatSegment with `NaN` value has some problems. + # The following tests cannot pass. + # + # def test_float_segment_and_nan(): + # nan = float("nan") + # assert nan != nan + # + # f1 = FloatSegment(value=float("nan")) + # f2 = FloatSegment(value=float("nan")) + # assert f1 != f2 + # + # f3 = FloatSegment(value=nan) + # f4 = FloatSegment(value=nan) + # assert f3 != f4 class IntegerSegment(Segment):