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

Method build

code_generators/interp_generator.py:689–741  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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 ):
694 opNum = next( OP_COUNT )
695
696 self.opNums.append( opNum )
697 passedArgs = [ arg[I] for arg in self.argFams ]
698
699 funcBody = EXPR( opNum, self.c_Template, retChar, *passedArgs,
700 vecType=self.vecType )
701
702 # The format for the Python tuple is (name,{lib},arg1type,...)
703 # or for casts, ('cast',{cast_mode},cast_dtype,original_dtype )
704 if self.py_Name == 'cast':
705 self.py_TupleKeys[opNum] = [tuple( [self.py_Name, lib, retChar] + passedArgs) ]
706 for alias in self.aliases:
707 # Cast aliases have the type explicit in the name
708 self.py_TupleKeys[opNum].append( tuple( [alias, lib] + passedArgs) )
709
710 else:
711 self.py_TupleKeys[opNum] = [ tuple( [self.py_Name, lib] + passedArgs) ]
712 for alias in self.aliases:
713 self.py_TupleKeys[opNum].append( tuple( [alias, lib] + passedArgs) )
714
715 # Make a unique name for the function, of the form
716 # {function}_{retchar}{argchar1,...}
717 if type(self.py_Name) == type:
718 funcName = self.py_Name.__name__.lower()
719 else:
720 funcName = self.py_Name
721
722 # print( 'lib: %d, #%d: '%(lib,I) + str(funcName) + str(passedArgs) )
723 # Bool's dchar '?' is illegal so we use '1' instead for function names
724 idArgs = [ arg.replace('?','1') for arg in passedArgs ]
725
726 funcNameUnique = ''.join( [funcName,'_',retChar.replace('?','1') ] + idArgs )
727
728 funcDec = 'static int\n' \
729 + funcNameUnique \
730 + '( npy_intp task_size, npy_intp pc, const NumExprObject *params )'
731
732 funcCall = funcNameUnique \
733 + '( task_size, pc, params );'
734
735 self.c_FunctionDeclares[opNum] = funcDec + ';'
736 self.c_OpTableEntrys[opNum] = 'case {0}: {1} break;\n'.format( opNum, funcCall)
737 self.c_FunctionImpls[opNum] = ''.join([funcDec, funcBody])
738
739 # Debugging output
740 #print( '##### %s #####' % opNum )
741 #print( cTable[opNum] )
742
743 @property
744 def test_Auto(self) -> str:

Callers 1

__init__Method · 0.95

Calls 1

EXPRFunction · 0.85

Tested by

no test coverage detected