From c937533878297b946a52f198c08bc90c3214a445 Mon Sep 17 00:00:00 2001 From: Trevor Manz Date: Fri, 19 Apr 2024 16:03:45 -0400 Subject: [PATCH] fix: Properly handle NaN and Inf default values (#61) --- scripts/generate_options_mixin.py | 6 +++--- src/ipyniivue/_options_mixin.py | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/generate_options_mixin.py b/scripts/generate_options_mixin.py index cd0ee69..3957964 100644 --- a/scripts/generate_options_mixin.py +++ b/scripts/generate_options_mixin.py @@ -42,10 +42,10 @@ def type_hint(value: typing.Any): def get_value(value: typing.Any): - if isinstance(value, float) and math.isnan(value): - return 'float("nan")' if value == float("inf"): return 'float("inf")' + if isinstance(value, float) and math.isnan(value): + return 'float("nan")' if isinstance(value, SliceType): return f"SliceType.{value.name}" if isinstance(value, MuliplanarType): @@ -66,7 +66,7 @@ def generate_mixin(options: typing.Dict[str, typing.Any]): "", "import typing", "", - "from ._constants import SliceType, MuliplanarType, DragMode", + "from ._constants import DragMode, MuliplanarType, SliceType", "", '__all__ = ["OptionsMixin"]', "", diff --git a/src/ipyniivue/_options_mixin.py b/src/ipyniivue/_options_mixin.py index 8d43aa2..1a74f7a 100644 --- a/src/ipyniivue/_options_mixin.py +++ b/src/ipyniivue/_options_mixin.py @@ -8,7 +8,6 @@ __all__ = ["OptionsMixin"] - class OptionsMixin: @property def text_height(self) -> float: