numpy-ts 0.2.0 → 0.3.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,15 @@ 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
+ - [ARCHITECTURE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/ARCHITECTURE.md) - Design and implementation details
205
+ - [TESTING-GUIDE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/TESTING-GUIDE.md) - How to add tests (unit, validation, benchmarks)
206
+ - [benchmarks/README.md](https://github.com/dupontcyborg/numpy-ts/blob/main/benchmarks/README.md) - Performance benchmarking guide
281
207
 
282
208
  ---
283
209
 
@@ -323,25 +249,28 @@ it('int8 overflow wraps like NumPy', () => {
323
249
 
324
250
  ## Design Decisions
325
251
 
326
- ### 1. BigInt for int64/uint64
327
- Exact representation over convenience. Different type but no precision loss.
252
+ **Pure TypeScript Implementation**
253
+ - Built from scratch without heavy dependencies
254
+ - Focus on correctness and NumPy compatibility
328
255
 
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.
256
+ **BigInt for int64/uint64**
257
+ - Exact representation over convenience
258
+ - No precision loss (different type but fully accurate)
331
259
 
332
- ### 3. String-Based Slicing
333
- `arr.slice('0:5', ':')` instead of `arr[0:5, :]` - TypeScript limitation, Pythonic compromise.
260
+ **String-Based Slicing**
261
+ - `arr.slice('0:5', ':')` instead of `arr[0:5, :]`
262
+ - TypeScript limitation, Pythonic compromise
334
263
 
335
- ### 4. View Tracking
336
- Track base array for views with `base` attribute. Enables zero-copy optimizations and matches NumPy semantics.
264
+ **View Tracking**
265
+ - Track base array with `base` attribute
266
+ - Zero-copy optimizations where possible
267
+ - Matches NumPy semantics
337
268
 
338
- ### 5. @stdlib Under the Hood
339
- Use battle-tested BLAS/LAPACK implementations. Focus on API, not reimplementing algorithms.
269
+ **Correctness First**
270
+ - Validate against Python NumPy before optimizing
271
+ - Performance improvements (WASM/SIMD) come later
340
272
 
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.
273
+ See [ARCHITECTURE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/ARCHITECTURE.md) for detailed design rationale.
345
274
 
346
275
  ---
347
276
 
@@ -360,8 +289,8 @@ npm test
360
289
 
361
290
  ### Adding New Features
362
291
 
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:
292
+ 1. Pick a function from [API-REFERENCE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/API-REFERENCE.md)
293
+ 2. Follow the [TESTING-GUIDE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/TESTING-GUIDE.md) to add:
365
294
  - Implementation in `src/`
366
295
  - Unit tests in `tests/unit/`
367
296
  - NumPy validation tests in `tests/validation/`
@@ -370,7 +299,7 @@ npm test
370
299
  4. Run benchmarks: `npm run bench:quick`
371
300
  5. Submit a pull request
372
301
 
373
- See [TESTING-GUIDE.md](./docs/TESTING-GUIDE.md) for detailed instructions on adding tests.
302
+ See [TESTING-GUIDE.md](https://github.com/dupontcyborg/numpy-ts/blob/main/docs/TESTING-GUIDE.md) for detailed instructions on adding tests.
374
303
 
375
304
  ---
376
305
 
@@ -405,36 +334,35 @@ npm run bench:view
405
334
 
406
335
  ### Performance Overview
407
336
 
408
- ![Benchmark Results](./benchmarks/results/plots/latest.png)
337
+ ![Benchmark Results](https://github.com/dupontcyborg/numpy-ts/blob/main/benchmarks/results/plots/latest.png)
409
338
 
410
- See [benchmarks/README.md](./benchmarks/README.md) for detailed benchmarking guide.
339
+ See [benchmarks/README.md](https://github.com/dupontcyborg/numpy-ts/blob/main/benchmarks/README.md) for detailed benchmarking guide.
411
340
 
412
341
  ---
413
342
 
414
343
  ## Performance Expectations
415
344
 
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
345
+ **Current (v1.0)** - Pure TypeScript:
346
+ - 10-100x slower than NumPy
347
+ - Focus on correctness and API completeness
421
348
 
422
- **v3.0** (Advanced):
423
- - 1-10x slower - SIMD, GPU for specific operations
349
+ **Future (v2.0+)** - Optimizations:
350
+ - WASM for compute-intensive operations
351
+ - SIMD for vectorized operations
352
+ - Target: 2-20x slower than NumPy
424
353
 
425
- Focus is correctness and completeness first, then performance.
354
+ Correctness and completeness first, then performance.
426
355
 
427
356
  ---
428
357
 
429
358
  ## License
430
359
 
431
- [MIT License](./LICENSE) - Copyright (c) 2025 Nicolas Dupont
360
+ [MIT License](https://github.com/dupontcyborg/numpy-ts/blob/main/LICENSE) - Copyright (c) 2025 Nicolas Dupont
432
361
 
433
362
  ---
434
363
 
435
364
  ## Links
436
365
 
437
- - **Documentation**: [`docs/`](./docs)
438
366
  - **NumPy**: https://numpy.org/
439
367
  - **@stdlib**: https://stdlib.io/
440
368
  - **Issues**: https://github.com/dupontcyborg/numpy-ts/issues