numpy-ts 0.2.0 → 0.4.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 CHANGED
@@ -5,27 +5,23 @@ Complete NumPy implementation for TypeScript and JavaScript
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
6
6
  ![Under Construction](https://img.shields.io/badge/Under%20Construction-red)
7
7
 
8
- **⚠️ WARNING: This project is under construction and is currently unstable. Expect breaking changes.**
8
+ **⚠️ WARNING: Under active development. API may change.**
9
9
 
10
10
  ---
11
11
 
12
12
  ## What is numpy-ts?
13
13
 
14
- A complete, functionally-equivalent implementation of NumPy 2.0+ for the TypeScript/JavaScript ecosystem. (At least that's the goal!)
14
+ A complete NumPy 2.0+ implementation for TypeScript/JavaScript, validated against Python NumPy.
15
15
 
16
- ### Goals
16
+ **Goals:**
17
+ - **100% API Coverage** - All NumPy functions and operations
18
+ - **Type Safety** - Full TypeScript support with inference
19
+ - **Correctness** - Cross-validated against Python NumPy
20
+ - **Cross-Platform** - Node.js and browsers
17
21
 
18
- - ✅ **100% NumPy 2.0+ API** - All 800+ functions
19
- - **Full Type Safety** - Complete TypeScript definitions
20
- - **Cross-Platform** - Node.js and browsers
21
- - ✅ **File Compatibility** - Read/write .npy and .npz files
22
- - ✅ **Correctness First** - Validated against Python NumPy
23
-
24
- ### Not Goals
25
-
26
- - ❌ Matching Python NumPy's exact performance (initially)
27
- - ❌ C API compatibility
28
- - ❌ Legacy NumPy 1.x deprecated functions
22
+ **Non-Goals:**
23
+ - Matching NumPy's C-optimized performance (initially)
24
+ - C API compatibility
29
25
 
30
26
  ---
31
27
 
@@ -108,6 +104,8 @@ const loaded = np.load('matrix.npy');
108
104
 
109
105
  ## Architecture
110
106
 
107
+ Pure TypeScript implementation with three layers:
108
+
111
109
  ```
112
110
  ┌────────────────────────────────┐
113
111
  │ NumPy-Compatible API │
@@ -119,23 +117,21 @@ const loaded = np.load('matrix.npy');
119
117
  └────────────┬───────────────────┘
120
118
 
121
119
  ┌────────────┴───────────────────┐
122
- Computational Backend
123
- @stdlib (BLAS/LAPACK)
120
+ TypeScript/JavaScript Core
121
+ Computational Engine
124
122
  └────────────────────────────────┘
125
123
  ```
126
124
 
127
- **We build**: NumPy API, NDArray class, broadcasting, slicing, view tracking
128
-
129
- **We use**: @stdlib for proven numerical computations
125
+ Built from scratch for correctness and NumPy compatibility.
130
126
 
131
127
  ---
132
128
 
133
129
  ## Key Features
134
130
 
135
131
  ### Comprehensive NumPy API
136
- - **Array creation**: `zeros`, `ones`, `arange`, `linspace` (all support dtype parameter)
132
+ - **Array creation**: `zeros`, `ones`, `arange`, `linspace`, `eye` (all support dtype parameter)
137
133
  - **Arithmetic operations**: `add`, `subtract`, `multiply`, `divide` with broadcasting
138
- - **Linear algebra**: `matmul` (using optimized BLAS)
134
+ - **Linear algebra**: `matmul`, `dot`, `transpose`
139
135
  - **Reductions**: `sum`, `mean`, `std`, `min`, `max` with axis support
140
136
  - **DTypes**: 11 types supported (float32/64, int8/16/32/64, uint8/16/32/64, bool)
141
137
  - Full dtype preservation across operations
@@ -199,85 +195,14 @@ import * as np from 'numpy-ts';
199
195
 
200
196
  ---
201
197
 
202
- ## Development Status
203
-
204
- ### Phase 0: Project Setup
205
- - [x] Package configuration
206
- - [x] TypeScript setup
207
- - [x] Build system (esbuild)
208
- - [x] Test framework (Vitest)
209
- - [x] Documentation consolidated
210
- - [x] Linting (ESLint + Prettier)
211
- - [x] @stdlib investigation and integration
212
- - [x] First working implementation
213
-
214
-
215
- ### Phase 1: Core Foundation
216
- - [x] NDArray wrapper class (using @stdlib/ndarray)
217
- - [x] Array creation: `zeros()`, `ones()`, `array()`, `arange()`, `linspace()`, `eye()`
218
- - [x] Matrix operations: `matmul()` using optimized BLAS
219
- - [x] Properties: `shape`, `ndim`, `size`, `dtype`, `data`, `strides`
220
- - [x] View tracking: `base` attribute, `flags` property
221
- - [x] Memory flags: `C_CONTIGUOUS`, `F_CONTIGUOUS`, `OWNDATA`
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
229
- - Full dtype preservation
230
- - NumPy-compatible promotion rules
231
- - BigInt support for int64/uint64
232
- - [x] Exponential operations - `sqrt()`, `power()`
233
- - [x] Testing
234
- - Unit tests for all operations
235
- - NumPy validation tests (cross-checked against Python NumPy 2.3.3)
236
- - Edge case validation (overflow, underflow, special values)
237
-
238
- ### Phase 2: Benchmarks & CI/CD
239
- - [X] CI/CD (GitHub Actions)
240
- - [X] PR workflow
241
- - [X] Publish workflow
242
- - [ ] Implement benchmarks
243
- - [X] Auto-calibrated benchmark runner (100ms samples, ops/sec metrics)
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)
249
- - [ ] Automated in CI/CD
250
-
251
- ### Phase 3: Essential Operations
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
259
-
260
- ### Phase 4: Extended Features
261
- - [ ] Random number generation
262
- - [ ] FFT operations (using fft.js)
263
- - [ ] I/O operations (.npy/.npz)
264
- - [ ] Advanced indexing
265
- - [ ] Complex numbers, datetime
266
- - [ ] Optional WASM mode
267
-
268
- See [API-REFERENCE.md](./docs/API-REFERENCE.md) for complete function checklist.
269
-
270
- ---
271
-
272
198
  ## Documentation
273
199
 
274
200
  ### User Documentation
275
- - [API-REFERENCE.md](./docs/API-REFERENCE.md) - Complete API checklist
201
+ - [API-REFERENCE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/API-REFERENCE.md) - Complete API checklist
276
202
 
277
203
  ### Developer Documentation
278
- - [ARCHITECTURE.md](./docs/ARCHITECTURE.md) - Design and implementation details
279
- - [TESTING-GUIDE.md](./docs/TESTING-GUIDE.md) - How to add tests (unit, validation, benchmarks)
280
- - [benchmarks/README.md](./benchmarks/README.md) - Performance benchmarking guide
204
+ - [TESTING-GUIDE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/TESTING-GUIDE.md) - How to add tests (unit, validation, benchmarks)
205
+ - [benchmarks/README.md](https://github.com/dupontcyborg/numpy-ts/blob/main/benchmarks/README.md) - Performance benchmarking guide
281
206
 
282
207
  ---
283
208
 
@@ -323,25 +248,26 @@ it('int8 overflow wraps like NumPy', () => {
323
248
 
324
249
  ## Design Decisions
325
250
 
326
- ### 1. BigInt for int64/uint64
327
- Exact representation over convenience. Different type but no precision loss.
328
-
329
- ### 2. No Complex Number Support (for now)
330
- Removed in favor of simplicity and focus on core numeric types. Can be added back if there's demand.
251
+ **Pure TypeScript Implementation**
252
+ - Built from scratch without heavy dependencies
253
+ - Focus on correctness and NumPy compatibility
331
254
 
332
- ### 3. String-Based Slicing
333
- `arr.slice('0:5', ':')` instead of `arr[0:5, :]` - TypeScript limitation, Pythonic compromise.
255
+ **BigInt for int64/uint64**
256
+ - Exact representation over convenience
257
+ - No precision loss (different type but fully accurate)
334
258
 
335
- ### 4. View Tracking
336
- Track base array for views with `base` attribute. Enables zero-copy optimizations and matches NumPy semantics.
259
+ **String-Based Slicing**
260
+ - `arr.slice('0:5', ':')` instead of `arr[0:5, :]`
261
+ - TypeScript limitation, Pythonic compromise
337
262
 
338
- ### 5. @stdlib Under the Hood
339
- Use battle-tested BLAS/LAPACK implementations. Focus on API, not reimplementing algorithms.
263
+ **View Tracking**
264
+ - Track base array with `base` attribute
265
+ - Zero-copy optimizations where possible
266
+ - Matches NumPy semantics
340
267
 
341
- ### 6. Correctness First
342
- Validate everything against Python NumPy before optimizing. WASM/SIMD later.
343
-
344
- See [ARCHITECTURE.md](./docs/ARCHITECTURE.md) for full rationale.
268
+ **Correctness First**
269
+ - Validate against Python NumPy before optimizing
270
+ - Performance improvements (WASM/SIMD) come later
345
271
 
346
272
  ---
347
273
 
@@ -360,8 +286,8 @@ npm test
360
286
 
361
287
  ### Adding New Features
362
288
 
363
- 1. Pick a function from [API-REFERENCE.md](./docs/API-REFERENCE.md)
364
- 2. Follow the [TESTING-GUIDE.md](./docs/TESTING-GUIDE.md) to add:
289
+ 1. Pick a function from [API-REFERENCE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/API-REFERENCE.md)
290
+ 2. Follow the [TESTING-GUIDE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/TESTING-GUIDE.md) to add:
365
291
  - Implementation in `src/`
366
292
  - Unit tests in `tests/unit/`
367
293
  - NumPy validation tests in `tests/validation/`
@@ -370,7 +296,7 @@ npm test
370
296
  4. Run benchmarks: `npm run bench:quick`
371
297
  5. Submit a pull request
372
298
 
373
- See [TESTING-GUIDE.md](./docs/TESTING-GUIDE.md) for detailed instructions on adding tests.
299
+ See [TESTING-GUIDE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/TESTING-GUIDE.md) for detailed instructions on adding tests.
374
300
 
375
301
  ---
376
302
 
@@ -405,38 +331,36 @@ npm run bench:view
405
331
 
406
332
  ### Performance Overview
407
333
 
408
- ![Benchmark Results](./benchmarks/results/plots/latest.png)
334
+ ![Benchmark Results](https://github.com/dupontcyborg/numpy-ts/blob/main/benchmarks/results/plots/latest.png)
409
335
 
410
- See [benchmarks/README.md](./benchmarks/README.md) for detailed benchmarking guide.
336
+ See [benchmarks/README.md](https://github.com/dupontcyborg/numpy-ts/blob/main/benchmarks/README.md) for detailed benchmarking guide.
411
337
 
412
338
  ---
413
339
 
414
340
  ## Performance Expectations
415
341
 
416
- **v1.0** (Pure JS + @stdlib):
417
- - 10-100x slower than NumPy - acceptable for correctness focus
418
-
419
- **v2.0** (Selective WASM):
420
- - 2-20x slower - optimized bottlenecks only
342
+ **Current (v1.0)** - Pure TypeScript:
343
+ - 10-100x slower than NumPy
344
+ - Focus on correctness and API completeness
421
345
 
422
- **v3.0** (Advanced):
423
- - 1-10x slower - SIMD, GPU for specific operations
346
+ **Future (v2.0+)** - Optimizations:
347
+ - WASM for compute-intensive operations
348
+ - SIMD for vectorized operations
349
+ - Target: 2-20x slower than NumPy
424
350
 
425
- Focus is correctness and completeness first, then performance.
351
+ Correctness and completeness first, then performance.
426
352
 
427
353
  ---
428
354
 
429
355
  ## License
430
356
 
431
- [MIT License](./LICENSE) - Copyright (c) 2025 Nicolas Dupont
357
+ [MIT License](https://github.com/dupontcyborg/numpy-ts/blob/main/LICENSE) - Copyright (c) 2025 Nicolas Dupont
432
358
 
433
359
  ---
434
360
 
435
361
  ## Links
436
362
 
437
- - **Documentation**: [`docs/`](./docs)
438
363
  - **NumPy**: https://numpy.org/
439
- - **@stdlib**: https://stdlib.io/
440
364
  - **Issues**: https://github.com/dupontcyborg/numpy-ts/issues
441
365
 
442
366
  ---