MCPcopy Create free account
hub / github.com/pydata/numexpr / Operation

Class Operation

code_generators/interp_generator.py:636–846  ·  view source on GitHub ↗

Test making Operation object-oriented as the factory functions are becoming grossly oversized. Takes a tokenized representation of a function/operation and builds it by string replacement over the specified dtypes. Valid replacement keywords are: $DEST,

Source from the content-addressed store, hash-verified

634# valid data type families. Eventually the actual operation lists should be
635# in a seperate file from the language rules that build the operation hash.
636class Operation(object):
637 '''
638 Test making Operation object-oriented as the factory functions are becoming
639 grossly oversized.
640
641 Takes a tokenized representation of a function/operation and builds it
642 by string replacement over the specified dtypes.
643
644 Valid replacement keywords are:
645 $DEST, $DTYPE0
646 $ARG1, $DTYPE1
647 $ARG2, $DTYPE
648 $ARG3, $DTYPE3
649 '''
650
651 # Could revert back to using *argFams here now that Python 2.7 support is
652 # dropped.
653 def __init__(self, py_Name: Union[ast.AST, str], c_Template: str,
654 libs: Sequence, retFam: List[str], argFams: List[List[str]],
655 vecType: int=TYPE_LOOP, aliases: List[str]=[], autotest: bool=True):
656 # py_Name is either an ast.Node or a string such as 'sqrt'
657 self.py_Name = py_Name
658 # c_Template is the actual C-code that will be generated.
659 self.c_Template = c_Template
660
661 self.vecType = vecType
662
663 self.autotest = autotest
664
665 # libs is a list, valid libraries are LIB_STD and LIB_VML, possibly
666 # LIB_SIMD later.
667 if type(libs) == list or type(libs) == tuple:
668 self.libs = libs
669 else:
670 self.libs = [libs]
671
672 # List of valid return character identifiers
673 self.retFam = retFam
674 # List of lists of valid argument character identifiers
675 self.argFams = argFams
676
677 if isinstance(aliases, (str, type)):
678 aliases = [aliases]
679 self.aliases = aliases
680
681 self.opNums = []
682 self.c_FunctionDeclares = {}
683 self.py_TupleKeys = {}
684 self.c_FunctionImpls = {}
685 self.c_OpTableEntrys = {}
686
687 self.build()
688
689 def build(self) -> None:
690 global OP_COUNT
691
692 for lib in self.libs:
693 for I, retChar in enumerate( self.retFam ):

Callers 3

CastFactoryFunction · 0.85
OpsFactoryFunction · 0.85
FunctionFactoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…