当前位置: 首页>>代码示例>>Python>>正文


Python math.__dict__方法代码示例

本文整理汇总了Python中math.__dict__方法的典型用法代码示例。如果您正苦于以下问题:Python math.__dict__方法的具体用法?Python math.__dict__怎么用?Python math.__dict__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在math的用法示例。


在下文中一共展示了math.__dict__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: next

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def next(self):
      if not self.shown:
        self.shown = True
        if self.ti != ():
          return self.ti, self.svg

      if not isinstance(self.svg, SVG): raise StopIteration
      if self.depth_limit != None and len(self.ti) >= self.depth_limit: raise StopIteration

      if "iterators" not in self.__dict__:
        self.iterators = []
        for i, s in enumerate(self.svg.sub):
          self.iterators.append(self.__class__(s, self.ti + (i,), self.depth_limit))
        for k, s in self.svg.attr.items():
          self.iterators.append(self.__class__(s, self.ti + (k,), self.depth_limit))
        self.iterators = itertools.chain(*self.iterators)

      return self.iterators.next()
  ### end nested class 
开发者ID:mortcanty,项目名称:earthengine,代码行数:21,代码来源:svgfig.py

示例2: funcRtoC

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def funcRtoC(expr, var="t", globals=None, locals=None):
  """Converts a complex "z(t)" string to a function acceptable for Curve.

  expr    required        string in the form "z(t)"
  var     default="t"   name of the independent variable
  globals default=None    dict of global variables used in the expression;
                          you may want to use Python's builtin globals()
  locals  default=None    dict of local variables
  """
  g = cmath.__dict__
  if globals != None: g.update(globals)
  output = eval("lambda %s: (%s)" % (var, expr), g, locals)
  split = lambda z: (z.real, z.imag)
  output2 = lambda t: split(output(t))
  output2.func_name = "%s -> %s" % (var, expr)
  return output2 
开发者ID:mortcanty,项目名称:earthengine,代码行数:18,代码来源:svgfig.py

示例3: set_axis_input

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def set_axis_input(self, axis_id, axis_val):
        if axis_val == self.axes_values[axis_id]:
            return

        self.axes_values[axis_id] = axis_val

        if len(axis_val) == 0:
            self.axes_coords[axis_id] = None
            self.axes_eval_success[axis_id] = True
        else:
            try:
                #self.axes_coords[axis_id] = float(eval(axis_val, {}, {}))
                self.axes_coords[axis_id] = \
                    float(eval(axis_val, math.__dict__))
                self.axes_eval_success[axis_id] = True
            except:
                self.axes_eval_success[axis_id] = False 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:space_view3d_enhanced_3d_cursor.py

示例4: funcRtoR2

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def funcRtoR2(expr, var="t", globals=None, locals=None):
  """Converts a "f(t), g(t)" string to a function acceptable for Curve.

  expr    required        string in the form "f(t), g(t)"
  var     default="t"   name of the independent variable
  globals default=None    dict of global variables used in the expression;
                          you may want to use Python's builtin globals()
  locals  default=None    dict of local variables
  """
  g = math.__dict__
  if globals != None: g.update(globals)
  output = eval("lambda %s: (%s)" % (var, expr), g, locals)
  output.func_name = "%s -> %s" % (var, expr)
  return output 
开发者ID:mortcanty,项目名称:earthengine,代码行数:16,代码来源:svgfig.py

示例5: funcRtoR

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def funcRtoR(expr, var="x", globals=None, locals=None):
  """Converts a "f(x)" string to a function acceptable for Curve.

  expr    required        string in the form "f(x)"
  var     default="x"   name of the independent variable
  globals default=None    dict of global variables used in the expression;
                          you may want to use Python's builtin globals()
  locals  default=None    dict of local variables
  """
  g = math.__dict__
  if globals != None: g.update(globals)
  output = eval("lambda %s: (%s, %s)" % (var, var, expr), g, locals)
  output.func_name = "%s -> %s" % (var, expr)
  return output 
开发者ID:mortcanty,项目名称:earthengine,代码行数:16,代码来源:svgfig.py

示例6: inheritdoc

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def inheritdoc(cls):
    def _fn(fn):
        if fn.__name__ in cls.__dict__:
            fn.__doc__ = cls.__dict__[fn.__name__].__doc__
        return fn
    return _fn


################################################################ attach sub-methods to the fill and plot methods 
开发者ID:histogrammar,项目名称:histogrammar-python,代码行数:11,代码来源:util.py

示例7: substitute_with_eval

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def substitute_with_eval(expression: sympy.Expr,
                         substitutions: Dict[str, Union[sympy.Expr, numpy.ndarray, str]]) -> sympy.Expr:
    """Substitutes only sympy.Symbols. Workaround for numpy like array behaviour. ~Factor 3 slower compared to subs"""
    substitutions = {k: v if isinstance(v, sympy.Expr) else sympify(v)
                     for k, v in substitutions.items()}

    for symbol in get_free_symbols(expression):
        symbol_name = str(symbol)
        if symbol_name not in substitutions:
            substitutions[symbol_name] = symbol

    string_representation = sympy.srepr(expression)
    return eval(string_representation, sympy.__dict__, {'Symbol': substitutions.__getitem__,
                                                        'Mul': numpy_compatible_mul}) 
开发者ID:qutech,项目名称:qupulse,代码行数:16,代码来源:sympy.py

示例8: import_module

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def import_module(modulename):
        module = __import__(modulename)
        for name in modulename.split(".")[1:]:
            module = module.__dict__[name]
        return module 
开发者ID:diana-hep,项目名称:oamap,代码行数:7,代码来源:util.py

示例9: parse_option

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def parse_option(row, arg):
        safe_dict = {}
        safe_dict.update(row.__dict__)
        safe_dict.update(math.__dict__)
        safe_dict.update(pycbc.pnutils.__dict__)
        return eval(arg, {"__builtins__":None}, safe_dict) 
开发者ID:gwastro,项目名称:pycbc,代码行数:8,代码来源:chisq.py

示例10: totrans

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def totrans(expr, vars=("x", "y"), globals=None, locals=None):
  """Converts to a coordinate transformation (a function that accepts
  two arguments and returns two values).

  expr       required                  a string expression or a function
                                       of two real or one complex value
  vars       default=("x", "y")    independent variable names;
                                       a singleton ("z",) is interpreted
                                       as complex
  globals    default=None              dict of global variables
  locals     default=None              dict of local variables
  """

  if callable(expr):
    if expr.func_code.co_argcount == 2:
      return expr

    elif expr.func_code.co_argcount == 1:
      split = lambda z: (z.real, z.imag)
      output = lambda x, y: split(expr(x + y*1j))
      output.func_name = expr.func_name
      return output

    else:
      raise TypeError, "must be a function of 2 or 1 variables"

  if len(vars) == 2:
    g = math.__dict__
    if globals != None: g.update(globals)
    output = eval("lambda %s, %s: (%s)" % (vars[0], vars[1], expr), g, locals)
    output.func_name = "%s,%s -> %s" % (vars[0], vars[1], expr)
    return output

  elif len(vars) == 1:
    g = cmath.__dict__
    if globals != None: g.update(globals)
    output = eval("lambda %s: (%s)" % (vars[0], expr), g, locals)
    split = lambda z: (z.real, z.imag)
    output2 = lambda x, y: split(output(x + y*1j))
    output2.func_name = "%s -> %s" % (vars[0], expr)
    return output2

  else:
    raise TypeError, "vars must have 2 or 1 elements" 
开发者ID:mortcanty,项目名称:earthengine,代码行数:46,代码来源:svgfig.py

示例11: stringfcn

# 需要导入模块: import math [as 别名]
# 或者: from math import __dict__ [as 别名]
def stringfcn(fcn):
    if isinstance(fcn, basestring):
        parsed = ast.parse(fcn).body
        if isinstance(parsed[-1], ast.Expr):
            parsed[-1] = ast.Return(parsed[-1].value)
            parsed[-1].lineno = parsed[-1].value.lineno
            parsed[-1].col_offset = parsed[-1].value.col_offset

        env = dict(math.__dict__)
        env.update(globals())

        free = set()
        defined = set(["None", "False", "True"])
        defined.update(env)
        def recurse(node):
            if isinstance(node, ast.Name):
                if isinstance(node.ctx, ast.Store):
                    defined.add(node.id)
                elif isinstance(node.ctx, ast.Load) and node.id not in defined:
                    free.add(node.id)
            elif isinstance(node, ast.AST):
                for n in node._fields:
                    recurse(getattr(node, n))
            elif isinstance(node, list):
                for x in node:
                    recurse(x)
        recurse(parsed)

        avoid = free.union(defined)
        fcnname = varname(avoid, "fcn")

        module = ast.parse("""
def {fcn}({params}):
    REPLACEME
""".format(fcn=fcnname, params=",".join(free)))
        module.body[0].body = parsed
        module = compile(module, "<fcn string>", "exec")

        doexec(module, env)
        fcn = env[fcnname]

    return fcn 
开发者ID:diana-hep,项目名称:oamap,代码行数:44,代码来源:util.py


注:本文中的math.__dict__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。