gt4py.cartesian.utils package
Submodules
gt4py.cartesian.utils.attrib module
- class gt4py.cartesian.utils.attrib.AttributeClassLike[source]
Bases:
object
- property as_dict
- property attributes
gt4py.cartesian.utils.base module
Basic utilities for Python programming.
- class gt4py.cartesian.utils.base.ClassProperty(fget=None, fset=None, fdel=None, doc=None)[source]
Bases:
object
Like a
property
, but the wrapped function is a class method.
- class gt4py.cartesian.utils.base.UniqueIdGenerator(start=1)[source]
Bases:
object
- property current
- property new
- gt4py.cartesian.utils.base.classmethod_to_function(class_method, instance=None, owner=<class 'NoneType'>, remove_cls_arg=False)[source]
- gt4py.cartesian.utils.base.classproperty
- gt4py.cartesian.utils.base.compose(*functions_or_iterable)[source]
Return a function that chains the input functions.
Derived from: https://mathieularose.com/function-composition-in-python/
- gt4py.cartesian.utils.base.flatten(nested_iterables, filter_none=False, *, skip_types=(<class 'str'>, <class 'bytes'>))[source]
- gt4py.cartesian.utils.base.flatten_iter(nested_iterables, filter_none=False, *, skip_types=(<class 'str'>, <class 'bytes'>))[source]
- gt4py.cartesian.utils.base.is_iterable_of(value, item_class, iterable_class=<class 'collections.abc.Iterable'>, *, optional=False, accept_mapping=True)[source]
- gt4py.cartesian.utils.base.is_mapping_of(value, key_class, value_class=None, mapping_class=<class 'collections.abc.Mapping'>, *, optional=False)[source]
- gt4py.cartesian.utils.base.make_dir(dir_name, *, mode=511, is_package=False, is_cache=False)[source]
- gt4py.cartesian.utils.base.make_local_dir(dir_name, base_dir=None, *, mode=511, is_package=False, is_cache=False)[source]
- gt4py.cartesian.utils.base.make_module_from_file(qualified_name, file_path, *, public_import=False)[source]
Import module from file.
References
https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly https://stackoverflow.com/a/43602645
- gt4py.cartesian.utils.base.normalize_mapping(mapping, key_types=(<class 'object'>, ), *, filter_none=False)[source]
- gt4py.cartesian.utils.base.patch_module(module, member, new_value, *, recursive=True)[source]
Monkey patch a module replacing a member with a new value.
gt4py.cartesian.utils.meta module
Utilities for runtime: introspection and bytecode.
- class gt4py.cartesian.utils.meta.ASTEvaluator(context: dict)[source]
Bases:
gt4py.cartesian.utils.meta.ASTPass
- AST_OP_TO_OP = {<class 'ast.UAdd'>: <built-in function pos>, <class 'ast.USub'>: <built-in function neg>, <class 'ast.Add'>: <built-in function add>, <class 'ast.Sub'>: <built-in function sub>, <class 'ast.Mult'>: <built-in function mul>, <class 'ast.Div'>: <built-in function truediv>, <class 'ast.Mod'>: <built-in function mod>, <class 'ast.Pow'>: <built-in function pow>, <class 'ast.Invert'>: <built-in function invert>, <class 'ast.BitOr'>: <built-in function or_>, <class 'ast.BitXor'>: <built-in function xor>, <class 'ast.BitAnd'>: <built-in function and_>, <class 'ast.Not'>: <built-in function not_>, <class 'ast.Eq'>: <built-in function eq>, <class 'ast.NotEq'>: <built-in function ne>, <class 'ast.Lt'>: <built-in function lt>, <class 'ast.LtE'>: <built-in function le>, <class 'ast.Gt'>: <built-in function gt>, <class 'ast.GtE'>: <built-in function ge>}
- visit_Attribute(node: ast.Attribute)[source]
- visit_BoolOp(node: ast.BoolOp)[source]
- visit_Compare(node: ast.Compare)[source]
- visit_UnaryOp(node: ast.UnaryOp)[source]
- class gt4py.cartesian.utils.meta.ASTPass[source]
Bases:
object
Clone of the ast.NodeVisitor that supports forwarding kwargs.
- class gt4py.cartesian.utils.meta.ASTTransformPass[source]
Bases:
gt4py.cartesian.utils.meta.ASTPass
Clone of the ast.NodeTransformer that supports forwarding kwargs.
- class gt4py.cartesian.utils.meta.AssignTargetsCollector(*, allow_multiple_targets)[source]
Bases:
gt4py.cartesian.utils.meta.ASTPass
- visit_Assign(node: ast.Assign)[source]
- class gt4py.cartesian.utils.meta.ImportsCollector[source]
Bases:
gt4py.cartesian.utils.meta.ASTPass
- visit_Import(node: ast.Import)[source]
- visit_ImportFrom(node: ast.ImportFrom)[source]
- class gt4py.cartesian.utils.meta.QualifiedNameCollector(prefixes=None, *, skip_decorators=True, skip_annotations=True)[source]
Bases:
gt4py.cartesian.utils.meta.ASTPass
- visit_Attribute(node: ast.Attribute)[source]
- gt4py.cartesian.utils.meta.ast_dump(definition, *, skip_annotations: bool = True, skip_decorators: bool = True, feature_version: Tuple[int, int]) str [source]
- gt4py.cartesian.utils.meta.ast_eval(ast_root, context, default=None)
- gt4py.cartesian.utils.meta.ast_unparse(ast_node)[source]
Call ast.unparse, but use astunparse for Python prior to 3.9.
- gt4py.cartesian.utils.meta.collect_assign_targets(ast_root, *, allow_multiple_targets=True)
- gt4py.cartesian.utils.meta.collect_imported_symbols(ast_root)
- gt4py.cartesian.utils.meta.collect_names(ast_root, prefixes=None, *, skip_decorators=True, skip_annotations=True)
- gt4py.cartesian.utils.meta.get_ast(func_or_source_or_ast, *, feature_version: Tuple[int, int])[source]
- gt4py.cartesian.utils.meta.get_closure(func, *, include_globals=True, included_nonlocals=True, include_builtins=True)[source]
- gt4py.cartesian.utils.meta.get_qualified_name_from_node(name_or_attribute, *, as_list=False)[source]
- gt4py.cartesian.utils.meta.map_symbol_names(ast_root, mapping, template_fmt=None, skip_names=None)
gt4py.cartesian.utils.text module
Text and templating utilities.