How to use the asteval.NameFinder function in asteval

To help you get started, we’ve selected a few asteval examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github newville / asteval / tests / test_1.py View on Github external
def test_namefinder(self):
        'test namefinder'
        ast = self.interp.parse('x+y+cos(z)')
        nf = NameFinder()
        nf.generic_visit(ast)
        self.assertTrue('x' in nf.names)
        self.assertTrue('y' in nf.names)
        self.assertTrue('z' in nf.names)
        self.assertTrue('cos' in nf.names)
github newville / asteval / tests / test_1.py View on Github external
def test_namefinder(self):
        'test namefinder'
        ast = self.interp.parse('x+y+cos(z)')
        nf = NameFinder()
        nf.generic_visit(ast)
        self.assertTrue('x' in nf.names)
        self.assertTrue('y' in nf.names)
        self.assertTrue('z' in nf.names)
        self.assertTrue('cos' in nf.names)
github newville / asteval / tests / test_asteval.py View on Github external
def test_namefinder(self):
        """test namefinder"""
        p = self.interp.parse('x+y+cos(z)')
        nf = NameFinder()
        nf.generic_visit(p)
        self.assertTrue('x' in nf.names)
        self.assertTrue('y' in nf.names)
        self.assertTrue('z' in nf.names)
        self.assertTrue('cos' in nf.names)
github newville / asteval / tests / test_asteval.py View on Github external
def test_namefinder(self):
        """test namefinder"""
        p = self.interp.parse('x+y+cos(z)')
        nf = NameFinder()
        nf.generic_visit(p)
        self.assertTrue('x' in nf.names)
        self.assertTrue('y' in nf.names)
        self.assertTrue('z' in nf.names)
        self.assertTrue('cos' in nf.names)
github pjamesjoyce / lcopt / lcopt / bw2_parameter_utils.py View on Github external
def get_symbols(expression):
    interpreter = asteval.Interpreter()
    nf = asteval.NameFinder()
    nf.generic_visit(interpreter.parse(expression))
    return set(nf.names).difference(EXISTING_SYMBOLS)