From a9d85c5dcf7485ab42cf0bcceb4756a1e09bfacc Mon Sep 17 00:00:00 2001 From: ddenoncin Date: Mon, 10 Jul 2023 16:17:50 +0200 Subject: [PATCH] initial commit --- LICENSE | 7 ++-- README.md | 10 +++++- TODO.md | 3 ++ libargfunc/__init__.py | 1 + libargfunc/constantes_libargfunc.py | 1 + libargfunc/libargfunc.py | 51 +++++++++++++++++++++++++++++ setup.py | 20 +++++++++++ 7 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 TODO.md create mode 100644 libargfunc/__init__.py create mode 100644 libargfunc/constantes_libargfunc.py create mode 100644 libargfunc/libargfunc.py create mode 100644 setup.py diff --git a/LICENSE b/LICENSE index 7a3094a..eadf858 100644 --- a/LICENSE +++ b/LICENSE @@ -1,11 +1,14 @@ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 Copyright (C) 2004 Sam Hocevar -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 + 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. \ No newline at end of file diff --git a/README.md b/README.md index 702778d..82c36cd 100644 --- a/README.md +++ b/README.md @@ -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 + +## Licence +[WTFPL](http://www.wtfpl.net/) diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..450577d --- /dev/null +++ b/TODO.md @@ -0,0 +1,3 @@ +# TODO LIST + +Faire des tests ? diff --git a/libargfunc/__init__.py b/libargfunc/__init__.py new file mode 100644 index 0000000..a109a9e --- /dev/null +++ b/libargfunc/__init__.py @@ -0,0 +1 @@ +from libargfunc.libargfunc import * diff --git a/libargfunc/constantes_libargfunc.py b/libargfunc/constantes_libargfunc.py new file mode 100644 index 0000000..0bc977e --- /dev/null +++ b/libargfunc/constantes_libargfunc.py @@ -0,0 +1 @@ +version = '0.2' diff --git a/libargfunc/libargfunc.py b/libargfunc/libargfunc.py new file mode 100644 index 0000000..20c4562 --- /dev/null +++ b/libargfunc/libargfunc.py @@ -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) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ff0545d --- /dev/null +++ b/setup.py @@ -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" + ] +) + +