formula_solver.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:Formulate 作者: BebeSparkelSparkel 项目源码 文件源码
def no_re_matches(re_pattern, length=5, max_attempts = 100):
  for count in range(max_attempts):
    try_string = ''.join(random.choice(string.ascii_letters) for x in range(length))
    if re_search_better(re_pattern, try_string) is None:
      return try_string
  raise ValueUnitsError('Non-matching pattern cannot be found')


# abstracts the sub-formula contained in parentheses to a unique variable name
# if there are any variables already in formula they need to be selected by the re pattern variables_re so that duplicate variable names are not created
# returns the formula with all the new variables in it and a dictionary with the new variables as keys and the origional expression as the values
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号