From 7413a76f8d8acb1f43a9ae54041b12bdbd5aa8c4 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Wed, 8 May 2019 14:44:35 +0200 Subject: [PATCH] Feat: import Expression from calculus and docstring in random --- mapytex/calculus/__init__.py | 23 +++++++++++++- mapytex/calculus/core/random/str_gene.py | 39 ++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 mapytex/calculus/core/random/str_gene.py diff --git a/mapytex/calculus/__init__.py b/mapytex/calculus/__init__.py index d9308ef..3914e98 100644 --- a/mapytex/calculus/__init__.py +++ b/mapytex/calculus/__init__.py @@ -8,9 +8,30 @@ """ Make calculus as a student +========================== + +Expression is the classe wich handle all calculus. It can randomly generate or import calculus, simplify them and explain them as a student would do. + +>>> from mapytex.calculus import Expression +>>> e = Expression.from_str("2x + 6 - 3x") +>>> print(e) +2x + 6 - 3x +>>> f = e.simplify() +>>> print(f) +- x + 6 +>>> for s in f.explain(): +... print(s) +2x + 6 - 3x +2x - 3x + 6 +(2 - 3) * x + 6 +- x + 6 + + """ -__all__ = [] +from .API import Expression + +__all__ = [Expression] # ----------------------------- diff --git a/mapytex/calculus/core/random/str_gene.py b/mapytex/calculus/core/random/str_gene.py new file mode 100644 index 0000000..7f857a7 --- /dev/null +++ b/mapytex/calculus/core/random/str_gene.py @@ -0,0 +1,39 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- +# vim:fenc=utf-8 +# +# Copyright © 2017 lafrite +# +# Distributed under terms of the MIT license. + +""" +Function to create random strings + +:example: + +>>> form = "{a} / {b} + {c} / {k*b}" +>>> conditions = [ +... "abs({b}) != 1", +... "{d} > 1", +... "{b} != {d}", +... "gcd({a},{b}) == 1", +... "gcd({c},{k*b}) == 1", +... ] +>>> #random_str(form, conditions) + +>>> form = "{a:int}x + {b:fraction}" +>>> conditions = [ +... "{b.denom} > 2", +... ] +>>> #random_str(form, conditions) + +""" +import random + +__all__ = [] + + +# ----------------------------- +# Reglages pour 'vim' +# vim:set autoindent expandtab tabstop=4 shiftwidth=4: +# cursor: 16 del