fyrefly 0.3.2__tar.gz → 0.4.0__tar.gz
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.
- {fyrefly-0.3.2 → fyrefly-0.4.0}/PKG-INFO +94 -10
- fyrefly-0.4.0/README.md +210 -0
- {fyrefly-0.3.2 → fyrefly-0.4.0}/pyproject.toml +1 -1
- fyrefly-0.4.0/src/fyrefly/__init__.py +26 -0
- fyrefly-0.4.0/src/fyrefly/quant.py +301 -0
- fyrefly-0.4.0/src/fyrefly/viz.py +236 -0
- fyrefly-0.4.0/tests/test_quant.py +208 -0
- fyrefly-0.4.0/tests/test_viz.py +132 -0
- fyrefly-0.3.2/README.md +0 -126
- fyrefly-0.3.2/src/fyrefly/__init__.py +0 -14
- fyrefly-0.3.2/src/fyrefly/viz.py +0 -132
- fyrefly-0.3.2/tests/test_viz.py +0 -66
- {fyrefly-0.3.2 → fyrefly-0.4.0}/.github/workflows/publish.yml +0 -0
- {fyrefly-0.3.2 → fyrefly-0.4.0}/.gitignore +0 -0
- {fyrefly-0.3.2 → fyrefly-0.4.0}/LICENSE +0 -0
- {fyrefly-0.3.2 → fyrefly-0.4.0}/src/fyrefly/ai.py +0 -0
- {fyrefly-0.3.2 → fyrefly-0.4.0}/src/fyrefly/core.py +0 -0
- {fyrefly-0.3.2 → fyrefly-0.4.0}/src/fyrefly/dataops.py +0 -0
- {fyrefly-0.3.2 → fyrefly-0.4.0}/tests/test_ai.py +0 -0
- {fyrefly-0.3.2 → fyrefly-0.4.0}/tests/test_core.py +0 -0
- {fyrefly-0.3.2 → fyrefly-0.4.0}/tests/test_dataops.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: fyrefly
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: A quant-based library to compute mathematical operations, run SQL queries, get AI-powered insights, and visualize your data.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Ninad077/fyrefly
|
|
6
6
|
Project-URL: Repository, https://github.com/Ninad077/fyrefly
|
|
@@ -58,6 +58,49 @@ mul() # 1 (identity)
|
|
|
58
58
|
diff(10, 3) # 7
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
+
## Usage — Quant formulas
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from fyrefly import si, ci, si_ci_diff, profit, loss, ap, gp, hp, avg, avgc, mode, median, hyp, slope, centroid
|
|
65
|
+
|
|
66
|
+
# Interest
|
|
67
|
+
si(1000, 2, 5) # 100.0 (Simple Interest: p, n, r)
|
|
68
|
+
ci(1000, 2, 10) # 210.0 (Compound Interest, annual by default)
|
|
69
|
+
ci(1000, 2, 10, "semi-annual") # 215.5 (compounded twice a year)
|
|
70
|
+
si_ci_diff(1000, 10, 2) # 10.0 (CI - SI, supports n = 2 or 3 only)
|
|
71
|
+
|
|
72
|
+
# Profit / Loss — smart-detects if you called the wrong one
|
|
73
|
+
profit(120, 100) # 20
|
|
74
|
+
profit(120, 100, "%") # (20, 20.0) value + percentage
|
|
75
|
+
loss(80, 100) # 20
|
|
76
|
+
loss(80, 100, "%") # (20, 20.0)
|
|
77
|
+
profit(80, 100) # raises: "this is a LOSS, not a profit. Use loss(80, 100) instead."
|
|
78
|
+
|
|
79
|
+
# Sequences: AP, GP, HP
|
|
80
|
+
ap(2, 3, 4) # [2, 5, 8, 11] full sequence
|
|
81
|
+
ap.tn(2, 3, 4) # 11 nth term
|
|
82
|
+
ap.sn(2, 3, 4) # 26.0 sum of first n terms
|
|
83
|
+
|
|
84
|
+
gp(2, 3, 4) # [2, 6, 18, 54]
|
|
85
|
+
gp.tn(2, 3, 4) # 54
|
|
86
|
+
gp.sn(2, 3, 4) # 80.0
|
|
87
|
+
|
|
88
|
+
hp(2, 3, 4) # [2.0, 0.2857..., 0.1538..., 0.1052...]
|
|
89
|
+
hp.tn(2, 3, 4) # 0.10526315789473684
|
|
90
|
+
hp.sn(2, 3, 4) # 2.5448235974551765
|
|
91
|
+
|
|
92
|
+
# Averages, mode, median
|
|
93
|
+
avg(10, 12, 13) # 11.666666666666666 plain average of individual numbers
|
|
94
|
+
avgc(5, 3, 10, 2) # 7.0 weighted avg from (value, count) pairs
|
|
95
|
+
mode(1, 1, 2, 2) # [1, 2]
|
|
96
|
+
median(1, 2, 3, 4) # 2.5
|
|
97
|
+
|
|
98
|
+
# Geometry
|
|
99
|
+
hyp(3, 4) # 5.0
|
|
100
|
+
slope((1, 2), (3, 4)) # 1.0
|
|
101
|
+
centroid((1, 2), (3, 2), (4, 5)) # (2.6666666666666665, 3.0)
|
|
102
|
+
```
|
|
103
|
+
|
|
61
104
|
## Usage — Data functions
|
|
62
105
|
|
|
63
106
|
```python
|
|
@@ -97,6 +140,8 @@ insights(c, api_key="AIza...")
|
|
|
97
140
|
|
|
98
141
|
The provider (Anthropic, OpenAI, Gemini, or any OpenAI-compatible API like Groq/Mistral) is **auto-detected from your API key's format** — you usually don't need to specify it. API keys can also be set via environment variables instead of passing them directly: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`.
|
|
99
142
|
|
|
143
|
+
Transient provider errors (rate limits, temporary server issues) are retried automatically with backoff before giving up.
|
|
144
|
+
|
|
100
145
|
⚠️ **Never commit an API key into a script you push to GitHub.** Use an environment variable instead:
|
|
101
146
|
```bash
|
|
102
147
|
export GEMINI_API_KEY="AIza..."
|
|
@@ -110,19 +155,42 @@ ask(c, "what were total sales by region?") # picked up automatically from the
|
|
|
110
155
|
```python
|
|
111
156
|
from fyrefly import viz
|
|
112
157
|
|
|
113
|
-
viz(c)
|
|
114
|
-
viz(c,
|
|
115
|
-
viz(c,
|
|
116
|
-
viz(c,
|
|
117
|
-
viz(c,
|
|
118
|
-
viz(c,
|
|
119
|
-
viz(c,
|
|
158
|
+
viz(c) # auto -> correlation heatmap
|
|
159
|
+
viz(c, "department") # auto -> bar chart of counts
|
|
160
|
+
viz(c, "age") # auto -> histogram
|
|
161
|
+
viz(c, "age", "salary") # auto -> scatter (both numeric)
|
|
162
|
+
viz(c, "department", "salary") # auto -> bar (mixed types)
|
|
163
|
+
viz(c, "age", "salary", kind="scatter")
|
|
164
|
+
viz(c, "department", "salary", kind="box")
|
|
165
|
+
viz(c, "department", kind="pie")
|
|
166
|
+
viz(c, "date", "revenue", kind="line")
|
|
120
167
|
viz(c, kind="pairplot", hue="department")
|
|
121
|
-
viz(c,
|
|
168
|
+
viz(c, "department", "salary", kind="bar", save="chart.png") # also saves a file
|
|
122
169
|
```
|
|
123
170
|
|
|
124
171
|
Supported chart types: `line`, `bar`, `barh`, `scatter`, `hist`, `box`, `violin`, `kde`, `pie`, `heatmap`, `pairplot`, `area`, plus `"auto"` which picks a sensible chart based on your data.
|
|
125
172
|
|
|
173
|
+
### Namespace-style shortcuts
|
|
174
|
+
|
|
175
|
+
Once exactly one DataFrame is loaded, you can also call chart types directly, without repeating the DataFrame each time:
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
c = load("data.csv")
|
|
179
|
+
|
|
180
|
+
viz.bar("department", "salary")
|
|
181
|
+
viz.scatter("age", "salary")
|
|
182
|
+
viz.line("date", "revenue")
|
|
183
|
+
viz.box("department", "salary")
|
|
184
|
+
viz.violin("department", "salary")
|
|
185
|
+
viz.hist("age") # single-column kinds take just x
|
|
186
|
+
viz.kde("salary")
|
|
187
|
+
viz.pie("department")
|
|
188
|
+
viz.heatmap() # no columns needed
|
|
189
|
+
viz.pairplot(hue="department") # no columns needed
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
If more than one DataFrame is loaded, the shortcut can't guess which one you mean — pass it explicitly as the first argument instead: `viz.bar(c, "department", "salary")`.
|
|
193
|
+
|
|
126
194
|
## Functions
|
|
127
195
|
|
|
128
196
|
| Function | Description | Needs API key? |
|
|
@@ -132,6 +200,21 @@ Supported chart types: `line`, `bar`, `barh`, `scatter`, `hist`, `box`, `violin`
|
|
|
132
200
|
| `div(*nos)` | Divides left to right: first ÷ second ÷ third ... | No |
|
|
133
201
|
| `mod(*nos)` | Finds remainder left to right: first % second % third ... | No |
|
|
134
202
|
| `diff(*nos)` | Subtracts left to right: first − second − third ... | No |
|
|
203
|
+
| `si(p, n, r)` | Simple Interest | No |
|
|
204
|
+
| `ci(p, n, r, freq)` | Compound Interest ("annual" or "semi-annual") | No |
|
|
205
|
+
| `si_ci_diff(p, r, n)` | CI − SI, for n = 2 or 3 years | No |
|
|
206
|
+
| `profit(sp, cp, "%")` | Profit value, or (value, %) if "%" passed — smart-detects a loss | No |
|
|
207
|
+
| `loss(sp, cp, "%")` | Loss value, or (value, %) if "%" passed — smart-detects a profit | No |
|
|
208
|
+
| `ap/.tn/.sn(a, d, n)` | Arithmetic Progression: sequence, nth term, sum of n terms | No |
|
|
209
|
+
| `gp/.tn/.sn(a, r, n)` | Geometric Progression: sequence, nth term, sum of n terms | No |
|
|
210
|
+
| `hp/.tn/.sn(a, d, n)` | Harmonic Progression: sequence, nth term, sum of n terms | No |
|
|
211
|
+
| `avg(*nos)` | Plain average of individual numbers | No |
|
|
212
|
+
| `avgc(*value_count_pairs)` | Weighted average from (value, count) pairs | No |
|
|
213
|
+
| `mode(*nos)` | Most frequent value(s) | No |
|
|
214
|
+
| `median(*nos)` | Median | No |
|
|
215
|
+
| `hyp(a, b)` | Hypotenuse of a right triangle | No |
|
|
216
|
+
| `slope(point1, point2)` | Slope between two (x, y) points | No |
|
|
217
|
+
| `centroid(p1, p2, p3)` | Centroid of a triangle from three (x, y) points | No |
|
|
135
218
|
| `load(path)` | Loads a CSV/Excel/Google Sheet into a DataFrame and previews it | No |
|
|
136
219
|
| `loadh(df)` | Previews just the column headers | No |
|
|
137
220
|
| `loadc(df)` | Previews the record count | No |
|
|
@@ -141,7 +224,8 @@ Supported chart types: `line`, `bar`, `barh`, `scatter`, `hist`, `box`, `violin`
|
|
|
141
224
|
| `clean(df)` | Dedupes, strips whitespace, standardizes column names | No |
|
|
142
225
|
| `ask(data, question, api_key=...)` | Converts a plain-English question into SQL and runs it | **Yes** |
|
|
143
226
|
| `insights(df, api_key=...)` | Generates a plain-English summary of a dataset | **Yes** |
|
|
144
|
-
| `viz(df, kind="auto", ...)` | Visualizes a DataFrame — 12+ chart types | No |
|
|
227
|
+
| `viz(df, x=None, y=None, kind="auto", ...)` | Visualizes a DataFrame — 12+ chart types | No |
|
|
228
|
+
| `viz.bar/.scatter/.line/.box/.violin/.hist/.kde/.pie/.heatmap/.pairplot` | Namespace shortcuts for each chart type — auto-detect the loaded DataFrame | No |
|
|
145
229
|
|
|
146
230
|
## Development
|
|
147
231
|
|
fyrefly-0.4.0/README.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Fyrefly
|
|
2
|
+
|
|
3
|
+
A quant-based library to compute mathematical operations, run SQL queries, get AI-powered insights, and visualize your data.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install fyrefly
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage — Math functions
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from fyrefly import add, mul, div, mod, diff
|
|
15
|
+
|
|
16
|
+
add(5, 4, 6, 10) # 25
|
|
17
|
+
mul(5, 4, 6, 10) # 1200
|
|
18
|
+
div(100, 5, 2) # 10.0
|
|
19
|
+
mod(17, 5) # 2
|
|
20
|
+
diff(10, 3, 2) # 5
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Each function accepts any number of arguments:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
add(1) # 1
|
|
27
|
+
add(1, 2, 3, 4, 5) # 15
|
|
28
|
+
mul() # 1 (identity)
|
|
29
|
+
diff(10, 3) # 7
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage — Quant formulas
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from fyrefly import si, ci, si_ci_diff, profit, loss, ap, gp, hp, avg, avgc, mode, median, hyp, slope, centroid
|
|
36
|
+
|
|
37
|
+
# Interest
|
|
38
|
+
si(1000, 2, 5) # 100.0 (Simple Interest: p, n, r)
|
|
39
|
+
ci(1000, 2, 10) # 210.0 (Compound Interest, annual by default)
|
|
40
|
+
ci(1000, 2, 10, "semi-annual") # 215.5 (compounded twice a year)
|
|
41
|
+
si_ci_diff(1000, 10, 2) # 10.0 (CI - SI, supports n = 2 or 3 only)
|
|
42
|
+
|
|
43
|
+
# Profit / Loss — smart-detects if you called the wrong one
|
|
44
|
+
profit(120, 100) # 20
|
|
45
|
+
profit(120, 100, "%") # (20, 20.0) value + percentage
|
|
46
|
+
loss(80, 100) # 20
|
|
47
|
+
loss(80, 100, "%") # (20, 20.0)
|
|
48
|
+
profit(80, 100) # raises: "this is a LOSS, not a profit. Use loss(80, 100) instead."
|
|
49
|
+
|
|
50
|
+
# Sequences: AP, GP, HP
|
|
51
|
+
ap(2, 3, 4) # [2, 5, 8, 11] full sequence
|
|
52
|
+
ap.tn(2, 3, 4) # 11 nth term
|
|
53
|
+
ap.sn(2, 3, 4) # 26.0 sum of first n terms
|
|
54
|
+
|
|
55
|
+
gp(2, 3, 4) # [2, 6, 18, 54]
|
|
56
|
+
gp.tn(2, 3, 4) # 54
|
|
57
|
+
gp.sn(2, 3, 4) # 80.0
|
|
58
|
+
|
|
59
|
+
hp(2, 3, 4) # [2.0, 0.2857..., 0.1538..., 0.1052...]
|
|
60
|
+
hp.tn(2, 3, 4) # 0.10526315789473684
|
|
61
|
+
hp.sn(2, 3, 4) # 2.5448235974551765
|
|
62
|
+
|
|
63
|
+
# Averages, mode, median
|
|
64
|
+
avg(10, 12, 13) # 11.666666666666666 plain average of individual numbers
|
|
65
|
+
avgc(5, 3, 10, 2) # 7.0 weighted avg from (value, count) pairs
|
|
66
|
+
mode(1, 1, 2, 2) # [1, 2]
|
|
67
|
+
median(1, 2, 3, 4) # 2.5
|
|
68
|
+
|
|
69
|
+
# Geometry
|
|
70
|
+
hyp(3, 4) # 5.0
|
|
71
|
+
slope((1, 2), (3, 4)) # 1.0
|
|
72
|
+
centroid((1, 2), (3, 2), (4, 5)) # (2.6666666666666665, 3.0)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Usage — Data functions
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from fyrefly import load, loadh, loadc, loads, sql, xtract, clean
|
|
79
|
+
|
|
80
|
+
c = load("data.csv") # loads a CSV/Excel/Google Sheet, previews it
|
|
81
|
+
loadh(c) # preview column headers
|
|
82
|
+
loadc(c) # preview record count
|
|
83
|
+
loads(c) # preview schema (columns + datatypes)
|
|
84
|
+
|
|
85
|
+
c = clean(c) # dedupe, strip whitespace, standardize column names
|
|
86
|
+
|
|
87
|
+
d = sql("select * from c where age > 30") # run ANY SQL query on loaded data
|
|
88
|
+
xtract(d) # export the result to CSV
|
|
89
|
+
xtract(sql("select * from c"), filename="all.csv") # chained form also works
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Note:** for Google Sheets, the sheet must be shared as "Anyone with the link – Viewer" for `load()` to access it.
|
|
93
|
+
|
|
94
|
+
## Usage — AI functions (require an API key)
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from fyrefly import ask, insights
|
|
98
|
+
|
|
99
|
+
c = load("sales.csv")
|
|
100
|
+
|
|
101
|
+
# Ask questions in plain English — converted to SQL and run automatically
|
|
102
|
+
ask(c, "what were total sales by region last quarter?", api_key="AIza...")
|
|
103
|
+
|
|
104
|
+
# Query across multiple datasets (e.g. a join) — scales to any count
|
|
105
|
+
ask((c, d), "who are our top customers by total sales?", api_key="AIza...")
|
|
106
|
+
ask((c, d, e), "...", api_key="AIza...")
|
|
107
|
+
|
|
108
|
+
# Get a plain-English summary of a dataset
|
|
109
|
+
insights(c, api_key="AIza...")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The provider (Anthropic, OpenAI, Gemini, or any OpenAI-compatible API like Groq/Mistral) is **auto-detected from your API key's format** — you usually don't need to specify it. API keys can also be set via environment variables instead of passing them directly: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`.
|
|
113
|
+
|
|
114
|
+
Transient provider errors (rate limits, temporary server issues) are retried automatically with backoff before giving up.
|
|
115
|
+
|
|
116
|
+
⚠️ **Never commit an API key into a script you push to GitHub.** Use an environment variable instead:
|
|
117
|
+
```bash
|
|
118
|
+
export GEMINI_API_KEY="AIza..."
|
|
119
|
+
```
|
|
120
|
+
```python
|
|
121
|
+
ask(c, "what were total sales by region?") # picked up automatically from the env var
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Usage — Visualization (no AI, no API key needed)
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from fyrefly import viz
|
|
128
|
+
|
|
129
|
+
viz(c) # auto -> correlation heatmap
|
|
130
|
+
viz(c, "department") # auto -> bar chart of counts
|
|
131
|
+
viz(c, "age") # auto -> histogram
|
|
132
|
+
viz(c, "age", "salary") # auto -> scatter (both numeric)
|
|
133
|
+
viz(c, "department", "salary") # auto -> bar (mixed types)
|
|
134
|
+
viz(c, "age", "salary", kind="scatter")
|
|
135
|
+
viz(c, "department", "salary", kind="box")
|
|
136
|
+
viz(c, "department", kind="pie")
|
|
137
|
+
viz(c, "date", "revenue", kind="line")
|
|
138
|
+
viz(c, kind="pairplot", hue="department")
|
|
139
|
+
viz(c, "department", "salary", kind="bar", save="chart.png") # also saves a file
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Supported chart types: `line`, `bar`, `barh`, `scatter`, `hist`, `box`, `violin`, `kde`, `pie`, `heatmap`, `pairplot`, `area`, plus `"auto"` which picks a sensible chart based on your data.
|
|
143
|
+
|
|
144
|
+
### Namespace-style shortcuts
|
|
145
|
+
|
|
146
|
+
Once exactly one DataFrame is loaded, you can also call chart types directly, without repeating the DataFrame each time:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
c = load("data.csv")
|
|
150
|
+
|
|
151
|
+
viz.bar("department", "salary")
|
|
152
|
+
viz.scatter("age", "salary")
|
|
153
|
+
viz.line("date", "revenue")
|
|
154
|
+
viz.box("department", "salary")
|
|
155
|
+
viz.violin("department", "salary")
|
|
156
|
+
viz.hist("age") # single-column kinds take just x
|
|
157
|
+
viz.kde("salary")
|
|
158
|
+
viz.pie("department")
|
|
159
|
+
viz.heatmap() # no columns needed
|
|
160
|
+
viz.pairplot(hue="department") # no columns needed
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
If more than one DataFrame is loaded, the shortcut can't guess which one you mean — pass it explicitly as the first argument instead: `viz.bar(c, "department", "salary")`.
|
|
164
|
+
|
|
165
|
+
## Functions
|
|
166
|
+
|
|
167
|
+
| Function | Description | Needs API key? |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| `add(*nos)` | Adds all given numbers | No |
|
|
170
|
+
| `mul(*nos)` | Multiplies all given numbers | No |
|
|
171
|
+
| `div(*nos)` | Divides left to right: first ÷ second ÷ third ... | No |
|
|
172
|
+
| `mod(*nos)` | Finds remainder left to right: first % second % third ... | No |
|
|
173
|
+
| `diff(*nos)` | Subtracts left to right: first − second − third ... | No |
|
|
174
|
+
| `si(p, n, r)` | Simple Interest | No |
|
|
175
|
+
| `ci(p, n, r, freq)` | Compound Interest ("annual" or "semi-annual") | No |
|
|
176
|
+
| `si_ci_diff(p, r, n)` | CI − SI, for n = 2 or 3 years | No |
|
|
177
|
+
| `profit(sp, cp, "%")` | Profit value, or (value, %) if "%" passed — smart-detects a loss | No |
|
|
178
|
+
| `loss(sp, cp, "%")` | Loss value, or (value, %) if "%" passed — smart-detects a profit | No |
|
|
179
|
+
| `ap/.tn/.sn(a, d, n)` | Arithmetic Progression: sequence, nth term, sum of n terms | No |
|
|
180
|
+
| `gp/.tn/.sn(a, r, n)` | Geometric Progression: sequence, nth term, sum of n terms | No |
|
|
181
|
+
| `hp/.tn/.sn(a, d, n)` | Harmonic Progression: sequence, nth term, sum of n terms | No |
|
|
182
|
+
| `avg(*nos)` | Plain average of individual numbers | No |
|
|
183
|
+
| `avgc(*value_count_pairs)` | Weighted average from (value, count) pairs | No |
|
|
184
|
+
| `mode(*nos)` | Most frequent value(s) | No |
|
|
185
|
+
| `median(*nos)` | Median | No |
|
|
186
|
+
| `hyp(a, b)` | Hypotenuse of a right triangle | No |
|
|
187
|
+
| `slope(point1, point2)` | Slope between two (x, y) points | No |
|
|
188
|
+
| `centroid(p1, p2, p3)` | Centroid of a triangle from three (x, y) points | No |
|
|
189
|
+
| `load(path)` | Loads a CSV/Excel/Google Sheet into a DataFrame and previews it | No |
|
|
190
|
+
| `loadh(df)` | Previews just the column headers | No |
|
|
191
|
+
| `loadc(df)` | Previews the record count | No |
|
|
192
|
+
| `loads(df)` | Previews the schema (columns + datatypes) | No |
|
|
193
|
+
| `sql(query)` | Runs any SQL query against a loaded DataFrame, by variable name | No |
|
|
194
|
+
| `xtract(df, filename=None)` | Exports a DataFrame to CSV in the current directory | No |
|
|
195
|
+
| `clean(df)` | Dedupes, strips whitespace, standardizes column names | No |
|
|
196
|
+
| `ask(data, question, api_key=...)` | Converts a plain-English question into SQL and runs it | **Yes** |
|
|
197
|
+
| `insights(df, api_key=...)` | Generates a plain-English summary of a dataset | **Yes** |
|
|
198
|
+
| `viz(df, x=None, y=None, kind="auto", ...)` | Visualizes a DataFrame — 12+ chart types | No |
|
|
199
|
+
| `viz.bar/.scatter/.line/.box/.violin/.hist/.kde/.pie/.heatmap/.pairplot` | Namespace shortcuts for each chart type — auto-detect the loaded DataFrame | No |
|
|
200
|
+
|
|
201
|
+
## Development
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
pip install -e ".[dev]"
|
|
205
|
+
pytest
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
MIT
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "fyrefly"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "A quant-based library to compute mathematical operations, run SQL queries, get AI-powered insights, and visualize your data."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""A quant-based library for math, SQL-powered data analysis, AI, and visualization."""
|
|
2
|
+
|
|
3
|
+
from .core import add, mul, div, mod, diff
|
|
4
|
+
from .dataops import load, loadh, loadc, loads, sql, xtract, clean
|
|
5
|
+
from .ai import ask, insights
|
|
6
|
+
from .viz import viz
|
|
7
|
+
from .quant import (
|
|
8
|
+
si, ci, si_ci_diff,
|
|
9
|
+
profit, loss,
|
|
10
|
+
ap, gp, hp,
|
|
11
|
+
avg, avgc, mode, median,
|
|
12
|
+
hyp, slope, centroid,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"add", "mul", "div", "mod", "diff",
|
|
17
|
+
"load", "loadh", "loadc", "loads", "sql", "xtract", "clean",
|
|
18
|
+
"ask", "insights",
|
|
19
|
+
"viz",
|
|
20
|
+
"si", "ci", "si_ci_diff",
|
|
21
|
+
"profit", "loss",
|
|
22
|
+
"ap", "gp", "hp",
|
|
23
|
+
"avg", "avgc", "mode", "median",
|
|
24
|
+
"hyp", "slope", "centroid",
|
|
25
|
+
]
|
|
26
|
+
__version__ = "0.4.0"
|