scientific-computing-system-2.0 4.0.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.
- scientific_computing_system_2_0-4.0.0/LICENSE +21 -0
- scientific_computing_system_2_0-4.0.0/PKG-INFO +213 -0
- scientific_computing_system_2_0-4.0.0/README.md +158 -0
- scientific_computing_system_2_0-4.0.0/pyproject.toml +137 -0
- scientific_computing_system_2_0-4.0.0/setup.cfg +4 -0
- scientific_computing_system_2_0-4.0.0/setup.py +39 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/__init__.py +805 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/_version.py +3 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/bayes.py +228 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/calculus.py +170 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/chaos.py +358 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/cli.py +166 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/distributions.py +375 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/geometry.py +213 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/graph.py +388 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/hypothesis.py +164 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/infotheory.py +184 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/integrate.py +176 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/interpolate.py +98 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/io.py +118 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/knowledge.py +210 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/linalg.py +183 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/metaheuristics.py +241 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/ml.py +525 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/modeling.py +618 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/montecarlo.py +185 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/nlp/__init__.py +18 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/nlp/attention.py +73 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/nlp/autograd.py +134 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/nlp/gpt.py +120 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/nlp/tokenizer.py +87 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/optimize.py +245 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/py.typed +0 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/quantum.py +213 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/rl.py +233 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/scientific.py +268 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/signals.py +209 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/sparse.py +208 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/special.py +273 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/spectral.py +95 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/src/_fast_kmeans.c +227 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/src/_fast_pagerank.c +214 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/stats.py +411 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/timeseries.py +151 -0
- scientific_computing_system_2_0-4.0.0/src/cds2/viz.py +201 -0
- scientific_computing_system_2_0-4.0.0/src/scientific_computing_system_2.0.egg-info/PKG-INFO +213 -0
- scientific_computing_system_2_0-4.0.0/src/scientific_computing_system_2.0.egg-info/SOURCES.txt +88 -0
- scientific_computing_system_2_0-4.0.0/src/scientific_computing_system_2.0.egg-info/dependency_links.txt +1 -0
- scientific_computing_system_2_0-4.0.0/src/scientific_computing_system_2.0.egg-info/entry_points.txt +2 -0
- scientific_computing_system_2_0-4.0.0/src/scientific_computing_system_2.0.egg-info/requires.txt +32 -0
- scientific_computing_system_2_0-4.0.0/src/scientific_computing_system_2.0.egg-info/top_level.txt +1 -0
- scientific_computing_system_2_0-4.0.0/tests/test_bayes.py +164 -0
- scientific_computing_system_2_0-4.0.0/tests/test_benchmarks.py +64 -0
- scientific_computing_system_2_0-4.0.0/tests/test_calculus.py +94 -0
- scientific_computing_system_2_0-4.0.0/tests/test_chaos.py +192 -0
- scientific_computing_system_2_0-4.0.0/tests/test_cli.py +77 -0
- scientific_computing_system_2_0-4.0.0/tests/test_coverage_gaps.py +529 -0
- scientific_computing_system_2_0-4.0.0/tests/test_distributions.py +115 -0
- scientific_computing_system_2_0-4.0.0/tests/test_geometry.py +143 -0
- scientific_computing_system_2_0-4.0.0/tests/test_graph.py +221 -0
- scientific_computing_system_2_0-4.0.0/tests/test_hypothesis.py +109 -0
- scientific_computing_system_2_0-4.0.0/tests/test_industrial.py +121 -0
- scientific_computing_system_2_0-4.0.0/tests/test_infotheory.py +153 -0
- scientific_computing_system_2_0-4.0.0/tests/test_integrate.py +146 -0
- scientific_computing_system_2_0-4.0.0/tests/test_interpolate.py +80 -0
- scientific_computing_system_2_0-4.0.0/tests/test_io.py +63 -0
- scientific_computing_system_2_0-4.0.0/tests/test_knowledge.py +95 -0
- scientific_computing_system_2_0-4.0.0/tests/test_linalg.py +105 -0
- scientific_computing_system_2_0-4.0.0/tests/test_mcmc.py +65 -0
- scientific_computing_system_2_0-4.0.0/tests/test_metaheuristics.py +107 -0
- scientific_computing_system_2_0-4.0.0/tests/test_ml.py +163 -0
- scientific_computing_system_2_0-4.0.0/tests/test_modeling.py +346 -0
- scientific_computing_system_2_0-4.0.0/tests/test_montecarlo.py +52 -0
- scientific_computing_system_2_0-4.0.0/tests/test_nlp.py +164 -0
- scientific_computing_system_2_0-4.0.0/tests/test_optimize.py +137 -0
- scientific_computing_system_2_0-4.0.0/tests/test_quantum.py +106 -0
- scientific_computing_system_2_0-4.0.0/tests/test_resampling.py +63 -0
- scientific_computing_system_2_0-4.0.0/tests/test_rl.py +138 -0
- scientific_computing_system_2_0-4.0.0/tests/test_scientific.py +160 -0
- scientific_computing_system_2_0-4.0.0/tests/test_signals.py +111 -0
- scientific_computing_system_2_0-4.0.0/tests/test_sparse.py +72 -0
- scientific_computing_system_2_0-4.0.0/tests/test_special.py +95 -0
- scientific_computing_system_2_0-4.0.0/tests/test_spectral.py +60 -0
- scientific_computing_system_2_0-4.0.0/tests/test_stats.py +153 -0
- scientific_computing_system_2_0-4.0.0/tests/test_timeseries.py +110 -0
- scientific_computing_system_2_0-4.0.0/tests/test_v31_industrial.py +110 -0
- scientific_computing_system_2_0-4.0.0/tests/test_v33_arcs.py +244 -0
- scientific_computing_system_2_0-4.0.0/tests/test_v33_gaps.py +245 -0
- scientific_computing_system_2_0-4.0.0/tests/test_v3_expansion.py +247 -0
- scientific_computing_system_2_0-4.0.0/tests/test_viz.py +81 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Furox88
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scientific-computing-system-2.0
|
|
3
|
+
Version: 4.0.0
|
|
4
|
+
Summary: A NumPy/SciPy/Pandas/Matplotlib-powered scientific computing platform: accelerated linear algebra, statistics, optimization, integration, interpolation, signal processing, Monte Carlo, graphs (with PageRank), machine learning, time series, visualization and I/O.
|
|
5
|
+
Author-email: Furox88 <furkanarkn1451@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Furox-Art/scientific-computing-system-2.0
|
|
8
|
+
Project-URL: Repository, https://github.com/Furox-Art/scientific-computing-system-2.0
|
|
9
|
+
Project-URL: Issues, https://github.com/Furox-Art/scientific-computing-system-2.0/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/Furox-Art/scientific-computing-system-2.0/releases
|
|
11
|
+
Keywords: scientific-computing,numpy,scipy,pandas,matplotlib,machine-learning,signal-processing,statistics,optimization,monte-carlo,graph-theory,pagerank,time-series,numerical-methods,data-analysis
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: numpy>=1.26
|
|
26
|
+
Requires-Dist: scipy>=1.11
|
|
27
|
+
Requires-Dist: pandas>=2.2
|
|
28
|
+
Requires-Dist: matplotlib>=3.8
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: openpyxl; extra == "dev"
|
|
31
|
+
Requires-Dist: pyarrow; extra == "dev"
|
|
32
|
+
Requires-Dist: pandas-stubs>=2.0; extra == "dev"
|
|
33
|
+
Requires-Dist: numpy<2.5,>=1.26; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
36
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
37
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
38
|
+
Provides-Extra: docs
|
|
39
|
+
Requires-Dist: mkdocs>=1.6; extra == "docs"
|
|
40
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
41
|
+
Requires-Dist: mkdocstrings[python]>=0.26; extra == "docs"
|
|
42
|
+
Provides-Extra: all
|
|
43
|
+
Requires-Dist: openpyxl; extra == "all"
|
|
44
|
+
Requires-Dist: pyarrow; extra == "all"
|
|
45
|
+
Requires-Dist: pandas-stubs>=2.0; extra == "all"
|
|
46
|
+
Requires-Dist: numpy<2.5,>=1.26; extra == "all"
|
|
47
|
+
Requires-Dist: pytest>=8.0; extra == "all"
|
|
48
|
+
Requires-Dist: pytest-cov; extra == "all"
|
|
49
|
+
Requires-Dist: ruff>=0.4; extra == "all"
|
|
50
|
+
Requires-Dist: mypy>=1.10; extra == "all"
|
|
51
|
+
Requires-Dist: mkdocs>=1.6; extra == "all"
|
|
52
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "all"
|
|
53
|
+
Requires-Dist: mkdocstrings[python]>=0.26; extra == "all"
|
|
54
|
+
Dynamic: license-file
|
|
55
|
+
|
|
56
|
+
# scientific-computing-system-2.0
|
|
57
|
+
|
|
58
|
+
[](https://github.com/Furox-Art/scientific-computing-system-2.0/actions/workflows/tests.yml)
|
|
59
|
+
[](https://pypi.org/project/scientific-computing-system-2.0/)
|
|
60
|
+
[](https://pypi.org/project/scientific-computing-system-2.0/)
|
|
61
|
+
[](LICENSE)
|
|
62
|
+
[](https://github.com/astral-sh/ruff)
|
|
63
|
+
|
|
64
|
+
**CDS v2** is a scientific computing platform built on the scientific Python
|
|
65
|
+
stack — NumPy, SciPy, pandas and matplotlib. The algorithms proven in the
|
|
66
|
+
pure-Python [cognitive-discovery-system](https://github.com/Furox88/cognitive-discovery-system)
|
|
67
|
+
(v1.x) form its foundation; v2 rebuilds them for speed and adds new domain
|
|
68
|
+
modules on top.
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install scientific-computing-system-2.0
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
From source:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
git clone https://github.com/Furox-Art/scientific-computing-system-2.0.git
|
|
80
|
+
cd scientific-computing-system-2.0
|
|
81
|
+
pip install -e .[dev]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Quick start
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
import numpy as np
|
|
88
|
+
import cds2
|
|
89
|
+
|
|
90
|
+
# Linear algebra
|
|
91
|
+
A = [[3.0, 1.0], [1.0, 2.0]]
|
|
92
|
+
b = [9.0, 8.0]
|
|
93
|
+
x = cds2.linalg.solve(A, b)
|
|
94
|
+
|
|
95
|
+
# Statistics
|
|
96
|
+
r = cds2.stats.independent_t_test([1, 2, 3, 4, 5], [3, 4, 5, 6, 7])
|
|
97
|
+
|
|
98
|
+
# Optimization
|
|
99
|
+
res = cds2.optimize.minimize(lambda v: (v[0] - 2) ** 2 + (v[1] + 1) ** 2, x0=[0.0, 0.0])
|
|
100
|
+
print(res.x) # ~ [2.0, -1.0]
|
|
101
|
+
|
|
102
|
+
# Signals
|
|
103
|
+
freqs, psd = cds2.signals.power_spectrum(np.sin(np.linspace(0, 100, 1024)), fs=256.0)
|
|
104
|
+
|
|
105
|
+
# Graphs with PageRank
|
|
106
|
+
adj = cds2.graph.from_edges(4, [(0, 1), (0, 2), (1, 3), (2, 3)], directed=True)
|
|
107
|
+
scores = cds2.graph.pagerank(adj)
|
|
108
|
+
|
|
109
|
+
# Information theory
|
|
110
|
+
h = cds2.infotheory.entropy([0.25, 0.25, 0.25, 0.25])
|
|
111
|
+
mi = cds2.infotheory.mutual_information([[0.5, 0.0], [0.0, 0.5]])
|
|
112
|
+
|
|
113
|
+
# Chaos / nonlinear dynamics
|
|
114
|
+
series = cds2.chaos.logistic_map(3.99, length=400, seed=1)
|
|
115
|
+
lyap = cds2.chaos.largest_lyapunov_exponent(series)
|
|
116
|
+
|
|
117
|
+
# Bayesian conjugate updates
|
|
118
|
+
post = cds2.bayes.beta_binomial_update(successes=7, failures=3)
|
|
119
|
+
print(post.mean) # 0.7
|
|
120
|
+
|
|
121
|
+
# Metaheuristics
|
|
122
|
+
res = cds2.metaheuristics.pso_minimize(lambda v: (v[0] - 3) ** 2, [(-10, 10)], seed=1)
|
|
123
|
+
|
|
124
|
+
# Geometry
|
|
125
|
+
area = cds2.geometry.hull_area([(0, 0), (1, 0), (0, 1)])
|
|
126
|
+
|
|
127
|
+
# Reinforcement learning
|
|
128
|
+
q_values, returns = cds2.rl.q_learn(cds2.rl.GridWorld(4, 4), episodes=300, seed=1)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Modules
|
|
132
|
+
|
|
133
|
+
| Module | Built on | Highlights |
|
|
134
|
+
|---|---|---|
|
|
135
|
+
| `cds2.linalg` | NumPy | solve, det, inv, pinv, eig/eigh, SVD, least squares, cholesky, cond |
|
|
136
|
+
| `cds2.stats` | scipy.stats | t-tests, ANOVA, non-parametrics, correlations, chi-square, effect sizes, normal dist helpers |
|
|
137
|
+
| `cds2.optimize` | scipy.optimize | minimize, roots (brentq/newton/system), linprog, least squares, curve fit |
|
|
138
|
+
| `cds2.integrate` | scipy.integrate | quad, 2-D/3-D integration, ODE solvers, trapezoid/simpson |
|
|
139
|
+
| `cds2.interpolate` | scipy.interpolate | linear/cubic/pchip, lagrange, griddata, regular grids |
|
|
140
|
+
| `cds2.signals` | scipy.signal | FFT, PSD/welch/spectrogram, Butterworth filters, peaks, envelope |
|
|
141
|
+
| `cds2.montecarlo` | NumPy Generator | pi estimate, MC integration/expectation, hit-or-miss (all seedable) |
|
|
142
|
+
| `cds2.graph` | scipy.sparse.csgraph | components, Dijkstra/Bellman-Ford/Floyd-Warshall, MST, topological order, PageRank |
|
|
143
|
+
| `cds2.ml` | NumPy/SciPy | LinearRegression, LogisticRegression, KMeans++, PCA, KNN, metrics, data generators |
|
|
144
|
+
| `cds2.timeseries` | pandas | moving average, EWM, differencing, seasonal decomposition, ACF/PACF, Ljung-Box |
|
|
145
|
+
| `cds2.viz` | matplotlib | series/histogram/scatter/heatmap/spectrum/regression/confusion plots |
|
|
146
|
+
| `cds2.io` | pandas | CSV/JSON read-write, optional Excel/Parquet bridges, DataFrame summaries |
|
|
147
|
+
| `cds2.calculus` | NumPy | derivative, complex-step gradient, jacobian, hessian |
|
|
148
|
+
| `cds2.special` | scipy.special | gamma, erf family, beta, Bessels, zeta |
|
|
149
|
+
| `cds2.sparse` | scipy.sparse.linalg | CG/GMRES/BiCGSTAB solvers, Lanczos eigenpairs, truncated SVD |
|
|
150
|
+
| `cds2.distributions` | scipy.stats | t, chi2, F, exponential, uniform, lognormal, poisson, binomial (pdf/cdf/ppf) |
|
|
151
|
+
| `cds2.spectral` | scipy.sparse | Laplacians, Fiedler vector, algebraic connectivity, spectral clustering |
|
|
152
|
+
| `cds2.infotheory` | NumPy | Shannon/joint/conditional entropy, KL & Jensen-Shannon divergence, mutual information, permutation entropy |
|
|
153
|
+
| `cds2.chaos` | NumPy | delay embedding, false nearest neighbours, Lyapunov exponent, correlation dimension, sample entropy, Hurst exponent, bifurcation scans |
|
|
154
|
+
| `cds2.bayes` | scipy.stats | Beta-Binomial / Normal-Normal / Gamma-Poisson conjugate updates, credible intervals, naive Bayes, Metropolis posteriors |
|
|
155
|
+
| `cds2.metaheuristics` | NumPy | real-coded genetic algorithm, particle swarm optimization, simulated annealing |
|
|
156
|
+
| `cds2.geometry` | scipy.spatial | convex hull, closest pair, point-in-polygon, polygon area/perimeter, line-segment intersection, rotations |
|
|
157
|
+
| `cds2.rl` | NumPy | Bernoulli bandits (epsilon-greedy, UCB1), tabular Q-learning, grid-world environment |
|
|
158
|
+
|
|
159
|
+
## CLI
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
cds2 info
|
|
163
|
+
cds2 stats 1,2,3,4,5
|
|
164
|
+
cds2 integrate sin --a 0 --b 3.14159
|
|
165
|
+
cds2 linsolve --a "3,1;1,2" --b "9,8"
|
|
166
|
+
cds2 plot 1,3,2,5,4 --file out.png
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Relationship to CDS v1.x
|
|
170
|
+
|
|
171
|
+
The original zero-dependency pure-Python line lives at
|
|
172
|
+
[Furox88/cognitive-discovery-system](https://github.com/Furox88/cognitive-discovery-system)
|
|
173
|
+
and remains available. v2 is an independent project that trades that
|
|
174
|
+
constraint for the speed and breadth of the scientific Python ecosystem.
|
|
175
|
+
|
|
176
|
+
Runnable case studies live in [examples/](examples/) - see the docs page for details.
|
|
177
|
+
|
|
178
|
+
## Benchmarks
|
|
179
|
+
|
|
180
|
+
cds2 races the scientific stack head-to-head — and ships its own **compiled C
|
|
181
|
+
kernels** where they help. Current scoreboard (full methodology in
|
|
182
|
+
[docs/benchmarks.md](docs/benchmarks.md)):
|
|
183
|
+
|
|
184
|
+
| Race | Baseline | cds2/baseline |
|
|
185
|
+
|---|---|---:|
|
|
186
|
+
| PageRank 400n (C kernel) | NetworkX | **0.18x** |
|
|
187
|
+
| K-Means 4k×2 k=8 (C kernel) | scikit-learn | **0.72x** |
|
|
188
|
+
| Linear regression 20k×10 | scikit-learn | **0.74x** |
|
|
189
|
+
| Monte Carlo pi 2M | hand-vectorized NumPy | **0.77x** |
|
|
190
|
+
| solve / eigh / rfft / welch / minimize | NumPy & SciPy | ~1.00x |
|
|
191
|
+
| describe 500k (adds quartiles) | SciPy | 1.10x |
|
|
192
|
+
|
|
193
|
+
Wrapper APIs hold parity with raw NumPy/SciPy; the KMeans Lloyd loop and
|
|
194
|
+
PageRank power iteration are from-scratch C extensions (`cds2._fast_kmeans`,
|
|
195
|
+
`cds2._fast_pagerank`) that beat the specialist libraries. A pure-Python
|
|
196
|
+
fallback wheel keeps compiler-less installs working.
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
python benchmarks/run_benchmarks.py # full run
|
|
200
|
+
python benchmarks/run_benchmarks.py --quick # smoke run
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Development
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
pip install -e .[dev]
|
|
207
|
+
pytest # run the test suite
|
|
208
|
+
ruff check . # lint
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## License
|
|
212
|
+
|
|
213
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# scientific-computing-system-2.0
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Furox-Art/scientific-computing-system-2.0/actions/workflows/tests.yml)
|
|
4
|
+
[](https://pypi.org/project/scientific-computing-system-2.0/)
|
|
5
|
+
[](https://pypi.org/project/scientific-computing-system-2.0/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/astral-sh/ruff)
|
|
8
|
+
|
|
9
|
+
**CDS v2** is a scientific computing platform built on the scientific Python
|
|
10
|
+
stack — NumPy, SciPy, pandas and matplotlib. The algorithms proven in the
|
|
11
|
+
pure-Python [cognitive-discovery-system](https://github.com/Furox88/cognitive-discovery-system)
|
|
12
|
+
(v1.x) form its foundation; v2 rebuilds them for speed and adds new domain
|
|
13
|
+
modules on top.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install scientific-computing-system-2.0
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
From source:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
git clone https://github.com/Furox-Art/scientific-computing-system-2.0.git
|
|
25
|
+
cd scientific-computing-system-2.0
|
|
26
|
+
pip install -e .[dev]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import numpy as np
|
|
33
|
+
import cds2
|
|
34
|
+
|
|
35
|
+
# Linear algebra
|
|
36
|
+
A = [[3.0, 1.0], [1.0, 2.0]]
|
|
37
|
+
b = [9.0, 8.0]
|
|
38
|
+
x = cds2.linalg.solve(A, b)
|
|
39
|
+
|
|
40
|
+
# Statistics
|
|
41
|
+
r = cds2.stats.independent_t_test([1, 2, 3, 4, 5], [3, 4, 5, 6, 7])
|
|
42
|
+
|
|
43
|
+
# Optimization
|
|
44
|
+
res = cds2.optimize.minimize(lambda v: (v[0] - 2) ** 2 + (v[1] + 1) ** 2, x0=[0.0, 0.0])
|
|
45
|
+
print(res.x) # ~ [2.0, -1.0]
|
|
46
|
+
|
|
47
|
+
# Signals
|
|
48
|
+
freqs, psd = cds2.signals.power_spectrum(np.sin(np.linspace(0, 100, 1024)), fs=256.0)
|
|
49
|
+
|
|
50
|
+
# Graphs with PageRank
|
|
51
|
+
adj = cds2.graph.from_edges(4, [(0, 1), (0, 2), (1, 3), (2, 3)], directed=True)
|
|
52
|
+
scores = cds2.graph.pagerank(adj)
|
|
53
|
+
|
|
54
|
+
# Information theory
|
|
55
|
+
h = cds2.infotheory.entropy([0.25, 0.25, 0.25, 0.25])
|
|
56
|
+
mi = cds2.infotheory.mutual_information([[0.5, 0.0], [0.0, 0.5]])
|
|
57
|
+
|
|
58
|
+
# Chaos / nonlinear dynamics
|
|
59
|
+
series = cds2.chaos.logistic_map(3.99, length=400, seed=1)
|
|
60
|
+
lyap = cds2.chaos.largest_lyapunov_exponent(series)
|
|
61
|
+
|
|
62
|
+
# Bayesian conjugate updates
|
|
63
|
+
post = cds2.bayes.beta_binomial_update(successes=7, failures=3)
|
|
64
|
+
print(post.mean) # 0.7
|
|
65
|
+
|
|
66
|
+
# Metaheuristics
|
|
67
|
+
res = cds2.metaheuristics.pso_minimize(lambda v: (v[0] - 3) ** 2, [(-10, 10)], seed=1)
|
|
68
|
+
|
|
69
|
+
# Geometry
|
|
70
|
+
area = cds2.geometry.hull_area([(0, 0), (1, 0), (0, 1)])
|
|
71
|
+
|
|
72
|
+
# Reinforcement learning
|
|
73
|
+
q_values, returns = cds2.rl.q_learn(cds2.rl.GridWorld(4, 4), episodes=300, seed=1)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Modules
|
|
77
|
+
|
|
78
|
+
| Module | Built on | Highlights |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `cds2.linalg` | NumPy | solve, det, inv, pinv, eig/eigh, SVD, least squares, cholesky, cond |
|
|
81
|
+
| `cds2.stats` | scipy.stats | t-tests, ANOVA, non-parametrics, correlations, chi-square, effect sizes, normal dist helpers |
|
|
82
|
+
| `cds2.optimize` | scipy.optimize | minimize, roots (brentq/newton/system), linprog, least squares, curve fit |
|
|
83
|
+
| `cds2.integrate` | scipy.integrate | quad, 2-D/3-D integration, ODE solvers, trapezoid/simpson |
|
|
84
|
+
| `cds2.interpolate` | scipy.interpolate | linear/cubic/pchip, lagrange, griddata, regular grids |
|
|
85
|
+
| `cds2.signals` | scipy.signal | FFT, PSD/welch/spectrogram, Butterworth filters, peaks, envelope |
|
|
86
|
+
| `cds2.montecarlo` | NumPy Generator | pi estimate, MC integration/expectation, hit-or-miss (all seedable) |
|
|
87
|
+
| `cds2.graph` | scipy.sparse.csgraph | components, Dijkstra/Bellman-Ford/Floyd-Warshall, MST, topological order, PageRank |
|
|
88
|
+
| `cds2.ml` | NumPy/SciPy | LinearRegression, LogisticRegression, KMeans++, PCA, KNN, metrics, data generators |
|
|
89
|
+
| `cds2.timeseries` | pandas | moving average, EWM, differencing, seasonal decomposition, ACF/PACF, Ljung-Box |
|
|
90
|
+
| `cds2.viz` | matplotlib | series/histogram/scatter/heatmap/spectrum/regression/confusion plots |
|
|
91
|
+
| `cds2.io` | pandas | CSV/JSON read-write, optional Excel/Parquet bridges, DataFrame summaries |
|
|
92
|
+
| `cds2.calculus` | NumPy | derivative, complex-step gradient, jacobian, hessian |
|
|
93
|
+
| `cds2.special` | scipy.special | gamma, erf family, beta, Bessels, zeta |
|
|
94
|
+
| `cds2.sparse` | scipy.sparse.linalg | CG/GMRES/BiCGSTAB solvers, Lanczos eigenpairs, truncated SVD |
|
|
95
|
+
| `cds2.distributions` | scipy.stats | t, chi2, F, exponential, uniform, lognormal, poisson, binomial (pdf/cdf/ppf) |
|
|
96
|
+
| `cds2.spectral` | scipy.sparse | Laplacians, Fiedler vector, algebraic connectivity, spectral clustering |
|
|
97
|
+
| `cds2.infotheory` | NumPy | Shannon/joint/conditional entropy, KL & Jensen-Shannon divergence, mutual information, permutation entropy |
|
|
98
|
+
| `cds2.chaos` | NumPy | delay embedding, false nearest neighbours, Lyapunov exponent, correlation dimension, sample entropy, Hurst exponent, bifurcation scans |
|
|
99
|
+
| `cds2.bayes` | scipy.stats | Beta-Binomial / Normal-Normal / Gamma-Poisson conjugate updates, credible intervals, naive Bayes, Metropolis posteriors |
|
|
100
|
+
| `cds2.metaheuristics` | NumPy | real-coded genetic algorithm, particle swarm optimization, simulated annealing |
|
|
101
|
+
| `cds2.geometry` | scipy.spatial | convex hull, closest pair, point-in-polygon, polygon area/perimeter, line-segment intersection, rotations |
|
|
102
|
+
| `cds2.rl` | NumPy | Bernoulli bandits (epsilon-greedy, UCB1), tabular Q-learning, grid-world environment |
|
|
103
|
+
|
|
104
|
+
## CLI
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
cds2 info
|
|
108
|
+
cds2 stats 1,2,3,4,5
|
|
109
|
+
cds2 integrate sin --a 0 --b 3.14159
|
|
110
|
+
cds2 linsolve --a "3,1;1,2" --b "9,8"
|
|
111
|
+
cds2 plot 1,3,2,5,4 --file out.png
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Relationship to CDS v1.x
|
|
115
|
+
|
|
116
|
+
The original zero-dependency pure-Python line lives at
|
|
117
|
+
[Furox88/cognitive-discovery-system](https://github.com/Furox88/cognitive-discovery-system)
|
|
118
|
+
and remains available. v2 is an independent project that trades that
|
|
119
|
+
constraint for the speed and breadth of the scientific Python ecosystem.
|
|
120
|
+
|
|
121
|
+
Runnable case studies live in [examples/](examples/) - see the docs page for details.
|
|
122
|
+
|
|
123
|
+
## Benchmarks
|
|
124
|
+
|
|
125
|
+
cds2 races the scientific stack head-to-head — and ships its own **compiled C
|
|
126
|
+
kernels** where they help. Current scoreboard (full methodology in
|
|
127
|
+
[docs/benchmarks.md](docs/benchmarks.md)):
|
|
128
|
+
|
|
129
|
+
| Race | Baseline | cds2/baseline |
|
|
130
|
+
|---|---|---:|
|
|
131
|
+
| PageRank 400n (C kernel) | NetworkX | **0.18x** |
|
|
132
|
+
| K-Means 4k×2 k=8 (C kernel) | scikit-learn | **0.72x** |
|
|
133
|
+
| Linear regression 20k×10 | scikit-learn | **0.74x** |
|
|
134
|
+
| Monte Carlo pi 2M | hand-vectorized NumPy | **0.77x** |
|
|
135
|
+
| solve / eigh / rfft / welch / minimize | NumPy & SciPy | ~1.00x |
|
|
136
|
+
| describe 500k (adds quartiles) | SciPy | 1.10x |
|
|
137
|
+
|
|
138
|
+
Wrapper APIs hold parity with raw NumPy/SciPy; the KMeans Lloyd loop and
|
|
139
|
+
PageRank power iteration are from-scratch C extensions (`cds2._fast_kmeans`,
|
|
140
|
+
`cds2._fast_pagerank`) that beat the specialist libraries. A pure-Python
|
|
141
|
+
fallback wheel keeps compiler-less installs working.
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
python benchmarks/run_benchmarks.py # full run
|
|
145
|
+
python benchmarks/run_benchmarks.py --quick # smoke run
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Development
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pip install -e .[dev]
|
|
152
|
+
pytest # run the test suite
|
|
153
|
+
ruff check . # lint
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "scientific-computing-system-2.0"
|
|
7
|
+
version = "4.0.0"
|
|
8
|
+
description = "A NumPy/SciPy/Pandas/Matplotlib-powered scientific computing platform: accelerated linear algebra, statistics, optimization, integration, interpolation, signal processing, Monte Carlo, graphs (with PageRank), machine learning, time series, visualization and I/O."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Furox88", email = "furkanarkn1451@gmail.com"},
|
|
15
|
+
]
|
|
16
|
+
keywords = [
|
|
17
|
+
"scientific-computing",
|
|
18
|
+
"numpy",
|
|
19
|
+
"scipy",
|
|
20
|
+
"pandas",
|
|
21
|
+
"matplotlib",
|
|
22
|
+
"machine-learning",
|
|
23
|
+
"signal-processing",
|
|
24
|
+
"statistics",
|
|
25
|
+
"optimization",
|
|
26
|
+
"monte-carlo",
|
|
27
|
+
"graph-theory",
|
|
28
|
+
"pagerank",
|
|
29
|
+
"time-series",
|
|
30
|
+
"numerical-methods",
|
|
31
|
+
"data-analysis",
|
|
32
|
+
]
|
|
33
|
+
classifiers = [
|
|
34
|
+
"Development Status :: 5 - Production/Stable",
|
|
35
|
+
"Intended Audience :: Science/Research",
|
|
36
|
+
"Programming Language :: Python :: 3",
|
|
37
|
+
"Programming Language :: Python :: 3.10",
|
|
38
|
+
"Programming Language :: Python :: 3.11",
|
|
39
|
+
"Programming Language :: Python :: 3.12",
|
|
40
|
+
"Programming Language :: Python :: 3.13",
|
|
41
|
+
"Topic :: Scientific/Engineering",
|
|
42
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
43
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
44
|
+
]
|
|
45
|
+
dependencies = [
|
|
46
|
+
"numpy>=1.26",
|
|
47
|
+
"scipy>=1.11",
|
|
48
|
+
"pandas>=2.2",
|
|
49
|
+
"matplotlib>=3.8",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[project.optional-dependencies]
|
|
53
|
+
dev = [
|
|
54
|
+
"openpyxl",
|
|
55
|
+
"pyarrow",
|
|
56
|
+
"pandas-stubs>=2.0",
|
|
57
|
+
# Cap numpy under 2.5 for the dev toolchain only: numpy>=2.5 stubs use
|
|
58
|
+
# `type` statements that mypy cannot parse with python_version = "3.10".
|
|
59
|
+
# The runtime dependency floor (numpy>=1.26) is unchanged.
|
|
60
|
+
"numpy>=1.26,<2.5",
|
|
61
|
+
"pytest>=8.0",
|
|
62
|
+
"pytest-cov",
|
|
63
|
+
"ruff>=0.4",
|
|
64
|
+
"mypy>=1.10",
|
|
65
|
+
]
|
|
66
|
+
docs = [
|
|
67
|
+
"mkdocs>=1.6",
|
|
68
|
+
"mkdocs-material>=9.5",
|
|
69
|
+
"mkdocstrings[python]>=0.26",
|
|
70
|
+
]
|
|
71
|
+
all = [
|
|
72
|
+
"openpyxl",
|
|
73
|
+
"pyarrow",
|
|
74
|
+
"pandas-stubs>=2.0",
|
|
75
|
+
"numpy>=1.26,<2.5",
|
|
76
|
+
"pytest>=8.0",
|
|
77
|
+
"pytest-cov",
|
|
78
|
+
"ruff>=0.4",
|
|
79
|
+
"mypy>=1.10",
|
|
80
|
+
"mkdocs>=1.6",
|
|
81
|
+
"mkdocs-material>=9.5",
|
|
82
|
+
"mkdocstrings[python]>=0.26",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
[project.scripts]
|
|
86
|
+
cds2 = "cds2.cli:main"
|
|
87
|
+
|
|
88
|
+
[project.urls]
|
|
89
|
+
Homepage = "https://github.com/Furox-Art/scientific-computing-system-2.0"
|
|
90
|
+
Repository = "https://github.com/Furox-Art/scientific-computing-system-2.0"
|
|
91
|
+
Issues = "https://github.com/Furox-Art/scientific-computing-system-2.0/issues"
|
|
92
|
+
Changelog = "https://github.com/Furox-Art/scientific-computing-system-2.0/releases"
|
|
93
|
+
|
|
94
|
+
[tool.setuptools.packages.find]
|
|
95
|
+
where = ["src"]
|
|
96
|
+
include = ["cds2*"]
|
|
97
|
+
|
|
98
|
+
[tool.setuptools.package-data]
|
|
99
|
+
cds2 = ["py.typed"]
|
|
100
|
+
|
|
101
|
+
[tool.mypy]
|
|
102
|
+
python_version = "3.10"
|
|
103
|
+
strict = true
|
|
104
|
+
files = ["src/cds2"]
|
|
105
|
+
|
|
106
|
+
[[tool.mypy.overrides]]
|
|
107
|
+
# SciPy and Matplotlib ship no inline types or stubs; their APIs are used
|
|
108
|
+
# through thin wrappers so the Any leakage is contained at call boundaries.
|
|
109
|
+
module = ["scipy.*", "matplotlib.*", "openpyxl.*"]
|
|
110
|
+
ignore_missing_imports = true
|
|
111
|
+
|
|
112
|
+
[tool.ruff]
|
|
113
|
+
line-length = 100
|
|
114
|
+
target-version = "py310"
|
|
115
|
+
|
|
116
|
+
[tool.ruff.lint]
|
|
117
|
+
select = ["E", "F", "I", "UP"]
|
|
118
|
+
ignore = ["E501"]
|
|
119
|
+
|
|
120
|
+
[tool.pytest.ini_options]
|
|
121
|
+
testpaths = ["tests"]
|
|
122
|
+
python_files = "test_*.py"
|
|
123
|
+
pythonpath = ["src", "."]
|
|
124
|
+
addopts = ["--strict-markers", "--strict-config"]
|
|
125
|
+
|
|
126
|
+
[tool.coverage.run]
|
|
127
|
+
source = ["src/cds2"]
|
|
128
|
+
branch = true
|
|
129
|
+
|
|
130
|
+
[tool.coverage.report]
|
|
131
|
+
show_missing = true
|
|
132
|
+
fail_under = 100
|
|
133
|
+
exclude_lines = [
|
|
134
|
+
"pragma: no cover",
|
|
135
|
+
"if __name__ == .__main__.:",
|
|
136
|
+
"if TYPE_CHECKING:",
|
|
137
|
+
]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Build script: declares the optional compiled accelerators."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from setuptools import Extension, setup
|
|
7
|
+
|
|
8
|
+
# OpenMP is enabled only where the toolchain handles our loop shapes:
|
|
9
|
+
# GCC on Linux (the industrial server target). MSVC's legacy OpenMP
|
|
10
|
+
# rejects Py_ssize_t/int-mixed loops (C3015) and Apple clang needs a
|
|
11
|
+
# separate libomp, so Windows and macOS build the serial kernel.
|
|
12
|
+
extra_compile_args: list[str] = []
|
|
13
|
+
extra_link_args: list[str] = []
|
|
14
|
+
if os.environ.get("CDS_NO_OPENMP") != "1" and sys.platform == "linux":
|
|
15
|
+
extra_compile_args = ["-O3", "-fopenmp"]
|
|
16
|
+
extra_link_args = ["-fopenmp"]
|
|
17
|
+
|
|
18
|
+
extensions = []
|
|
19
|
+
if os.environ.get("CDS_PURE") != "1":
|
|
20
|
+
# optional=True keeps installation working on machines without a C
|
|
21
|
+
# compiler; cds2 then uses its NumPy fallback at runtime.
|
|
22
|
+
extensions.append(
|
|
23
|
+
Extension(
|
|
24
|
+
"cds2._fast_kmeans",
|
|
25
|
+
sources=["src/cds2/src/_fast_kmeans.c"],
|
|
26
|
+
extra_compile_args=extra_compile_args,
|
|
27
|
+
extra_link_args=extra_link_args,
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
extensions.append(
|
|
31
|
+
Extension(
|
|
32
|
+
"cds2._fast_pagerank",
|
|
33
|
+
sources=["src/cds2/src/_fast_pagerank.c"],
|
|
34
|
+
extra_compile_args=extra_compile_args,
|
|
35
|
+
extra_link_args=extra_link_args,
|
|
36
|
+
)
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
setup(ext_modules=extensions)
|