initial commit
parent
c7f0c44d1e
commit
a9d85c5dcf
@ -1,11 +1,14 @@
|
|||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
|
||||||
Version 2, December 2004
|
Version 2, December 2004
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
|
Everyone is permitted to copy and distribute verbatim or modified copies of
|
||||||
|
this license document, and changing it is allowed as long as the name is changed.
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
0. You just DO WHAT THE FUCK YOU WANT TO.
|
@ -1,2 +1,10 @@
|
|||||||
# libargfunc
|
# Libcurses
|
||||||
|
|
||||||
|
Regroupe des fonctions faites maison pour nettoyer les arguments à fournir pour définir une fonction
|
||||||
|
|
||||||
|
## Contributions
|
||||||
|
|
||||||
|
Toute contribution est la bienvenue, et peut m'être adressée à l'adresse <math@denoncin.fr>
|
||||||
|
|
||||||
|
## Licence
|
||||||
|
[WTFPL](http://www.wtfpl.net/)
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
from libargfunc.libargfunc import *
|
@ -0,0 +1 @@
|
|||||||
|
version = '0.2'
|
@ -0,0 +1,51 @@
|
|||||||
|
import sympy as sp
|
||||||
|
|
||||||
|
def sympify(expression):
|
||||||
|
"""expression est une chaîne de caractère qu'il faut transformer en objet sympy. On retourne une liste dont le deuxième élément est un booléen déterminant si la conversion a fonctionné
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
sp.sympify(expression)
|
||||||
|
return [sp.sympify(expression),True]
|
||||||
|
except:
|
||||||
|
return ["Impossible de convertir l'expression",False]
|
||||||
|
|
||||||
|
def sympify_intervalle(string):
|
||||||
|
"""string est une expression de la forme a,b avec a,b des flottants ou oo ou -oo
|
||||||
|
"""
|
||||||
|
intervalle = string.split(',')
|
||||||
|
if len(intervalle) != 2:
|
||||||
|
return ["La chaîne de caractère n'est pas au format [a,b]",False]
|
||||||
|
|
||||||
|
borne_inf = intervalle[0][0]
|
||||||
|
borne_sup = intervalle[1][-1]
|
||||||
|
caracteres_admissibles = ['[',']']
|
||||||
|
if borne_inf not in caracteres_admissibles or borne_sup not in caracteres_admissibles:
|
||||||
|
return ["La chaîne de caractère n'est pas au bon format [a,b]",False]
|
||||||
|
|
||||||
|
a = intervalle[0][1:]
|
||||||
|
b = intervalle[1][:-1]
|
||||||
|
|
||||||
|
try:
|
||||||
|
a = sp.sympify(a)
|
||||||
|
except:
|
||||||
|
return ["la borne inférieure n'est pas au bon format",False]
|
||||||
|
try:
|
||||||
|
b = sp.sympify(b)
|
||||||
|
except:
|
||||||
|
return ["la borne supérieure n'est pas au bon format",False]
|
||||||
|
|
||||||
|
if borne_inf == '[' and borne_sup == ']':
|
||||||
|
return [sp.Interval(a,b),True]
|
||||||
|
elif borne_inf == ']' and borne_sup == '[':
|
||||||
|
return [sp.Interval.open(a,b),True]
|
||||||
|
elif borne_inf == ']' and borne_sup == ']':
|
||||||
|
return [sp.Interval.Ropen(a,b),True]
|
||||||
|
elif borne_inf == '[' and borne_sup == '[':
|
||||||
|
return [sp.Interval.Lopen(a,b),True]
|
||||||
|
|
||||||
|
def sympify_intervalle2(string):
|
||||||
|
if string == '':
|
||||||
|
return ['',True]
|
||||||
|
else:
|
||||||
|
return sympify_intervalle(string)
|
@ -0,0 +1,20 @@
|
|||||||
|
from setuptools import setup, find_packages
|
||||||
|
from libargfunc.constantes_libargfunc import version
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="libargfunc",
|
||||||
|
version=version,
|
||||||
|
packages=find_packages(),
|
||||||
|
|
||||||
|
install_requires=["sympy"],
|
||||||
|
|
||||||
|
author="David Denoncin",
|
||||||
|
author_email="math@denoncin.fr",
|
||||||
|
url="math.denoncin.fr",
|
||||||
|
description="Mes fonctions perso pour nettoyer les arguments donnés pour définir une fonction",
|
||||||
|
classifiers=[
|
||||||
|
"Licence :: WTFPL"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue