Arrangement of python



  • There is a rigid variable species

    ((143+131+44)*123)*((4343/10000)/24)
    

    If you put it in an interpreter, the pie will give the result of the expression. We have to do the same in the violin, but string variables are not recognized as an arithmetic expression and lead them in raw form. Function int() won't help, because the row contains symbols "(, ^,+, ..." What function is performed if the interpreter introduces print(1+1)? Can this function be called in a script?



  • Use the module. https://github.com/pydata/numexpr/wiki/Numexpr-Users-Guide :

    In [66]: import numexpr as ne
    

    In [67]: ne.evaluate('((143+131+44)123)((4343/10000)/24)')
    Out[67]: array(707.8004250000001)

    In [68]: ne.evaluate('((143+131+44)123)((4343/10000)/24)').tolist()
    Out[68]: 707.8004250000001

    numexpr can process variables and formulas:

    In [70]: a = 10

    In [71]: b = 2

    In [72]: ne.evaluate('a ** b')
    Out[72]: array(100, dtype=int32)

    In [73]: ne.evaluate('log(a)')
    Out[73]: array(2.302585092994046)

    PS for the approval of developers numexpr 0.95x - 20x faster NumPyNot to mention Vanilla Python♪ ♪ ♪




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2