numpy-ts 0.1.0 → 0.2.0
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.
- package/README.md +36 -39
- package/dist/numpy-ts.browser.js +2 -2
- package/dist/numpy-ts.esm.js +2 -2
- package/dist/numpy-ts.node.cjs +2 -2
- package/dist/types/core/ndarray.d.ts +40 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/compute.d.ts +9 -0
- package/dist/types/ops/arithmetic.d.ts +59 -0
- package/dist/types/ops/exponential.d.ts +28 -0
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -5,14 +5,13 @@ Complete NumPy implementation for TypeScript and JavaScript
|
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|

|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
> This project is under construction and is currently unstable. Expect breaking changes.
|
|
8
|
+
**⚠️ WARNING: This project is under construction and is currently unstable. Expect breaking changes.**
|
|
10
9
|
|
|
11
10
|
---
|
|
12
11
|
|
|
13
12
|
## What is numpy-ts?
|
|
14
13
|
|
|
15
|
-
A complete, functionally-equivalent implementation of NumPy 2.0+ for the JavaScript ecosystem. (At least that's the goal!)
|
|
14
|
+
A complete, functionally-equivalent implementation of NumPy 2.0+ for the TypeScript/JavaScript ecosystem. (At least that's the goal!)
|
|
16
15
|
|
|
17
16
|
### Goals
|
|
18
17
|
|
|
@@ -188,27 +187,21 @@ const c = a.add(b); // (3, 4) + (4,) → (3, 4)
|
|
|
188
187
|
|
|
189
188
|
---
|
|
190
189
|
|
|
191
|
-
## Installation
|
|
190
|
+
## Installation
|
|
192
191
|
|
|
193
192
|
```bash
|
|
194
193
|
npm install numpy-ts
|
|
195
194
|
```
|
|
196
195
|
|
|
197
|
-
### Node.js
|
|
198
196
|
```typescript
|
|
199
|
-
import * as np from 'numpy-ts
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Browser
|
|
203
|
-
```typescript
|
|
204
|
-
import * as np from 'numpy-ts/browser';
|
|
197
|
+
import * as np from 'numpy-ts';
|
|
205
198
|
```
|
|
206
199
|
|
|
207
200
|
---
|
|
208
201
|
|
|
209
202
|
## Development Status
|
|
210
203
|
|
|
211
|
-
### Phase 0: Project Setup
|
|
204
|
+
### Phase 0: Project Setup
|
|
212
205
|
- [x] Package configuration
|
|
213
206
|
- [x] TypeScript setup
|
|
214
207
|
- [x] Build system (esbuild)
|
|
@@ -219,24 +212,25 @@ import * as np from 'numpy-ts/browser';
|
|
|
219
212
|
- [x] First working implementation
|
|
220
213
|
|
|
221
214
|
|
|
222
|
-
### Phase 1: Core Foundation
|
|
215
|
+
### Phase 1: Core Foundation
|
|
223
216
|
- [x] NDArray wrapper class (using @stdlib/ndarray)
|
|
224
217
|
- [x] Array creation: `zeros()`, `ones()`, `array()`, `arange()`, `linspace()`, `eye()`
|
|
225
218
|
- [x] Matrix operations: `matmul()` using optimized BLAS
|
|
226
219
|
- [x] Properties: `shape`, `ndim`, `size`, `dtype`, `data`, `strides`
|
|
227
220
|
- [x] View tracking: `base` attribute, `flags` property
|
|
228
221
|
- [x] Memory flags: `C_CONTIGUOUS`, `F_CONTIGUOUS`, `OWNDATA`
|
|
229
|
-
- [x]
|
|
230
|
-
- [x] Broadcasting
|
|
231
|
-
- [x] String-based slicing
|
|
232
|
-
- [x] Reductions with axis support
|
|
233
|
-
- [x] Comparison operations
|
|
234
|
-
- [x] Reshape operations
|
|
235
|
-
- [x] DType system
|
|
222
|
+
- [x] Arithmetic operations: `add()`, `subtract()`, `multiply()`, `divide()`, `mod()`, `floor_divide()`, `negative()`, `positive()`, `absolute()`, `sign()`, `reciprocal()`
|
|
223
|
+
- [x] Broadcasting - fully integrated into all operations
|
|
224
|
+
- [x] String-based slicing - `arr.slice('0:5', ':')`, `row()`, `col()`, etc.
|
|
225
|
+
- [x] Reductions with axis support - `sum(axis, keepdims)`, `mean()`, `max()`, `min()`
|
|
226
|
+
- [x] Comparison operations - `greater()`, `less()`, `equal()`, `isclose()`, `allclose()`
|
|
227
|
+
- [x] Reshape operations - `reshape()`, `flatten()`, `ravel()`, `transpose()`, `squeeze()`, `expand_dims()`
|
|
228
|
+
- [x] DType system - 11 types: float32/64, int8/16/32/64, uint8/16/32/64, bool
|
|
236
229
|
- Full dtype preservation
|
|
237
230
|
- NumPy-compatible promotion rules
|
|
238
231
|
- BigInt support for int64/uint64
|
|
239
|
-
- [x]
|
|
232
|
+
- [x] Exponential operations - `sqrt()`, `power()`
|
|
233
|
+
- [x] Testing
|
|
240
234
|
- Unit tests for all operations
|
|
241
235
|
- NumPy validation tests (cross-checked against Python NumPy 2.3.3)
|
|
242
236
|
- Edge case validation (overflow, underflow, special values)
|
|
@@ -246,17 +240,22 @@ import * as np from 'numpy-ts/browser';
|
|
|
246
240
|
- [X] PR workflow
|
|
247
241
|
- [X] Publish workflow
|
|
248
242
|
- [ ] Implement benchmarks
|
|
249
|
-
- [
|
|
243
|
+
- [X] Auto-calibrated benchmark runner (100ms samples, ops/sec metrics)
|
|
250
244
|
- [X] Comparison against Python NumPy
|
|
245
|
+
- [X] Matching Python/TypeScript output format
|
|
246
|
+
- [X] Ops/sec visualization (HTML/PNG)
|
|
247
|
+
- [ ] **Result validation** - Verify numpy-ts and NumPy produce same results before benchmarking
|
|
248
|
+
- [ ] Regression tracking (vs. previous runs)
|
|
251
249
|
- [ ] Automated in CI/CD
|
|
252
250
|
|
|
253
251
|
### Phase 3: Essential Operations
|
|
254
|
-
- [
|
|
255
|
-
- [ ] Linear algebra (using @stdlib LAPACK)
|
|
256
|
-
- [
|
|
257
|
-
- [
|
|
258
|
-
- [ ]
|
|
259
|
-
- [
|
|
252
|
+
- [x] Matrix operations (using @stdlib BLAS)
|
|
253
|
+
- [ ] Linear algebra (using @stdlib LAPACK) - eig, svd, qr, etc.
|
|
254
|
+
- [x] Reductions with axis support
|
|
255
|
+
- [x] Arithmetic functions - 11/11 complete
|
|
256
|
+
- [ ] Mathematical functions - 2/40+ (sqrt, power) - trigonometric, exponential, rounding, etc.
|
|
257
|
+
- [x] Comparison operations
|
|
258
|
+
- [x] dtype consistency testing
|
|
260
259
|
|
|
261
260
|
### Phase 4: Extended Features
|
|
262
261
|
- [ ] Random number generation
|
|
@@ -278,7 +277,6 @@ See [API-REFERENCE.md](./docs/API-REFERENCE.md) for complete function checklist.
|
|
|
278
277
|
### Developer Documentation
|
|
279
278
|
- [ARCHITECTURE.md](./docs/ARCHITECTURE.md) - Design and implementation details
|
|
280
279
|
- [TESTING-GUIDE.md](./docs/TESTING-GUIDE.md) - How to add tests (unit, validation, benchmarks)
|
|
281
|
-
- [IMPLEMENTATION-NOTES.md](./docs/IMPLEMENTATION-NOTES.md) - Development notes and decisions
|
|
282
280
|
- [benchmarks/README.md](./benchmarks/README.md) - Performance benchmarking guide
|
|
283
281
|
|
|
284
282
|
---
|
|
@@ -390,22 +388,21 @@ See [TESTING-GUIDE.md](./docs/TESTING-GUIDE.md) for detailed instructions on add
|
|
|
390
388
|
|
|
391
389
|
## Benchmarking
|
|
392
390
|
|
|
393
|
-
Compare numpy-ts performance against Python NumPy:
|
|
391
|
+
Compare numpy-ts performance against Python NumPy with auto-calibrated benchmarks:
|
|
394
392
|
|
|
395
393
|
```bash
|
|
396
|
-
#
|
|
397
|
-
npm run bench:quick
|
|
398
|
-
|
|
399
|
-
# Run standard benchmarks (~5-10 min)
|
|
400
|
-
npm run bench
|
|
394
|
+
# Quick benchmarks (~2-3 min) - 1 sample, 50ms/sample
|
|
395
|
+
source ~/.zshrc && conda activate py313 && npm run bench:quick
|
|
401
396
|
|
|
402
|
-
#
|
|
403
|
-
npm run bench
|
|
397
|
+
# Standard benchmarks (~5-10 min) - 5 samples, 100ms/sample (default)
|
|
398
|
+
source ~/.zshrc && conda activate py313 && npm run bench
|
|
404
399
|
|
|
405
|
-
# View interactive HTML report
|
|
400
|
+
# View interactive HTML report with ops/sec comparison
|
|
406
401
|
npm run bench:view
|
|
407
402
|
```
|
|
408
403
|
|
|
404
|
+
**Both modes use the same array sizes** - only sampling strategy differs (quick for speed, standard for accuracy).
|
|
405
|
+
|
|
409
406
|
### Performance Overview
|
|
410
407
|
|
|
411
408
|

|
|
@@ -444,4 +441,4 @@ Focus is correctness and completeness first, then performance.
|
|
|
444
441
|
|
|
445
442
|
---
|
|
446
443
|
|
|
447
|
-
**Ready to bring NumPy to JavaScript!** ⭐
|
|
444
|
+
**Ready to bring NumPy to TypeScript + JavaScript!** ⭐
|