binary-equalab 1.0.0__py3-none-any.whl → 2.0.0__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.
@@ -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,210 @@
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]v1.0.0[/dim]
25
- ║ [dim italic]"El álgebra también siente"[/dim italic]
26
- ╚══════════════════════════════════════════════════════════╝[/bold orange1]
27
-
28
- [dim]Comandos:[/dim]
29
- [cyan]help[/cyan] - Lista de funciones disponibles
30
- [cyan]exit[/cyan] - Salir
31
- [cyan]cls[/cyan] - Limpiar pantalla
32
-
33
- [dim]Ejemplos:[/dim]
34
- derivar(x^2 + 3x, x)
35
- integrar(sin(x), x)
36
- van(0.10, -1000, 300, 400, 500)
37
- """
38
-
39
- HELP_TEXT = """
40
- ## Funciones Disponibles
41
-
42
- ### Cálculo
43
- | Función | Ejemplo |
44
- |---------|---------|
45
- | `derivar(expr, var)` | `derivar(x^2, x)` → `2*x` |
46
- | `integrar(expr, var)` | `integrar(sin(x), x)` → `-cos(x)` |
47
- | `limite(expr, var, punto)` | `limite(sin(x)/x, x, 0)` → `1` |
48
- | `sumatoria(expr, var, a, b)` | `sumatoria(n^2, n, 1, 10)` |
49
-
50
- ### Álgebra
51
- | Función | Ejemplo |
52
- |---------|---------|
53
- | `simplificar(expr)` | `simplificar((x^2-1)/(x-1))` |
54
- | `expandir(expr)` | `expandir((x+1)^2)` |
55
- | `factorizar(expr)` | `factorizar(x^2-1)` |
56
- | `resolver(expr, var)` | `resolver(x^2-4, x)` → `[-2, 2]` |
57
-
58
- ### Estadística
59
- | Función | Ejemplo |
60
- |---------|---------|
61
- | `media(...)` | `media(1, 2, 3, 4, 5)` → `3` |
62
- | `mediana(...)` | `mediana(1, 2, 3, 4, 5)` → `3` |
63
- | `desviacion(...)` | `desviacion(1, 2, 3, 4, 5)` |
64
- | `varianza(...)` | `varianza(1, 2, 3, 4, 5)` |
65
-
66
- ### Finanzas
67
- | Función | Ejemplo |
68
- |---------|---------|
69
- | `van(tasa, flujo0, flujo1, ...)` | `van(0.10, -1000, 300, 400)` |
70
- | `tir(flujo0, flujo1, ...)` | `tir(-1000, 300, 400, 500)` |
71
- | `depreciar(costo, residual, años)` | `depreciar(10000, 1000, 5)` |
72
- | `interes_simple(capital, tasa, tiempo)` | `interes_simple(1000, 0.05, 3)` |
73
- | `interes_compuesto(capital, tasa, n, tiempo)` | `interes_compuesto(1000, 0.05, 12, 3)` |
74
- """
75
-
76
-
77
- def get_prompt_style():
78
- return Style.from_dict({
79
- 'prompt': '#ff6b35 bold',
80
- })
81
-
82
-
83
- def repl():
84
- """Start the interactive REPL."""
85
- console.print(BANNER)
86
-
87
- engine = MathEngine()
88
-
89
- # Setup history file
90
- history_path = os.path.expanduser("~/.binary_math_history")
91
- session: PromptSession = PromptSession(
92
- history=FileHistory(history_path),
93
- auto_suggest=AutoSuggestFromHistory(),
94
- style=get_prompt_style(),
95
- )
96
-
97
- while True:
98
- try:
99
- # Read input
100
- user_input = session.prompt([('class:prompt', '>>> ')]).strip()
101
-
102
- if not user_input:
103
- continue
104
-
105
- # Handle special commands
106
- if user_input.lower() in ('exit', 'quit', 'q'):
107
- console.print("[dim]¡Hasta luego![/dim]")
108
- break
109
-
110
- if user_input.lower() in ('cls', 'clear'):
111
- console.clear()
112
- console.print(BANNER)
113
- continue
114
-
115
- if user_input.lower() == 'help':
116
- console.print(Markdown(HELP_TEXT))
117
- continue
118
-
119
- if user_input.lower() == 'history':
120
- for i, h in enumerate(engine.history[-10:], 1):
121
- console.print(f"[dim]{i}.[/dim] {h}")
122
- continue
123
-
124
- # Evaluate expression
125
- try:
126
- result = engine.evaluate(user_input)
127
-
128
- if result is None:
129
- continue
130
-
131
- # Format output
132
- if isinstance(result, (list, tuple)):
133
- console.print(f"[bold green]→[/bold green] {list(result)}")
134
- elif isinstance(result, dict):
135
- for key, value in result.items():
136
- console.print(f" [cyan]{key}:[/cyan] {value}")
137
- else:
138
- console.print(f"[bold green]→[/bold green] {result}")
139
-
140
- except Exception as e:
141
- console.print(f"[bold red]Error:[/bold red] {e}")
142
-
143
- except KeyboardInterrupt:
144
- console.print()
145
- continue
146
- except EOFError:
147
- console.print("\n[dim]¡Hasta luego![/dim]")
148
- break
149
-
150
-
151
- def one_liner(expression: str):
152
- """Evaluate a single expression from command line."""
153
- engine = MathEngine()
154
- try:
155
- result = engine.evaluate(expression)
156
- if isinstance(result, (list, tuple)):
157
- print(list(result))
158
- elif isinstance(result, dict):
159
- for key, value in result.items():
160
- print(f"{key}: {value}")
161
- else:
162
- print(result)
163
- except Exception as e:
164
- print(f"Error: {e}", file=sys.stderr)
165
- sys.exit(1)
166
-
167
-
168
- def main():
169
- """CLI entry point."""
170
- if len(sys.argv) > 1:
171
- # One-liner mode
172
- expression = " ".join(sys.argv[1:])
173
- one_liner(expression)
174
- else:
175
- # REPL mode
176
- repl()
177
-
178
-
179
- if __name__ == "__main__":
180
- main()
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
+
86
+
87
+ def get_prompt_style():
88
+ return Style.from_dict({
89
+ 'prompt': '#ff6b35 bold',
90
+ })
91
+
92
+
93
+ def repl():
94
+ """Start the interactive REPL."""
95
+ console.print(BANNER)
96
+
97
+ engine = MathEngine()
98
+
99
+ # Setup history file
100
+ history_path = os.path.expanduser("~/.binary_math_history")
101
+ session: PromptSession = PromptSession(
102
+ history=FileHistory(history_path),
103
+ auto_suggest=AutoSuggestFromHistory(),
104
+ style=get_prompt_style(),
105
+ )
106
+
107
+ while True:
108
+ try:
109
+ # Read input
110
+ user_input = session.prompt([('class:prompt', '>>> ')]).strip()
111
+
112
+ if not user_input:
113
+ continue
114
+
115
+ # Handle special commands
116
+ if user_input.lower() in ('exit', 'quit', 'q'):
117
+ console.print("[dim]¡Hasta luego![/dim]")
118
+ break
119
+
120
+ if user_input.lower() in ('cls', 'clear'):
121
+ console.clear()
122
+ console.print(BANNER)
123
+ continue
124
+
125
+ if user_input.lower() == 'help':
126
+ console.print(Markdown(HELP_TEXT))
127
+ continue
128
+
129
+ if user_input.lower() == 'history':
130
+ for i, h in enumerate(engine.history[-10:], 1):
131
+ console.print(f"[dim]{i}.[/dim] {h}")
132
+ continue
133
+
134
+ # Evaluate expression
135
+ try:
136
+ result = engine.evaluate(user_input)
137
+
138
+ if result is None:
139
+ continue
140
+
141
+ # Format output
142
+ if isinstance(result, (list, tuple)):
143
+ console.print(f"[bold green]→[/bold green] {list(result)}")
144
+ elif isinstance(result, dict):
145
+ for key, value in result.items():
146
+ console.print(f" [cyan]{key}:[/cyan] {value}")
147
+ else:
148
+ console.print(f"[bold green]→[/bold green] {result}")
149
+
150
+ except Exception as e:
151
+ console.print(f"[bold red]Error:[/bold red] {e}")
152
+
153
+ except KeyboardInterrupt:
154
+ console.print()
155
+ continue
156
+ except EOFError:
157
+ console.print("\n[dim]¡Hasta luego![/dim]")
158
+ break
159
+
160
+
161
+ def one_liner(expression: str):
162
+ """Evaluate a single expression from command line."""
163
+ engine = MathEngine()
164
+ try:
165
+ result = engine.evaluate(expression)
166
+ if isinstance(result, (list, tuple)):
167
+ print(list(result))
168
+ elif isinstance(result, dict):
169
+ for key, value in result.items():
170
+ print(f"{key}: {value}")
171
+ else:
172
+ print(result)
173
+ except Exception as e:
174
+ print(f"Error: {e}", file=sys.stderr)
175
+ sys.exit(1)
176
+
177
+
178
+ def main():
179
+ """CLI entry point."""
180
+ if len(sys.argv) > 1 and sys.argv[1] == 'setup-shell':
181
+ from .shell_setup import run_setup
182
+ run_setup()
183
+ elif len(sys.argv) > 1 and sys.argv[1] == 'feedback':
184
+ import webbrowser
185
+ print("""
186
+ ╔═══════════════════════════════════════╗
187
+ ║ 💬 Feedback & Soporte ║
188
+ ╚═══════════════════════════════════════╝
189
+
190
+ ¡Gracias por usar Binary EquaLab! ❤️
191
+
192
+ Estoy abierto a cualquier sugerencia, apoyo, financiamiento,
193
+ compañía, o reporte de errores.
194
+
195
+ 🐛 Bugs / Mejoras: https://github.com/Malexnnn/BinaryEqualab/issues
196
+ 📧 Contacto: Ver perfil de GitHub
197
+ """)
198
+ webbrowser.open("https://github.com/Malexnnn/BinaryEqualab")
199
+
200
+ elif len(sys.argv) > 1:
201
+ # One-liner mode
202
+ expression = " ".join(sys.argv[1:])
203
+ one_liner(expression)
204
+ else:
205
+ # REPL mode
206
+ repl()
207
+
208
+
209
+ if __name__ == "__main__":
210
+ main()