fxtensor-salmon 1.2.1__tar.gz → 1.2.2__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.
- {fxtensor_salmon-1.2.1/src/fxtensor_salmon.egg-info → fxtensor_salmon-1.2.2}/PKG-INFO +25 -1
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/README.md +24 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/pyproject.toml +1 -1
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2/src/fxtensor_salmon.egg-info}/PKG-INFO +25 -1
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/LICENSE +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/setup.cfg +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon/__init__.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon/core.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon/discopy.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon/io.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon/operations.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon/profile.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon/special.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon.egg-info/SOURCES.txt +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon.egg-info/dependency_links.txt +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon.egg-info/requires.txt +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon.egg-info/top_level.txt +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/tests/test_almost_surely.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/tests/test_axioms.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/tests/test_discopy.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/tests/test_fxtensor.py +0 -0
- {fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/tests/test_inference.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fxtensor_salmon
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Markov Tensor Module
|
|
5
5
|
Author-email: Tadachika Oki <sakesnare@gmail.com>
|
|
6
6
|
License: Copyright 2025 Tadachika Oki
|
|
@@ -371,6 +371,22 @@ The `fxtensor-salmon` library is designed based on the **Markov Category**, a fr
|
|
|
371
371
|
- **Objects**: State spaces, represented in `FXTensor` as `domain` or `codomain` (e.g., `[['Urban', 'Rural']]` or `[[2]]`).
|
|
372
372
|
- **Morphisms**: Markov kernels (probabilistic transitions), represented by `FXTensor` instances with profile and data.
|
|
373
373
|
|
|
374
|
+
### String diagrams
|
|
375
|
+
|
|
376
|
+
Diagrams are read top to bottom (inputs at the top, outputs at the bottom). The drawing conventions are referenced from T. Fritz (arXiv:1908.07021), implemented independently in TikZ. Boxes are morphisms, triangles are states `I → X`, a black dot branching downwards is `copy`, and a wire ending in a black dot is discard `!`. Sources are in [`docs/diagrams/`](https://github.com/salmonsnare/fxtensor-salmon/tree/v1.2.2/docs/diagrams/).
|
|
377
|
+
|
|
378
|
+
Copy is coassociative, counital and cocommutative:
|
|
379
|
+
|
|
380
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/copy_associativity.svg" alt="coassociativity">
|
|
381
|
+
|
|
382
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/copy_counitality.svg" alt="counitality">
|
|
383
|
+
|
|
384
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/copy_commutativity.svg" alt="cocommutativity">
|
|
385
|
+
|
|
386
|
+
Every morphism is Markov (discard is natural), `f ; ! = !` — in `FXTensor`, each row of a kernel sums to 1:
|
|
387
|
+
|
|
388
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/discard_naturality.svg" alt="f ; ! = !">
|
|
389
|
+
|
|
374
390
|
### Markov Category Operations
|
|
375
391
|
|
|
376
392
|
| Method | Role | When to use |
|
|
@@ -398,8 +414,12 @@ result = tensor1.composition(tensor2)
|
|
|
398
414
|
assert np.allclose(result.data, [[0.78, 0.22], [0.54, 0.46]])
|
|
399
415
|
```
|
|
400
416
|
|
|
417
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/composition.svg" alt="f ; g">
|
|
418
|
+
|
|
401
419
|
#### `tensor_product` — independent systems in parallel
|
|
402
420
|
|
|
421
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/tensor_product.svg" alt="f ⊗ g">
|
|
422
|
+
|
|
403
423
|
Use to put two morphisms (or two states) next to each other without coupling.
|
|
404
424
|
|
|
405
425
|
```python
|
|
@@ -473,6 +493,8 @@ assert np.allclose(joint_xy.data, [[0.06, 0.09, 0.15], [0.14, 0.21, 0.35]])
|
|
|
473
493
|
|
|
474
494
|
#### `bayesian_inversion` — posterior kernel
|
|
475
495
|
|
|
496
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/bayesian_inversion.svg" alt="p;copy;(id⊗f) = p;f;copy;(f†⊗id)">
|
|
497
|
+
|
|
476
498
|
For a prior `p: I → X` and a kernel `f: X → Y`, `f.bayesian_inversion(p)` returns `f†: Y → X` with `f†(x|y) = p(x) f(y|x) / Σ p(x') f(y|x')` (Cho & Jacobs). It satisfies `p ; copy ; (id ⊗ f) = p ; f ; copy ; (f† ⊗ id)`. Outputs with zero evidence stay zero.
|
|
477
499
|
|
|
478
500
|
```python
|
|
@@ -498,6 +520,8 @@ assert np.allclose(c.data, [[[0.25, 0.75], [1/3, 2/3]]])
|
|
|
498
520
|
|
|
499
521
|
#### `support`, `almost_surely_equal`, `is_absolutely_continuous` — a.s. reasoning
|
|
500
522
|
|
|
523
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/almost_surely_equal.svg" alt="p;copy;(id⊗f) = p;copy;(id⊗g)">
|
|
524
|
+
|
|
501
525
|
`support()` returns the 0/1 indicator of nonzero entries (same profile and labels). `f.almost_surely_equal(g, p)` checks Fritz's `p ; copy ; (id ⊗ f) = p ; copy ; (id ⊗ g)`, i.e. `f` and `g` agree on the support of `p`. `p.is_absolutely_continuous(q)` checks `p ≪ q` (zero in `q` implies zero in `p`; input-wise for kernels, cf. arXiv:2308.00651). Zero is judged with `_ATOL`; labels are not compared.
|
|
502
526
|
|
|
503
527
|
```python
|
|
@@ -342,6 +342,22 @@ The `fxtensor-salmon` library is designed based on the **Markov Category**, a fr
|
|
|
342
342
|
- **Objects**: State spaces, represented in `FXTensor` as `domain` or `codomain` (e.g., `[['Urban', 'Rural']]` or `[[2]]`).
|
|
343
343
|
- **Morphisms**: Markov kernels (probabilistic transitions), represented by `FXTensor` instances with profile and data.
|
|
344
344
|
|
|
345
|
+
### String diagrams
|
|
346
|
+
|
|
347
|
+
Diagrams are read top to bottom (inputs at the top, outputs at the bottom). The drawing conventions are referenced from T. Fritz (arXiv:1908.07021), implemented independently in TikZ. Boxes are morphisms, triangles are states `I → X`, a black dot branching downwards is `copy`, and a wire ending in a black dot is discard `!`. Sources are in [`docs/diagrams/`](https://github.com/salmonsnare/fxtensor-salmon/tree/v1.2.2/docs/diagrams/).
|
|
348
|
+
|
|
349
|
+
Copy is coassociative, counital and cocommutative:
|
|
350
|
+
|
|
351
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/copy_associativity.svg" alt="coassociativity">
|
|
352
|
+
|
|
353
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/copy_counitality.svg" alt="counitality">
|
|
354
|
+
|
|
355
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/copy_commutativity.svg" alt="cocommutativity">
|
|
356
|
+
|
|
357
|
+
Every morphism is Markov (discard is natural), `f ; ! = !` — in `FXTensor`, each row of a kernel sums to 1:
|
|
358
|
+
|
|
359
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/discard_naturality.svg" alt="f ; ! = !">
|
|
360
|
+
|
|
345
361
|
### Markov Category Operations
|
|
346
362
|
|
|
347
363
|
| Method | Role | When to use |
|
|
@@ -369,8 +385,12 @@ result = tensor1.composition(tensor2)
|
|
|
369
385
|
assert np.allclose(result.data, [[0.78, 0.22], [0.54, 0.46]])
|
|
370
386
|
```
|
|
371
387
|
|
|
388
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/composition.svg" alt="f ; g">
|
|
389
|
+
|
|
372
390
|
#### `tensor_product` — independent systems in parallel
|
|
373
391
|
|
|
392
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/tensor_product.svg" alt="f ⊗ g">
|
|
393
|
+
|
|
374
394
|
Use to put two morphisms (or two states) next to each other without coupling.
|
|
375
395
|
|
|
376
396
|
```python
|
|
@@ -444,6 +464,8 @@ assert np.allclose(joint_xy.data, [[0.06, 0.09, 0.15], [0.14, 0.21, 0.35]])
|
|
|
444
464
|
|
|
445
465
|
#### `bayesian_inversion` — posterior kernel
|
|
446
466
|
|
|
467
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/bayesian_inversion.svg" alt="p;copy;(id⊗f) = p;f;copy;(f†⊗id)">
|
|
468
|
+
|
|
447
469
|
For a prior `p: I → X` and a kernel `f: X → Y`, `f.bayesian_inversion(p)` returns `f†: Y → X` with `f†(x|y) = p(x) f(y|x) / Σ p(x') f(y|x')` (Cho & Jacobs). It satisfies `p ; copy ; (id ⊗ f) = p ; f ; copy ; (f† ⊗ id)`. Outputs with zero evidence stay zero.
|
|
448
470
|
|
|
449
471
|
```python
|
|
@@ -469,6 +491,8 @@ assert np.allclose(c.data, [[[0.25, 0.75], [1/3, 2/3]]])
|
|
|
469
491
|
|
|
470
492
|
#### `support`, `almost_surely_equal`, `is_absolutely_continuous` — a.s. reasoning
|
|
471
493
|
|
|
494
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/almost_surely_equal.svg" alt="p;copy;(id⊗f) = p;copy;(id⊗g)">
|
|
495
|
+
|
|
472
496
|
`support()` returns the 0/1 indicator of nonzero entries (same profile and labels). `f.almost_surely_equal(g, p)` checks Fritz's `p ; copy ; (id ⊗ f) = p ; copy ; (id ⊗ g)`, i.e. `f` and `g` agree on the support of `p`. `p.is_absolutely_continuous(q)` checks `p ≪ q` (zero in `q` implies zero in `p`; input-wise for kernels, cf. arXiv:2308.00651). Zero is judged with `_ATOL`; labels are not compared.
|
|
473
497
|
|
|
474
498
|
```python
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fxtensor_salmon
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Markov Tensor Module
|
|
5
5
|
Author-email: Tadachika Oki <sakesnare@gmail.com>
|
|
6
6
|
License: Copyright 2025 Tadachika Oki
|
|
@@ -371,6 +371,22 @@ The `fxtensor-salmon` library is designed based on the **Markov Category**, a fr
|
|
|
371
371
|
- **Objects**: State spaces, represented in `FXTensor` as `domain` or `codomain` (e.g., `[['Urban', 'Rural']]` or `[[2]]`).
|
|
372
372
|
- **Morphisms**: Markov kernels (probabilistic transitions), represented by `FXTensor` instances with profile and data.
|
|
373
373
|
|
|
374
|
+
### String diagrams
|
|
375
|
+
|
|
376
|
+
Diagrams are read top to bottom (inputs at the top, outputs at the bottom). The drawing conventions are referenced from T. Fritz (arXiv:1908.07021), implemented independently in TikZ. Boxes are morphisms, triangles are states `I → X`, a black dot branching downwards is `copy`, and a wire ending in a black dot is discard `!`. Sources are in [`docs/diagrams/`](https://github.com/salmonsnare/fxtensor-salmon/tree/v1.2.2/docs/diagrams/).
|
|
377
|
+
|
|
378
|
+
Copy is coassociative, counital and cocommutative:
|
|
379
|
+
|
|
380
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/copy_associativity.svg" alt="coassociativity">
|
|
381
|
+
|
|
382
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/copy_counitality.svg" alt="counitality">
|
|
383
|
+
|
|
384
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/copy_commutativity.svg" alt="cocommutativity">
|
|
385
|
+
|
|
386
|
+
Every morphism is Markov (discard is natural), `f ; ! = !` — in `FXTensor`, each row of a kernel sums to 1:
|
|
387
|
+
|
|
388
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/discard_naturality.svg" alt="f ; ! = !">
|
|
389
|
+
|
|
374
390
|
### Markov Category Operations
|
|
375
391
|
|
|
376
392
|
| Method | Role | When to use |
|
|
@@ -398,8 +414,12 @@ result = tensor1.composition(tensor2)
|
|
|
398
414
|
assert np.allclose(result.data, [[0.78, 0.22], [0.54, 0.46]])
|
|
399
415
|
```
|
|
400
416
|
|
|
417
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/composition.svg" alt="f ; g">
|
|
418
|
+
|
|
401
419
|
#### `tensor_product` — independent systems in parallel
|
|
402
420
|
|
|
421
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/tensor_product.svg" alt="f ⊗ g">
|
|
422
|
+
|
|
403
423
|
Use to put two morphisms (or two states) next to each other without coupling.
|
|
404
424
|
|
|
405
425
|
```python
|
|
@@ -473,6 +493,8 @@ assert np.allclose(joint_xy.data, [[0.06, 0.09, 0.15], [0.14, 0.21, 0.35]])
|
|
|
473
493
|
|
|
474
494
|
#### `bayesian_inversion` — posterior kernel
|
|
475
495
|
|
|
496
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/bayesian_inversion.svg" alt="p;copy;(id⊗f) = p;f;copy;(f†⊗id)">
|
|
497
|
+
|
|
476
498
|
For a prior `p: I → X` and a kernel `f: X → Y`, `f.bayesian_inversion(p)` returns `f†: Y → X` with `f†(x|y) = p(x) f(y|x) / Σ p(x') f(y|x')` (Cho & Jacobs). It satisfies `p ; copy ; (id ⊗ f) = p ; f ; copy ; (f† ⊗ id)`. Outputs with zero evidence stay zero.
|
|
477
499
|
|
|
478
500
|
```python
|
|
@@ -498,6 +520,8 @@ assert np.allclose(c.data, [[[0.25, 0.75], [1/3, 2/3]]])
|
|
|
498
520
|
|
|
499
521
|
#### `support`, `almost_surely_equal`, `is_absolutely_continuous` — a.s. reasoning
|
|
500
522
|
|
|
523
|
+
<img src="https://raw.githubusercontent.com/salmonsnare/fxtensor-salmon/v1.2.2/docs/diagrams/almost_surely_equal.svg" alt="p;copy;(id⊗f) = p;copy;(id⊗g)">
|
|
524
|
+
|
|
501
525
|
`support()` returns the 0/1 indicator of nonzero entries (same profile and labels). `f.almost_surely_equal(g, p)` checks Fritz's `p ; copy ; (id ⊗ f) = p ; copy ; (id ⊗ g)`, i.e. `f` and `g` agree on the support of `p`. `p.is_absolutely_continuous(q)` checks `p ≪ q` (zero in `q` implies zero in `p`; input-wise for kernels, cf. arXiv:2308.00651). Zero is judged with `_ATOL`; labels are not compared.
|
|
502
526
|
|
|
503
527
|
```python
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fxtensor_salmon-1.2.1 → fxtensor_salmon-1.2.2}/src/fxtensor_salmon.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|