38 Commits

Author SHA1 Message Date
fadd93b9a6 Feat: change frac to dfrac for fractions 2019-11-04 09:43:52 +01:00
cb8010c7ac Feat: force subtree to be str and tex instead of txt in tree2tex 2019-11-04 09:39:52 +01:00
f12ec38746 Feat: Polynomial are displayed in nicer order! 2019-10-30 21:12:58 +01:00
f8b24472d1 Fix: clean __init__ 2019-10-30 20:59:09 +01:00
240857a7ad Fix: chante value to content in raw 2019-10-30 20:58:46 +01:00
70ec6933ac Feat: missing_times works with RdLeaf 2019-10-30 18:46:57 +01:00
91779bd945 Feat: Add doctest to rdstr2 2019-10-30 10:49:07 +01:00
69e1e43966 Feat: raw methods for tokens 2019-10-16 22:45:41 +02:00
16a6c4953d Feat: remove precision setting for Decimal 2019-10-15 19:41:09 +02:00
84c71f6b5d Feat: overload pow for tokens 2019-10-15 19:32:19 +02:00
2a74722b19 Feat: add doctest add int and Decimal 2019-10-15 19:15:32 +02:00
43fd46379c Feat: dirty way to get decimal approx of a function 2019-10-14 22:26:51 +02:00
2d296cf1d2 Feat: allowing to import Decimal 2019-10-14 22:22:08 +02:00
12109156d1 Feat: allow import Integer in calculus 2019-10-13 22:38:49 +02:00
2fad004d6d Feat: dirty sub (repeatition in explain) 2019-10-13 22:38:49 +02:00
207dead5d0 Feat: doctest for operation between Token and str 2019-10-13 22:38:49 +02:00
e24bff23db Feat: tokens can operate with builtin int 2019-10-13 22:38:49 +02:00
69c2b3718d Fix: precessing -> processing 2019-10-13 22:38:49 +02:00
9c25142a4b Feat: start using nox 2019-10-13 22:38:49 +02:00
931e55c35e Fix: Black does its job 2019-10-13 22:38:49 +02:00
aba43c9f19 Feat: no more round in quadratic roots 2019-07-17 09:55:32 +02:00
b93f34bc38 Feat: MOnumber creating with a integer string 2019-07-17 09:53:03 +02:00
204fdf755b Feat: to_be_token decorator and force token to be Integer when it's
possible
2019-07-17 09:49:50 +02:00
d75fd4c4cf Feat: tokenify for everything! 2019-07-17 09:25:12 +02:00
a32b684b6b Feat: Test and validate roots (but not elegant) 2019-07-16 16:49:33 +02:00
a5f062a151 Feat: doctest for composing Expressions 2019-07-16 09:31:30 +02:00
f8e1c7f962 Feat: Expression call works with tokens 2019-07-16 09:30:30 +02:00
1685c73051 Feat: Allow pure string rendering 2019-07-16 09:09:39 +02:00
04ac74d17a Fix: move __call__ to expressions 2019-07-15 18:37:16 +02:00
23ab39f7d4 Feat: add tree2tex in all import 2019-07-15 18:36:59 +02:00
41385ec561 Feat: Polynoms can be differentiate!!!! 2019-07-15 17:48:59 +02:00
8389a319f0 Fix: Issue with typing null monomial 2019-07-15 17:27:38 +02:00
6e24756746 Fix: replace notimplemented by NotImplementedError 2019-07-15 17:16:00 +02:00
d45ab560c9 Feat: coefficients, delta and some roots for polynomial, Linear and Quadratic 2019-07-15 11:59:28 +02:00
fa8beb6bb2 Feat: Polynomial can be evaluated 2019-07-15 11:14:48 +02:00
b81281d78a Feat: Move some import into functions 2019-07-15 11:09:59 +02:00
071b8caf1d Feat: start working on eval for polynoms 2019-07-15 10:42:49 +02:00
1ed0b9715a Fix: typing filter for multiply 2019-07-15 10:42:13 +02:00
8 changed files with 10 additions and 71 deletions

View File

@@ -1,18 +0,0 @@
kind: pipeline
name: default
steps:
- name: testing
image: python
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,5 +1,4 @@
# Mapytex
[![Build Status](https://drone.opytex.org/api/badges/lafrite/Mapytex/status.svg)](https://drone.opytex.org/lafrite/Mapytex)
Formal calculus with explanation python module and exercises creation tools.

View File

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

View File

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

View File

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

View File

@@ -47,8 +47,8 @@ Tree with RdLeaf replaced by generated values
>>> leafs
['a', 'a*k']
>>> rd_varia = extract_rv(leafs)
>>> sorted(list(rd_varia))
['a', 'k']
>>> rd_varia # doctest: +SKIP
{'a', 'k'}
>>> generated = random_generator(rd_varia, conditions=['a%2+1'])
>>> generated # doctest: +SKIP
{'a': 7, 'k': 4}
@@ -61,18 +61,8 @@ 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__ = ["generator"]
from random import choice
from functools import reduce
from .leaf import RdLeaf
@@ -254,27 +244,3 @@ 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={}):
""" 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
:return: dictionnary of generated variables
:example:
>>> values = list_generator(["a", "a*b", "b", "c"])
>>> values # doctest: +SKIP
>>> values["a"] * values["b"] == values["a*b"]
True
>>> values["a*b"] # doctest: +SKIP
>>> values["a"] * values["b"] # doctest: +SKIP
"""
rv = extract_rv(var_list)
rv_gen = random_generator(rv, conditions, rejected, min_max, variables_scope)
generated = compute_leafs(var_list, rv_gen)
return generated

View File

@@ -23,18 +23,12 @@ def random_generator(
:param v_max: maximum accepted value
:param exact_mean: if set, the last generated number will be create in order that the computed mean is exacly equal to "exact_mean"
>>> random_generator(10) # doctest: +SKIP
[-0.76, 0.46, 0.19, 0.08, -1.13, -0.5, 0.47, -2.11, 0.16, -1.05]
>>> random_generator(10, distrib = uniform, rd_args = (5, 10)) # doctest: +SKIP
[9.01, 5.32, 5.59, 8.8, 7.36, 6.9, 6.05, 7.44, 9.47, 6.95]
>>> random_generator(10, distrib = "uniform", rd_args = (5, 10)) # doctest: +SKIP
[7.85, 9.01, 5.32, 5.59, 8.8, 7.36, 6.9, 6.05, 7.44, 9.47]
>>> random_generator(10, v_min = 0) # doctest: +SKIP
[0.46, 0.19, 0.08, 0.47, 0.16, 0.87, 0.17, 1.79, 0.19, 1.12]
>>> random_generator(10, exact_mean = 0) # doctest: +SKIP
[-0.76, 0.46, 0.19, 0.08, -1.13, -0.5, 0.47, -2.11, 0.16, 3.14]
>>> random_generator(10, distrib = gauss, rd_args = (50,20), nbr_format = int) # doctest: +SKIP
[34, 59, 53, 51, 27, 40, 59, 7, 53, 28]
>>> random_generator(10)
>>> random_generator(10, distrib = uniform, rd_args = (5, 10))
>>> random_generator(10, distrib = "uniform", rd_args = (5, 10))
>>> random_generator(10, v_min = 0)
>>> random_generator(10, exact_mean = 0)
>>> random_generator(10, distrib = gauss, rd_args = (50,20), nbr_format = int)
"""
# if exact_mean is set, we create automaticaly only length-1 value

View File

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