@thi.ng/fuzzy-viz 2.1.119 → 2.1.122

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-02-10T08:59:56Z
3
+ - **Last updated**: 2024-02-22T11:59:16Z
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
@@ -18,7 +18,7 @@
18
18
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
19
19
 
20
20
  > [!NOTE]
21
- > This is one of 189 standalone projects, maintained as part
21
+ > This is one of 190 standalone projects, maintained as part
22
22
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
23
23
  > and anti-framework.
24
24
  >
@@ -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.01 KB
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
  ![fuzzy set visualization of the example l-var](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/fuzzy/temperature-lvar-2.svg)
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
- [-20, 40],
97
- {
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
- }
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
- cogStrategy({ samples: 1000 }),
136
- fuzzySetToAscii({ width: 40, height: 8 })
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.119",
3
+ "version": "2.1.122",
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.23",
39
- "@thi.ng/fuzzy": "^2.1.66",
40
- "@thi.ng/hiccup": "^5.1.12",
41
- "@thi.ng/hiccup-svg": "^5.2.11",
42
- "@thi.ng/math": "^5.10.0",
43
- "@thi.ng/strings": "^3.7.14",
44
- "@thi.ng/text-canvas": "^2.6.38"
38
+ "@thi.ng/api": "^8.9.25",
39
+ "@thi.ng/fuzzy": "^2.1.68",
40
+ "@thi.ng/hiccup": "^5.1.14",
41
+ "@thi.ng/hiccup-svg": "^5.2.14",
42
+ "@thi.ng/math": "^5.10.2",
43
+ "@thi.ng/strings": "^3.7.16",
44
+ "@thi.ng/text-canvas": "^3.0.2"
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": "25ee18f7db6d03f0b76787267ab071d16df94888\n"
94
+ "gitHead": "4513a1c703bdbf0f0867f03e547e47692e415fac\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 { barChartHLines } from "@thi.ng/text-canvas/bars";
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 = barChartHLines(height, vals, 0, 1).map(
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);