MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _convert_to_ast

Function _convert_to_ast

tensorflow/python/autograph/pyct/templates.py:217–230  ·  view source on GitHub ↗

Converts from a known data type to AST.

(n)

Source from the content-addressed store, hash-verified

215
216
217def _convert_to_ast(n):
218 """Converts from a known data type to AST."""
219 # Note: When generating AST nodes from strings/QNs in isolation, ctx is
220 # unknown. ctx must be filled in according to the template being used.
221 # See ReplaceTransformer.visit_Name.
222 if isinstance(n, str):
223 return gast.Name(id=n, ctx=None, annotation=None, type_comment=None)
224 if isinstance(n, qual_names.QN):
225 return n.ast()
226 if isinstance(n, list):
227 return [_convert_to_ast(e) for e in n]
228 if isinstance(n, tuple):
229 return tuple(_convert_to_ast(e) for e in n)
230 return n
231
232
233def replace(template, **replacements):

Callers 1

replaceFunction · 0.85

Calls 3

tupleFunction · 0.85
astMethod · 0.80
NameMethod · 0.45

Tested by

no test coverage detected