From 8d4a6e7abc68859ca60a1b83f6c48e8db36af81e Mon Sep 17 00:00:00 2001 From: lgiacome Date: Mon, 18 Nov 2024 16:48:43 +0100 Subject: [PATCH] move _handle_kind to component --- xwakes/basewake.py | 12 ------------ xwakes/resonator.py | 3 ++- xwakes/thick_resistive_wall.py | 3 ++- xwakes/wit/component.py | 12 ++++++++++++ 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/xwakes/basewake.py b/xwakes/basewake.py index d8f9edbe..e194c05f 100644 --- a/xwakes/basewake.py +++ b/xwakes/basewake.py @@ -84,18 +84,6 @@ def __init__(self, components): self.components = components -def _handle_kind(kind): - if isinstance(kind, str): - kind = [kind] - - if isinstance(kind, (list, tuple)): - kind = {kk: 1.0 for kk in kind} - - assert hasattr(kind, 'keys') - - return kind - - def _expand_components(components): _expanded_components = [] for cc in components: diff --git a/xwakes/resonator.py b/xwakes/resonator.py index abff5a1f..6e1fe09d 100644 --- a/xwakes/resonator.py +++ b/xwakes/resonator.py @@ -1,6 +1,7 @@ from typing import Tuple -from .basewake import BaseWake, _handle_kind +from .basewake import BaseWake +from .wit.component import _handle_kind from .wit import ComponentResonator diff --git a/xwakes/thick_resistive_wall.py b/xwakes/thick_resistive_wall.py index ee64e4f0..ee5ae9d3 100644 --- a/xwakes/thick_resistive_wall.py +++ b/xwakes/thick_resistive_wall.py @@ -1,6 +1,7 @@ from typing import Tuple -from .basewake import BaseWake, _handle_kind +from .basewake import BaseWake +from .wit.component import _handle_kind from .wit import ComponentClassicThickWall diff --git a/xwakes/wit/component.py b/xwakes/wit/component.py index e0493513..41b2eee9 100644 --- a/xwakes/wit/component.py +++ b/xwakes/wit/component.py @@ -41,6 +41,18 @@ } +def _handle_kind(kind): + if isinstance(kind, str): + kind = [kind] + + if isinstance(kind, (list, tuple)): + kind = {kk: 1.0 for kk in kind} + + assert hasattr(kind, 'keys') + + return kind + + def mix_fine_and_rough_sampling(start: float, stop: float, rough_points: int, fine_points: int, rois: List[Tuple[float, float]]): """