From 3ddf218bb7b0ff191875ef46a2da836cf82903b9 Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Wed, 15 Nov 2023 22:28:35 +0900 Subject: [PATCH] code style cleanup --- pystencilssfg/configuration.py | 1 - pystencilssfg/context.py | 2 +- pystencilssfg/source_concepts/cpp/std_vector.py | 2 +- pystencilssfg/tree/deferred_nodes.py | 10 ++++------ pystencilssfg/tree/dispatcher.py | 3 ++- pystencilssfg/tree/visitors.py | 2 -- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/pystencilssfg/configuration.py b/pystencilssfg/configuration.py index 07a6b17..1de3a19 100644 --- a/pystencilssfg/configuration.py +++ b/pystencilssfg/configuration.py @@ -4,7 +4,6 @@ from typing import Sequence, Any from enum import Enum, auto from dataclasses import dataclass, replace, asdict, InitVar from argparse import ArgumentParser -from os import path from importlib import util as iutil diff --git a/pystencilssfg/context.py b/pystencilssfg/context.py index 9bed7e0..e11d827 100644 --- a/pystencilssfg/context.py +++ b/pystencilssfg/context.py @@ -10,7 +10,7 @@ from pystencils.astnodes import KernelFunction from .configuration import SfgConfiguration, config_from_commandline, merge_configurations, SfgCodeStyle from .kernel_namespace import SfgKernelNamespace, SfgKernelHandle -from .tree import SfgCallTreeNode, SfgSequence, SfgKernelCallNode, SfgStatements +from .tree import SfgCallTreeNode, SfgKernelCallNode, SfgStatements from .tree.deferred_nodes import SfgDeferredFieldMapping from .tree.builders import SfgBranchBuilder, make_sequence from .tree.visitors import CollectIncludes diff --git a/pystencilssfg/source_concepts/cpp/std_vector.py b/pystencilssfg/source_concepts/cpp/std_vector.py index 5398f5d..a4e5ac2 100644 --- a/pystencilssfg/source_concepts/cpp/std_vector.py +++ b/pystencilssfg/source_concepts/cpp/std_vector.py @@ -4,7 +4,7 @@ from pystencils.typing import FieldPointerSymbol, FieldStrideSymbol, FieldShapeS from ...tree import SfgStatements from ..source_objects import SrcField, SrcVector -from ..source_objects import SrcObject, TypedSymbolOrObject +from ..source_objects import TypedSymbolOrObject from ...types import SrcType, PsType, cpp_typename from ...source_components.header_include import SfgHeaderInclude from ...exceptions import SfgException diff --git a/pystencilssfg/tree/deferred_nodes.py b/pystencilssfg/tree/deferred_nodes.py index 3eb42e5..ae364bb 100644 --- a/pystencilssfg/tree/deferred_nodes.py +++ b/pystencilssfg/tree/deferred_nodes.py @@ -1,14 +1,9 @@ from __future__ import annotations from typing import TYPE_CHECKING -from pystencilssfg.context import SfgContext - -if TYPE_CHECKING: - from ..context import SfgContext - from abc import ABC, abstractmethod -from pystencils import Field, TypedSymbol +from pystencils import Field from pystencils.typing import FieldPointerSymbol, FieldShapeSymbol, FieldStrideSymbol from ..exceptions import SfgException @@ -19,6 +14,9 @@ from .builders import make_sequence from ..source_concepts import SrcField from ..source_concepts.source_objects import TypedSymbolOrObject +if TYPE_CHECKING: + from ..context import SfgContext + class SfgDeferredNode(SfgCallTreeNode, ABC): """Nodes of this type are inserted as placeholders into the kernel call tree diff --git a/pystencilssfg/tree/dispatcher.py b/pystencilssfg/tree/dispatcher.py index 9ecba48..04108ed 100644 --- a/pystencilssfg/tree/dispatcher.py +++ b/pystencilssfg/tree/dispatcher.py @@ -1,5 +1,5 @@ from __future__ import annotations -from typing import Callable, TypeVar, Generic, Any, ParamSpec, Concatenate +from typing import Callable, TypeVar, Generic, ParamSpec from types import MethodType from functools import wraps @@ -10,6 +10,7 @@ V = TypeVar("V") R = TypeVar("R") P = ParamSpec("P") + class VisitorDispatcher(Generic[V, R]): def __init__(self, wrapped_method: Callable[..., R]): self._dispatch_dict: dict[type, Callable[..., R]] = {} diff --git a/pystencilssfg/tree/visitors.py b/pystencilssfg/tree/visitors.py index 434e271..7660cf2 100644 --- a/pystencilssfg/tree/visitors.py +++ b/pystencilssfg/tree/visitors.py @@ -4,8 +4,6 @@ from typing import TYPE_CHECKING from functools import reduce -from pystencils.typing import TypedSymbol - from .basic_nodes import SfgCallTreeNode, SfgCallTreeLeaf, SfgSequence, SfgStatements from .deferred_nodes import SfgParamCollectionDeferredNode from .dispatcher import visitor -- GitLab