@thi.ng/fuzzy-viz 2.1.119 → 2.1.121
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/CHANGELOG.md +7 -1
- package/README.md +16 -14
- package/package.json +9 -9
- package/strategy.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-02-
|
|
3
|
+
- **Last updated**: 2024-02-19T16:07:07Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [2.1.120](https://github.com/thi-ng/umbrella/tree/@thi.ng/fuzzy-viz@2.1.120) (2024-02-19)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- update imports ([6888d2d](https://github.com/thi-ng/umbrella/commit/6888d2d))
|
|
17
|
+
|
|
12
18
|
### [2.1.96](https://github.com/thi-ng/umbrella/tree/@thi.ng/fuzzy-viz@2.1.96) (2023-11-09)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ For Node.js REPL:
|
|
|
65
65
|
const fuzzyViz = await import("@thi.ng/fuzzy-viz");
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 1.
|
|
68
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 1.00 KB
|
|
69
69
|
|
|
70
70
|
## Dependencies
|
|
71
71
|
|
|
@@ -88,19 +88,18 @@ variable](https://github.com/thi-ng/umbrella/tree/develop/packages/fuzzy#linguis
|
|
|
88
88
|
|
|
89
89
|

|
|
90
90
|
|
|
91
|
-
```ts
|
|
91
|
+
```ts tangle:export/readme-svg.ts
|
|
92
|
+
import { invSigmoid, sigmoid, trapezoid, variable } from "@thi.ng/fuzzy";
|
|
92
93
|
import { varToSvg } from "@thi.ng/fuzzy-viz";
|
|
94
|
+
import { writeFileSync } from "fs";
|
|
93
95
|
|
|
94
96
|
// temperature sets (in celsius)
|
|
95
|
-
const temp = variable(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
hot: sigmoid(32, 2)
|
|
102
|
-
}
|
|
103
|
-
);
|
|
97
|
+
const temp = variable([-20, 40], {
|
|
98
|
+
freezing: invSigmoid(0, 2),
|
|
99
|
+
cold: trapezoid(-1, 2, 16, 20),
|
|
100
|
+
warm: trapezoid(15, 20, 30, 34),
|
|
101
|
+
hot: sigmoid(32, 2),
|
|
102
|
+
});
|
|
104
103
|
|
|
105
104
|
// generate & write SVG file
|
|
106
105
|
writeFileSync("temperature.svg", varToSvg(temp, { samples: 200 }));
|
|
@@ -130,10 +129,13 @@ accumulate. If re-using the instrumented strategy for multiple `defuzz()`
|
|
|
130
129
|
invocations, it's highly recommended to clear any previous results using
|
|
131
130
|
`.clear()`.
|
|
132
131
|
|
|
133
|
-
```ts
|
|
132
|
+
```ts tangle:export/readme-ascii.ts
|
|
133
|
+
import { centroidStrategy, gaussian } from "@thi.ng/fuzzy";
|
|
134
|
+
import { fuzzySetToAscii, instrumentStrategy } from "@thi.ng/fuzzy-viz";
|
|
135
|
+
|
|
134
136
|
const strategy = instrumentStrategy(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
centroidStrategy({ samples: 1000 }),
|
|
138
|
+
fuzzySetToAscii({ width: 40, height: 8 })
|
|
137
139
|
);
|
|
138
140
|
|
|
139
141
|
// apply strategy as normal (well, usually done via defuzz())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/fuzzy-viz",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.121",
|
|
4
4
|
"description": "Visualization, instrumentation & introspection utils for @thi.ng/fuzzy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"test": "bun test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.9.
|
|
39
|
-
"@thi.ng/fuzzy": "^2.1.
|
|
40
|
-
"@thi.ng/hiccup": "^5.1.
|
|
41
|
-
"@thi.ng/hiccup-svg": "^5.2.
|
|
42
|
-
"@thi.ng/math": "^5.10.
|
|
43
|
-
"@thi.ng/strings": "^3.7.
|
|
44
|
-
"@thi.ng/text-canvas": "^
|
|
38
|
+
"@thi.ng/api": "^8.9.24",
|
|
39
|
+
"@thi.ng/fuzzy": "^2.1.67",
|
|
40
|
+
"@thi.ng/hiccup": "^5.1.13",
|
|
41
|
+
"@thi.ng/hiccup-svg": "^5.2.13",
|
|
42
|
+
"@thi.ng/math": "^5.10.1",
|
|
43
|
+
"@thi.ng/strings": "^3.7.15",
|
|
44
|
+
"@thi.ng/text-canvas": "^3.0.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@microsoft/api-extractor": "^7.40.1",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"parent": "@thi.ng/fuzzy",
|
|
92
92
|
"year": 2020
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "2724c87ca41810f2112f9d8c3d6b90dfaeea876b\n"
|
|
95
95
|
}
|
package/strategy.js
CHANGED
|
@@ -3,7 +3,7 @@ import { convertTree } from "@thi.ng/hiccup-svg/convert";
|
|
|
3
3
|
import { serialize } from "@thi.ng/hiccup/serialize";
|
|
4
4
|
import { fit } from "@thi.ng/math/fit";
|
|
5
5
|
import { repeat } from "@thi.ng/strings/repeat";
|
|
6
|
-
import {
|
|
6
|
+
import { barChartVLines } from "@thi.ng/text-canvas/bars";
|
|
7
7
|
import { varToHiccup } from "./var.js";
|
|
8
8
|
const instrumentStrategy = (strategy, instrument) => {
|
|
9
9
|
const acc = [];
|
|
@@ -53,7 +53,7 @@ const fuzzySetToAscii = (opts) => (fn, domain, res) => {
|
|
|
53
53
|
vals.push(fn(i));
|
|
54
54
|
}
|
|
55
55
|
const index = Math.round(fit(res, min, max, 0, vals.length));
|
|
56
|
-
let chart =
|
|
56
|
+
let chart = barChartVLines(height, vals, 0, 1).map(
|
|
57
57
|
(line) => line.substring(0, index) + "|" + line.substring(index + 1)
|
|
58
58
|
).join("\n").replace(/ /g, empty);
|
|
59
59
|
const legend = repeat(" ", index) + "^ " + res.toFixed(2);
|