binary-equalab 1.0.0__py3-none-any.whl → 2.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- binary_equalab/__init__.py +23 -23
- binary_equalab/cli.py +244 -180
- binary_equalab/engine.py +492 -405
- binary_equalab/functions.py +18 -18
- binary_equalab/geometry.py +69 -0
- binary_equalab/giac_poc.py +74 -0
- binary_equalab/parser_enhanced.py +66 -0
- binary_equalab/shell_setup.py +128 -0
- binary_equalab/sonify.py +91 -0
- {binary_equalab-1.0.0.dist-info → binary_equalab-2.0.1.dist-info}/METADATA +35 -6
- binary_equalab-2.0.1.dist-info/RECORD +13 -0
- {binary_equalab-1.0.0.dist-info → binary_equalab-2.0.1.dist-info}/entry_points.txt +1 -0
- binary_equalab-1.0.0.dist-info/RECORD +0 -8
- {binary_equalab-1.0.0.dist-info → binary_equalab-2.0.1.dist-info}/WHEEL +0 -0
binary_equalab/__init__.py
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Binary EquaLab CLI
|
|
3
|
-
Command-line CAS calculator with Spanish math functions.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
__version__ = "1.0.0"
|
|
7
|
-
__author__ = "BinaryEquaLab Team"
|
|
8
|
-
|
|
9
|
-
from .engine import MathEngine
|
|
10
|
-
from .functions import (
|
|
11
|
-
derivar, integrar, limite, sumatoria,
|
|
12
|
-
simplificar, expandir, factorizar, resolver,
|
|
13
|
-
van, tir, depreciar, interes_simple, interes_compuesto,
|
|
14
|
-
media, mediana, desviacion, varianza
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
__all__ = [
|
|
18
|
-
"MathEngine",
|
|
19
|
-
"derivar", "integrar", "limite", "sumatoria",
|
|
20
|
-
"simplificar", "expandir", "factorizar", "resolver",
|
|
21
|
-
"van", "tir", "depreciar", "interes_simple", "interes_compuesto",
|
|
22
|
-
"media", "mediana", "desviacion", "varianza",
|
|
23
|
-
]
|
|
1
|
+
"""
|
|
2
|
+
Binary EquaLab CLI
|
|
3
|
+
Command-line CAS calculator with Spanish math functions.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "1.0.0"
|
|
7
|
+
__author__ = "BinaryEquaLab Team"
|
|
8
|
+
|
|
9
|
+
from .engine import MathEngine
|
|
10
|
+
from .functions import (
|
|
11
|
+
derivar, integrar, limite, sumatoria,
|
|
12
|
+
simplificar, expandir, factorizar, resolver,
|
|
13
|
+
van, tir, depreciar, interes_simple, interes_compuesto,
|
|
14
|
+
media, mediana, desviacion, varianza
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"MathEngine",
|
|
19
|
+
"derivar", "integrar", "limite", "sumatoria",
|
|
20
|
+
"simplificar", "expandir", "factorizar", "resolver",
|
|
21
|
+
"van", "tir", "depreciar", "interes_simple", "interes_compuesto",
|
|
22
|
+
"media", "mediana", "desviacion", "varianza",
|
|
23
|
+
]
|
binary_equalab/cli.py
CHANGED
|
@@ -1,180 +1,244 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Binary EquaLab CLI
|
|
3
|
-
Interactive REPL and command-line interface.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
import sys
|
|
7
|
-
from typing import Optional
|
|
8
|
-
from rich.console import Console
|
|
9
|
-
from rich.panel import Panel
|
|
10
|
-
from rich.markdown import Markdown
|
|
11
|
-
from rich.text import Text
|
|
12
|
-
from prompt_toolkit import PromptSession
|
|
13
|
-
from prompt_toolkit.history import FileHistory
|
|
14
|
-
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
|
|
15
|
-
from prompt_toolkit.styles import Style
|
|
16
|
-
import os
|
|
17
|
-
|
|
18
|
-
from .engine import MathEngine
|
|
19
|
-
|
|
20
|
-
console = Console()
|
|
21
|
-
|
|
22
|
-
BANNER = """
|
|
23
|
-
[bold orange1]╔══════════════════════════════════════════════════════════╗
|
|
24
|
-
║ [white]Binary EquaLab CLI[/white] [dim]
|
|
25
|
-
║ [dim italic]"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
[cyan]
|
|
31
|
-
[cyan]
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
|
47
|
-
|
|
48
|
-
| `
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
|
62
|
-
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
|
70
|
-
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
1
|
+
"""
|
|
2
|
+
Binary EquaLab CLI
|
|
3
|
+
Interactive REPL and command-line interface.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
from typing import Optional
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
from rich.panel import Panel
|
|
10
|
+
from rich.markdown import Markdown
|
|
11
|
+
from rich.text import Text
|
|
12
|
+
from prompt_toolkit import PromptSession
|
|
13
|
+
from prompt_toolkit.history import FileHistory
|
|
14
|
+
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
|
|
15
|
+
from prompt_toolkit.styles import Style
|
|
16
|
+
import os
|
|
17
|
+
|
|
18
|
+
from .engine import MathEngine
|
|
19
|
+
|
|
20
|
+
console = Console()
|
|
21
|
+
|
|
22
|
+
BANNER = """
|
|
23
|
+
[bold orange1]╔══════════════════════════════════════════════════════════╗
|
|
24
|
+
║ [white]Binary EquaLab CLI[/white] [dim]Aurora v2.0[/dim] ║
|
|
25
|
+
║ [dim italic]"Las matemáticas también sienten,[/dim italic] ║
|
|
26
|
+
║ [dim italic] pero estas no se equivocan."[/dim italic] ║
|
|
27
|
+
╚══════════════════════════════════════════════════════════╝[/bold orange1]
|
|
28
|
+
|
|
29
|
+
[dim]Comandos:[/dim]
|
|
30
|
+
[cyan]help[/cyan] - Lista de funciones disponibles
|
|
31
|
+
[cyan]exit[/cyan] - Salir
|
|
32
|
+
[cyan]cls[/cyan] - Limpiar pantalla
|
|
33
|
+
|
|
34
|
+
[dim]Pro Tip:[/dim] Usa [bold]sonify(expr)[/bold] para escuchar funciones o [bold]recta(p1, p2)[/bold] para geometría.
|
|
35
|
+
|
|
36
|
+
[dim]Ejemplos:[/dim]
|
|
37
|
+
derivar(cos^2(2x))
|
|
38
|
+
sonify(sin(440*2*pi*t))
|
|
39
|
+
distancia((0,0), (1,1))
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
HELP_TEXT = """
|
|
43
|
+
## Funciones Disponibles
|
|
44
|
+
|
|
45
|
+
### Cálculo
|
|
46
|
+
| Función | Ejemplo |
|
|
47
|
+
|---------|---------|
|
|
48
|
+
| `derivar(expr, var)` | `derivar(x^2, x)` → `2*x` |
|
|
49
|
+
| `integrar(expr, var)` | `integrar(sin(x), x)` → `-cos(x)` |
|
|
50
|
+
|
|
51
|
+
### Audio & Geometría (NUEVO)
|
|
52
|
+
| Función | Ejemplo |
|
|
53
|
+
|---------|---------|
|
|
54
|
+
| `sonify(expr)` | `sonify(sin(440t))` (Genera output.wav) |
|
|
55
|
+
| `distancia(p1, p2)` | `distancia((0,0), (3,4))` → `5` |
|
|
56
|
+
| `recta(p1, p2)` | `recta((0,0), (1,1))` → `y=x` |
|
|
57
|
+
| `limite(expr, var, punto)` | `limite(sin(x)/x, x, 0)` → `1` |
|
|
58
|
+
| `sumatoria(expr, var, a, b)` | `sumatoria(n^2, n, 1, 10)` |
|
|
59
|
+
|
|
60
|
+
### Álgebra
|
|
61
|
+
| Función | Ejemplo |
|
|
62
|
+
|---------|---------|
|
|
63
|
+
| `simplificar(expr)` | `simplificar((x^2-1)/(x-1))` |
|
|
64
|
+
| `expandir(expr)` | `expandir((x+1)^2)` |
|
|
65
|
+
| `factorizar(expr)` | `factorizar(x^2-1)` |
|
|
66
|
+
| `resolver(expr, var)` | `resolver(x^2-4, x)` → `[-2, 2]` |
|
|
67
|
+
|
|
68
|
+
### Estadística
|
|
69
|
+
| Función | Ejemplo |
|
|
70
|
+
|---------|---------|
|
|
71
|
+
| `media(...)` | `media(1, 2, 3, 4, 5)` → `3` |
|
|
72
|
+
| `mediana(...)` | `mediana(1, 2, 3, 4, 5)` → `3` |
|
|
73
|
+
| `desviacion(...)` | `desviacion(1, 2, 3, 4, 5)` |
|
|
74
|
+
| `varianza(...)` | `varianza(1, 2, 3, 4, 5)` |
|
|
75
|
+
|
|
76
|
+
### Finanzas
|
|
77
|
+
| Función | Ejemplo |
|
|
78
|
+
|---------|---------|
|
|
79
|
+
| `van(tasa, flujo0, flujo1, ...)` | `van(0.10, -1000, 300, 400)` |
|
|
80
|
+
| `tir(flujo0, flujo1, ...)` | `tir(-1000, 300, 400, 500)` |
|
|
81
|
+
| `depreciar(costo, residual, años)` | `depreciar(10000, 1000, 5)` |
|
|
82
|
+
| `interes_simple(capital, tasa, tiempo)` | `interes_simple(1000, 0.05, 3)` |
|
|
83
|
+
| `interes_compuesto(capital, tasa, n, tiempo)` | `interes_compuesto(1000, 0.05, 12, 3)` |
|
|
84
|
+
|
|
85
|
+
### Aliases y Accesos Directos
|
|
86
|
+
- **Shell**: Puedes ejecutar el programa como `binary-equalab`, `bneqls`, `beq` o `binary-math`.
|
|
87
|
+
- **Trigonometría**: `seno`=`sin`, `coseno`=`cos`, `tangente`=`tan`.
|
|
88
|
+
- **General**: `sonificar`=`sonify`, `derivada`=`derivar`.
|
|
89
|
+
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def get_prompt_style():
|
|
94
|
+
return Style.from_dict({
|
|
95
|
+
'prompt': '#ff6b35 bold',
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def print_banner():
|
|
100
|
+
"""Print the CLI banner using Rich panels."""
|
|
101
|
+
title = Text("Binary EquaLab CLI", style="bold white")
|
|
102
|
+
version = Text("Aurora v2.0.0", style="dim")
|
|
103
|
+
slogan = Text('"Las matemáticas también sienten,\npero estas no se equivocan."', style="dim italic")
|
|
104
|
+
|
|
105
|
+
content = Text.assemble(title, " ", version, "\n\n", slogan, justify="center")
|
|
106
|
+
panel = Panel(
|
|
107
|
+
content,
|
|
108
|
+
border_style="bold orange1",
|
|
109
|
+
expand=False,
|
|
110
|
+
subtitle="[dim]Escribe 'help' para ver comandos[/dim]"
|
|
111
|
+
)
|
|
112
|
+
console.print(panel)
|
|
113
|
+
|
|
114
|
+
def repl():
|
|
115
|
+
"""Start the interactive REPL."""
|
|
116
|
+
print_banner()
|
|
117
|
+
|
|
118
|
+
engine = MathEngine()
|
|
119
|
+
|
|
120
|
+
# Setup history file
|
|
121
|
+
history_path = os.path.expanduser("~/.binary_math_history")
|
|
122
|
+
session: PromptSession = PromptSession(
|
|
123
|
+
history=FileHistory(history_path),
|
|
124
|
+
auto_suggest=AutoSuggestFromHistory(),
|
|
125
|
+
style=get_prompt_style(),
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
while True:
|
|
129
|
+
try:
|
|
130
|
+
# Read input
|
|
131
|
+
user_input = session.prompt([('class:prompt', '>>> ')]).strip()
|
|
132
|
+
|
|
133
|
+
if not user_input:
|
|
134
|
+
continue
|
|
135
|
+
|
|
136
|
+
# Handle special commands
|
|
137
|
+
cmd = user_input.lower()
|
|
138
|
+
if cmd in ('exit', 'quit', 'q'):
|
|
139
|
+
console.print("[dim]¡Hasta luego![/dim]")
|
|
140
|
+
break
|
|
141
|
+
|
|
142
|
+
if cmd in ('cls', 'clear'):
|
|
143
|
+
console.clear()
|
|
144
|
+
print_banner()
|
|
145
|
+
continue
|
|
146
|
+
|
|
147
|
+
if cmd == 'help':
|
|
148
|
+
console.print(Markdown(HELP_TEXT))
|
|
149
|
+
continue
|
|
150
|
+
|
|
151
|
+
if cmd == 'history':
|
|
152
|
+
for i, h in enumerate(engine.history[-10:], 1):
|
|
153
|
+
console.print(f"[dim]{i}.[/dim] {h}")
|
|
154
|
+
continue
|
|
155
|
+
|
|
156
|
+
# --- Easter Eggs ---
|
|
157
|
+
if cmd == 'binary':
|
|
158
|
+
console.print(Panel("[bold cyan]Las matemáticas también sienten.[/bold cyan]", border_style="cyan"))
|
|
159
|
+
continue
|
|
160
|
+
if cmd == 'aldra':
|
|
161
|
+
console.print(Panel("[bold magenta]De Aldra para la gente, gratis y con alma.[/bold magenta]", border_style="magenta"))
|
|
162
|
+
continue
|
|
163
|
+
if cmd == 'lupe':
|
|
164
|
+
console.print(Panel("[bold white]In Memoriam.[/bold white]", border_style="white"))
|
|
165
|
+
continue
|
|
166
|
+
# -------------------
|
|
167
|
+
|
|
168
|
+
# Evaluate expression
|
|
169
|
+
try:
|
|
170
|
+
result = engine.evaluate(user_input)
|
|
171
|
+
|
|
172
|
+
if result is None:
|
|
173
|
+
continue
|
|
174
|
+
|
|
175
|
+
# Format output
|
|
176
|
+
if isinstance(result, (list, tuple)):
|
|
177
|
+
console.print(f"[bold green]→[/bold green] {list(result)}")
|
|
178
|
+
elif isinstance(result, dict):
|
|
179
|
+
for key, value in result.items():
|
|
180
|
+
console.print(f" [cyan]{key}:[/cyan] {value}")
|
|
181
|
+
else:
|
|
182
|
+
console.print(f"[bold green]→[/bold green] {result}")
|
|
183
|
+
|
|
184
|
+
except Exception as e:
|
|
185
|
+
console.print(f"[bold red]Error:[/bold red] {e}")
|
|
186
|
+
|
|
187
|
+
except KeyboardInterrupt:
|
|
188
|
+
console.print()
|
|
189
|
+
continue
|
|
190
|
+
except EOFError:
|
|
191
|
+
console.print("\n[dim]¡Hasta luego![/dim]")
|
|
192
|
+
break
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def one_liner(expression: str):
|
|
196
|
+
"""Evaluate a single expression from command line."""
|
|
197
|
+
engine = MathEngine()
|
|
198
|
+
try:
|
|
199
|
+
result = engine.evaluate(expression)
|
|
200
|
+
if isinstance(result, (list, tuple)):
|
|
201
|
+
print(list(result))
|
|
202
|
+
elif isinstance(result, dict):
|
|
203
|
+
for key, value in result.items():
|
|
204
|
+
print(f"{key}: {value}")
|
|
205
|
+
else:
|
|
206
|
+
print(result)
|
|
207
|
+
except Exception as e:
|
|
208
|
+
print(f"Error: {e}", file=sys.stderr)
|
|
209
|
+
sys.exit(1)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def main():
|
|
213
|
+
"""CLI entry point."""
|
|
214
|
+
if len(sys.argv) > 1 and sys.argv[1] == 'setup-shell':
|
|
215
|
+
from .shell_setup import run_setup
|
|
216
|
+
run_setup()
|
|
217
|
+
elif len(sys.argv) > 1 and sys.argv[1] == 'feedback':
|
|
218
|
+
import webbrowser
|
|
219
|
+
print("""
|
|
220
|
+
╔═══════════════════════════════════════╗
|
|
221
|
+
║ 💬 Feedback & Soporte ║
|
|
222
|
+
╚═══════════════════════════════════════╝
|
|
223
|
+
|
|
224
|
+
¡Gracias por usar Binary EquaLab! ❤️
|
|
225
|
+
|
|
226
|
+
Estoy abierto a cualquier sugerencia, apoyo, financiamiento,
|
|
227
|
+
compañía, o reporte de errores.
|
|
228
|
+
|
|
229
|
+
🐛 Bugs / Mejoras: https://github.com/Malexnnn/BinaryEqualab/issues
|
|
230
|
+
📧 Contacto: Ver perfil de GitHub
|
|
231
|
+
""")
|
|
232
|
+
webbrowser.open("https://github.com/Malexnnn/BinaryEqualab")
|
|
233
|
+
|
|
234
|
+
elif len(sys.argv) > 1:
|
|
235
|
+
# One-liner mode
|
|
236
|
+
expression = " ".join(sys.argv[1:])
|
|
237
|
+
one_liner(expression)
|
|
238
|
+
else:
|
|
239
|
+
# REPL mode
|
|
240
|
+
repl()
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
if __name__ == "__main__":
|
|
244
|
+
main()
|