Feat: import Expression from calculus and docstring in random

This commit is contained in:
Bertrand Benjamin 2019-05-08 14:44:35 +02:00
parent f87e6c5727
commit 7413a76f8d
2 changed files with 61 additions and 1 deletions

View File

@ -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]
# -----------------------------

View File

@ -0,0 +1,39 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2017 lafrite <lafrite@Poivre>
#
# 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