Commit 1bac7a70 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[widgets][parameterwidget] Improve InputType

parent a0ab5175
......@@ -74,13 +74,7 @@ def parameter_default_map(prefix_path, algorithm_name):
# Fixtures
for item in InputType
if item not in [InputType.UNKNOWN, InputType.BOOL, InputType.STRING]
def numerical_input_type(request):
return request.param
......@@ -115,6 +109,22 @@ def parameter_name(request):
# Tests
class TestInputType:
"""Test the InputType enum class"""
def test_numerical_info(self, numerical_input_type):
type_ = type(numerical_input_type.numpy_info)
assert type_ in [np.iinfo, np.finfo]
[item for item in InputType if item not in InputType.numerical_types()],
def test_non_numerical_info(self, input_type):
with pytest.raises(RuntimeError):
class TestBoolSetupWidget:
"""Test the BoolSetupWidget is set up and works correctly"""
......@@ -26,7 +26,6 @@
import numpy as np
from enum import Enum, unique
from collections import namedtuple
from PyQt5.QtCore import Qt
from PyQt5.QtCore import pyqtSignal
......@@ -77,16 +76,26 @@ class InputType(Enum):
def numpy_info(self):
info = None
if np.issubdtype(self.np_type, np.floating):
if self is InputType.UNKNOWN:
raise RuntimeError(f"Invalid type")
elif np.issubdtype(self.np_type, np.floating):
info = np.finfo(self.np_type)
elif np.issubdtype(self.np_type, np.integer):
info = np.iinfo(self.np_type)
Info = namedtuple("Info", ["min", "max"])
info = Info(0, 0)
raise RuntimeError(f"No information available for {self}")
return info
def numerical_types():
return [
for item in InputType
if item not in [InputType.UNKNOWN, InputType.BOOL, InputType.STRING]
class StackedWidget(QStackedWidget):
"""Subclass that will use the current widget height to adjust the stack
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment