50 Commits

Author SHA1 Message Date
7f8939eab2 Test: separate expression build and showing it
All checks were successful
continuous-integration/drone/push Build is passing
2020-08-21 19:07:34 +02:00
0cadc6734e Feat: return value for random_list
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-08-20 20:50:54 +02:00
f767aa390c Fix: rename list_generator to random_list
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-08-20 20:42:46 +02:00
55985bfe20 Tagging: bad version number!
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-08-20 17:40:16 +02:00
41d0de79cc Tagging: change version to 2.2
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing
2020-08-20 17:38:06 +02:00
3b5c01e5cc Feat: random list generator
All checks were successful
continuous-integration/drone/push Build is passing
2020-08-20 17:36:38 +02:00
73b19e9644 Feat: add autopublishing
All checks were successful
continuous-integration/drone/push Build is passing
2020-08-20 17:02:09 +02:00
27e7dcba20 Feat: doctest skip
All checks were successful
continuous-integration/drone/push Build is passing
2020-08-20 16:59:40 +02:00
5f398b4c8d Feat: change frac to dfrac for fractions 2020-08-20 16:59:40 +02:00
ec823c85eb Feat: force subtree to be str and tex instead of txt in tree2tex 2020-08-20 16:59:40 +02:00
d72a2be175 Feat: Polynomial are displayed in nicer order! 2020-08-20 16:59:40 +02:00
e596c1af60 Fix: clean __init__ 2020-08-20 16:59:40 +02:00
b84cf047bd Fix: chante value to content in raw 2020-08-20 16:59:40 +02:00
d446139af3 Feat: missing_times works with RdLeaf 2020-08-20 16:59:40 +02:00
975728f8dc Feat: Add doctest to rdstr2 2020-08-20 16:59:40 +02:00
2317296534 Feat: raw methods for tokens 2020-08-20 16:59:40 +02:00
c211ed1591 Feat: remove precision setting for Decimal 2020-08-20 16:59:40 +02:00
0c84c63ad3 Feat: overload pow for tokens 2020-08-20 16:59:40 +02:00
25bfb7699b Feat: add doctest add int and Decimal 2020-08-20 16:59:40 +02:00
0abd80655a Feat: dirty way to get decimal approx of a function 2020-08-20 16:59:40 +02:00
a3f7efca12 Feat: allowing to import Decimal 2020-08-20 16:59:40 +02:00
1a74c54548 Feat: allow import Integer in calculus 2020-08-20 16:59:40 +02:00
1dccaabd86 Feat: dirty sub (repeatition in explain) 2020-08-20 16:59:40 +02:00
510f6a1fa2 Feat: doctest for operation between Token and str 2020-08-20 16:59:40 +02:00
6b353d2dd0 Feat: tokens can operate with builtin int 2020-08-20 16:59:40 +02:00
fbfaeb5a58 Fix: precessing -> processing 2020-08-20 16:59:40 +02:00
1a4e8ffb19 Feat: start using nox 2020-08-20 16:59:40 +02:00
d6bb61dc48 Fix: Black does its job 2020-08-20 16:59:40 +02:00
02214b0f82 Feat: no more round in quadratic roots 2020-08-20 16:59:40 +02:00
e52fec4057 Feat: MOnumber creating with a integer string 2020-08-20 16:59:40 +02:00
219d923ff5 Feat: to_be_token decorator and force token to be Integer when it's
possible
2020-08-20 16:59:40 +02:00
419e5955eb Feat: tokenify for everything! 2020-08-20 16:59:40 +02:00
f471a1efb3 Feat: Test and validate roots (but not elegant) 2020-08-20 16:59:40 +02:00
7600962fe4 Feat: doctest for composing Expressions 2020-08-20 16:59:40 +02:00
3e258b2d41 Feat: Expression call works with tokens 2020-08-20 16:59:40 +02:00
9f492378c8 Feat: Allow pure string rendering 2020-08-20 16:59:40 +02:00
0c3c20262e Fix: move __call__ to expressions 2020-08-20 16:59:40 +02:00
b3ec098b0b Feat: add tree2tex in all import 2020-08-20 16:59:40 +02:00
9d9224fcba Feat: Polynoms can be differentiate!!!! 2020-08-20 16:59:40 +02:00
b53de690d5 Fix: Issue with typing null monomial 2020-08-20 16:59:40 +02:00
beb319f21d Fix: replace notimplemented by NotImplementedError 2020-08-20 16:59:40 +02:00
50f77c4d60 Feat: coefficients, delta and some roots for polynomial, Linear and Quadratic 2020-08-20 16:59:40 +02:00
a83b5ada8d Feat: Polynomial can be evaluated 2020-08-20 16:59:40 +02:00
0aba5eaef6 Feat: Move some import into functions 2020-08-20 16:59:40 +02:00
0faaf481ca Feat: start working on eval for polynoms 2020-08-20 16:59:40 +02:00
b51ac7880d Fix: typing filter for multiply 2020-08-20 16:59:40 +02:00
fdf3b088f2 Mise à jour de 'README.md'
Some checks failed
continuous-integration/drone/push Build is failing
2020-07-18 06:29:21 +00:00
c7bd77e341 Mise à jour de '.drone.yml'
Some checks failed
continuous-integration/drone/push Build is failing
2020-07-18 06:21:50 +00:00
37601be549 Feat: nothing
Some checks failed
continuous-integration/drone/push Build is failing
2020-07-17 20:37:51 +02:00
19cdddf27e Feat: add a drone for testing 2020-07-17 20:37:00 +02:00
7 changed files with 61 additions and 6 deletions

View File

@@ -7,3 +7,12 @@ steps:
commands:
- pip install -r requirements.txt
- pytest --doctest-modules ./mapytex/
- name: Publish
image: plugins/pypi
settings:
username:
from_secret: pypi_username
password:
from_secret: pypi_password
when:
event: tag

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
# encoding: utf-8
from .calculus import Expression, Integer, Decimal
from .calculus import Expression, Integer, Decimal, random_list
# Expression.set_render('tex')

View File

@@ -136,9 +136,11 @@ class Expression(object):
:returns: TODO
:example:
>>> Expression.random("{a}/{a*k}") # doctest: +SKIP
>>> e = Expression.random("{a}/{a*k}")
>>> e # doctest: +SKIP
<Exp: -3 / -15>
>>> Expression.random("{a}/{a*k} - 3*{b}", variables_scope={'a':{'min_max':(10, 30)}}) # doctest: +SKIP
>>> e = Expression.random("{a}/{a*k} - 3*{b}", variables_scope={'a':{'min_max':(10, 30)}})
>>> e # doctest: +SKIP
<Exp: 18 / 108 - 3 * 9>
>>> e = Expression.random("{a}*x + {b}*x + 3", ["a>b"], rejected=[0, 1])
>>> ee = e.simplify()

View File

@@ -31,6 +31,7 @@ Expression is the classe wich handle all calculus. It can randomly generate or i
"""
from .API import Expression, Integer, Decimal
from .core import random_list
from decimal import getcontext
#getcontext().prec = 2

View File

@@ -66,6 +66,7 @@ from .tree import Tree, AssocialTree
from .compute import compute
from .typing import typing, TypingError
from .renders import tree2txt, tree2tex
from .random import list_generator as random_list
# -----------------------------

View File

@@ -47,8 +47,8 @@ Tree with RdLeaf replaced by generated values
>>> leafs
['a', 'a*k']
>>> rd_varia = extract_rv(leafs)
>>> rd_varia # doctest: +SKIP
{'a', 'k'}
>>> sorted(list(rd_varia))
['a', 'k']
>>> generated = random_generator(rd_varia, conditions=['a%2+1'])
>>> generated # doctest: +SKIP
{'a': 7, 'k': 4}
@@ -61,8 +61,18 @@ Tree with RdLeaf replaced by generated values
> 7
> 28
List generator
--------------
This function ignores tree structure and works with lists
>>> values = list_generator(["a", "a*b", "b", "c"], conditions=["b%c==1"])
>>> values # doctest: +SKIP
{'a': -8, 'a*b': -40, 'b': 5, 'c': 4}
"""
__all__ = ["list_generator"]
from random import choice
from functools import reduce
from .leaf import RdLeaf
@@ -244,3 +254,35 @@ def build_variable_scope(rd_variables, rejected, min_max, variables_scope):
except KeyError:
complete_scope[v]["min_max"] = min_max
return complete_scope
def list_generator(var_list, conditions=[], rejected=[0], min_max=(-10, 10), variables_scope={}, dictionnary=False):
""" Generate random computed values from the list
:param rd_variables: list of random variables to generate (can be computed value - "a*b")
:param conditions: condition over variables
:param rejected: Rejected values for the generator (default [0])
:param min_max: (min, max) limits in between variables will be generated
:param variables_scope: rejected and min_max define for individual variables
:param dictionnary: the return value will be a dictionnary with var_list as keys (default False)
:return: dictionnary of generated variables
:example:
>>> a, ab, b, c = list_generator(["a", "a*b", "b", "c"])
>>> a, ab, b, c # doctest: +SKIP
(5, -20, -4, -3)
>>> a * b == ab
True
>>> ab # doctest: +SKIP
-20
>>> a, b # doctest: +SKIP
5, -4
>>> list_generator(["a", "a*b", "b", "c"], dictionnary=True) # doctest: +SKIP
{'a': -3, 'a*b': 18, 'b': -6, 'c': -4}
"""
rv = extract_rv(var_list)
rv_gen = random_generator(rv, conditions, rejected, min_max, variables_scope)
generated = compute_leafs(var_list, rv_gen)
if dictionnary:
return generated
return [generated[v] for v in var_list]

View File

@@ -7,7 +7,7 @@ except ImportError:
setup(
name="mapytex",
version="2.1",
version="2.3.2",
description="Computing like a student",
author="Benjamin Bertrand",
author_email="programming@opytex.org",