Оптимизмрован код, исправлены параметры отображения факторов экспримента

This commit is contained in:
2026-05-26 22:50:16 +05:00
parent 63b5f0a49f
commit 1ddfe20a8d
3 changed files with 75 additions and 100 deletions
+8 -8
View File
@@ -16,7 +16,7 @@ import numpy as np
# Типы расчёта шага
FACTOR_TYPES = {
'absolute': 'абс', # абсолютный шаг
'absolute': 'ед.', # абсолютный шаг
'relative': '%', # относительный шаг (процент от нулевого уровня)
}
@@ -33,7 +33,7 @@ def calculate_factor_levels(
Параметры:
center_value: нулевой уровень фактора (центральная точка)
step_value: значение шага
step_type: тип шага ("абс" - абсолютный, "%" - относительный)
step_type: тип шага ("ед." - абсолютный, "%" - относительный)
base_value: базовое значение для относительного шага (если None, используется center_value)
Возвращает:
@@ -42,14 +42,14 @@ def calculate_factor_levels(
Пример:
>>> calculate_factor_levels(100, 10, "%")
(110.0, 90.0)
>>> calculate_factor_levels(100, 20, "абс")
>>> calculate_factor_levels(100, 20, "ед.")
(120.0, 80.0)
"""
# Определяем абсолютное значение шага
if step_type == "%":
base = base_value if base_value is not None else center_value
step_abs = center_value * step_value / 100
else: # "абс" или "absolute"
else: # "ед." или "absolute"
step_abs = step_value
high_level = center_value + step_abs
@@ -79,7 +79,7 @@ def generate_factorial_design(
- center (float): нулевой уровень (0)
- unit (str): единица измерения
- step (float, опционально): шаг варьирования
- step_type (str, опционально): тип шага ("абс" или "%")
- step_type (str, опционально): тип шага ("ед." или "%")
Минимально необходимые ключи: name, low, high, center, unit
@@ -297,7 +297,7 @@ def create_factor_from_reagent(
step_value = center_value * step_percent / 100
high_level, low_level = calculate_factor_levels(
center_value, step_value, "абс"
center_value, step_value, "ед."
)
return {
@@ -306,7 +306,7 @@ def create_factor_from_reagent(
'low': low_level,
'high': high_level,
'step': step_value,
'step_type': 'абс',
'step_type': 'ед.',
'unit': reagent.get('unit', volume_unit),
'percentage': reagent.get('percentage', 0),
'dilution_factor': reagent.get('dilution_factor', 1.0)
@@ -336,7 +336,7 @@ def create_factor_from_reagent(
step_value = center_value * step_percent / 100
high_level, low_level = calculate_factor_levels(
center_value, step_value, "абс"
center_value, step_value, "ед."
)
return {