@jrc03c/make-key 0.0.34 → 0.0.35

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/dist/make-key.js CHANGED
@@ -1,55 +1,25 @@
1
1
  (() => {
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined")
12
- return require.apply(this, arguments);
13
- throw new Error('Dynamic require of "' + x + '" is not supported');
14
- });
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
29
- mod2
30
- ));
31
-
32
- // node_modules/@jrc03c/js-math-tools/dist/js-math-tools.import.mjs
33
- var __defProp2 = Object.defineProperty;
34
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
35
- var __publicField = (obj, key, value) => {
36
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
37
- return value;
38
- };
2
+ // node_modules/@jrc03c/js-math-tools/src/is-number.mjs
39
3
  function isNumber(x) {
40
4
  return typeof x === "number" && !isNaN(x) || typeof x === "bigint";
41
5
  }
42
- var isBrowser = new Function(`
43
- try {
44
- return this === window
45
- } catch(e) {}
46
6
 
47
- try {
48
- return typeof importScripts !== "undefined"
49
- } catch(e) {}
7
+ // node_modules/@jrc03c/js-math-tools/src/is-browser.mjs
8
+ var isBrowser = new Function(
9
+ `
10
+ try {
11
+ return this === window
12
+ } catch(e) {}
13
+
14
+ try {
15
+ return !!importScripts
16
+ } catch(e){}
17
+
18
+ return false
19
+ `
20
+ );
50
21
 
51
- return false
52
- `);
22
+ // node_modules/@jrc03c/js-math-tools/src/math-error.mjs
53
23
  var MathError = class extends Error {
54
24
  constructor(message) {
55
25
  if (isBrowser()) {
@@ -59,10 +29,14 @@
59
29
  }
60
30
  }
61
31
  };
32
+
33
+ // node_modules/@jrc03c/js-math-tools/src/assert.mjs
62
34
  function assert(isTrue, message) {
63
35
  if (!isTrue)
64
36
  throw new MathError(message);
65
37
  }
38
+
39
+ // node_modules/@jrc03c/js-math-tools/src/helpers/array-types.mjs
66
40
  var arrayTypes = [
67
41
  Array,
68
42
  ArrayBuffer,
@@ -78,9 +52,13 @@
78
52
  Uint8Array,
79
53
  Uint8ClampedArray
80
54
  ];
55
+
56
+ // node_modules/@jrc03c/js-math-tools/src/is-undefined.mjs
81
57
  function isUndefined(x) {
82
58
  return x === null || typeof x === "undefined";
83
59
  }
60
+
61
+ // node_modules/@jrc03c/js-math-tools/src/is-array.mjs
84
62
  var typeStrings = arrayTypes.map((s2) => s2.name);
85
63
  function isArray(obj) {
86
64
  try {
@@ -95,6 +73,8 @@
95
73
  return false;
96
74
  }
97
75
  }
76
+
77
+ // node_modules/@jrc03c/js-math-tools/src/is-dataframe.mjs
98
78
  function isDataFrame(x) {
99
79
  try {
100
80
  return !!x._symbol && x._symbol === Symbol.for("@jrc03c/js-math-tools/dataframe");
@@ -102,12 +82,18 @@
102
82
  return false;
103
83
  }
104
84
  }
85
+
86
+ // node_modules/@jrc03c/js-math-tools/src/is-function.mjs
105
87
  function isFunction(fn) {
106
88
  return typeof fn === "function";
107
89
  }
90
+
91
+ // node_modules/@jrc03c/js-math-tools/src/is-object.mjs
108
92
  function isObject(x) {
109
93
  return typeof x === "object" && !isUndefined(x) && !isArray(x);
110
94
  }
95
+
96
+ // node_modules/@jrc03c/js-math-tools/src/is-series.mjs
111
97
  function isSeries(x) {
112
98
  try {
113
99
  return !!x._symbol && x._symbol === Symbol.for("@jrc03c/js-math-tools/series");
@@ -115,6 +101,8 @@
115
101
  return false;
116
102
  }
117
103
  }
104
+
105
+ // node_modules/@jrc03c/js-math-tools/src/index-of.mjs
118
106
  function indexOf(x, fn) {
119
107
  if (isDataFrame(x)) {
120
108
  const index = indexOf(x.values, fn);
@@ -133,12 +121,15 @@
133
121
  }
134
122
  return index;
135
123
  }
136
- assert(isObject(x) || isArray(x), "You must pass (1) an object, array, Series, or DataFrame and (2) a function or value into the `indexOf` function!");
124
+ assert(
125
+ isObject(x) || isArray(x),
126
+ "You must pass (1) an object, array, Series, or DataFrame and (2) a function or value into the `indexOf` function!"
127
+ );
137
128
  if (!isFunction(fn)) {
138
129
  const value = fn;
139
130
  fn = (v) => v === value;
140
131
  }
141
- function helper5(x2, fn2, checked) {
132
+ function helper4(x2, fn2, checked) {
142
133
  checked = checked || [];
143
134
  if (checked.indexOf(x2) > -1) {
144
135
  return null;
@@ -152,7 +143,7 @@
152
143
  if (fn2(value)) {
153
144
  return [key];
154
145
  }
155
- const results = helper5(value, fn2, checked);
146
+ const results = helper4(value, fn2, checked);
156
147
  if (results && results.length > 0) {
157
148
  return [key].concat(results);
158
149
  }
@@ -164,7 +155,7 @@
164
155
  if (fn2(value)) {
165
156
  return [i];
166
157
  }
167
- const results = helper5(value, fn2, checked);
158
+ const results = helper4(value, fn2, checked);
168
159
  if (results && results.length > 0) {
169
160
  return [i].concat(results);
170
161
  }
@@ -183,15 +174,17 @@
183
174
  return false;
184
175
  }
185
176
  }
186
- const paths = helper5(x, safeFn);
177
+ const paths = helper4(x, safeFn);
187
178
  if (paths && paths.length > 0) {
188
179
  return paths;
189
180
  } else {
190
181
  return null;
191
182
  }
192
183
  }
184
+
185
+ // node_modules/@jrc03c/js-math-tools/src/copy.mjs
193
186
  function copy(x) {
194
- function helper5(x2) {
187
+ function helper4(x2) {
195
188
  if (typeof x2 === "object") {
196
189
  if (x2 === null) {
197
190
  return null;
@@ -203,32 +196,32 @@
203
196
  return x2.map((v) => copy(v));
204
197
  }
205
198
  if (isSeries(x2)) {
206
- const out3 = x2.copy();
207
- out3.values = copy(out3.values);
208
- return out3;
199
+ const out2 = x2.copy();
200
+ out2.values = copy(out2.values);
201
+ return out2;
209
202
  }
210
203
  if (isDataFrame(x2)) {
211
- const out3 = x2.copy();
212
- out3.values = copy(x2.values);
213
- return out3;
204
+ const out2 = x2.copy();
205
+ out2.values = copy(x2.values);
206
+ return out2;
214
207
  }
215
208
  if (x2 instanceof Date) {
216
209
  return new Date(x2.getTime());
217
210
  }
218
211
  x2 = decycle(x2);
219
- const out2 = {};
212
+ const out = {};
220
213
  Object.keys(x2).concat(Object.getOwnPropertySymbols(x2)).forEach((key) => {
221
- out2[key] = copy(x2[key]);
214
+ out[key] = copy(x2[key]);
222
215
  });
223
- return out2;
216
+ return out;
224
217
  } else {
225
218
  return x2;
226
219
  }
227
220
  }
228
- return helper5(decycle(x));
221
+ return helper4(decycle(x));
229
222
  }
230
223
  function decycle(x) {
231
- function helper5(x2, checked, currentPath) {
224
+ function helper4(x2, checked, currentPath) {
232
225
  checked = checked || [];
233
226
  currentPath = currentPath || "";
234
227
  if (checked.indexOf(x2) > -1) {
@@ -254,10 +247,10 @@
254
247
  if (typeof x2.constructor !== "undefined" && x2.constructor.name !== "Array") {
255
248
  return x2.slice();
256
249
  }
257
- return x2.map((v, i) => helper5(v, checked, currentPath + "/" + i));
250
+ return x2.map((v, i) => helper4(v, checked, currentPath + "/" + i));
258
251
  } else {
259
252
  Object.keys(x2).concat(Object.getOwnPropertySymbols(x2)).forEach((key) => {
260
- x2[key] = helper5(x2[key], checked, currentPath + "/" + key.toString());
253
+ x2[key] = helper4(x2[key], checked, currentPath + "/" + key.toString());
261
254
  });
262
255
  return x2;
263
256
  }
@@ -266,29 +259,33 @@
266
259
  }
267
260
  }
268
261
  const orig = x;
269
- let out2 = helper5(orig);
262
+ let out = helper4(orig);
270
263
  if (isDataFrame(x)) {
271
264
  const temp = x.copy();
272
- temp._values = out2.values;
273
- temp._columns = out2.columns;
274
- temp._index = out2.index;
275
- out2 = temp;
265
+ temp._values = out.values;
266
+ temp._columns = out.columns;
267
+ temp._index = out.index;
268
+ out = temp;
276
269
  }
277
270
  if (isSeries(x)) {
278
271
  const temp = x.copy();
279
- temp.name = out2.name;
280
- temp._values = out2.values;
281
- temp._index = out2.index;
282
- out2 = temp;
272
+ temp.name = out.name;
273
+ temp._values = out.values;
274
+ temp._index = out.index;
275
+ out = temp;
283
276
  }
284
- return out2;
277
+ return out;
285
278
  }
279
+
280
+ // node_modules/@jrc03c/js-math-tools/src/is-date.mjs
286
281
  function isDate(x) {
287
282
  return x instanceof Date && x.toString() !== "Invalid Date";
288
283
  }
284
+
285
+ // node_modules/@jrc03c/js-math-tools/src/is-equal.mjs
289
286
  var numberTypes = ["number", "int", "float", "bigint"];
290
287
  function isEqual(a, b) {
291
- function helper5(a2, b2) {
288
+ function helper4(a2, b2) {
292
289
  const aType = typeof a2;
293
290
  const bType = typeof b2;
294
291
  if (aType !== bType && !numberTypes.includes(aType) && !numberTypes.includes(bType))
@@ -337,7 +334,7 @@
337
334
  return false;
338
335
  for (let i = 0; i < aKeys.length; i++) {
339
336
  const key = aKeys[i];
340
- if (!helper5(a2[key], b2[key]))
337
+ if (!helper4(a2[key], b2[key]))
341
338
  return false;
342
339
  }
343
340
  return true;
@@ -345,17 +342,19 @@
345
342
  }
346
343
  }
347
344
  try {
348
- return helper5(a, b);
345
+ return helper4(a, b);
349
346
  } catch (e) {
350
- return helper5(decycle(a), decycle(b));
347
+ return helper4(decycle(a), decycle(b));
351
348
  }
352
349
  }
350
+
351
+ // node_modules/@jrc03c/js-math-tools/src/helpers/counter.mjs
353
352
  function makeKey(n) {
354
353
  const alpha = "abcdefg1234567890";
355
- let out2 = "";
356
- while (out2.length < n)
357
- out2 += alpha[Math.floor(Math.random() * alpha.length)];
358
- return out2;
354
+ let out = "";
355
+ while (out.length < n)
356
+ out += alpha[Math.floor(Math.random() * alpha.length)];
357
+ return out;
359
358
  }
360
359
  var NULL_KEY = makeKey(16);
361
360
  var UNDEFINED_KEY = makeKey(16);
@@ -415,35 +414,42 @@
415
414
  return this.values.map((v) => ({ value: v, count: this.get(v) }));
416
415
  }
417
416
  toObject() {
418
- const out2 = {};
417
+ const out = {};
419
418
  this.values.forEach((value) => {
420
- out2[value] = this.get(value);
419
+ out[value] = this.get(value);
421
420
  });
422
- return out2;
421
+ return out;
423
422
  }
424
423
  };
424
+
425
+ // node_modules/@jrc03c/js-math-tools/src/flatten.mjs
425
426
  function flatten(arr) {
426
427
  if (isDataFrame(arr) || isSeries(arr)) {
427
428
  return flatten(arr.values);
428
429
  }
429
- assert(isArray(arr), "The `flatten` function only works on arrays, Series, and DataFrames!");
430
- function helper5(arr2) {
431
- let out2 = [];
430
+ assert(
431
+ isArray(arr),
432
+ "The `flatten` function only works on arrays, Series, and DataFrames!"
433
+ );
434
+ function helper4(arr2) {
435
+ let out = [];
432
436
  arr2.forEach((child) => {
433
437
  if (isArray(child)) {
434
- out2 = out2.concat(helper5(child));
438
+ out = out.concat(helper4(child));
435
439
  } else {
436
- out2.push(child);
440
+ out.push(child);
437
441
  }
438
442
  });
439
- return out2;
443
+ return out;
440
444
  }
441
- return helper5(arr);
445
+ return helper4(arr);
442
446
  }
447
+
448
+ // node_modules/@jrc03c/js-math-tools/src/stats.mjs
443
449
  function stats(x, options) {
444
450
  options = options || {};
445
451
  const counts = new Counter();
446
- const out2 = {};
452
+ const out = {};
447
453
  const xflat = flatten(x);
448
454
  const xnums = [];
449
455
  let max2 = -Infinity;
@@ -473,21 +479,23 @@
473
479
  counts.increment(v);
474
480
  }
475
481
  const mean2 = sum2 / xnums.length;
476
- out2.counts = counts;
477
- out2.max = max2;
478
- out2.mean = mean2;
479
- out2.min = min2;
480
- out2.n = xflat.length;
481
- out2.sum = sum2;
482
- if (isNaN(out2.mean)) {
483
- out2.max = NaN;
484
- out2.min = NaN;
482
+ out.counts = counts;
483
+ out.max = max2;
484
+ out.mean = mean2;
485
+ out.min = min2;
486
+ out.n = xflat.length;
487
+ out.sum = sum2;
488
+ if (isNaN(out.mean)) {
489
+ out.max = NaN;
490
+ out.min = NaN;
485
491
  }
486
492
  if (options.shouldDropNaNs) {
487
- out2.nWithoutNaNs = xnums.length;
493
+ out.nWithoutNaNs = xnums.length;
488
494
  }
489
495
  if (options.mode) {
490
- const sortedCountPairs = Array.from(counts.values.map((v) => [v, counts.get(v)])).toSorted((a, b) => b[1] - a[1]);
496
+ const sortedCountPairs = Array.from(
497
+ counts.values.map((v) => [v, counts.get(v)])
498
+ ).toSorted((a, b) => b[1] - a[1]);
491
499
  const highestCount = sortedCountPairs[0][1];
492
500
  const mode2 = [];
493
501
  for (const pair of sortedCountPairs) {
@@ -497,26 +505,26 @@
497
505
  break;
498
506
  }
499
507
  }
500
- out2.mode = mode2.toSorted();
508
+ out.mode = mode2.toSorted();
501
509
  }
502
510
  if (options.median) {
503
511
  if (isNaN(mean2)) {
504
- out2.median = NaN;
512
+ out.median = NaN;
505
513
  } else {
506
514
  const xnumsSorted = xnums.toSorted((a, b) => Number(a) - Number(b));
507
515
  const middle = Math.floor(xnumsSorted.length / 2);
508
516
  if (xnumsSorted.length % 2 === 0) {
509
517
  const left = xnumsSorted[middle - 1];
510
518
  const right = xnumsSorted[middle];
511
- out2.median = (Number(left) + Number(right)) / 2;
519
+ out.median = (Number(left) + Number(right)) / 2;
512
520
  if (resultsShouldIncludeBigInts && typeof left === "bigint" && typeof right === "bigint") {
513
521
  try {
514
- out2.median = BigInt(out2.median);
522
+ out.median = BigInt(out.median);
515
523
  } catch (e) {
516
524
  }
517
525
  }
518
526
  } else {
519
- out2.median = xnumsSorted[middle];
527
+ out.median = xnumsSorted[middle];
520
528
  }
521
529
  }
522
530
  }
@@ -527,20 +535,20 @@
527
535
  }
528
536
  variance2 /= xnums.length;
529
537
  const stdev2 = Math.sqrt(variance2);
530
- out2.stdev = stdev2;
531
- out2.variance = variance2;
538
+ out.stdev = stdev2;
539
+ out.variance = variance2;
532
540
  }
533
541
  if (resultsShouldIncludeBigInts) {
534
542
  try {
535
- out2.sum = BigInt(out2.sum);
543
+ out.sum = BigInt(out.sum);
536
544
  } catch (e) {
537
545
  }
538
546
  try {
539
- out2.mean = BigInt(out2.mean);
547
+ out.mean = BigInt(out.mean);
540
548
  } catch (e) {
541
549
  }
542
550
  if (options.mode) {
543
- out2.mode = out2.mode.map((v) => {
551
+ out.mode = out.mode.map((v) => {
544
552
  try {
545
553
  return BigInt(v);
546
554
  } catch (e) {
@@ -549,8 +557,10 @@
549
557
  });
550
558
  }
551
559
  }
552
- return out2;
560
+ return out;
553
561
  }
562
+
563
+ // node_modules/@jrc03c/js-math-tools/src/count.mjs
554
564
  function count(arr, matcher) {
555
565
  const { counts } = stats(arr);
556
566
  if (!isUndefined(matcher)) {
@@ -570,6 +580,8 @@
570
580
  }
571
581
  return counts;
572
582
  }
583
+
584
+ // node_modules/@jrc03c/js-math-tools/src/is-jagged.mjs
573
585
  function helper(x) {
574
586
  if (isDataFrame(x) || isSeries(x)) {
575
587
  return helper(x.values);
@@ -602,11 +614,16 @@
602
614
  function isJagged(x) {
603
615
  return helper(decycle(x));
604
616
  }
617
+
618
+ // node_modules/@jrc03c/js-math-tools/src/is-nested.mjs
605
619
  function isNested(x) {
606
620
  if (isDataFrame(x) || isSeries(x)) {
607
621
  return isNested(x.values);
608
622
  }
609
- assert(isArray(x), "The `isNested` function only works on arrays, Series, and DataFrames!");
623
+ assert(
624
+ isArray(x),
625
+ "The `isNested` function only works on arrays, Series, and DataFrames!"
626
+ );
610
627
  for (let i = 0; i < x.length; i++) {
611
628
  if (isArray(x[i])) {
612
629
  return true;
@@ -614,6 +631,8 @@
614
631
  }
615
632
  return false;
616
633
  }
634
+
635
+ // node_modules/@jrc03c/js-math-tools/src/ndarray.mjs
617
636
  var error = "You must pass a natural number or a one-dimensional array of natural numbers into the `ndarray` function!";
618
637
  function ndarray(shape2) {
619
638
  assert(!isUndefined(shape2), error);
@@ -627,37 +646,56 @@
627
646
  assert(isNumber(s2), error);
628
647
  assert(s2 >= 0, error);
629
648
  assert(Math.floor(s2) === s2, error);
630
- assert(s2 !== Infinity, "We can't create an array containing an infinite number of values!");
649
+ assert(
650
+ s2 !== Infinity,
651
+ "We can't create an array containing an infinite number of values!"
652
+ );
631
653
  if (shape2.length === 1) {
632
- const out2 = [];
654
+ const out = [];
633
655
  for (let i = 0; i < s2; i++)
634
- out2.push(void 0);
635
- return out2;
656
+ out.push(void 0);
657
+ return out;
636
658
  } else {
637
- const out2 = [];
659
+ const out = [];
638
660
  for (let i = 0; i < s2; i++) {
639
- out2.push(ndarray(shape2.slice(1)));
661
+ out.push(ndarray(shape2.slice(1)));
640
662
  }
641
- return out2;
663
+ return out;
642
664
  }
643
665
  }
666
+
667
+ // node_modules/@jrc03c/js-math-tools/src/reverse.mjs
644
668
  function reverse(arr) {
645
669
  if (isDataFrame(arr) || isSeries(arr)) {
646
- const out3 = arr.copy();
647
- out3.values = reverse(out3.values);
648
- out3.index = reverse(out3.index);
649
- return out3;
670
+ const out2 = arr.copy();
671
+ out2.values = reverse(out2.values);
672
+ out2.index = reverse(out2.index);
673
+ return out2;
650
674
  }
651
- assert(isArray(arr), "The `reverse` function only works on arrays, Series, and DataFrames!");
652
- const out2 = [];
675
+ assert(
676
+ isArray(arr),
677
+ "The `reverse` function only works on arrays, Series, and DataFrames!"
678
+ );
679
+ const out = [];
653
680
  for (let i = arr.length - 1; i >= 0; i--)
654
- out2.push(arr[i]);
655
- return out2;
681
+ out.push(arr[i]);
682
+ return out;
656
683
  }
684
+
685
+ // node_modules/@jrc03c/js-math-tools/src/range.mjs
657
686
  function range(a, b, step = 1) {
658
- assert(!isUndefined(a) && !isUndefined(b) && !isUndefined(step), "You must pass two numbers and optionally a step value to the `range` function!");
659
- assert(isNumber(a) && isNumber(b) && isNumber(step), "You must pass two numbers and optionally a step value to the `range` function!");
660
- assert(step > 0, "The step value must be greater than 0! (NOTE: The step value is a magnitude; it does not indicate direction.)");
687
+ assert(
688
+ !isUndefined(a) && !isUndefined(b) && !isUndefined(step),
689
+ "You must pass two numbers and optionally a step value to the `range` function!"
690
+ );
691
+ assert(
692
+ isNumber(a) && isNumber(b) && isNumber(step),
693
+ "You must pass two numbers and optionally a step value to the `range` function!"
694
+ );
695
+ assert(
696
+ step > 0,
697
+ "The step value must be greater than 0! (NOTE: The step value is a magnitude; it does not indicate direction.)"
698
+ );
661
699
  let shouldReverse = false;
662
700
  const shouldIncludeBigInts = typeof a === "bigint" || typeof b === "bigint" || typeof step === "bigint";
663
701
  a = Number(a);
@@ -669,28 +707,30 @@
669
707
  a = b + step;
670
708
  b = buffer + step;
671
709
  }
672
- let out2 = [];
710
+ let out = [];
673
711
  for (let i = a; i < b; i += step) {
674
712
  if (shouldIncludeBigInts) {
675
713
  try {
676
- out2.push(BigInt(i));
714
+ out.push(BigInt(i));
677
715
  } catch (e) {
678
- out2.push(i);
716
+ out.push(i);
679
717
  }
680
718
  } else {
681
- out2.push(i);
719
+ out.push(i);
682
720
  }
683
721
  }
684
722
  if (shouldReverse)
685
- out2 = reverse(out2);
686
- return out2;
723
+ out = reverse(out);
724
+ return out;
687
725
  }
726
+
727
+ // node_modules/@jrc03c/js-math-tools/src/set.mjs
688
728
  function makeKey2(n) {
689
729
  const alpha = "abcdefg1234567890";
690
- let out2 = "";
691
- while (out2.length < n)
692
- out2 += alpha[Math.floor(Math.random() * alpha.length)];
693
- return out2;
730
+ let out = "";
731
+ while (out.length < n)
732
+ out += alpha[Math.floor(Math.random() * alpha.length)];
733
+ return out;
694
734
  }
695
735
  var NULL_KEY2 = makeKey2(256);
696
736
  var UNDEFINED_KEY2 = makeKey2(256);
@@ -701,17 +741,22 @@
701
741
  if (isDataFrame(arr) || isSeries(arr)) {
702
742
  return set(arr.values);
703
743
  }
704
- assert(isArray(arr), "The `set` function only works on arrays, Series, and DataFrames!");
705
- const out2 = [];
744
+ assert(
745
+ isArray(arr),
746
+ "The `set` function only works on arrays, Series, and DataFrames!"
747
+ );
748
+ const out = [];
706
749
  const temp = {};
707
750
  flatten(arr).forEach((item) => {
708
751
  const key = typeof item === "object" && item === null ? NULL_KEY2 : isUndefined(item) ? UNDEFINED_KEY2 : isFunction(item) ? item.toString() : typeof item === "symbol" ? item.toString() + " - " + SYMBOL_KEY2 : item === Infinity ? INFINITY_KEY2 : item === -Infinity ? MINUS_INFINITY_KEY2 : typeof item === "bigint" ? item.toString() : isDataFrame(item) ? item.toJSONString() : isSeries(item) ? JSON.stringify(item.toObject()) : JSON.stringify(item);
709
752
  if (!temp[key])
710
- out2.push(item);
753
+ out.push(item);
711
754
  temp[key] = true;
712
755
  });
713
- return out2;
756
+ return out;
714
757
  }
758
+
759
+ // node_modules/@jrc03c/js-math-tools/src/shape.mjs
715
760
  function helper2(x) {
716
761
  if (isArray(x)) {
717
762
  const childShapes = helper2(x[0]);
@@ -724,105 +769,120 @@
724
769
  if (isDataFrame(x) || isSeries(x)) {
725
770
  return shape(x.values);
726
771
  }
727
- assert(isArray(x), "The `shape` function only works on arrays, Series, and DataFrames!");
772
+ assert(
773
+ isArray(x),
774
+ "The `shape` function only works on arrays, Series, and DataFrames!"
775
+ );
728
776
  return helper2(x);
729
777
  }
778
+
779
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-append.mjs
730
780
  function dfAppend(df, x, axis) {
731
781
  if (isUndefined(axis)) {
732
782
  axis = 0;
733
783
  }
734
- assert(axis === 0 || axis === 1 || axis === "vertical" || axis === "horizontal", 'The only valid axis values for use when appending data to a DataFrame are 0, 1, "vertical", and "horizontal". Note that 0 == "horizontal" and 1 == "vertical".');
784
+ assert(
785
+ axis === 0 || axis === 1 || axis === "vertical" || axis === "horizontal",
786
+ 'The only valid axis values for use when appending data to a DataFrame are 0, 1, "vertical", and "horizontal". Note that 0 == "horizontal" and 1 == "vertical".'
787
+ );
735
788
  if (isArray(x)) {
736
- assert(!isJagged(x), "The array of data you're trying to append to this DataFrame is jagged!");
789
+ assert(
790
+ !isJagged(x),
791
+ "The array of data you're trying to append to this DataFrame is jagged!"
792
+ );
737
793
  const xShape = shape(x);
738
794
  if (xShape.length === 1) {
739
795
  if (axis === 0) {
740
- const out2 = df.copy();
741
- out2._values.push(x);
796
+ const out = df.copy();
797
+ out._values.push(x);
742
798
  const maxRowLength = Math.max(df.shape[1], xShape[0]);
743
- out2._values.forEach((row) => {
799
+ out._values.forEach((row) => {
744
800
  while (row.length < maxRowLength) {
745
801
  row.push(void 0);
746
802
  }
747
803
  });
748
- while (out2._index.length < out2._values.length) {
749
- out2._index.push("row" + out2._index.length);
804
+ while (out._index.length < out._values.length) {
805
+ out._index.push("row" + out._index.length);
750
806
  }
751
- while (out2._columns.length < maxRowLength) {
752
- out2._columns.push("col" + out2._columns.length);
807
+ while (out._columns.length < maxRowLength) {
808
+ out._columns.push("col" + out._columns.length);
753
809
  }
754
- return out2;
810
+ return out;
755
811
  } else {
756
812
  const maxColLength = Math.max(df.shape[0], xShape[0]);
757
- const out2 = df.copy();
813
+ const out = df.copy();
758
814
  range(0, maxColLength).forEach((i) => {
759
- if (i >= out2._values.length) {
760
- out2._values.push(ndarray(df.shape[1]));
815
+ if (i >= out._values.length) {
816
+ out._values.push(ndarray(df.shape[1]));
761
817
  }
762
- out2._values[i].push(x[i]);
818
+ out._values[i].push(x[i]);
763
819
  });
764
- while (out2._index.length < out2._values.length) {
765
- out2._index.push("row" + out2._index.length);
820
+ while (out._index.length < out._values.length) {
821
+ out._index.push("row" + out._index.length);
766
822
  }
767
- while (out2._columns.length < out2._values[0].length) {
768
- out2._columns.push("col" + out2._columns.length);
823
+ while (out._columns.length < out._values[0].length) {
824
+ out._columns.push("col" + out._columns.length);
769
825
  }
770
- return out2;
826
+ return out;
771
827
  }
772
828
  } else if (xShape.length === 2) {
773
829
  if (axis === 0) {
774
- const maxRowLength = Math.max(...x.map((row) => row.length).concat([df.shape[1]]));
775
- const out2 = df.copy();
776
- out2._values = out2._values.concat(x).map((row) => {
830
+ const maxRowLength = Math.max(
831
+ ...x.map((row) => row.length).concat([df.shape[1]])
832
+ );
833
+ const out = df.copy();
834
+ out._values = out._values.concat(x).map((row) => {
777
835
  while (row.length < maxRowLength) {
778
836
  row.push(void 0);
779
837
  }
780
838
  return row;
781
839
  });
782
- while (out2._index.length < out2._values.length) {
783
- out2._index.push("row" + out2._index.length);
840
+ while (out._index.length < out._values.length) {
841
+ out._index.push("row" + out._index.length);
784
842
  }
785
- while (out2._columns.length < maxRowLength) {
786
- out2._columns.push("col" + out2._columns.length);
843
+ while (out._columns.length < maxRowLength) {
844
+ out._columns.push("col" + out._columns.length);
787
845
  }
788
- return out2;
846
+ return out;
789
847
  } else {
790
848
  const maxRowLength = Math.max(...x.map((row) => row.length)) + df.shape[1];
791
849
  const maxColLength = Math.max(df.shape[0], xShape[0]);
792
- const out2 = df.copy();
850
+ const out = df.copy();
793
851
  range(0, maxColLength).forEach((i) => {
794
- if (i >= out2._values.length) {
795
- out2._values.push(ndarray(df.shape[1]));
852
+ if (i >= out._values.length) {
853
+ out._values.push(ndarray(df.shape[1]));
796
854
  }
797
- out2._values[i] = out2._values[i].concat(x[i]);
798
- while (out2._values[i].length < maxRowLength) {
799
- out2._values[i].push(void 0);
855
+ out._values[i] = out._values[i].concat(x[i]);
856
+ while (out._values[i].length < maxRowLength) {
857
+ out._values[i].push(void 0);
800
858
  }
801
859
  });
802
- while (out2._index.length < out2._values.length) {
803
- out2._index.push("row" + out2._index.length);
860
+ while (out._index.length < out._values.length) {
861
+ out._index.push("row" + out._index.length);
804
862
  }
805
- while (out2._columns.length < maxRowLength) {
806
- out2._columns.push("col" + out2._columns.length);
863
+ while (out._columns.length < maxRowLength) {
864
+ out._columns.push("col" + out._columns.length);
807
865
  }
808
- return out2;
866
+ return out;
809
867
  }
810
868
  } else {
811
- throw new MathError("Only 1- and 2-dimensional arrays can be appended to a DataFrame!");
869
+ throw new MathError(
870
+ "Only 1- and 2-dimensional arrays can be appended to a DataFrame!"
871
+ );
812
872
  }
813
873
  } else if (isSeries(x)) {
814
- const out2 = dfAppend(df, x.values, axis);
874
+ const out = dfAppend(df, x.values, axis);
815
875
  if (axis === 0) {
816
- out2.index[out2.index.length - 1] = out2.index.indexOf(x.name) > -1 ? x.name + " (2)" : x.name;
876
+ out.index[out.index.length - 1] = out.index.indexOf(x.name) > -1 ? x.name + " (2)" : x.name;
817
877
  } else {
818
- out2.columns[out2.columns.length - 1] = out2.columns.indexOf(x.name) > -1 ? x.name + " (2)" : x.name;
878
+ out.columns[out.columns.length - 1] = out.columns.indexOf(x.name) > -1 ? x.name + " (2)" : x.name;
819
879
  }
820
- return out2;
880
+ return out;
821
881
  } else if (isDataFrame(x)) {
822
882
  if (axis === 0) {
823
- const out2 = df.copy();
824
- const maxRowLength = set(out2._columns.concat(x._columns)).length;
825
- out2._values.forEach((row) => {
883
+ const out = df.copy();
884
+ const maxRowLength = set(out._columns.concat(x._columns)).length;
885
+ out._values.forEach((row) => {
826
886
  while (row.length < maxRowLength) {
827
887
  row.push(void 0);
828
888
  }
@@ -830,7 +890,7 @@
830
890
  x.apply((row) => {
831
891
  const rowCopy = row.copy();
832
892
  const temp = [];
833
- out2._columns.forEach((col) => {
893
+ out._columns.forEach((col) => {
834
894
  const index = rowCopy._index.indexOf(col);
835
895
  if (index > -1) {
836
896
  temp.push(rowCopy._values[index]);
@@ -840,42 +900,58 @@
840
900
  temp.push(void 0);
841
901
  }
842
902
  });
843
- out2._values.push(temp.concat(rowCopy._values));
903
+ out._values.push(temp.concat(rowCopy._values));
844
904
  }, 1);
845
- out2._columns = out2._columns.concat(x._columns.filter((c) => out2._columns.indexOf(c) < 0));
846
- while (out2._index.length < out2._values.length) {
847
- const newRowName = "row" + out2._index.length;
848
- out2._index.push(newRowName + (df._index.indexOf(newRowName) > -1 ? " (2)" : ""));
849
- }
850
- return out2;
905
+ out._columns = out._columns.concat(
906
+ x._columns.filter((c) => out._columns.indexOf(c) < 0)
907
+ );
908
+ while (out._index.length < out._values.length) {
909
+ const newRowName = "row" + out._index.length;
910
+ out._index.push(
911
+ newRowName + (df._index.indexOf(newRowName) > -1 ? " (2)" : "")
912
+ );
913
+ }
914
+ return out;
851
915
  } else {
852
- const out2 = df.copy();
853
- out2._index.forEach((rowName, i) => {
916
+ const out = df.copy();
917
+ out._index.forEach((rowName, i) => {
854
918
  const xIndex = x._index.indexOf(rowName);
855
919
  if (xIndex > -1) {
856
- out2._values[i] = out2._values[i].concat(x._values[xIndex]);
920
+ out._values[i] = out._values[i].concat(x._values[xIndex]);
857
921
  } else {
858
- out2._values[i] = out2._values[i].concat(ndarray(x.shape[1]));
922
+ out._values[i] = out._values[i].concat(ndarray(x.shape[1]));
859
923
  }
860
924
  });
861
925
  x._index.forEach((rowName, i) => {
862
- const outIndex = out2._index.indexOf(rowName);
926
+ const outIndex = out._index.indexOf(rowName);
863
927
  if (outIndex < 0) {
864
- out2._index.push(rowName);
865
- out2._values.push(ndarray(out2._columns.length).concat(x._values[i]));
928
+ out._index.push(rowName);
929
+ out._values.push(ndarray(out._columns.length).concat(x._values[i]));
866
930
  }
867
931
  });
868
- out2._columns = out2._columns.concat(x._columns.map((c) => c + (out2._columns.indexOf(c) > -1 ? " (2)" : "")));
869
- return out2;
932
+ out._columns = out._columns.concat(
933
+ x._columns.map((c) => c + (out._columns.indexOf(c) > -1 ? " (2)" : ""))
934
+ );
935
+ return out;
870
936
  }
871
937
  } else {
872
- throw new MathError("Only 1- or 2-dimensional arrays, Series, and DataFrames can be appended to a DataFrame!");
938
+ throw new MathError(
939
+ "Only 1- or 2-dimensional arrays, Series, and DataFrames can be appended to a DataFrame!"
940
+ );
873
941
  }
874
942
  }
943
+
944
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-apply.mjs
875
945
  function dfApply(DataFrame2, Series2, df, fn, axis) {
876
946
  axis = axis || 0;
877
- assert(isFunction(fn), "The first parameter to the `apply` method must be a function.");
878
- assert(axis === 0 || axis === 1, "The second parameter to the `apply` method (the `axis`) must be 0 or 1.");
947
+ assert(
948
+ isFunction(fn),
949
+ "The first parameter to the `apply` method must be a function."
950
+ );
951
+ assert(
952
+ axis === 0 || axis === 1,
953
+ "The second parameter to the `apply` method (the `axis`) must be 0 or 1."
954
+ );
879
955
  if (axis === 0) {
880
956
  const temp = {};
881
957
  let shouldReturnADataFrame;
@@ -894,13 +970,13 @@
894
970
  }
895
971
  });
896
972
  if (shouldReturnADataFrame) {
897
- const out2 = new DataFrame2(temp);
898
- out2.index = df.index;
899
- return out2;
973
+ const out = new DataFrame2(temp);
974
+ out.index = df.index;
975
+ return out;
900
976
  } else {
901
- const out2 = new Series2(df.columns.map((colName) => temp[colName]));
902
- out2.index = df.columns;
903
- return out2;
977
+ const out = new Series2(df.columns.map((colName) => temp[colName]));
978
+ out.index = df.columns;
979
+ return out;
904
980
  }
905
981
  } else if (axis === 1) {
906
982
  let shouldReturnADataFrame;
@@ -919,36 +995,48 @@
919
995
  }
920
996
  });
921
997
  if (shouldReturnADataFrame) {
922
- const out2 = new DataFrame2(temp);
923
- out2.index = df.index;
924
- out2.columns = df.columns;
925
- return out2;
998
+ const out = new DataFrame2(temp);
999
+ out.index = df.index;
1000
+ out.columns = df.columns;
1001
+ return out;
926
1002
  } else {
927
- const out2 = new Series2(temp);
928
- out2.index = df.index;
929
- return out2;
1003
+ const out = new Series2(temp);
1004
+ out.index = df.index;
1005
+ return out;
930
1006
  }
931
1007
  }
932
1008
  }
1009
+
1010
+ // node_modules/@jrc03c/js-math-tools/src/is-string.mjs
933
1011
  function isString(s2) {
934
1012
  return typeof s2 === "string";
935
1013
  }
1014
+
1015
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-assign.mjs
936
1016
  function dfAssign(DataFrame2, Series2, df, p1, p2) {
937
1017
  const isDataFrame2 = (x) => x instanceof DataFrame2;
938
1018
  const isSeries2 = (x) => x instanceof Series2;
939
1019
  if (!isUndefined(p2)) {
940
- assert(isString(p1), "If passing two arguments into the `assign` method, then the first argument must be a string name!");
941
- assert(isArray(p2) && !isJagged(p2) && shape(p2).length === 1, "If passing two arguments into the `assign` method, then the second argument must be a 1-dimensional array!");
942
- const out2 = df.append(p2, 1);
943
- out2.columns[out2.columns.length - 1] = p1;
944
- return out2;
1020
+ assert(
1021
+ isString(p1),
1022
+ "If passing two arguments into the `assign` method, then the first argument must be a string name!"
1023
+ );
1024
+ assert(
1025
+ isArray(p2) && !isJagged(p2) && shape(p2).length === 1,
1026
+ "If passing two arguments into the `assign` method, then the second argument must be a 1-dimensional array!"
1027
+ );
1028
+ const out = df.append(p2, 1);
1029
+ out.columns[out.columns.length - 1] = p1;
1030
+ return out;
945
1031
  } else {
946
1032
  if (isDataFrame2(p1)) {
947
1033
  return df.append(p1, 1);
948
1034
  } else if (isSeries2(p1)) {
949
1035
  return df.append(p1, 1);
950
1036
  } else if (isObject(p1)) {
951
- const maxColumnLength = Math.max(...Object.keys(p1).concat(Object.getOwnPropertySymbols(p1)).map((key) => p1[key].length));
1037
+ const maxColumnLength = Math.max(
1038
+ ...Object.keys(p1).concat(Object.getOwnPropertySymbols(p1)).map((key) => p1[key].length)
1039
+ );
952
1040
  Object.keys(p1).concat(Object.getOwnPropertySymbols(p1)).forEach((key) => {
953
1041
  while (p1[key].length < maxColumnLength) {
954
1042
  p1[key].push(void 0);
@@ -956,18 +1044,24 @@
956
1044
  });
957
1045
  return df.append(new DataFrame2(p1), 1);
958
1046
  } else {
959
- throw new MathError("You must pass a DataFrame, Series, or object into the `assign` method!");
1047
+ throw new MathError(
1048
+ "You must pass a DataFrame, Series, or object into the `assign` method!"
1049
+ );
960
1050
  }
961
1051
  }
962
1052
  }
1053
+
1054
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-copy.mjs
963
1055
  function dfCopy(DataFrame2, df) {
964
1056
  if (df.isEmpty)
965
1057
  return new DataFrame2();
966
- const out2 = new DataFrame2(copy(df.values));
967
- out2.columns = df.columns.slice();
968
- out2.index = df.index.slice();
969
- return out2;
1058
+ const out = new DataFrame2(copy(df.values));
1059
+ out.columns = df.columns.slice();
1060
+ out.index = df.index.slice();
1061
+ return out;
970
1062
  }
1063
+
1064
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-drop.mjs
971
1065
  function dfDrop(DataFrame2, Series2, df, rows, cols) {
972
1066
  if (isUndefined(rows))
973
1067
  rows = [];
@@ -977,10 +1071,22 @@
977
1071
  rows = [rows];
978
1072
  if (isString(cols) || isNumber(cols))
979
1073
  cols = [cols];
980
- assert(isArray(rows), "The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings.");
981
- assert(isArray(cols), "The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings.");
982
- assert(shape(rows).length === 1, "The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings.");
983
- assert(shape(cols).length === 1, "The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings.");
1074
+ assert(
1075
+ isArray(rows),
1076
+ "The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."
1077
+ );
1078
+ assert(
1079
+ isArray(cols),
1080
+ "The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."
1081
+ );
1082
+ assert(
1083
+ shape(rows).length === 1,
1084
+ "The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."
1085
+ );
1086
+ assert(
1087
+ shape(cols).length === 1,
1088
+ "The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."
1089
+ );
984
1090
  let outIndex, outColumns;
985
1091
  df.index.forEach((row, i) => {
986
1092
  if (rows.indexOf(row) < 0 && rows.indexOf(i) < 0) {
@@ -996,30 +1102,45 @@
996
1102
  outColumns.push(col);
997
1103
  }
998
1104
  });
999
- let out2 = df.get(outIndex, outColumns);
1000
- if (out2 instanceof Series2) {
1105
+ let out = df.get(outIndex, outColumns);
1106
+ if (out instanceof Series2) {
1001
1107
  let temp = new DataFrame2();
1002
- temp = temp.assign(out2);
1003
- if (df.index.indexOf(out2.name) > -1)
1108
+ temp = temp.assign(out);
1109
+ if (df.index.indexOf(out.name) > -1)
1004
1110
  temp = temp.transpose();
1005
- out2 = temp;
1111
+ out = temp;
1006
1112
  }
1007
- return out2;
1113
+ return out;
1008
1114
  }
1115
+
1116
+ // node_modules/@jrc03c/js-math-tools/src/helpers/is-integer.mjs
1009
1117
  function isInteger(x) {
1010
1118
  return isNumber(x) && (x >= 0 ? Math.floor(x) === x : Math.ceil(x) === x);
1011
1119
  }
1120
+
1121
+ // node_modules/@jrc03c/js-math-tools/src/helpers/is-whole-number.mjs
1012
1122
  function isWholeNumber(x) {
1013
1123
  return isInteger(x) && x >= 0;
1014
1124
  }
1125
+
1126
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-drop-missing.mjs
1015
1127
  function dfDropMissing(DataFrame2, Series2, df, axis, condition, threshold) {
1016
1128
  axis = axis || 0;
1017
- assert(axis === 0 || axis === 1, "The first parameter of the `dropMissing` method (the `axis`) must be 0 or 1.");
1129
+ assert(
1130
+ axis === 0 || axis === 1,
1131
+ "The first parameter of the `dropMissing` method (the `axis`) must be 0 or 1."
1132
+ );
1018
1133
  threshold = threshold || 0;
1019
- assert(isWholeNumber(threshold), "The third parameter of the `dropMissing` method (the `threshold`) should be a whole number (meaning that data should be dropped if it contains more than `threshold` null values).");
1134
+ assert(
1135
+ isWholeNumber(threshold),
1136
+ "The third parameter of the `dropMissing` method (the `threshold`) should be a whole number (meaning that data should be dropped if it contains more than `threshold` null values)."
1137
+ );
1020
1138
  condition = threshold > 0 ? "none" : condition || "any";
1021
- assert(condition === "any" || condition === "all" || condition === "none", "The second parameter of the `dropMissing` method (the `condition` parameter, which indicates the condition under which data should be dropped) should be 'any' or 'all' (meaning that if 'any' of the data contains null values, then it should be dropped; or that if 'all' of the data contains null values, then it should be dropped).");
1022
- function helper5(values) {
1139
+ assert(
1140
+ condition === "any" || condition === "all" || condition === "none",
1141
+ "The second parameter of the `dropMissing` method (the `condition` parameter, which indicates the condition under which data should be dropped) should be 'any' or 'all' (meaning that if 'any' of the data contains null values, then it should be dropped; or that if 'all' of the data contains null values, then it should be dropped)."
1142
+ );
1143
+ function helper4(values) {
1023
1144
  if (threshold > 0) {
1024
1145
  let count2 = 0;
1025
1146
  for (let i = 0; i < values.length; i++) {
@@ -1045,28 +1166,28 @@
1045
1166
  }
1046
1167
  return values;
1047
1168
  }
1048
- let out2 = df.copy();
1169
+ let out = df.copy();
1049
1170
  const tempID = Math.random().toString();
1050
1171
  if (axis === 0) {
1051
- out2 = out2.assign(tempID, out2.index);
1052
- const newValues = out2.values.map(helper5).filter((row) => row.length > 0);
1172
+ out = out.assign(tempID, out.index);
1173
+ const newValues = out.values.map(helper4).filter((row) => row.length > 0);
1053
1174
  if (shape(newValues).length < 2)
1054
1175
  return new DataFrame2();
1055
- out2.values = newValues;
1056
- let newIndex = out2.get(null, tempID);
1176
+ out.values = newValues;
1177
+ let newIndex = out.get(null, tempID);
1057
1178
  if (isUndefined(newIndex))
1058
1179
  return new DataFrame2();
1059
1180
  if (isString(newIndex))
1060
1181
  newIndex = [newIndex];
1061
1182
  if (newIndex instanceof Series2)
1062
1183
  newIndex = newIndex.values;
1063
- out2.index = newIndex;
1064
- out2 = out2.drop(null, tempID);
1184
+ out.index = newIndex;
1185
+ out = out.drop(null, tempID);
1065
1186
  } else if (axis === 1) {
1066
1187
  const temp = {};
1067
- out2.columns.forEach((colName, i) => {
1068
- const values = out2.values.map((row) => row[i]);
1069
- const newValues = helper5(values);
1188
+ out.columns.forEach((colName, i) => {
1189
+ const values = out.values.map((row) => row[i]);
1190
+ const newValues = helper4(values);
1070
1191
  if (newValues.length > 0) {
1071
1192
  temp[colName] = newValues;
1072
1193
  }
@@ -1075,36 +1196,52 @@
1075
1196
  return new DataFrame2();
1076
1197
  }
1077
1198
  const newOut = new DataFrame2(temp);
1078
- newOut.index = out2.index;
1199
+ newOut.index = out.index;
1079
1200
  return newOut;
1080
1201
  }
1081
- return out2;
1202
+ return out;
1082
1203
  }
1204
+
1205
+ // node_modules/@jrc03c/js-math-tools/src/drop-nan.mjs
1083
1206
  function dropNaN(x) {
1084
1207
  if (isDataFrame(x) || isSeries(x)) {
1085
1208
  return x.dropNaN(...Object.values(arguments).slice(1));
1086
1209
  }
1087
- assert(isArray(x), "The `dropNaN` function only works on arrays, Series, and DataFrames!");
1088
- const out2 = [];
1210
+ assert(
1211
+ isArray(x),
1212
+ "The `dropNaN` function only works on arrays, Series, and DataFrames!"
1213
+ );
1214
+ const out = [];
1089
1215
  x.forEach((v) => {
1090
1216
  try {
1091
- return out2.push(dropNaN(v));
1217
+ return out.push(dropNaN(v));
1092
1218
  } catch (e) {
1093
1219
  if (isNumber(v)) {
1094
- return out2.push(v);
1220
+ return out.push(v);
1095
1221
  }
1096
1222
  }
1097
1223
  });
1098
- return out2;
1224
+ return out;
1099
1225
  }
1226
+
1227
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-drop-nan.mjs
1100
1228
  function dfDropNaN(DataFrame2, df, axis, condition, threshold) {
1101
1229
  axis = axis || 0;
1102
- assert(axis === 0 || axis === 1, "The first parameter of the `dropNaN` method (the `axis`) must be 0 or 1.");
1230
+ assert(
1231
+ axis === 0 || axis === 1,
1232
+ "The first parameter of the `dropNaN` method (the `axis`) must be 0 or 1."
1233
+ );
1103
1234
  threshold = threshold || 0;
1104
- assert(isWholeNumber(threshold), "The third parameter of the `dropNaN` method (the `threshold`) should be a whole number (meaning that data should be dropped if it contains more than `threshold` NaN values).");
1235
+ assert(
1236
+ isWholeNumber(threshold),
1237
+ "The third parameter of the `dropNaN` method (the `threshold`) should be a whole number (meaning that data should be dropped if it contains more than `threshold` NaN values)."
1238
+ );
1105
1239
  condition = threshold > 0 ? "none" : condition || "any";
1106
- assert(condition === "any" || condition === "all" || condition === "none", "The second parameter of the `dropNaN` method (the `condition` parameter, which indicates the condition under which data should be dropped) should be 'any' or 'all' (meaning that if 'any' of the data contains NaN values, then it should be dropped; or that if 'all' of the data contains NaN values, then it should be dropped).");
1107
- function helper5(values) {
1240
+ assert(
1241
+ condition === "any" || condition === "all" || condition === "none",
1242
+ "The second parameter of the `dropNaN` method (the `condition` parameter, which indicates the condition under which data should be dropped) should be 'any' or 'all' (meaning that if 'any' of the data contains NaN values, then it should be dropped; or that if 'all' of the data contains NaN values, then it should be dropped)."
1243
+ );
1244
+ function helper4(values) {
1108
1245
  const numericalValues = dropNaN(values);
1109
1246
  if (threshold > 0)
1110
1247
  return values.length - numericalValues.length < threshold;
@@ -1114,51 +1251,59 @@
1114
1251
  return numericalValues.length > 0;
1115
1252
  return true;
1116
1253
  }
1117
- const out2 = df.copy();
1254
+ const out = df.copy();
1118
1255
  if (axis === 0) {
1119
- const rowsToKeep = out2.index.filter((row) => {
1120
- const values = out2.get(row, null).values;
1121
- return helper5(values);
1256
+ const rowsToKeep = out.index.filter((row) => {
1257
+ const values = out.get(row, null).values;
1258
+ return helper4(values);
1122
1259
  });
1123
1260
  if (rowsToKeep.length > 0)
1124
- return out2.get(rowsToKeep, null);
1261
+ return out.get(rowsToKeep, null);
1125
1262
  else
1126
1263
  return new DataFrame2();
1127
1264
  } else if (axis === 1) {
1128
- const colsToKeep = out2.columns.filter((col) => {
1129
- const values = out2.get(null, col).values;
1130
- return helper5(values);
1265
+ const colsToKeep = out.columns.filter((col) => {
1266
+ const values = out.get(null, col).values;
1267
+ return helper4(values);
1131
1268
  });
1132
1269
  if (colsToKeep.length > 0)
1133
- return out2.get(null, colsToKeep);
1270
+ return out.get(null, colsToKeep);
1134
1271
  else
1135
1272
  return new DataFrame2();
1136
1273
  }
1137
- return out2;
1274
+ return out;
1138
1275
  }
1276
+
1277
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-filter.mjs
1139
1278
  function arrayToObject(x) {
1140
- const out2 = {};
1279
+ const out = {};
1141
1280
  flatten(x).forEach((value, i) => {
1142
- out2[value] = i;
1281
+ out[value] = i;
1143
1282
  });
1144
- return out2;
1283
+ return out;
1145
1284
  }
1146
1285
  function undoArrayToObject(obj) {
1147
1286
  return Object.keys(obj).concat(Object.getOwnPropertySymbols(obj)).sort((a, b) => obj[a] - obj[b]);
1148
1287
  }
1149
1288
  function dfFilter(DataFrame2, Series2, df, fn, axis) {
1150
- assert(isFunction(fn), "The `filter` method takes a single parameter: a function that is used to filter the values.");
1289
+ assert(
1290
+ isFunction(fn),
1291
+ "The `filter` method takes a single parameter: a function that is used to filter the values."
1292
+ );
1151
1293
  if (isUndefined(axis))
1152
1294
  axis = 0;
1153
- assert(axis === 0 || axis === 1, "The `axis` parameter to the `filter` method must be 0 or 1.");
1154
- let out2 = df.copy();
1155
- if (out2.isEmpty)
1156
- return out2;
1157
- const index = arrayToObject(out2.index);
1158
- const columns = arrayToObject(out2.columns);
1295
+ assert(
1296
+ axis === 0 || axis === 1,
1297
+ "The `axis` parameter to the `filter` method must be 0 or 1."
1298
+ );
1299
+ let out = df.copy();
1300
+ if (out.isEmpty)
1301
+ return out;
1302
+ const index = arrayToObject(out.index);
1303
+ const columns = arrayToObject(out.columns);
1159
1304
  if (axis === 0) {
1160
1305
  let count2 = 0;
1161
- const newValues = out2.values.filter((row, i) => {
1306
+ const newValues = out.values.filter((row, i) => {
1162
1307
  const series = new Series2(row);
1163
1308
  series.name = df.index[i];
1164
1309
  series.index = df.columns;
@@ -1166,7 +1311,7 @@
1166
1311
  if (shouldKeep) {
1167
1312
  count2++;
1168
1313
  } else {
1169
- delete index[out2.index[i]];
1314
+ delete index[out.index[i]];
1170
1315
  }
1171
1316
  return shouldKeep;
1172
1317
  });
@@ -1179,12 +1324,12 @@
1179
1324
  temp.index = undoArrayToObject(columns);
1180
1325
  return temp;
1181
1326
  }
1182
- out2.values = newValues;
1183
- out2.index = undoArrayToObject(index);
1327
+ out.values = newValues;
1328
+ out.index = undoArrayToObject(index);
1184
1329
  } else if (axis === 1) {
1185
- out2 = out2.transpose();
1330
+ out = out.transpose();
1186
1331
  let count2 = 0;
1187
- const newValues = out2.values.filter((row, i) => {
1332
+ const newValues = out.values.filter((row, i) => {
1188
1333
  const series = new Series2(row);
1189
1334
  series.name = df.columns[i];
1190
1335
  series.index = df.index;
@@ -1192,7 +1337,7 @@
1192
1337
  if (shouldKeep) {
1193
1338
  count2++;
1194
1339
  } else {
1195
- delete columns[out2.index[i]];
1340
+ delete columns[out.index[i]];
1196
1341
  }
1197
1342
  return shouldKeep;
1198
1343
  });
@@ -1205,12 +1350,14 @@
1205
1350
  temp.index = undoArrayToObject(index);
1206
1351
  return temp;
1207
1352
  }
1208
- out2.values = newValues;
1209
- out2.index = undoArrayToObject(columns);
1210
- out2 = out2.transpose();
1353
+ out.values = newValues;
1354
+ out.index = undoArrayToObject(columns);
1355
+ out = out.transpose();
1211
1356
  }
1212
- return out2;
1357
+ return out;
1213
1358
  }
1359
+
1360
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-get.mjs
1214
1361
  function dfGet(df, rows, cols) {
1215
1362
  if (isString(rows) || isNumber(rows))
1216
1363
  rows = [rows];
@@ -1227,13 +1374,25 @@
1227
1374
  }
1228
1375
  }
1229
1376
  const types = set((rows || []).concat(cols || []).map((v) => typeof v));
1230
- assert(types.length <= 2, "Only whole numbers and/or strings are allowed in `get` arrays!");
1377
+ assert(
1378
+ types.length <= 2,
1379
+ "Only whole numbers and/or strings are allowed in `get` arrays!"
1380
+ );
1231
1381
  if (types.length === 1) {
1232
- assert(types[0] === "string" || types[0] === "number", "Only whole numbers and/or strings are allowed in `get` arrays!");
1382
+ assert(
1383
+ types[0] === "string" || types[0] === "number",
1384
+ "Only whole numbers and/or strings are allowed in `get` arrays!"
1385
+ );
1233
1386
  }
1234
1387
  if (types.length === 2) {
1235
- assert(types.indexOf("string") > -1, "Only whole numbers and/or strings are allowed in `get` arrays!");
1236
- assert(types.indexOf("number") > -1, "Only whole numbers and/or strings are allowed in `get` arrays!");
1388
+ assert(
1389
+ types.indexOf("string") > -1,
1390
+ "Only whole numbers and/or strings are allowed in `get` arrays!"
1391
+ );
1392
+ assert(
1393
+ types.indexOf("number") > -1,
1394
+ "Only whole numbers and/or strings are allowed in `get` arrays!"
1395
+ );
1237
1396
  }
1238
1397
  if (!isUndefined(rows)) {
1239
1398
  rows = rows.map((r) => {
@@ -1265,6 +1424,8 @@
1265
1424
  }
1266
1425
  return df.getSubsetByNames(rows, cols);
1267
1426
  }
1427
+
1428
+ // node_modules/@jrc03c/js-math-tools/src/sort.mjs
1268
1429
  function alphaSort(a, b) {
1269
1430
  try {
1270
1431
  if (a < b)
@@ -1288,24 +1449,32 @@
1288
1449
  if (isDataFrame(arr) || isSeries(arr)) {
1289
1450
  return arr.sort(...Object.values(arguments).slice(1));
1290
1451
  }
1291
- assert(isArray(arr), "The `sort` function only works on arrays, Series, and DataFrames!");
1292
- assert(isFunction(fn), "The second parameter of the `sort` function must be a comparison function!");
1293
- const out2 = arr.slice();
1294
- out2.sort(fn);
1295
- return out2;
1452
+ assert(
1453
+ isArray(arr),
1454
+ "The `sort` function only works on arrays, Series, and DataFrames!"
1455
+ );
1456
+ assert(
1457
+ isFunction(fn),
1458
+ "The second parameter of the `sort` function must be a comparison function!"
1459
+ );
1460
+ const out = arr.slice();
1461
+ out.sort(fn);
1462
+ return out;
1296
1463
  }
1464
+
1465
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-get-dummies.mjs
1297
1466
  function camelify(text) {
1298
1467
  const temp = text.toLowerCase();
1299
- let out2 = "";
1468
+ let out = "";
1300
1469
  for (let i = 0; i < temp.length; i++) {
1301
1470
  const char = temp[i];
1302
1471
  if (char.match(/[a-z0-9]/g)) {
1303
- out2 += char;
1472
+ out += char;
1304
1473
  } else {
1305
- out2 += " ";
1474
+ out += " ";
1306
1475
  }
1307
1476
  }
1308
- const words = out2.split(" ").filter((word) => word.length > 0);
1477
+ const words = out.split(" ").filter((word) => word.length > 0);
1309
1478
  return words[0] + words.slice(1).map((word) => word[0].toUpperCase() + word.substring(1)).join("");
1310
1479
  }
1311
1480
  function dfGetDummies(DataFrame2, df, columns) {
@@ -1316,9 +1485,15 @@
1316
1485
  }
1317
1486
  const temp = {};
1318
1487
  columns.forEach((col) => {
1319
- assert(isString(col), "You must pass either a string or a one-dimensional array of strings into the `getDummies` (AKA `oneHotEncode`) method!");
1488
+ assert(
1489
+ isString(col),
1490
+ "You must pass either a string or a one-dimensional array of strings into the `getDummies` (AKA `oneHotEncode`) method!"
1491
+ );
1320
1492
  const colIndex = df.columns.indexOf(col);
1321
- assert(colIndex > -1, `The given DataFrame does not have a column called "${col}"!`);
1493
+ assert(
1494
+ colIndex > -1,
1495
+ `The given DataFrame does not have a column called "${col}"!`
1496
+ );
1322
1497
  const values = df.values.map((row) => row[colIndex]);
1323
1498
  const valuesSet = sort(set(values));
1324
1499
  values.forEach((value) => {
@@ -1335,10 +1510,12 @@
1335
1510
  });
1336
1511
  });
1337
1512
  });
1338
- const out2 = new DataFrame2(temp);
1339
- out2.index = df.index;
1340
- return out2;
1513
+ const out = new DataFrame2(temp);
1514
+ out.index = df.index;
1515
+ return out;
1341
1516
  }
1517
+
1518
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-get-subset-by-indices.mjs
1342
1519
  function dfGetSubsetByIndices(df, rowIndices, colIndices) {
1343
1520
  const dataShape = df.shape;
1344
1521
  if (isUndefined(rowIndices))
@@ -1349,22 +1526,48 @@
1349
1526
  rowIndices = [rowIndices];
1350
1527
  if (isNumber(colIndices))
1351
1528
  colIndices = [colIndices];
1352
- assert(isArray(rowIndices) && isArray(colIndices), "The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers.");
1353
- assert(shape(rowIndices).length === 1 && shape(colIndices).length === 1, "The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers.");
1354
- assert(rowIndices.length > 0, "The `rowIndices` array must contain at least one index.");
1355
- assert(colIndices.length > 0, "The `colIndices` array must contain at least one index.");
1529
+ assert(
1530
+ isArray(rowIndices) && isArray(colIndices),
1531
+ "The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."
1532
+ );
1533
+ assert(
1534
+ shape(rowIndices).length === 1 && shape(colIndices).length === 1,
1535
+ "The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."
1536
+ );
1537
+ assert(
1538
+ rowIndices.length > 0,
1539
+ "The `rowIndices` array must contain at least one index."
1540
+ );
1541
+ assert(
1542
+ colIndices.length > 0,
1543
+ "The `colIndices` array must contain at least one index."
1544
+ );
1356
1545
  rowIndices.forEach((rowIndex) => {
1357
- assert(isWholeNumber(rowIndex), "The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers.");
1358
- assert(rowIndex < df.index.length, `The row index ${rowIndex} is out of bounds.`);
1546
+ assert(
1547
+ isWholeNumber(rowIndex),
1548
+ "The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."
1549
+ );
1550
+ assert(
1551
+ rowIndex < df.index.length,
1552
+ `The row index ${rowIndex} is out of bounds.`
1553
+ );
1359
1554
  });
1360
1555
  colIndices.forEach((colIndex) => {
1361
- assert(isWholeNumber(colIndex), "The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers.");
1362
- assert(colIndex < df.columns.length, `The column index ${colIndex} is out of bounds.`);
1556
+ assert(
1557
+ isWholeNumber(colIndex),
1558
+ "The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."
1559
+ );
1560
+ assert(
1561
+ colIndex < df.columns.length,
1562
+ `The column index ${colIndex} is out of bounds.`
1563
+ );
1363
1564
  });
1364
1565
  const rows = rowIndices.map((i) => df.index[i]);
1365
1566
  const cols = colIndices.map((i) => df.columns[i]);
1366
1567
  return df.getSubsetByNames(rows, cols);
1367
1568
  }
1569
+
1570
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-get-subset-by-names.mjs
1368
1571
  function dfGetSubsetByNames(DataFrame2, Series2, df, rows, cols) {
1369
1572
  if (isUndefined(rows))
1370
1573
  rows = df.index;
@@ -1374,17 +1577,41 @@
1374
1577
  rows = [rows];
1375
1578
  if (isString(cols))
1376
1579
  cols = [cols];
1377
- assert(isArray(rows) && isArray(cols), "The `rows` and `cols` parameters must be 1-dimensional arrays of strings.");
1378
- assert(shape(rows).length === 1 && shape(cols).length === 1, "The `rows` and `cols` parameters must be 1-dimensional arrays of strings.");
1379
- assert(rows.length > 0, "The `rows` array must contain at least one row name.");
1380
- assert(cols.length > 0, "The `cols` array must contain at least one column name.");
1580
+ assert(
1581
+ isArray(rows) && isArray(cols),
1582
+ "The `rows` and `cols` parameters must be 1-dimensional arrays of strings."
1583
+ );
1584
+ assert(
1585
+ shape(rows).length === 1 && shape(cols).length === 1,
1586
+ "The `rows` and `cols` parameters must be 1-dimensional arrays of strings."
1587
+ );
1588
+ assert(
1589
+ rows.length > 0,
1590
+ "The `rows` array must contain at least one row name."
1591
+ );
1592
+ assert(
1593
+ cols.length > 0,
1594
+ "The `cols` array must contain at least one column name."
1595
+ );
1381
1596
  rows.forEach((row) => {
1382
- assert(isString(row), "The `rows` and `cols` parameters must be 1-dimensional arrays of strings.");
1383
- assert(df.index.indexOf(row) > -1, `The row name "${row}" does not exist in the list of rows.`);
1597
+ assert(
1598
+ isString(row),
1599
+ "The `rows` and `cols` parameters must be 1-dimensional arrays of strings."
1600
+ );
1601
+ assert(
1602
+ df.index.indexOf(row) > -1,
1603
+ `The row name "${row}" does not exist in the list of rows.`
1604
+ );
1384
1605
  });
1385
1606
  cols.forEach((col) => {
1386
- assert(isString(col), "The `rows` and `cols` parameters must be 1-dimensional arrays of strings.");
1387
- assert(df.columns.indexOf(col) > -1, `The column name "${col}" does not exist in the list of columns.`);
1607
+ assert(
1608
+ isString(col),
1609
+ "The `rows` and `cols` parameters must be 1-dimensional arrays of strings."
1610
+ );
1611
+ assert(
1612
+ df.columns.indexOf(col) > -1,
1613
+ `The column name "${col}" does not exist in the list of columns.`
1614
+ );
1388
1615
  });
1389
1616
  const values = rows.map((row) => {
1390
1617
  return cols.map((col) => {
@@ -1395,22 +1622,24 @@
1395
1622
  return values[0][0];
1396
1623
  }
1397
1624
  if (rows.length === 1) {
1398
- const out3 = new Series2(values[0]);
1399
- out3.name = rows[0];
1400
- out3.index = cols;
1401
- return out3;
1625
+ const out2 = new Series2(values[0]);
1626
+ out2.name = rows[0];
1627
+ out2.index = cols;
1628
+ return out2;
1402
1629
  }
1403
1630
  if (cols.length === 1) {
1404
- const out3 = new Series2(values.map((v) => v[0]));
1405
- out3.name = cols[0];
1406
- out3.index = rows;
1407
- return out3;
1408
- }
1409
- const out2 = new DataFrame2(values);
1410
- out2.columns = cols;
1411
- out2.index = rows;
1412
- return out2;
1631
+ const out2 = new Series2(values.map((v) => v[0]));
1632
+ out2.name = cols[0];
1633
+ out2.index = rows;
1634
+ return out2;
1635
+ }
1636
+ const out = new DataFrame2(values);
1637
+ out.columns = cols;
1638
+ out.index = rows;
1639
+ return out;
1413
1640
  }
1641
+
1642
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-print.mjs
1414
1643
  function dfPrint(DataFrame2, Series2, df) {
1415
1644
  function truncate(s2, maxLength2) {
1416
1645
  if (isString(s2)) {
@@ -1432,8 +1661,12 @@
1432
1661
  const halfMaxRows = Math.floor(maxRows / 2);
1433
1662
  const maxColumns = typeof process === "undefined" ? 10 : Math.floor(process.stdout.columns / 24) - 1;
1434
1663
  const halfMaxColumns = Math.floor(maxColumns / 2);
1435
- const tempRows = maxRows > df.index.length ? null : range(0, halfMaxRows).concat(range(df.index.length - halfMaxRows, df.index.length));
1436
- const tempColumns = maxColumns > df.columns.length ? null : range(0, halfMaxColumns).concat(range(df.columns.length - halfMaxColumns, df.columns.length));
1664
+ const tempRows = maxRows > df.index.length ? null : range(0, halfMaxRows).concat(
1665
+ range(df.index.length - halfMaxRows, df.index.length)
1666
+ );
1667
+ const tempColumns = maxColumns > df.columns.length ? null : range(0, halfMaxColumns).concat(
1668
+ range(df.columns.length - halfMaxColumns, df.columns.length)
1669
+ );
1437
1670
  let temp = df.get(tempRows, tempColumns);
1438
1671
  if (temp instanceof Series2) {
1439
1672
  if (df.shape[0] === 1) {
@@ -1448,7 +1681,11 @@
1448
1681
  }
1449
1682
  if (maxRows <= df.index.length) {
1450
1683
  temp._index.splice(halfMaxRows, 0, "...");
1451
- temp._values.splice(halfMaxRows, 0, range(0, temp.columns.length).map(() => "..."));
1684
+ temp._values.splice(
1685
+ halfMaxRows,
1686
+ 0,
1687
+ range(0, temp.columns.length).map(() => "...")
1688
+ );
1452
1689
  }
1453
1690
  if (maxColumns <= df.columns.length) {
1454
1691
  temp._columns.splice(halfMaxColumns, 0, "...");
@@ -1473,31 +1710,40 @@
1473
1710
  console.log("Shape:", df.shape, "\n");
1474
1711
  return df;
1475
1712
  }
1713
+
1714
+ // node_modules/@jrc03c/js-math-tools/src/helpers/left-pad.mjs
1476
1715
  function leftPad(x, maxLength) {
1477
1716
  assert(isNumber(x), "The `leftPad` function only works on numbers!");
1478
- let out2 = x.toString();
1479
- while (out2.length < maxLength)
1480
- out2 = "0" + out2;
1481
- return out2;
1717
+ let out = x.toString();
1718
+ while (out.length < maxLength)
1719
+ out = "0" + out;
1720
+ return out;
1482
1721
  }
1722
+
1723
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-reset-index.mjs
1483
1724
  function dfResetIndex(df, shouldSkipCopying) {
1484
- const out2 = shouldSkipCopying ? df : df.copy();
1485
- out2.index = range(0, df.shape[0]).map((i) => {
1486
- return "row" + leftPad(i, (out2.index.length - 1).toString().length);
1725
+ const out = shouldSkipCopying ? df : df.copy();
1726
+ out.index = range(0, df.shape[0]).map((i) => {
1727
+ return "row" + leftPad(i, (out.index.length - 1).toString().length);
1487
1728
  });
1488
- return out2;
1729
+ return out;
1489
1730
  }
1731
+
1732
+ // node_modules/@jrc03c/js-math-tools/src/product.mjs
1490
1733
  function product(arr, shouldDropNaNs) {
1491
1734
  if (isDataFrame(arr) || isSeries(arr)) {
1492
1735
  return product(arr.values, shouldDropNaNs);
1493
1736
  }
1494
- assert(isArray(arr), "The `product` function only works on arrays, Series, and DataFrames!");
1737
+ assert(
1738
+ isArray(arr),
1739
+ "The `product` function only works on arrays, Series, and DataFrames!"
1740
+ );
1495
1741
  try {
1496
1742
  if (arr.length === 0)
1497
1743
  return NaN;
1498
1744
  const temp = flatten(arr);
1499
1745
  let resultShouldBeABigInt = false;
1500
- let out2 = 1;
1746
+ let out = 1;
1501
1747
  for (let v of temp) {
1502
1748
  if (!isNumber(v)) {
1503
1749
  if (shouldDropNaNs) {
@@ -1510,36 +1756,52 @@
1510
1756
  resultShouldBeABigInt = true;
1511
1757
  v = Number(v);
1512
1758
  }
1513
- out2 *= v;
1759
+ out *= v;
1514
1760
  }
1515
1761
  if (resultShouldBeABigInt) {
1516
1762
  try {
1517
- return BigInt(out2);
1763
+ return BigInt(out);
1518
1764
  } catch (e) {
1519
1765
  }
1520
1766
  }
1521
- return out2;
1767
+ return out;
1522
1768
  } catch (e) {
1523
1769
  return NaN;
1524
1770
  }
1525
1771
  }
1772
+
1773
+ // node_modules/@jrc03c/js-math-tools/src/helpers/is-natural-number.mjs
1526
1774
  function isNaturalNumber(x) {
1527
1775
  return isInteger(x) && x > 0;
1528
1776
  }
1777
+
1778
+ // node_modules/@jrc03c/js-math-tools/src/reshape.mjs
1529
1779
  function reshape(x, newShape) {
1530
1780
  if (isDataFrame(x) || isSeries(x)) {
1531
1781
  return reshape(x.values, newShape);
1532
1782
  }
1533
- assert(isArray(x), "The first argument passed into the `reshape` function must be an array!");
1783
+ assert(
1784
+ isArray(x),
1785
+ "The first argument passed into the `reshape` function must be an array!"
1786
+ );
1534
1787
  if (isNumber(newShape))
1535
1788
  newShape = [newShape];
1536
- assert(isArray(newShape), "The second argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!");
1537
- assert(shape(newShape).length === 1, "The first argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!");
1789
+ assert(
1790
+ isArray(newShape),
1791
+ "The second argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!"
1792
+ );
1793
+ assert(
1794
+ shape(newShape).length === 1,
1795
+ "The first argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!"
1796
+ );
1538
1797
  newShape = newShape.map((v) => {
1539
1798
  if (typeof v === "bigint") {
1540
1799
  v = Number(v);
1541
1800
  }
1542
- assert(isNaturalNumber(v), "The first argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!");
1801
+ assert(
1802
+ isNaturalNumber(v),
1803
+ "The first argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!"
1804
+ );
1543
1805
  return Number(v);
1544
1806
  });
1545
1807
  if (newShape.length === 0) {
@@ -1549,31 +1811,36 @@
1549
1811
  if (newShape.length === 1 && newShape[0] === temp.length) {
1550
1812
  return temp;
1551
1813
  }
1552
- assert(product(newShape) === temp.length, "The new shape doesn't match the number of values available in `x` (the first argument passed into the `reshape` function)!");
1553
- const out2 = [];
1814
+ assert(
1815
+ product(newShape) === temp.length,
1816
+ "The new shape doesn't match the number of values available in `x` (the first argument passed into the `reshape` function)!"
1817
+ );
1818
+ const out = [];
1554
1819
  const step = Math.floor(temp.length / newShape[0]);
1555
1820
  for (let i = 0; i < newShape[0]; i++) {
1556
1821
  const row = temp.slice(i * step, (i + 1) * step);
1557
- out2.push(reshape(row, newShape.slice(1)));
1822
+ out.push(reshape(row, newShape.slice(1)));
1558
1823
  }
1559
- return out2;
1824
+ return out;
1560
1825
  }
1826
+
1827
+ // node_modules/@jrc03c/js-math-tools/src/random.mjs
1561
1828
  var MAX = Math.pow(2, 64);
1562
1829
  var s = [];
1563
1830
  seed(Math.floor(Math.random() * MAX));
1564
1831
  function splitmix64(state, n) {
1565
1832
  state = uint(state);
1566
- function helper5() {
1833
+ function helper4() {
1567
1834
  state += uint("0x9e3779b97f4a7c15");
1568
1835
  let z = copy(state);
1569
1836
  z = (z ^ z >> BigInt(30)) * uint("0xbf58476d1ce4e5b9");
1570
1837
  z = (z ^ z >> BigInt(27)) * uint("0x94d049bb133111eb");
1571
1838
  return z ^ z >> BigInt(31);
1572
1839
  }
1573
- const out2 = [];
1840
+ const out = [];
1574
1841
  for (let i = 0; i < n; i++)
1575
- out2.push(helper5());
1576
- return out2;
1842
+ out.push(helper4());
1843
+ return out;
1577
1844
  }
1578
1845
  function uint(x) {
1579
1846
  return BigInt.asUintN(64, BigInt(x));
@@ -1588,7 +1855,10 @@
1588
1855
  val = Number(val);
1589
1856
  }
1590
1857
  if (!isUndefined(val)) {
1591
- assert(isNumber(val), "If passing a value into the `seed` function, then that value must be an integer!");
1858
+ assert(
1859
+ isNumber(val),
1860
+ "If passing a value into the `seed` function, then that value must be an integer!"
1861
+ );
1592
1862
  const temp = splitmix64(Math.floor(val), 4);
1593
1863
  s[0] = temp[0];
1594
1864
  s[1] = temp[1];
@@ -1616,28 +1886,45 @@
1616
1886
  shape2 = [shape2];
1617
1887
  return reshape(ndarray(product(shape2)).map(next), shape2);
1618
1888
  }
1889
+
1890
+ // node_modules/@jrc03c/js-math-tools/src/shuffle.mjs
1619
1891
  function shuffle(arr) {
1620
1892
  if (isDataFrame(arr) || isSeries(arr)) {
1621
1893
  return arr.shuffle(...Object.values(arguments).slice(1));
1622
1894
  }
1623
- assert(isArray(arr), "The `shuffle` function only works on arrays, Series, and DataFrames!");
1624
- const out2 = [];
1895
+ assert(
1896
+ isArray(arr),
1897
+ "The `shuffle` function only works on arrays, Series, and DataFrames!"
1898
+ );
1899
+ const out = [];
1625
1900
  const temp = arr.slice();
1626
1901
  for (let i = 0; i < arr.length; i++) {
1627
1902
  const index = Math.floor(random() * temp.length);
1628
- out2.push(temp.splice(index, 1)[0]);
1903
+ out.push(temp.splice(index, 1)[0]);
1629
1904
  }
1630
- return out2;
1905
+ return out;
1631
1906
  }
1907
+
1908
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-shuffle.mjs
1632
1909
  function dfShuffle(df, axis) {
1633
1910
  if (isUndefined(axis))
1634
1911
  axis = 0;
1635
- assert(axis === 0 || axis === 1, "The `axis` parameter to the `shuffle` must be 0, 1, or undefined.");
1636
- return df.get(axis === 0 ? shuffle(df.index) : null, axis === 1 ? shuffle(df.columns) : null);
1912
+ assert(
1913
+ axis === 0 || axis === 1,
1914
+ "The `axis` parameter to the `shuffle` must be 0, 1, or undefined."
1915
+ );
1916
+ return df.get(
1917
+ axis === 0 ? shuffle(df.index) : null,
1918
+ axis === 1 ? shuffle(df.columns) : null
1919
+ );
1637
1920
  }
1921
+
1922
+ // node_modules/@jrc03c/js-math-tools/src/is-boolean.mjs
1638
1923
  function isBoolean(x) {
1639
1924
  return typeof x === "boolean";
1640
1925
  }
1926
+
1927
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-sort.mjs
1641
1928
  function dfSort(df, a, b) {
1642
1929
  if (isFunction(a)) {
1643
1930
  return dfSortByFunction(df, a, b);
@@ -1647,8 +1934,14 @@
1647
1934
  }
1648
1935
  function dfSortByFunction(df, fn, axis) {
1649
1936
  axis = isUndefined(axis) ? 0 : axis;
1650
- assert(isFunction(fn), "When sorting a DataFrame using a function, the first argument to the `sort` method must be a function!");
1651
- assert(isNumber(axis), "When sorting a DataFrame using a function, the second argument to the `sort` method must be null, undefined, 0, or 1 to indicate the axis along which the data should be sorted! An axis of 0 means that the rows will be sorted relative to each other, whereas an axis of 1 means that the columns will be sorted relative to each other.");
1937
+ assert(
1938
+ isFunction(fn),
1939
+ "When sorting a DataFrame using a function, the first argument to the `sort` method must be a function!"
1940
+ );
1941
+ assert(
1942
+ isNumber(axis),
1943
+ "When sorting a DataFrame using a function, the second argument to the `sort` method must be null, undefined, 0, or 1 to indicate the axis along which the data should be sorted! An axis of 0 means that the rows will be sorted relative to each other, whereas an axis of 1 means that the columns will be sorted relative to each other."
1944
+ );
1652
1945
  if (axis === 0) {
1653
1946
  const index = sort(df.index, (a, b) => {
1654
1947
  return fn(df.get(a, null), df.get(b, null));
@@ -1662,9 +1955,9 @@
1662
1955
  }
1663
1956
  }
1664
1957
  function dfSortByColumns(df, cols, directions) {
1665
- let out2 = df.copy();
1958
+ let out = df.copy();
1666
1959
  const indexID = random().toString();
1667
- out2 = out2.assign(indexID, out2.index);
1960
+ out = out.assign(indexID, out.index);
1668
1961
  if (isUndefined(cols)) {
1669
1962
  cols = [indexID];
1670
1963
  directions = [true];
@@ -1674,38 +1967,62 @@
1674
1967
  if (isBoolean(directions) || isString(directions))
1675
1968
  directions = [directions];
1676
1969
  }
1677
- assert(isArray(cols), "The first parameter of the `sort` method must be (1) a string or index representing a column name or index, respectively; (2) a 1-dimensional array of strings and/or indices; or (3) null.");
1678
- assert(shape(cols).length === 1, "The first parameter of the `sort` method must be (1) a string or index representing a column name or index, respectively; (2) a 1-dimensional array of strings and/or indices; or (3) null.");
1970
+ assert(
1971
+ isArray(cols),
1972
+ "The first parameter of the `sort` method must be (1) a string or index representing a column name or index, respectively; (2) a 1-dimensional array of strings and/or indices; or (3) null."
1973
+ );
1974
+ assert(
1975
+ shape(cols).length === 1,
1976
+ "The first parameter of the `sort` method must be (1) a string or index representing a column name or index, respectively; (2) a 1-dimensional array of strings and/or indices; or (3) null."
1977
+ );
1679
1978
  if (isUndefined(directions))
1680
1979
  directions = range(0, cols.length).map(() => true);
1681
- assert(isArray(directions), "The second parameter of the `sort` method must be (1) a string or boolean representing the sort direction ('ascending' / 'descending', or true / false); (2) a 1-dimensional array of strings and/or booleans; or (3) null.");
1682
- assert(shape(directions).length === 1, "The second parameter of the `sort` method must be (1) a string or boolean representing the sort direction ('ascending' / 'descending', or true / false); (2) a 1-dimensional array of strings and/or booleans; or (3) null.");
1683
- assert(cols.length === directions.length, "The arrays passed into the `sort` method must be equal in length.");
1980
+ assert(
1981
+ isArray(directions),
1982
+ "The second parameter of the `sort` method must be (1) a string or boolean representing the sort direction ('ascending' / 'descending', or true / false); (2) a 1-dimensional array of strings and/or booleans; or (3) null."
1983
+ );
1984
+ assert(
1985
+ shape(directions).length === 1,
1986
+ "The second parameter of the `sort` method must be (1) a string or boolean representing the sort direction ('ascending' / 'descending', or true / false); (2) a 1-dimensional array of strings and/or booleans; or (3) null."
1987
+ );
1988
+ assert(
1989
+ cols.length === directions.length,
1990
+ "The arrays passed into the `sort` method must be equal in length."
1991
+ );
1684
1992
  cols = cols.map((col) => {
1685
- assert(isString(col) || isNumber(col), "Column references can either be column names (as strings) or column indices (as whole numbers).");
1993
+ assert(
1994
+ isString(col) || isNumber(col),
1995
+ "Column references can either be column names (as strings) or column indices (as whole numbers)."
1996
+ );
1686
1997
  if (isString(col)) {
1687
- const index = out2.columns.indexOf(col);
1998
+ const index = out.columns.indexOf(col);
1688
1999
  assert(index > -1, `The column "${col}" does not exist!`);
1689
2000
  return index;
1690
2001
  }
1691
2002
  if (isNumber(col)) {
1692
2003
  assert(isWholeNumber(col), "Column indices must be whole numbers!");
1693
- assert(col < out2.columns.length, `The index ${col} is out of bounds!`);
2004
+ assert(col < out.columns.length, `The index ${col} is out of bounds!`);
1694
2005
  return col;
1695
2006
  }
1696
2007
  });
1697
2008
  directions = directions.map((dir) => {
1698
- assert(isString(dir) || isBoolean(dir), "Direction references can either be strings ('ascending' or 'descending') or booleans (true or false).");
2009
+ assert(
2010
+ isString(dir) || isBoolean(dir),
2011
+ "Direction references can either be strings ('ascending' or 'descending') or booleans (true or false)."
2012
+ );
1699
2013
  if (isString(dir)) {
1700
2014
  const value = dir.trim().toLowerCase();
1701
- assert(value === "ascending" || value === "descending", "Direction references can either be strings ('ascending' or 'descending') or booleans (true or false).");
2015
+ assert(
2016
+ value === "ascending" || value === "descending",
2017
+ "Direction references can either be strings ('ascending' or 'descending') or booleans (true or false)."
2018
+ );
1702
2019
  return value === "ascending";
1703
2020
  }
1704
2021
  if (isBoolean(dir)) {
1705
2022
  return dir;
1706
2023
  }
1707
2024
  });
1708
- out2.values = sort(out2.values, (a, b) => {
2025
+ out.values = sort(out.values, (a, b) => {
1709
2026
  let counter = 0;
1710
2027
  while (a[cols[counter]] === b[cols[counter]] && counter < cols.length) {
1711
2028
  counter++;
@@ -1718,25 +2035,30 @@
1718
2035
  if (a[cols[counter]] > b[cols[counter]])
1719
2036
  return isAscending ? 1 : -1;
1720
2037
  });
1721
- const indexNumber = out2.columns.indexOf(indexID);
1722
- out2.index = out2.values.map((row) => row[indexNumber]);
1723
- out2 = out2.dropColumns(indexID);
1724
- return out2;
2038
+ const indexNumber = out.columns.indexOf(indexID);
2039
+ out.index = out.values.map((row) => row[indexNumber]);
2040
+ out = out.dropColumns(indexID);
2041
+ return out;
1725
2042
  }
2043
+
2044
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-to-detailed-object.mjs
1726
2045
  function dfToDetailedObject(df, axis) {
1727
2046
  if (isUndefined(axis)) {
1728
2047
  axis = 0;
1729
2048
  } else {
1730
- assert(axis === 0 || axis === 1, "The axis parameter of the `toDetailedObject` method must be undefined, 0, or 1. An axis of 0 indicates that the returned object should be organized first by rows and then by columns. An axis of 1 indicates that the returned object should be organized first by columns and then by rows.");
2049
+ assert(
2050
+ axis === 0 || axis === 1,
2051
+ "The axis parameter of the `toDetailedObject` method must be undefined, 0, or 1. An axis of 0 indicates that the returned object should be organized first by rows and then by columns. An axis of 1 indicates that the returned object should be organized first by columns and then by rows."
2052
+ );
1731
2053
  }
1732
- const out2 = {};
2054
+ const out = {};
1733
2055
  if (axis === 0) {
1734
2056
  df.index.forEach((rowName, i) => {
1735
2057
  const temp = {};
1736
2058
  df.columns.forEach((colName, j) => {
1737
2059
  temp[colName] = df.values[i][j];
1738
2060
  });
1739
- out2[rowName] = temp;
2061
+ out[rowName] = temp;
1740
2062
  });
1741
2063
  } else {
1742
2064
  df.columns.forEach((colName, j) => {
@@ -1744,114 +2066,107 @@
1744
2066
  df.index.forEach((rowName, i) => {
1745
2067
  temp[rowName] = df.values[i][j];
1746
2068
  });
1747
- out2[colName] = temp;
2069
+ out[colName] = temp;
1748
2070
  });
1749
2071
  }
1750
- return out2;
2072
+ return out;
1751
2073
  }
2074
+
2075
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-to-json-string.mjs
1752
2076
  function dfToJSONString(df, axis) {
1753
2077
  return JSON.stringify(df.toObject(axis));
1754
2078
  }
1755
- async function dfToJSON(df, filename, axis) {
1756
- const out2 = dfToJSONString(df, axis);
1757
- let downloadedInBrowser = false;
1758
- let wroteToDiskInNode = false;
1759
- let browserError, nodeError;
1760
- try {
1761
- let newFilename = filename;
1762
- if (filename.includes("/")) {
1763
- const parts = filename.split("/");
1764
- newFilename = parts[parts.length - 1];
1765
- }
1766
- const a = document.createElement("a");
1767
- a.href = `data:application/json;charset=utf-8,${encodeURIComponent(out2)}`;
1768
- a.download = newFilename;
1769
- a.dispatchEvent(new MouseEvent("click"));
1770
- downloadedInBrowser = true;
1771
- } catch (e) {
1772
- browserError = e;
1773
- }
1774
- try {
1775
- const fs = await import("node:fs");
1776
- const path = await import("node:path");
1777
- fs.writeFileSync(path.resolve(filename), out2, "utf8");
1778
- wroteToDiskInNode = true;
1779
- } catch (e) {
1780
- nodeError = e;
1781
- }
1782
- if (!downloadedInBrowser && !wroteToDiskInNode) {
1783
- if (typeof window !== "undefined") {
1784
- throw new MathError(browserError);
1785
- } else if (typeof module !== "undefined") {
1786
- throw new MathError(nodeError);
1787
- } else {
1788
- throw new MathError("I don't know what's going wrong, but it doesn't seem like you're in Node or the browser, and we couldn't download and/or write the file to disk!");
1789
- }
1790
- }
1791
- return df;
2079
+
2080
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-to-json.mjs
2081
+ async function dfToJSON(df, axis) {
2082
+ return JSON.parse(dfToJSONString(df, axis));
1792
2083
  }
2084
+
2085
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/df-to-object.mjs
1793
2086
  function dfToObject(df) {
1794
- const out2 = {};
2087
+ const out = {};
1795
2088
  df.columns.forEach((col) => {
1796
- out2[col] = df.get(col).values;
2089
+ out[col] = df.get(col).values;
1797
2090
  });
1798
- return out2;
2091
+ return out;
1799
2092
  }
2093
+
2094
+ // node_modules/@jrc03c/js-math-tools/src/transpose.mjs
1800
2095
  function transpose(arr) {
1801
2096
  if (isDataFrame(arr) || isSeries(arr)) {
1802
2097
  return arr.transpose();
1803
2098
  }
1804
- assert(isArray(arr), "The `transpose` function only works on arrays, Series, and DataFrames!");
2099
+ assert(
2100
+ isArray(arr),
2101
+ "The `transpose` function only works on arrays, Series, and DataFrames!"
2102
+ );
1805
2103
  const theShape = shape(arr);
1806
- assert(theShape.length <= 2, "I'm not smart enough to know how to transpose arrays that have more than 2 dimensions. Sorry for the inconvenience! Please only pass 1- or 2-dimensional arrays into the `transpose` function!");
2104
+ assert(
2105
+ theShape.length <= 2,
2106
+ "I'm not smart enough to know how to transpose arrays that have more than 2 dimensions. Sorry for the inconvenience! Please only pass 1- or 2-dimensional arrays into the `transpose` function!"
2107
+ );
1807
2108
  if (theShape.length === 1) {
1808
2109
  return reverse(arr);
1809
2110
  } else if (theShape.length === 2) {
1810
- const out2 = ndarray(reverse(theShape));
2111
+ const out = ndarray(reverse(theShape));
1811
2112
  for (let row = 0; row < theShape[0]; row++) {
1812
2113
  for (let col = 0; col < theShape[1]; col++) {
1813
- out2[col][row] = arr[row][col];
2114
+ out[col][row] = arr[row][col];
1814
2115
  }
1815
2116
  }
1816
- return out2;
2117
+ return out;
1817
2118
  }
1818
2119
  }
2120
+
2121
+ // node_modules/@jrc03c/js-math-tools/src/series/series-append.mjs
1819
2122
  function seriesAppend(Series2, series, x) {
1820
2123
  if (isSeries(x)) {
1821
2124
  return new Series2(series.values.concat(x.values));
1822
2125
  }
1823
2126
  if (isArray(x)) {
1824
2127
  const xShape = shape(x);
1825
- assert(xShape.length === 1 && !isNested(xShape), "Only vectors can be appended to Series!");
1826
- const out2 = series.copy();
2128
+ assert(
2129
+ xShape.length === 1 && !isNested(xShape),
2130
+ "Only vectors can be appended to Series!"
2131
+ );
2132
+ const out = series.copy();
1827
2133
  x.forEach((v, i) => {
1828
- out2._values.push(v);
1829
- out2._index.push("item" + (series.values.length + i));
2134
+ out._values.push(v);
2135
+ out._index.push("item" + (series.values.length + i));
1830
2136
  });
1831
- return out2;
2137
+ return out;
1832
2138
  }
1833
2139
  return seriesAppend(series, [x]);
1834
2140
  }
2141
+
2142
+ // node_modules/@jrc03c/js-math-tools/src/series/series-apply.mjs
1835
2143
  function seriesApply(series, fn) {
1836
- assert(isFunction(fn), "The parameter to the `apply` method must be a function.");
1837
- const out2 = series.copy();
1838
- out2._values = out2._values.map((v, i) => fn(v, i));
1839
- return out2;
2144
+ assert(
2145
+ isFunction(fn),
2146
+ "The parameter to the `apply` method must be a function."
2147
+ );
2148
+ const out = series.copy();
2149
+ out._values = out._values.map((v, i) => fn(v, i));
2150
+ return out;
1840
2151
  }
2152
+
2153
+ // node_modules/@jrc03c/js-math-tools/src/series/series-drop-missing.mjs
1841
2154
  function seriesDropMissing(series) {
1842
- const out2 = series.copy();
2155
+ const out = series.copy();
1843
2156
  const outIndex = [];
1844
- out2._values = out2.values.filter((v, i) => {
2157
+ out._values = out.values.filter((v, i) => {
1845
2158
  if (isUndefined(v)) {
1846
2159
  return false;
1847
2160
  } else {
1848
- outIndex.push(out2.index[i]);
2161
+ outIndex.push(out.index[i]);
1849
2162
  return true;
1850
2163
  }
1851
2164
  });
1852
- out2._index = outIndex;
1853
- return out2;
2165
+ out._index = outIndex;
2166
+ return out;
1854
2167
  }
2168
+
2169
+ // node_modules/@jrc03c/js-math-tools/src/series/series-drop-nan.mjs
1855
2170
  function seriesDropNaN(Series2, series) {
1856
2171
  const index = [];
1857
2172
  const values = [];
@@ -1861,33 +2176,37 @@
1861
2176
  index.push(series.index[i]);
1862
2177
  }
1863
2178
  });
1864
- const out2 = new Series2(values);
1865
- out2.name = series.name;
1866
- out2.index = index;
1867
- return out2;
2179
+ const out = new Series2(values);
2180
+ out.name = series.name;
2181
+ out.index = index;
2182
+ return out;
1868
2183
  }
2184
+
2185
+ // node_modules/@jrc03c/js-math-tools/src/series/series-filter.mjs
1869
2186
  function seriesFilter(Series2, series, fn) {
1870
- let out2 = series.copy();
1871
- const index = copy(out2.index);
2187
+ let out = series.copy();
2188
+ const index = copy(out.index);
1872
2189
  const indicesToRemove = [];
1873
- const newValues = out2.values.filter((value, i) => {
1874
- const shouldKeep = fn(value, i, out2.values);
2190
+ const newValues = out.values.filter((value, i) => {
2191
+ const shouldKeep = fn(value, i, out.values);
1875
2192
  if (!shouldKeep)
1876
- indicesToRemove.push(out2.index[i]);
2193
+ indicesToRemove.push(out.index[i]);
1877
2194
  return shouldKeep;
1878
2195
  });
1879
2196
  indicesToRemove.forEach((i) => {
1880
2197
  index.splice(index.indexOf(i), 1);
1881
2198
  });
1882
2199
  if (newValues.length === 0) {
1883
- out2 = new Series2();
1884
- out2.name = series.name;
1885
- return out2;
2200
+ out = new Series2();
2201
+ out.name = series.name;
2202
+ return out;
1886
2203
  }
1887
- out2.values = newValues;
1888
- out2.index = index;
1889
- return out2;
2204
+ out.values = newValues;
2205
+ out.index = index;
2206
+ return out;
1890
2207
  }
2208
+
2209
+ // node_modules/@jrc03c/js-math-tools/src/series/series-get.mjs
1891
2210
  function seriesGet(series, indices) {
1892
2211
  if (isString(indices) || isNumber(indices))
1893
2212
  indices = [indices];
@@ -1897,13 +2216,25 @@
1897
2216
  }
1898
2217
  }
1899
2218
  const types = set((indices || []).map((v) => typeof v));
1900
- assert(types.length <= 2, "Only whole numbers and/or strings are allowed in `get` arrays!");
2219
+ assert(
2220
+ types.length <= 2,
2221
+ "Only whole numbers and/or strings are allowed in `get` arrays!"
2222
+ );
1901
2223
  if (types.length === 1) {
1902
- assert(types[0] === "string" || types[0] === "number", "Only whole numbers and/or strings are allowed in `get` arrays!");
2224
+ assert(
2225
+ types[0] === "string" || types[0] === "number",
2226
+ "Only whole numbers and/or strings are allowed in `get` arrays!"
2227
+ );
1903
2228
  }
1904
2229
  if (types.length === 2) {
1905
- assert(types.indexOf("string") > -1, "Only whole numbers and/or strings are allowed in `get` arrays!");
1906
- assert(types.indexOf("number") > -1, "Only whole numbers and/or strings are allowed in `get` arrays!");
2230
+ assert(
2231
+ types.indexOf("string") > -1,
2232
+ "Only whole numbers and/or strings are allowed in `get` arrays!"
2233
+ );
2234
+ assert(
2235
+ types.indexOf("number") > -1,
2236
+ "Only whole numbers and/or strings are allowed in `get` arrays!"
2237
+ );
1907
2238
  }
1908
2239
  if (!isUndefined(indices)) {
1909
2240
  indices = indices.map((i) => {
@@ -1921,68 +2252,112 @@
1921
2252
  }
1922
2253
  return series.getSubsetByNames(indices);
1923
2254
  }
2255
+
2256
+ // node_modules/@jrc03c/js-math-tools/src/series/series-get-subset-by-indices.mjs
1924
2257
  function seriesGetSubsetByIndices(series, indices) {
1925
2258
  const dataShape = series.shape;
1926
2259
  if (isUndefined(indices))
1927
2260
  indices = range(0, dataShape[0]);
1928
- assert(isArray(indices), "The `indices` array must be 1-dimensional array of whole numbers.");
1929
- assert(shape(indices).length === 1, "The `indices` array must be a 1-dimensional array of whole numbers.");
1930
- assert(indices.length > 0, "The `indices` array must contain at least one index.");
2261
+ assert(
2262
+ isArray(indices),
2263
+ "The `indices` array must be 1-dimensional array of whole numbers."
2264
+ );
2265
+ assert(
2266
+ shape(indices).length === 1,
2267
+ "The `indices` array must be a 1-dimensional array of whole numbers."
2268
+ );
2269
+ assert(
2270
+ indices.length > 0,
2271
+ "The `indices` array must contain at least one index."
2272
+ );
1931
2273
  indices.forEach((index) => {
1932
- assert(isWholeNumber(index), "The `indices` array must be a 1-dimensional array of whole numbers.");
1933
- assert(index < series.index.length, `The row index ${index} is out of bounds.`);
2274
+ assert(
2275
+ isWholeNumber(index),
2276
+ "The `indices` array must be a 1-dimensional array of whole numbers."
2277
+ );
2278
+ assert(
2279
+ index < series.index.length,
2280
+ `The row index ${index} is out of bounds.`
2281
+ );
1934
2282
  });
1935
2283
  const rows = indices.map((i) => series.index[i]);
1936
2284
  return series.getSubsetByNames(rows);
1937
2285
  }
2286
+
2287
+ // node_modules/@jrc03c/js-math-tools/src/series/series-get-subset-by-names.mjs
1938
2288
  function seriesGetSubsetByNames(Series2, series, indices) {
1939
2289
  if (isUndefined(indices))
1940
2290
  indices = series.index;
1941
- assert(isArray(indices), "The `indices` array must be a 1-dimensional array of strings.");
1942
- assert(shape(indices).length === 1, "The `indices` array must be a 1-dimensional array of strings.");
1943
- assert(indices.length > 0, "The `indices` array must contain at least one index name.");
2291
+ assert(
2292
+ isArray(indices),
2293
+ "The `indices` array must be a 1-dimensional array of strings."
2294
+ );
2295
+ assert(
2296
+ shape(indices).length === 1,
2297
+ "The `indices` array must be a 1-dimensional array of strings."
2298
+ );
2299
+ assert(
2300
+ indices.length > 0,
2301
+ "The `indices` array must contain at least one index name."
2302
+ );
1944
2303
  indices.forEach((name) => {
1945
2304
  assert(isString(name), "The `indices` array must contain only strings.");
1946
- assert(series.index.indexOf(name) > -1, `The name "${name}" does not exist in the index.`);
2305
+ assert(
2306
+ series.index.indexOf(name) > -1,
2307
+ `The name "${name}" does not exist in the index.`
2308
+ );
1947
2309
  });
1948
2310
  const values = indices.map((name) => {
1949
2311
  return series.values[series.index.indexOf(name)];
1950
2312
  });
1951
2313
  if (values.length === 1)
1952
2314
  return values[0];
1953
- const out2 = new Series2(values);
1954
- out2.index = indices;
1955
- out2.name = series.name;
1956
- return out2;
2315
+ const out = new Series2(values);
2316
+ out.index = indices;
2317
+ out.name = series.name;
2318
+ return out;
1957
2319
  }
2320
+
2321
+ // node_modules/@jrc03c/js-math-tools/src/series/series-print.mjs
1958
2322
  function seriesPrint(series) {
1959
2323
  let temp = series.copy();
1960
2324
  const maxRows = typeof window === "undefined" ? 20 : 10;
1961
2325
  if (temp.index.length > maxRows) {
1962
- temp = temp.get(range(0, maxRows / 2).concat(range(temp.index.length - maxRows / 2, temp.index.length)));
2326
+ temp = temp.get(
2327
+ range(0, maxRows / 2).concat(
2328
+ range(temp.index.length - maxRows / 2, temp.index.length)
2329
+ )
2330
+ );
1963
2331
  const tempIndex = copy(temp.index);
1964
2332
  tempIndex.splice(Math.floor(tempIndex.length / 2), 0, "...");
1965
2333
  temp.values.push("...");
1966
2334
  temp.index.push("...");
1967
2335
  temp = temp.get(tempIndex);
1968
2336
  }
1969
- const out2 = {};
2337
+ const out = {};
1970
2338
  temp.values.forEach((value, i) => {
1971
2339
  const obj = {};
1972
2340
  obj[temp.name] = value;
1973
- out2[temp.index[i]] = obj;
2341
+ out[temp.index[i]] = obj;
1974
2342
  });
1975
- console.table(out2);
2343
+ console.table(out);
1976
2344
  console.log("Shape:", series.shape, "\n");
1977
2345
  return series;
1978
2346
  }
2347
+
2348
+ // node_modules/@jrc03c/js-math-tools/src/series/series-shuffle.mjs
1979
2349
  function seriesShuffle(series) {
1980
- const out2 = series.copy();
1981
- return out2.get(shuffle(out2.index));
2350
+ const out = series.copy();
2351
+ return out.get(shuffle(out.index));
1982
2352
  }
2353
+
2354
+ // node_modules/@jrc03c/js-math-tools/src/series/series-sort.mjs
1983
2355
  function seriesSort(Series2, series, fn) {
1984
2356
  fn = fn || ((a, b) => a < b ? -1 : 1);
1985
- assert(isUndefined(fn) || isFunction(fn), "You must pass undefined, null, or a comparison function as the second argument to the `sort` method!");
2357
+ assert(
2358
+ isUndefined(fn) || isFunction(fn),
2359
+ "You must pass undefined, null, or a comparison function as the second argument to the `sort` method!"
2360
+ );
1986
2361
  const pairs = transpose([series.values, series.index]);
1987
2362
  const temp = sort(pairs, (aPair, bPair) => {
1988
2363
  return fn(aPair[0], bPair[0]);
@@ -1993,35 +2368,43 @@
1993
2368
  newValues.push(pair[0]);
1994
2369
  newIndex.push(pair[1]);
1995
2370
  });
1996
- const out2 = new Series2();
1997
- out2._values = newValues;
1998
- out2._index = newIndex;
1999
- out2.name = series.name;
2000
- return out2;
2371
+ const out = new Series2();
2372
+ out._values = newValues;
2373
+ out._index = newIndex;
2374
+ out.name = series.name;
2375
+ return out;
2001
2376
  }
2377
+
2378
+ // node_modules/@jrc03c/js-math-tools/src/series/series-sort-by-index.mjs
2002
2379
  function seriesSortByIndex(Series2, series) {
2003
2380
  let temp = transpose([series.values, series.index]);
2004
- temp = transpose(sort(temp, (a, b) => {
2005
- if (a[1] === b[1])
2006
- return 0;
2007
- if (a[1] < b[1])
2008
- return -1;
2009
- if (a[1] > b[1])
2010
- return 1;
2011
- }));
2012
- const out2 = new Series2(temp[0]);
2013
- out2.index = temp[1];
2014
- out2.name = series.name;
2015
- return out2;
2381
+ temp = transpose(
2382
+ sort(temp, (a, b) => {
2383
+ if (a[1] === b[1])
2384
+ return 0;
2385
+ if (a[1] < b[1])
2386
+ return -1;
2387
+ if (a[1] > b[1])
2388
+ return 1;
2389
+ })
2390
+ );
2391
+ const out = new Series2(temp[0]);
2392
+ out.index = temp[1];
2393
+ out.name = series.name;
2394
+ return out;
2016
2395
  }
2396
+
2397
+ // node_modules/@jrc03c/js-math-tools/src/series/series-to-object.mjs
2017
2398
  function seriesToObject(series) {
2018
- const out2 = {};
2019
- out2[series.name] = {};
2399
+ const out = {};
2400
+ out[series.name] = {};
2020
2401
  series.index.forEach((index, i) => {
2021
- out2[series.name][index] = series.values[i];
2402
+ out[series.name][index] = series.values[i];
2022
2403
  });
2023
- return out2;
2404
+ return out;
2024
2405
  }
2406
+
2407
+ // node_modules/@jrc03c/js-math-tools/src/series/index.mjs
2025
2408
  var SERIES_SYMBOL = Symbol.for("@jrc03c/js-math-tools/series");
2026
2409
  function createSeriesClass(DataFrame2) {
2027
2410
  class Series2 {
@@ -2055,13 +2438,18 @@
2055
2438
  set(x) {
2056
2439
  assert(isArray(x), "The new values must be a 1-dimensional array!");
2057
2440
  const dataShape = shape(x);
2058
- assert(dataShape.length === 1, "The new array of values must be 1-dimensional!");
2441
+ assert(
2442
+ dataShape.length === 1,
2443
+ "The new array of values must be 1-dimensional!"
2444
+ );
2059
2445
  if (dataShape[0] < this._index.length) {
2060
2446
  this._index = this._index.slice(0, dataShape[0]);
2061
2447
  } else if (dataShape[0] > this._index.length) {
2062
- this._index = this._index.concat(range(this._index.length, dataShape[0]).map((i) => {
2063
- return "item" + leftPad(i, (x.length - 1).toString().length);
2064
- }));
2448
+ this._index = this._index.concat(
2449
+ range(this._index.length, dataShape[0]).map((i) => {
2450
+ return "item" + leftPad(i, (x.length - 1).toString().length);
2451
+ })
2452
+ );
2065
2453
  }
2066
2454
  this._values = x;
2067
2455
  }
@@ -2079,9 +2467,18 @@
2079
2467
  return this._index;
2080
2468
  },
2081
2469
  set(x) {
2082
- assert(isArray(x), "The new index must be a 1-dimensional array of strings!");
2083
- assert(x.length === this.shape[0], "The new index must be the same length as the old index!");
2084
- assert(shape(x).length === 1, "The new index must be a 1-dimensional array of strings!");
2470
+ assert(
2471
+ isArray(x),
2472
+ "The new index must be a 1-dimensional array of strings!"
2473
+ );
2474
+ assert(
2475
+ x.length === this.shape[0],
2476
+ "The new index must be the same length as the old index!"
2477
+ );
2478
+ assert(
2479
+ shape(x).length === 1,
2480
+ "The new index must be a 1-dimensional array of strings!"
2481
+ );
2085
2482
  x.forEach((value) => {
2086
2483
  assert(isString(value), "All of the row names must be strings!");
2087
2484
  });
@@ -2095,14 +2492,23 @@
2095
2492
  this.index = copy(data.index);
2096
2493
  } else if (isArray(data)) {
2097
2494
  const dataShape = shape(data);
2098
- assert(dataShape.length === 1, "When passing an array into the constructor of a Series, the array must be 1-dimensional!");
2495
+ assert(
2496
+ dataShape.length === 1,
2497
+ "When passing an array into the constructor of a Series, the array must be 1-dimensional!"
2498
+ );
2099
2499
  this.values = data;
2100
2500
  } else if (data instanceof Object) {
2101
2501
  const keys = Object.keys(data).concat(Object.getOwnPropertySymbols(data)).map((v) => v.toString());
2102
- assert(keys.length === 1, "When passing an object into the constructor of a Series, the object must have only 1 key-value pair, where the key is the name of the data and the value is the 1-dimensional array of values!");
2502
+ assert(
2503
+ keys.length === 1,
2504
+ "When passing an object into the constructor of a Series, the object must have only 1 key-value pair, where the key is the name of the data and the value is the 1-dimensional array of values!"
2505
+ );
2103
2506
  const name = keys[0];
2104
2507
  const values = data[name];
2105
- assert(shape(values).length === 1, "When passing an object into the constructor of a Series, the object must have only 1 key-value pair, where the key is the name of the data and the value is the 1-dimensional array of values!");
2508
+ assert(
2509
+ shape(values).length === 1,
2510
+ "When passing an object into the constructor of a Series, the object must have only 1 key-value pair, where the key is the name of the data and the value is the 1-dimensional array of values!"
2511
+ );
2106
2512
  this.name = name;
2107
2513
  this.values = values.slice();
2108
2514
  }
@@ -2118,11 +2524,11 @@
2118
2524
  return this.values.filter((v) => !isUndefined(v)).length === 0;
2119
2525
  }
2120
2526
  clear() {
2121
- const out2 = this.copy();
2122
- out2.values.forEach((v, i) => {
2123
- out2.values[i] = void 0;
2527
+ const out = this.copy();
2528
+ out.values.forEach((v, i) => {
2529
+ out.values[i] = void 0;
2124
2530
  });
2125
- return out2;
2531
+ return out;
2126
2532
  }
2127
2533
  get(indices) {
2128
2534
  return seriesGet(this, indices);
@@ -2140,24 +2546,24 @@
2140
2546
  return this.getSubsetByIndices(indices);
2141
2547
  }
2142
2548
  reverse() {
2143
- const out2 = new Series2(reverse(this.values));
2144
- out2.index = reverse(this.index);
2145
- out2.name = this.name;
2146
- return out2;
2549
+ const out = new Series2(reverse(this.values));
2550
+ out.index = reverse(this.index);
2551
+ out.name = this.name;
2552
+ return out;
2147
2553
  }
2148
2554
  resetIndex() {
2149
- const out2 = this.copy();
2150
- out2.index = range(0, this.shape[0]).map((i) => {
2151
- return "item" + leftPad(i, (out2.index.length - 1).toString().length);
2555
+ const out = this.copy();
2556
+ out.index = range(0, this.shape[0]).map((i) => {
2557
+ return "item" + leftPad(i, (out.index.length - 1).toString().length);
2152
2558
  });
2153
- return out2;
2559
+ return out;
2154
2560
  }
2155
2561
  copy() {
2156
- const out2 = new Series2();
2157
- out2._values = copy(this.values);
2158
- out2._index = copy(this.index);
2159
- out2.name = this.name;
2160
- return out2;
2562
+ const out = new Series2();
2563
+ out._values = copy(this.values);
2564
+ out._index = copy(this.index);
2565
+ out.name = this.name;
2566
+ return out;
2161
2567
  }
2162
2568
  append(x) {
2163
2569
  return seriesAppend(Series2, this, x);
@@ -2193,16 +2599,16 @@
2193
2599
  return seriesFilter(Series2, this, fn);
2194
2600
  }
2195
2601
  toDataFrame() {
2196
- const out2 = new DataFrame2(transpose([this.values]));
2197
- out2.columns = [this.name];
2198
- out2.index = this.index;
2199
- return out2;
2602
+ const out = new DataFrame2(transpose([this.values]));
2603
+ out.columns = [this.name];
2604
+ out.index = this.index;
2605
+ return out;
2200
2606
  }
2201
2607
  transpose() {
2202
- const out2 = this.copy();
2203
- out2.values = reverse(out2.values);
2204
- out2.index = reverse(out2.index);
2205
- return out2;
2608
+ const out = this.copy();
2609
+ out.values = reverse(out.values);
2610
+ out.index = reverse(out.index);
2611
+ return out;
2206
2612
  }
2207
2613
  getDummies() {
2208
2614
  return this.toDataFrame().getDummies();
@@ -2213,13 +2619,15 @@
2213
2619
  }
2214
2620
  return Series2;
2215
2621
  }
2622
+
2623
+ // node_modules/@jrc03c/js-math-tools/src/dataframe/index.mjs
2216
2624
  var DATAFRAME_SYMBOL = Symbol.for("@jrc03c/js-math-tools/dataframe");
2217
2625
  function makeKey3(n) {
2218
2626
  const alpha = "abcdefghijklmnopqrstuvwxyz1234567890";
2219
- let out2 = "";
2627
+ let out = "";
2220
2628
  for (let i = 0; i < n; i++)
2221
- out2 += alpha[Math.floor(random() * alpha.length)];
2222
- return out2;
2629
+ out += alpha[Math.floor(random() * alpha.length)];
2630
+ return out;
2223
2631
  }
2224
2632
  var DataFrame = class {
2225
2633
  static [Symbol.hasInstance](x) {
@@ -2254,20 +2662,27 @@
2254
2662
  set(x) {
2255
2663
  assert(isArray(x), "The new values must be a 2-dimensional array!");
2256
2664
  const dataShape = shape(x);
2257
- assert(dataShape.length === 2, "The new array of values must be 2-dimensional!");
2665
+ assert(
2666
+ dataShape.length === 2,
2667
+ "The new array of values must be 2-dimensional!"
2668
+ );
2258
2669
  if (dataShape[0] < this._index.length) {
2259
2670
  this._index = this._index.slice(0, dataShape[0]);
2260
2671
  } else if (dataShape[0] > this._index.length) {
2261
- this._index = this._index.concat(range(this._index.length, dataShape[0]).map((i) => {
2262
- return "row" + leftPad(i, (dataShape[0] - 1).toString().length);
2263
- }));
2672
+ this._index = this._index.concat(
2673
+ range(this._index.length, dataShape[0]).map((i) => {
2674
+ return "row" + leftPad(i, (dataShape[0] - 1).toString().length);
2675
+ })
2676
+ );
2264
2677
  }
2265
2678
  if (dataShape[1] < this._columns.length) {
2266
2679
  this._columns = this._columns.slice(0, dataShape[1]);
2267
2680
  } else if (dataShape[1] > this._columns.length) {
2268
- this._columns = this._columns.concat(range(this._columns.length, dataShape[1]).map((i) => {
2269
- return "col" + leftPad(i, (dataShape[1] - 1).toString().length);
2270
- }));
2681
+ this._columns = this._columns.concat(
2682
+ range(this._columns.length, dataShape[1]).map((i) => {
2683
+ return "col" + leftPad(i, (dataShape[1] - 1).toString().length);
2684
+ })
2685
+ );
2271
2686
  }
2272
2687
  this._values = x;
2273
2688
  }
@@ -2285,9 +2700,18 @@
2285
2700
  return this._columns;
2286
2701
  },
2287
2702
  set(x) {
2288
- assert(isArray(x), "The new columns list must be a 1-dimensional array of strings!");
2289
- assert(this.isEmpty || x.length === this.shape[1], "The new columns list must be the same length as the old columns list!");
2290
- assert(shape(x).length === 1, "The new columns list must be a 1-dimensional array of strings!");
2703
+ assert(
2704
+ isArray(x),
2705
+ "The new columns list must be a 1-dimensional array of strings!"
2706
+ );
2707
+ assert(
2708
+ this.isEmpty || x.length === this.shape[1],
2709
+ "The new columns list must be the same length as the old columns list!"
2710
+ );
2711
+ assert(
2712
+ shape(x).length === 1,
2713
+ "The new columns list must be a 1-dimensional array of strings!"
2714
+ );
2291
2715
  x = x.map((v) => {
2292
2716
  if (typeof v !== "string") {
2293
2717
  v = JSON.stringify(v) || v.toString();
@@ -2299,11 +2723,11 @@
2299
2723
  });
2300
2724
  const counts = (() => {
2301
2725
  const temp = count(x);
2302
- const out2 = {};
2726
+ const out = {};
2303
2727
  temp.values.forEach((v) => {
2304
- out2[v] = temp.get(v);
2728
+ out[v] = temp.get(v);
2305
2729
  });
2306
- return out2;
2730
+ return out;
2307
2731
  })();
2308
2732
  x = x.map((v) => {
2309
2733
  if (counts[v] > 1) {
@@ -2327,9 +2751,18 @@
2327
2751
  return this._index;
2328
2752
  },
2329
2753
  set(x) {
2330
- assert(isArray(x), "The new index must be a 1-dimensional array of strings!");
2331
- assert(this.isEmpty || x.length === this.shape[0], "The new index must be the same length as the old index!");
2332
- assert(shape(x).length === 1, "The new index must be a 1-dimensional array of strings!");
2754
+ assert(
2755
+ isArray(x),
2756
+ "The new index must be a 1-dimensional array of strings!"
2757
+ );
2758
+ assert(
2759
+ this.isEmpty || x.length === this.shape[0],
2760
+ "The new index must be the same length as the old index!"
2761
+ );
2762
+ assert(
2763
+ shape(x).length === 1,
2764
+ "The new index must be a 1-dimensional array of strings!"
2765
+ );
2333
2766
  x = x.map((v) => {
2334
2767
  if (typeof v !== "string") {
2335
2768
  v = JSON.stringify(v) || v.toString();
@@ -2341,11 +2774,11 @@
2341
2774
  });
2342
2775
  const counts = (() => {
2343
2776
  const temp = count(x);
2344
- const out2 = {};
2777
+ const out = {};
2345
2778
  temp.values.forEach((v) => {
2346
- out2[v] = temp.get(v);
2779
+ out[v] = temp.get(v);
2347
2780
  });
2348
- return out2;
2781
+ return out;
2349
2782
  })();
2350
2783
  x = x.map((v) => {
2351
2784
  if (counts[v] > 1) {
@@ -2356,7 +2789,10 @@
2356
2789
  this._index = x;
2357
2790
  }
2358
2791
  });
2359
- assert(isUndefined(data) || isObject(data) || isArray(data), "The `data` passed into the constructor of a DataFrame must be either (1) an object where the key-value pairs are (respectively) column names and 1-dimensional arrays of values, or (2) a 2-dimensional array of values.");
2792
+ assert(
2793
+ isUndefined(data) || isObject(data) || isArray(data),
2794
+ "The `data` passed into the constructor of a DataFrame must be either (1) an object where the key-value pairs are (respectively) column names and 1-dimensional arrays of values, or (2) a 2-dimensional array of values."
2795
+ );
2360
2796
  if (data) {
2361
2797
  if (data instanceof DataFrame) {
2362
2798
  this.values = copy(data.values);
@@ -2364,8 +2800,14 @@
2364
2800
  this.index = copy(data.index);
2365
2801
  } else if (isArray(data)) {
2366
2802
  const dataShape = shape(data);
2367
- assert(dataShape.length === 2, "The `data` array passed into the constructor of a DataFrame must be 2-dimensional!");
2368
- assert(!isJagged(data), "The 2-dimensional array passed into the constructor of a DataFrame must not contain sub-arrays (i.e., rows) of different lengths!");
2803
+ assert(
2804
+ dataShape.length === 2,
2805
+ "The `data` array passed into the constructor of a DataFrame must be 2-dimensional!"
2806
+ );
2807
+ assert(
2808
+ !isJagged(data),
2809
+ "The 2-dimensional array passed into the constructor of a DataFrame must not contain sub-arrays (i.e., rows) of different lengths!"
2810
+ );
2369
2811
  this.values = data;
2370
2812
  } else {
2371
2813
  this._columns = Object.keys(data).concat(Object.getOwnPropertySymbols(data)).map((v) => v.toString());
@@ -2377,7 +2819,10 @@
2377
2819
  lastColName = col;
2378
2820
  lastColLength = data[col].length;
2379
2821
  }
2380
- assert(data[col].length === lastColLength, `The object passed into the DataFrame constructor contains arrays of different lengths! The key "${lastColName}" points to an array containing ${lastColLength} items, and the key "${col}" points to an array containing ${data[col].length} items.`);
2822
+ assert(
2823
+ data[col].length === lastColLength,
2824
+ `The object passed into the DataFrame constructor contains arrays of different lengths! The key "${lastColName}" points to an array containing ${lastColLength} items, and the key "${col}" points to an array containing ${data[col].length} items.`
2825
+ );
2381
2826
  lastColLength = data[col].length;
2382
2827
  const values = data[col];
2383
2828
  temp.push(values);
@@ -2409,10 +2854,10 @@
2409
2854
  return this.values.length === 0 || this.values.every((row) => row.length === 0);
2410
2855
  }
2411
2856
  clear() {
2412
- const out2 = new DataFrame(ndarray(this.shape));
2413
- out2.columns = this.columns.slice();
2414
- out2.index = this.index.slice();
2415
- return out2;
2857
+ const out = new DataFrame(ndarray(this.shape));
2858
+ out.columns = this.columns.slice();
2859
+ out.index = this.index.slice();
2860
+ return out;
2416
2861
  }
2417
2862
  get(rows, cols) {
2418
2863
  if (arguments.length === 0) {
@@ -2440,10 +2885,10 @@
2440
2885
  return dfGetDummies(DataFrame, this, columns);
2441
2886
  }
2442
2887
  transpose() {
2443
- const out2 = new DataFrame(transpose(this.values));
2444
- out2.columns = this.index.slice();
2445
- out2.index = this.columns.slice();
2446
- return out2;
2888
+ const out = new DataFrame(transpose(this.values));
2889
+ out.columns = this.index.slice();
2890
+ out.index = this.columns.slice();
2891
+ return out;
2447
2892
  }
2448
2893
  get T() {
2449
2894
  return this.transpose();
@@ -2516,12 +2961,19 @@
2516
2961
  }
2517
2962
  };
2518
2963
  var Series = createSeriesClass(DataFrame);
2964
+
2965
+ // node_modules/@jrc03c/js-math-tools/src/max.mjs
2519
2966
  function max(arr, shouldDropNaNs) {
2520
2967
  return stats(arr, { shouldDropNaNs }).max;
2521
2968
  }
2969
+
2970
+ // node_modules/@jrc03c/js-math-tools/src/vectorize.mjs
2522
2971
  function vectorize(fn) {
2523
- assert(isFunction(fn), "You must pass a function into the `vectorize` function!");
2524
- return function helper5() {
2972
+ assert(
2973
+ isFunction(fn),
2974
+ "You must pass a function into the `vectorize` function!"
2975
+ );
2976
+ return function helper4() {
2525
2977
  let hasSeries, hasDataFrames;
2526
2978
  const series = [];
2527
2979
  const dataframes = [];
@@ -2542,11 +2994,19 @@
2542
2994
  }
2543
2995
  }).map((key) => arguments[key]);
2544
2996
  childArrays.slice(0, -1).forEach((s2, i) => {
2545
- assert(isEqual(isArray(s2) ? shape(s2) : s2.shape, isArray(childArrays[i + 1]) ? shape(childArrays[i + 1]) : childArrays[i + 1].shape), `When passing multiple arrays into the \`${fn.name}\` function, all of the arrays must have the same shape!`);
2997
+ assert(
2998
+ isEqual(
2999
+ isArray(s2) ? shape(s2) : s2.shape,
3000
+ isArray(childArrays[i + 1]) ? shape(childArrays[i + 1]) : childArrays[i + 1].shape
3001
+ ),
3002
+ `When passing multiple arrays into the \`${fn.name}\` function, all of the arrays must have the same shape!`
3003
+ );
2546
3004
  });
2547
3005
  if (childArrays.length > 0) {
2548
- const maxLength = max(childArrays.map((a) => a.length ? a.length : a.values.length));
2549
- const out2 = range(0, maxLength).map((i) => {
3006
+ const maxLength = max(
3007
+ childArrays.map((a) => a.length ? a.length : a.values.length)
3008
+ );
3009
+ const out = range(0, maxLength).map((i) => {
2550
3010
  const args = Object.keys(arguments).map((key) => {
2551
3011
  if (isArray(arguments[key])) {
2552
3012
  return arguments[key][i];
@@ -2558,42 +3018,44 @@
2558
3018
  return arguments[key];
2559
3019
  }
2560
3020
  });
2561
- return helper5(...args);
3021
+ return helper4(...args);
2562
3022
  });
2563
3023
  if (hasDataFrames) {
2564
3024
  try {
2565
- if (dataframes.length === 1 && isEqual(shape(dataframes[0]), shape(out2))) {
2566
- const temp = new DataFrame(out2);
3025
+ if (dataframes.length === 1 && isEqual(shape(dataframes[0]), shape(out))) {
3026
+ const temp = new DataFrame(out);
2567
3027
  temp.index = dataframes[0].index.slice();
2568
3028
  temp.columns = dataframes[0].columns.slice();
2569
3029
  return temp;
2570
3030
  } else {
2571
- return new DataFrame(out2);
3031
+ return new DataFrame(out);
2572
3032
  }
2573
3033
  } catch (e) {
2574
- return out2;
3034
+ return out;
2575
3035
  }
2576
3036
  }
2577
3037
  if (hasSeries) {
2578
3038
  try {
2579
- if (series.length === 1 && series[0].length === out2.length) {
2580
- const temp = new Series(out2);
3039
+ if (series.length === 1 && series[0].length === out.length) {
3040
+ const temp = new Series(out);
2581
3041
  temp.name = series[0].name;
2582
3042
  temp.index = series[0].index.slice();
2583
3043
  return temp;
2584
3044
  } else {
2585
- return new Series(out2);
3045
+ return new Series(out);
2586
3046
  }
2587
3047
  } catch (e) {
2588
- return out2;
3048
+ return out;
2589
3049
  }
2590
3050
  }
2591
- return out2;
3051
+ return out;
2592
3052
  } else {
2593
3053
  return fn(...arguments);
2594
3054
  }
2595
3055
  };
2596
3056
  }
3057
+
3058
+ // node_modules/@jrc03c/js-math-tools/src/abs.mjs
2597
3059
  function abs(x) {
2598
3060
  try {
2599
3061
  if (!isNumber(x))
@@ -2608,9 +3070,11 @@
2608
3070
  }
2609
3071
  }
2610
3072
  var vabs = vectorize(abs);
3073
+
3074
+ // node_modules/@jrc03c/js-math-tools/src/add.mjs
2611
3075
  function add() {
2612
3076
  try {
2613
- let out2 = 0;
3077
+ let out = 0;
2614
3078
  let resultShouldBeABigInt = false;
2615
3079
  const x = Object.values(arguments);
2616
3080
  for (let v of x) {
@@ -2620,20 +3084,22 @@
2620
3084
  resultShouldBeABigInt = true;
2621
3085
  v = Number(v);
2622
3086
  }
2623
- out2 += v;
3087
+ out += v;
2624
3088
  }
2625
3089
  if (resultShouldBeABigInt) {
2626
3090
  try {
2627
- return BigInt(out2);
3091
+ return BigInt(out);
2628
3092
  } catch (e) {
2629
3093
  }
2630
3094
  }
2631
- return out2;
3095
+ return out;
2632
3096
  } catch (e) {
2633
3097
  return NaN;
2634
3098
  }
2635
3099
  }
2636
3100
  var vadd = vectorize(add);
3101
+
3102
+ // node_modules/@jrc03c/js-math-tools/src/apply.mjs
2637
3103
  function apply(x, fn) {
2638
3104
  try {
2639
3105
  return fn(x);
@@ -2642,6 +3108,8 @@
2642
3108
  }
2643
3109
  }
2644
3110
  var vapply = vectorize(apply);
3111
+
3112
+ // node_modules/@jrc03c/js-math-tools/src/arccos.mjs
2645
3113
  function arccos(x) {
2646
3114
  try {
2647
3115
  if (!isNumber(x))
@@ -2655,6 +3123,8 @@
2655
3123
  }
2656
3124
  }
2657
3125
  var varccos = vectorize(arccos);
3126
+
3127
+ // node_modules/@jrc03c/js-math-tools/src/arcsin.mjs
2658
3128
  function arcsin(x) {
2659
3129
  try {
2660
3130
  if (!isNumber(x))
@@ -2668,6 +3138,8 @@
2668
3138
  }
2669
3139
  }
2670
3140
  var varcsin = vectorize(arcsin);
3141
+
3142
+ // node_modules/@jrc03c/js-math-tools/src/arctan.mjs
2671
3143
  function arctan(x) {
2672
3144
  try {
2673
3145
  if (!isNumber(x))
@@ -2681,208 +3153,8 @@
2681
3153
  }
2682
3154
  }
2683
3155
  var varctan = vectorize(arctan);
2684
- function argmax(x, shouldDropNaNs) {
2685
- if (isDataFrame(x)) {
2686
- const index = argmax(x.values, shouldDropNaNs);
2687
- return [x.index[index[0]], x.columns[index[1]]];
2688
- }
2689
- if (isSeries(x)) {
2690
- const index = argmax(x.values, shouldDropNaNs);
2691
- return x.index[index];
2692
- }
2693
- assert(isArray(x), "The `argmax` function only works on arrays, Series, and DataFrames!");
2694
- try {
2695
- const out2 = indexOf(x, max(x, shouldDropNaNs));
2696
- if (out2) {
2697
- if (out2.length === 0) {
2698
- return void 0;
2699
- } else if (out2.length === 1) {
2700
- return out2[0];
2701
- } else {
2702
- return out2;
2703
- }
2704
- } else {
2705
- return void 0;
2706
- }
2707
- } catch (e) {
2708
- return void 0;
2709
- }
2710
- }
2711
- function min(arr, shouldDropNaNs) {
2712
- return stats(arr, { shouldDropNaNs }).min;
2713
- }
2714
- function argmin(x, shouldDropNaNs) {
2715
- if (isDataFrame(x)) {
2716
- const index = argmin(x.values, shouldDropNaNs);
2717
- return [x.index[index[0]], x.columns[index[1]]];
2718
- }
2719
- if (isSeries(x)) {
2720
- const index = argmin(x.values, shouldDropNaNs);
2721
- return x.index[index];
2722
- }
2723
- assert(isArray(x), "The `argmin` function only works on arrays, Series, and DataFrames!");
2724
- try {
2725
- const out2 = indexOf(x, min(x, shouldDropNaNs));
2726
- if (out2) {
2727
- if (out2.length === 0) {
2728
- return void 0;
2729
- } else if (out2.length === 1) {
2730
- return out2[0];
2731
- } else {
2732
- return out2;
2733
- }
2734
- } else {
2735
- return void 0;
2736
- }
2737
- } catch (e) {
2738
- return void 0;
2739
- }
2740
- }
2741
- function cast(value, type) {
2742
- if (isDataFrame(value) || isSeries(value)) {
2743
- return value.apply((item) => cast(item, type));
2744
- }
2745
- if (isArray(value)) {
2746
- return value.map((v) => cast(v, type));
2747
- }
2748
- if (type === "null") {
2749
- return null;
2750
- }
2751
- if (type === "number") {
2752
- if (isUndefined(value)) {
2753
- return NaN;
2754
- }
2755
- const booleanValue = cast(value, "boolean");
2756
- if (isBoolean(booleanValue)) {
2757
- return booleanValue ? 1 : 0;
2758
- }
2759
- try {
2760
- JSON.parse(value);
2761
- } catch (e) {
2762
- const dateValue = cast(value, "date");
2763
- if (isDate(dateValue)) {
2764
- return dateValue.getTime();
2765
- }
2766
- }
2767
- const out2 = parseFloat(value);
2768
- if (isNaN(out2))
2769
- return NaN;
2770
- return out2;
2771
- }
2772
- if (type === "int") {
2773
- const out2 = cast(value, "number");
2774
- return out2 >= 0 ? Math.floor(out2) : Math.ceil(out2);
2775
- }
2776
- if (type === "float") {
2777
- return cast(value, "number");
2778
- }
2779
- if (type === "bigint") {
2780
- if (typeof value === "bigint") {
2781
- return value;
2782
- }
2783
- return BigInt(cast(value, "int"));
2784
- }
2785
- if (type === "boolean") {
2786
- if (isBoolean(value)) {
2787
- return value;
2788
- }
2789
- if (isNumber(value)) {
2790
- if (value === 0) {
2791
- return false;
2792
- }
2793
- if (value === 1) {
2794
- return true;
2795
- }
2796
- return null;
2797
- }
2798
- try {
2799
- const vBool = (typeof value === "object" ? value.toString() === "null" ? "false" : JSON.stringify(value) : value.toString()).trim().toLowerCase();
2800
- if (vBool === "true" || vBool === "yes" || vBool === "y") {
2801
- return true;
2802
- }
2803
- if (vBool === "false" || vBool === "no" || vBool === "n") {
2804
- return false;
2805
- }
2806
- return null;
2807
- } catch (e) {
2808
- return null;
2809
- }
2810
- }
2811
- if (type === "date") {
2812
- if (isDate(value)) {
2813
- return value;
2814
- }
2815
- if (isUndefined(value)) {
2816
- return null;
2817
- }
2818
- const valueFloat = parseFloat(value);
2819
- if (!isNaN(valueFloat)) {
2820
- const out2 = new Date(value);
2821
- if (!isDate(out2))
2822
- return null;
2823
- return out2;
2824
- }
2825
- const valueDate = Date.parse(value);
2826
- if (!isNaN(valueDate)) {
2827
- return new Date(valueDate);
2828
- }
2829
- return null;
2830
- }
2831
- if (type === "object") {
2832
- if (isObject(value)) {
2833
- return value;
2834
- }
2835
- const booleanValue = cast(value, "boolean");
2836
- if (isBoolean(booleanValue)) {
2837
- return null;
2838
- }
2839
- try {
2840
- const numberValue = cast(value, "number");
2841
- if (isNumber(numberValue)) {
2842
- JSON.parse(value);
2843
- return null;
2844
- }
2845
- } catch (e) {
2846
- }
2847
- const dateValue = cast(value, "date");
2848
- if (dateValue) {
2849
- return dateValue;
2850
- }
2851
- try {
2852
- const out2 = JSON.parse(value);
2853
- if (isArray(out2)) {
2854
- return out2.map((v) => cast(v, type));
2855
- } else {
2856
- return out2;
2857
- }
2858
- } catch (e) {
2859
- return null;
2860
- }
2861
- }
2862
- if (type === "string") {
2863
- if (isUndefined(value)) {
2864
- if (isEqual(value, void 0)) {
2865
- return "undefined";
2866
- }
2867
- return "null";
2868
- }
2869
- if (value instanceof Date) {
2870
- return value.toJSON();
2871
- }
2872
- const valueString = (() => {
2873
- if (typeof value === "object") {
2874
- if (value === null) {
2875
- return "null";
2876
- } else {
2877
- return JSON.stringify(value);
2878
- }
2879
- } else {
2880
- return value.toString();
2881
- }
2882
- })();
2883
- return valueString;
2884
- }
2885
- }
3156
+
3157
+ // node_modules/@jrc03c/js-math-tools/src/ceil.mjs
2886
3158
  function ceil(x) {
2887
3159
  try {
2888
3160
  if (!isNumber(x))
@@ -2895,6 +3167,8 @@
2895
3167
  }
2896
3168
  }
2897
3169
  var vceil = vectorize(ceil);
3170
+
3171
+ // node_modules/@jrc03c/js-math-tools/src/chop.mjs
2898
3172
  function chop(x, threshold) {
2899
3173
  try {
2900
3174
  if (!isNumber(x))
@@ -2912,19 +3186,21 @@
2912
3186
  }
2913
3187
  }
2914
3188
  var vchop = vectorize(chop);
3189
+
3190
+ // node_modules/@jrc03c/js-math-tools/src/int.mjs
2915
3191
  function int(x) {
2916
3192
  if (isDataFrame(x) || isSeries(x)) {
2917
- const out2 = x.copy();
2918
- out2.values = int(out2.values);
2919
- return out2;
3193
+ const out = x.copy();
3194
+ out.values = int(out.values);
3195
+ return out;
2920
3196
  }
2921
3197
  if (isArray(x)) {
2922
3198
  return x.map((v) => int(v));
2923
3199
  } else {
2924
3200
  try {
2925
- const out2 = JSON.parse(x);
2926
- if (isNumber(out2)) {
2927
- return typeof out2 === "bigint" ? Number(out2) : out2 >= 0 ? Math.floor(out2) : Math.ceil(out2);
3201
+ const out = JSON.parse(x);
3202
+ if (isNumber(out)) {
3203
+ return typeof out === "bigint" ? Number(out) : out >= 0 ? Math.floor(out) : Math.ceil(out);
2928
3204
  }
2929
3205
  return NaN;
2930
3206
  } catch (e) {
@@ -2933,6 +3209,8 @@
2933
3209
  }
2934
3210
  }
2935
3211
  var vint = vectorize(int);
3212
+
3213
+ // node_modules/@jrc03c/js-math-tools/src/clamp.mjs
2936
3214
  function clamp(x, a, b) {
2937
3215
  try {
2938
3216
  if (!isNumber(x))
@@ -2954,174 +3232,8 @@
2954
3232
  }
2955
3233
  }
2956
3234
  var vclamp = vectorize(clamp);
2957
- function combinationsIterator(x, r) {
2958
- function* helper5(x2, r2) {
2959
- if (r2 > x2.length) {
2960
- yield x2;
2961
- } else if (r2 <= 0) {
2962
- yield [];
2963
- } else if (x2.length < 2) {
2964
- yield x2;
2965
- } else {
2966
- for (let i = 0; i < x2.length; i++) {
2967
- const item = x2[i];
2968
- const after = x2.slice(i + 1);
2969
- if (after.length < r2 - 1) {
2970
- continue;
2971
- }
2972
- if (r2 - 1 >= 0) {
2973
- for (const child of combinationsIterator(after, r2 - 1)) {
2974
- yield [item].concat(child);
2975
- }
2976
- }
2977
- }
2978
- }
2979
- }
2980
- if (isDataFrame(x) || isSeries(x)) {
2981
- return combinationsIterator(x.values, r);
2982
- }
2983
- assert(isArray(x), "The `combinations` function only works on arrays, Series, and DataFrames!");
2984
- assert(isNumber(r) && vint(r) === r && r >= 0, "`r` must be a non-negative integer!");
2985
- return helper5(flatten(x), r);
2986
- }
2987
- function combinations(x, r) {
2988
- const out2 = [];
2989
- for (const combo of combinationsIterator(x, r)) {
2990
- out2.push(combo.slice());
2991
- }
2992
- return out2;
2993
- }
2994
- function intersect() {
2995
- const arrays = Object.values(arguments).map((x) => {
2996
- if (isDataFrame(x) || isSeries(x)) {
2997
- return set(x.values);
2998
- }
2999
- assert(isArray(x), "The `intersect` function only works on arrays, Series, and DataFrames!");
3000
- return set(x);
3001
- });
3002
- const all = set(arrays);
3003
- return all.filter((v) => {
3004
- return arrays.every((arr) => arr.findIndex((other) => isEqual(other, v)) > -1);
3005
- });
3006
- }
3007
- var _IndexMatcher = class {
3008
- constructor(mode2) {
3009
- assert(isUndefined(mode2) || mode2 === _IndexMatcher.DROP_NAN_MODE || mode2 === _IndexMatcher.DROP_MISSING_MODE, "The `mode` value passed into the `IndexMatcher` constructor must be undefined or one of [IndexMatcher.DROP_NAN_MODE, IndexMatcher.DROP_MISSING_MODE]! (By default, the mode is `Indexer.DROP_MISSING_MODE`.)");
3010
- this.mode = !isUndefined(mode2) ? mode2 : _IndexMatcher.DROP_NAN_MODE;
3011
- this.index = null;
3012
- }
3013
- fit() {
3014
- const indices = [];
3015
- Object.values(arguments).forEach((x) => {
3016
- if (isArray(x)) {
3017
- const xshape = shape(x);
3018
- if (xshape.length === 1) {
3019
- x = new Series(x);
3020
- } else if (xshape.length === 2) {
3021
- x = new DataFrame(x);
3022
- } else {
3023
- throw new Error("The `IndexMatcher.fit` method only works on arrays, Series, and DataFrames!");
3024
- }
3025
- }
3026
- assert(isDataFrame(x) || isSeries(x), "The `IndexMatcher.fit` method only works on arrays, Series, and DataFrames!");
3027
- if (this.mode === _IndexMatcher.DROP_MISSING_MODE) {
3028
- indices.push(x.dropMissing().index);
3029
- } else {
3030
- indices.push(x.dropNaN().index);
3031
- }
3032
- });
3033
- this.index = intersect(...indices);
3034
- return this;
3035
- }
3036
- transform() {
3037
- assert(!!this.index, "The IndexMatcher hasn't been fitted yet! Please call the `fit` method before calling the `transform` method.");
3038
- const out2 = Object.values(arguments).map((x) => {
3039
- if (isArray(x)) {
3040
- const xshape = shape(x);
3041
- if (xshape.length === 1) {
3042
- return new Series(x).get(this.index).values;
3043
- } else if (xshape.length === 2) {
3044
- return new DataFrame(x).get(this.index, null).values;
3045
- } else {
3046
- throw new Error("The `IndexMatcher.fit` method only works on arrays, Series, and DataFrames!");
3047
- }
3048
- }
3049
- assert(isDataFrame(x) || isSeries(x), "The `IndexMatcher.fit` method only works on arrays, Series, and DataFrames!");
3050
- return x.get(this.index, null);
3051
- });
3052
- return out2.length === 1 ? out2[0] : out2;
3053
- }
3054
- fitAndTransform() {
3055
- return this.fit(...arguments).transform(...arguments);
3056
- }
3057
- };
3058
- var IndexMatcher = _IndexMatcher;
3059
- __publicField(IndexMatcher, "DROP_NAN_MODE", "DROP_NAN_MODE");
3060
- __publicField(IndexMatcher, "DROP_MISSING_MODE", "DROP_MISSING_MODE");
3061
- function covariance(x, y, shouldDropNaNs, shouldAlsoReturnStatsObjects) {
3062
- if (isSeries(x)) {
3063
- return covariance(x.values, y, shouldDropNaNs, shouldAlsoReturnStatsObjects);
3064
- }
3065
- if (isSeries(y)) {
3066
- return covariance(x, y.values, shouldDropNaNs, shouldAlsoReturnStatsObjects);
3067
- }
3068
- assert(isArray(x) && isArray(y) && shape(x).length === 1 && shape(y).length === 1, "The `covariance` function only works on 1-dimensional arrays and Series!");
3069
- assert(x.length === y.length, "The two arrays or Series passed into the `covariance` function must have the same length!");
3070
- if (shouldDropNaNs) {
3071
- return covariance(...new IndexMatcher().fitAndTransform(x, y), false, shouldAlsoReturnStatsObjects);
3072
- }
3073
- try {
3074
- const xstats = stats(x, { stdev: shouldAlsoReturnStatsObjects });
3075
- const ystats = stats(y, { stdev: shouldAlsoReturnStatsObjects });
3076
- const mx = Number(xstats.mean);
3077
- const my = Number(ystats.mean);
3078
- if (!isNumber(mx) || !isNumber(my)) {
3079
- return NaN;
3080
- }
3081
- const n = Math.max(x.length, y.length);
3082
- let out2 = 0;
3083
- for (let i = 0; i < n; i++) {
3084
- let vx = x[i];
3085
- let vy = y[i];
3086
- if (!isNumber(vx))
3087
- return NaN;
3088
- if (!isNumber(vy))
3089
- return NaN;
3090
- if (typeof vx === "bigint") {
3091
- vx = Number(vx);
3092
- }
3093
- if (typeof vy === "bigint") {
3094
- vy = Number(vy);
3095
- }
3096
- out2 += (vx - mx) * (vy - my);
3097
- }
3098
- if (shouldAlsoReturnStatsObjects) {
3099
- return [out2 / x.length, xstats, ystats];
3100
- } else {
3101
- return out2 / x.length;
3102
- }
3103
- } catch (e) {
3104
- return NaN;
3105
- }
3106
- }
3107
- function correl(x, y, shouldDropNaNs) {
3108
- if (isSeries(x)) {
3109
- return correl(x.values, y, shouldDropNaNs);
3110
- }
3111
- if (isSeries(y)) {
3112
- return correl(x, y.values, shouldDropNaNs);
3113
- }
3114
- assert(isArray(x) && isArray(y) && shape(x).length === 1 && shape(y).length === 1, "The `correl` function only works on 1-dimensional arrays and Series!");
3115
- assert(x.length === y.length, "The two arrays or Series passed into the `correl` function must have the same length!");
3116
- try {
3117
- const shouldAlsoReturnStatsObjects = true;
3118
- const [num, xstats, ystats] = covariance(x, y, shouldDropNaNs, shouldAlsoReturnStatsObjects);
3119
- const den = xstats.stdev * ystats.stdev;
3120
- return num / den;
3121
- } catch (e) {
3122
- return NaN;
3123
- }
3124
- }
3235
+
3236
+ // node_modules/@jrc03c/js-math-tools/src/cos.mjs
3125
3237
  function cos(x) {
3126
3238
  try {
3127
3239
  if (!isNumber(x))
@@ -3135,6 +3247,8 @@
3135
3247
  }
3136
3248
  }
3137
3249
  var vcos = vectorize(cos);
3250
+
3251
+ // node_modules/@jrc03c/js-math-tools/src/helpers/data-types.mjs
3138
3252
  var dataTypes = Object.freeze({
3139
3253
  boolean: "boolean",
3140
3254
  date: "date",
@@ -3143,24 +3257,8 @@
3143
3257
  object: "object",
3144
3258
  string: "string"
3145
3259
  });
3146
- function diff(a, b) {
3147
- if (isDataFrame(a) || isSeries(a)) {
3148
- return diff(a.values, b);
3149
- }
3150
- if (isDataFrame(b) || isSeries(b)) {
3151
- return diff(a, b.values);
3152
- }
3153
- assert(isArray(a) && isArray(b), "The `diff` function only works on arrays, Series, and DataFrames!");
3154
- const aTemp = set(a);
3155
- const bTemp = set(b);
3156
- const out2 = [];
3157
- aTemp.forEach((item) => {
3158
- if (bTemp.findIndex((other) => isEqual(other, item)) < 0) {
3159
- out2.push(item);
3160
- }
3161
- });
3162
- return out2;
3163
- }
3260
+
3261
+ // node_modules/@jrc03c/js-math-tools/src/pow.mjs
3164
3262
  function pow(x, p) {
3165
3263
  try {
3166
3264
  if (!isNumber(x))
@@ -3168,11 +3266,11 @@
3168
3266
  if (!isNumber(p))
3169
3267
  return NaN;
3170
3268
  if (typeof x === "bigint" || typeof p === "bigint") {
3171
- const out2 = pow(Number(x), Number(p));
3269
+ const out = pow(Number(x), Number(p));
3172
3270
  try {
3173
- return BigInt(out2);
3271
+ return BigInt(out);
3174
3272
  } catch (e) {
3175
- return out2;
3273
+ return out;
3176
3274
  }
3177
3275
  }
3178
3276
  return Math.pow(x, p);
@@ -3181,16 +3279,18 @@
3181
3279
  }
3182
3280
  }
3183
3281
  var vpow = vectorize(pow);
3282
+
3283
+ // node_modules/@jrc03c/js-math-tools/src/sqrt.mjs
3184
3284
  function sqrt(x) {
3185
3285
  try {
3186
3286
  if (!isNumber(x))
3187
3287
  return NaN;
3188
3288
  if (typeof x === "bigint") {
3189
- const out2 = sqrt(Number(x));
3289
+ const out = sqrt(Number(x));
3190
3290
  try {
3191
- return BigInt(out2);
3291
+ return BigInt(out);
3192
3292
  } catch (e) {
3193
- return out2;
3293
+ return out;
3194
3294
  }
3195
3295
  }
3196
3296
  return Math.sqrt(x);
@@ -3199,13 +3299,15 @@
3199
3299
  }
3200
3300
  }
3201
3301
  var vsqrt = vectorize(sqrt);
3302
+
3303
+ // node_modules/@jrc03c/js-math-tools/src/multiply.mjs
3202
3304
  function multiply() {
3203
3305
  try {
3204
3306
  const x = Object.values(arguments);
3205
3307
  if (x.length === 0)
3206
3308
  return NaN;
3207
3309
  let resultShouldBeABigInt = false;
3208
- let out2 = 1;
3310
+ let out = 1;
3209
3311
  for (let v of x) {
3210
3312
  if (!isNumber(v))
3211
3313
  return NaN;
@@ -3213,201 +3315,23 @@
3213
3315
  resultShouldBeABigInt = true;
3214
3316
  v = Number(v);
3215
3317
  }
3216
- out2 *= v;
3318
+ out *= v;
3217
3319
  }
3218
3320
  if (resultShouldBeABigInt) {
3219
3321
  try {
3220
- return BigInt(out2);
3322
+ return BigInt(out);
3221
3323
  } catch (e) {
3222
3324
  }
3223
3325
  }
3224
- return out2;
3326
+ return out;
3225
3327
  } catch (e) {
3226
3328
  return NaN;
3227
3329
  }
3228
3330
  }
3229
3331
  var vmultiply = vectorize(multiply);
3230
- function scale() {
3231
- return vmultiply(...arguments);
3232
- }
3233
- function subtract(a, b) {
3234
- return vadd(a, scale(b, -1));
3235
- }
3236
- function sum(arr, shouldDropNaNs) {
3237
- return stats(arr, { shouldDropNaNs }).sum;
3238
- }
3239
- function distance(a, b) {
3240
- if (isNumber(a) && isNumber(b)) {
3241
- return vabs(a - b);
3242
- }
3243
- if (isDataFrame(a) || isSeries(a)) {
3244
- return distance(a.values, b);
3245
- }
3246
- if (isDataFrame(b) || isSeries(b)) {
3247
- return distance(a, b.values);
3248
- }
3249
- if (isArray(a) && isArray(b)) {
3250
- assert(isEqual(shape(a), shape(b)), "If passing two arrays, Series, or DataFrames into the `distance` function, then those objects must have the same shape!");
3251
- }
3252
- try {
3253
- return vsqrt(sum(vpow(subtract(a, b), 2)));
3254
- } catch (e) {
3255
- return NaN;
3256
- }
3257
- }
3258
- function divide(a, b) {
3259
- return scale(a, vpow(b, -1));
3260
- }
3261
- function dot(a, b) {
3262
- if (isDataFrame(a)) {
3263
- const temp = dot(a.values, b);
3264
- if (shape(temp).length === 1) {
3265
- const out2 = new Series(temp);
3266
- out2.name = isSeries(b) ? b.name : out2.name;
3267
- out2.index = a.index.slice();
3268
- return out2;
3269
- } else {
3270
- const out2 = new DataFrame(temp);
3271
- out2.index = a.index.slice();
3272
- if (isDataFrame(b)) {
3273
- out2.columns = b.columns.slice();
3274
- }
3275
- return out2;
3276
- }
3277
- }
3278
- if (isDataFrame(b)) {
3279
- const temp = dot(a, b.values);
3280
- if (shape(temp).length === 1) {
3281
- const out2 = new Series(temp);
3282
- out2.name = isSeries(a) ? a.name : out2.name;
3283
- out2.index = b.columns.slice();
3284
- return out2;
3285
- } else {
3286
- const out2 = new DataFrame(temp);
3287
- out2.columns = b.columns.slice();
3288
- return out2;
3289
- }
3290
- }
3291
- if (isSeries(a)) {
3292
- return dot(a.values, b);
3293
- }
3294
- if (isSeries(b)) {
3295
- return dot(a, b.values);
3296
- }
3297
- assert(isArray(a) && isArray(b), "The `dot` function only works on arrays, Series, and DataFrames!");
3298
- const aShape = shape(a);
3299
- const bShape = shape(b);
3300
- assert(aShape.length <= 2 && bShape.length <= 2, "I'm not smart enough to know how to get the dot-product of arrays that have more than 2 dimensions. Sorry for the inconvenience! Please only pass 1- or 2-dimensional arrays into the `dot` function!");
3301
- assert(aShape[aShape.length - 1] === bShape[0], `There's a dimension misalignment in the two arrays you passed into the \`dot\` function. (${aShape[aShape.length - 1]} !== ${bShape[0]})`);
3302
- if (aShape.length === 1 && bShape.length === 1) {
3303
- return sum(scale(a, b));
3304
- } else if (aShape.length === 1 && bShape.length === 2) {
3305
- return transpose(b).map((col) => dot(a, col));
3306
- } else if (aShape.length === 2 && bShape.length === 1) {
3307
- return a.map((row) => dot(row, b));
3308
- } else if (aShape.length === 2 && bShape.length === 2) {
3309
- const bTranspose = transpose(b);
3310
- const out2 = [];
3311
- for (let i = 0; i < a.length; i++) {
3312
- const row = [];
3313
- for (let j = 0; j < bTranspose.length; j++) {
3314
- row.push(dot(a[i], bTranspose[j]));
3315
- }
3316
- out2.push(row);
3317
- }
3318
- return out2;
3319
- }
3320
- }
3321
- function dropMissing(x) {
3322
- if (isDataFrame(x) || isSeries(x)) {
3323
- return x.dropMissing(...Object.values(arguments).slice(1));
3324
- }
3325
- assert(isArray(x), "The `dropMissing` function only works on arrays, Series, and DataFrames!");
3326
- const out2 = [];
3327
- x.forEach((v) => {
3328
- try {
3329
- return out2.push(dropMissing(v));
3330
- } catch (e) {
3331
- if (!isUndefined(v)) {
3332
- out2.push(v);
3333
- }
3334
- }
3335
- });
3336
- return out2;
3337
- }
3338
- function dropMissingPairwise(a, b) {
3339
- if (isDataFrame(a) || isSeries(a)) {
3340
- return dropMissingPairwise(a.values, b);
3341
- }
3342
- if (isDataFrame(b) || isSeries(b)) {
3343
- return dropMissingPairwise(a, b.values);
3344
- }
3345
- assert(isArray(a) && isArray(b), "The `dropMissingPairwise` function only works on arrays, Series, and DataFrames!");
3346
- assert(isEqual(shape(a), shape(b)), "The two arrays, Series, and/or DataFrames passed into the `dropMissingPairwise` function must have the same shape!");
3347
- const aOut = [];
3348
- const bOut = [];
3349
- for (let i = 0; i < a.length; i++) {
3350
- try {
3351
- const [aChildren, bChildren] = dropMissingPairwise(a[i], b[i]);
3352
- aOut.push(aChildren);
3353
- bOut.push(bChildren);
3354
- } catch (e) {
3355
- if (!isUndefined(a[i]) && !isUndefined(b[i])) {
3356
- aOut.push(a[i]);
3357
- bOut.push(b[i]);
3358
- }
3359
- }
3360
- }
3361
- return [aOut, bOut];
3362
- }
3363
- function dropNaNPairwise(a, b) {
3364
- if (isDataFrame(a) || isSeries(a)) {
3365
- return dropNaNPairwise(a.values, b);
3366
- }
3367
- if (isDataFrame(b) || isSeries(b)) {
3368
- return dropNaNPairwise(a, b.values);
3369
- }
3370
- assert(isArray(a) && isArray(b), "The `dropNaNPairwise` only works on arrays, Series, and DataFrames!");
3371
- assert(isEqual(shape(a), shape(b)), "The two arrays, Series, and/or DataFrames passed into the `dropNaNPairwise` must have the same shape!");
3372
- const aOut = [];
3373
- const bOut = [];
3374
- for (let i = 0; i < a.length; i++) {
3375
- try {
3376
- const [aChildren, bChildren] = dropNaNPairwise(a[i], b[i]);
3377
- aOut.push(aChildren);
3378
- bOut.push(bChildren);
3379
- } catch (e) {
3380
- if (isNumber(a[i]) && isNumber(b[i])) {
3381
- aOut.push(a[i]);
3382
- bOut.push(b[i]);
3383
- }
3384
- }
3385
- }
3386
- return [aOut, bOut];
3387
- }
3388
- function dropUndefined(x) {
3389
- return dropMissing(x);
3390
- }
3391
- function every(x, fn) {
3392
- if (isDataFrame(x) || isSeries(x)) {
3393
- return every(x.values, fn);
3394
- }
3395
- assert(isArray(x), "The first argument passed into the `every` function must be an array, Series, or DataFrame!");
3396
- assert(isFunction(fn), "The second argument passed into the `every` function must be a function!");
3397
- for (const v of x) {
3398
- if (isArray(v)) {
3399
- if (!every(v, fn)) {
3400
- return false;
3401
- }
3402
- } else {
3403
- if (!fn(v)) {
3404
- return false;
3405
- }
3406
- }
3407
- }
3408
- return true;
3409
- }
3410
- function exp(x) {
3332
+
3333
+ // node_modules/@jrc03c/js-math-tools/src/exp.mjs
3334
+ function exp(x) {
3411
3335
  try {
3412
3336
  if (!isNumber(x))
3413
3337
  return NaN;
@@ -3424,6 +3348,8 @@
3424
3348
  }
3425
3349
  }
3426
3350
  var vexp = vectorize(exp);
3351
+
3352
+ // node_modules/@jrc03c/js-math-tools/src/factorial.mjs
3427
3353
  function factorial(n) {
3428
3354
  try {
3429
3355
  if (typeof n === "bigint") {
@@ -3439,137 +3365,8 @@
3439
3365
  }
3440
3366
  }
3441
3367
  var vfactorial = vectorize(factorial);
3442
- function find(x, fn) {
3443
- if (isDataFrame(x)) {
3444
- return find(x.values, fn);
3445
- }
3446
- if (isSeries(x)) {
3447
- return find(x.values, fn);
3448
- }
3449
- assert(isObject(x) || isArray(x), "You must pass (1) an object, array, Series, or DataFrame and (2) a function or value into the `find` function!");
3450
- if (!isFunction(fn)) {
3451
- const value = fn;
3452
- fn = (v) => v === value;
3453
- }
3454
- function helper5(x2, fn2, checked) {
3455
- checked = checked || [];
3456
- if (checked.indexOf(x2) > -1) {
3457
- return null;
3458
- }
3459
- if (isObject(x2)) {
3460
- checked.push(x2);
3461
- const keys = Object.keys(x2).concat(Object.getOwnPropertySymbols(x2));
3462
- for (let i = 0; i < keys.length; i++) {
3463
- const key = keys[i];
3464
- const value = x2[key];
3465
- if (fn2(value)) {
3466
- return value;
3467
- }
3468
- const result = helper5(value, fn2, checked);
3469
- if (result) {
3470
- return result;
3471
- }
3472
- }
3473
- } else if (isArray(x2)) {
3474
- checked.push(x2);
3475
- for (let i = 0; i < x2.length; i++) {
3476
- const value = x2[i];
3477
- if (fn2(value)) {
3478
- return value;
3479
- }
3480
- const result = helper5(value, fn2, checked);
3481
- if (result) {
3482
- return result;
3483
- }
3484
- }
3485
- } else {
3486
- if (fn2(x2)) {
3487
- return x2;
3488
- }
3489
- }
3490
- return null;
3491
- }
3492
- function safeFn(v) {
3493
- try {
3494
- return fn(v);
3495
- } catch (e) {
3496
- return false;
3497
- }
3498
- }
3499
- return helper5(x, safeFn);
3500
- }
3501
- function findAll(x, fn) {
3502
- if (isDataFrame(x)) {
3503
- return findAll(x.values, fn);
3504
- }
3505
- if (isSeries(x)) {
3506
- return findAll(x.values, fn);
3507
- }
3508
- assert(isObject(x) || isArray(x), "You must pass (1) an object, array, Series, or DataFrame and (2) a function or value into the `findAll` function!");
3509
- if (!isFunction(fn)) {
3510
- const value = fn;
3511
- fn = (v) => v === value;
3512
- }
3513
- function helper5(x2, fn2, checked) {
3514
- checked = checked || [];
3515
- if (checked.indexOf(x2) > -1) {
3516
- return null;
3517
- }
3518
- if (isObject(x2)) {
3519
- checked.push(x2);
3520
- const keys = Object.keys(x2).concat(Object.getOwnPropertySymbols(x2));
3521
- const out2 = [];
3522
- for (let i = 0; i < keys.length; i++) {
3523
- const key = keys[i];
3524
- const value = x2[key];
3525
- let alreadyStoredThisValue = false;
3526
- if (fn2(value)) {
3527
- out2.push(value);
3528
- alreadyStoredThisValue = true;
3529
- }
3530
- const results2 = helper5(value, fn2, checked);
3531
- if (results2 && results2.length > 0) {
3532
- results2.slice(alreadyStoredThisValue ? 1 : 0).forEach((r) => out2.push(r));
3533
- }
3534
- }
3535
- return out2;
3536
- } else if (isArray(x2)) {
3537
- checked.push(x2);
3538
- const out2 = [];
3539
- for (let i = 0; i < x2.length; i++) {
3540
- const value = x2[i];
3541
- let alreadyStoredThisValue = false;
3542
- if (fn2(value)) {
3543
- out2.push(value);
3544
- alreadyStoredThisValue = true;
3545
- }
3546
- const results2 = helper5(value, fn2, checked);
3547
- if (results2 && results2.length > 0) {
3548
- results2.slice(alreadyStoredThisValue ? 1 : 0).forEach((r) => out2.push(r));
3549
- }
3550
- }
3551
- return out2;
3552
- } else {
3553
- if (fn2(x2)) {
3554
- return [x2];
3555
- }
3556
- }
3557
- return null;
3558
- }
3559
- function safeFn(v) {
3560
- try {
3561
- return fn(v);
3562
- } catch (e) {
3563
- return false;
3564
- }
3565
- }
3566
- const results = helper5(x, safeFn);
3567
- if (results && results.length > 0) {
3568
- return results;
3569
- } else {
3570
- return null;
3571
- }
3572
- }
3368
+
3369
+ // node_modules/@jrc03c/js-math-tools/src/float.mjs
3573
3370
  function float(x) {
3574
3371
  try {
3575
3372
  if (x === "Infinity") {
@@ -3578,15 +3375,17 @@
3578
3375
  if (x === "-Infinity") {
3579
3376
  return -Infinity;
3580
3377
  }
3581
- const out2 = JSON.parse(x);
3582
- if (isNumber(out2))
3583
- return out2;
3378
+ const out = JSON.parse(x);
3379
+ if (isNumber(out))
3380
+ return out;
3584
3381
  return NaN;
3585
3382
  } catch (e) {
3586
3383
  return NaN;
3587
3384
  }
3588
3385
  }
3589
3386
  var vfloat = vectorize(float);
3387
+
3388
+ // node_modules/@jrc03c/js-math-tools/src/floor.mjs
3590
3389
  function floor(x) {
3591
3390
  try {
3592
3391
  if (!isNumber(x))
@@ -3600,189 +3399,8 @@
3600
3399
  }
3601
3400
  }
3602
3401
  var vfloor = vectorize(floor);
3603
- function zeros(shape2) {
3604
- if (isNumber(shape2))
3605
- shape2 = [shape2];
3606
- const out2 = [];
3607
- const n = product(shape2);
3608
- for (let i = 0; i < n; i++)
3609
- out2.push(0);
3610
- return reshape(out2, shape2);
3611
- }
3612
- function identity(size) {
3613
- if (typeof size === "bigint") {
3614
- size = vint(size);
3615
- }
3616
- assert(!isUndefined(size), "You must pass an integer greater than 0 (representing the size) into the `identity` function!");
3617
- assert(isNumber(size), "You must pass an integer greater than 0 (representing the size) into the `identity` function!");
3618
- assert(vint(size) === size, "You must pass an integer greater than 0 (representing the size) into the `identity` function!");
3619
- assert(size > 0, "You must pass an integer greater than 0 (representing the size) into the `identity` function!");
3620
- const out2 = zeros([size, size]);
3621
- for (let i = 0; i < size; i++)
3622
- out2[i][i] = 1;
3623
- return out2;
3624
- }
3625
- var booleanValues = ["true", "false", "yes", "no"];
3626
- var nullValues = ["null", "none", "nan", "na", "n/a", "", "undefined"];
3627
- function checkIfInteger(results) {
3628
- if (results.type === "number") {
3629
- if (typeof results.value !== "undefined") {
3630
- results.isInteger = vint(results.value) === results.value;
3631
- } else {
3632
- results.isInteger = every(results.values, (v) => isNumber(v) ? vint(v) === v : true);
3633
- }
3634
- }
3635
- return results;
3636
- }
3637
- function inferType(arr) {
3638
- if (isDataFrame(arr)) {
3639
- const out2 = arr.copy();
3640
- const results = inferType(arr.values);
3641
- out2.values = results.values;
3642
- return checkIfInteger({ type: results.type, values: out2 });
3643
- }
3644
- if (isSeries(arr)) {
3645
- const out2 = arr.copy();
3646
- const results = inferType(arr.values);
3647
- out2.values = results.values;
3648
- return checkIfInteger({ type: results.type, values: out2 });
3649
- }
3650
- if (!isArray(arr)) {
3651
- const out2 = inferType([arr]);
3652
- out2.value = out2.values[0];
3653
- delete out2.values;
3654
- return checkIfInteger(out2);
3655
- }
3656
- assert(isArray(arr), "The `inferType` function only works on arrays, Series, and DataFrames!");
3657
- const types = flatten(arr).map((v) => {
3658
- if (v === void 0)
3659
- return "null";
3660
- try {
3661
- if (typeof v === "object") {
3662
- const temp = new Date(v.getTime());
3663
- if (isDate(temp)) {
3664
- return "date";
3665
- }
3666
- }
3667
- } catch (e) {
3668
- }
3669
- if (!isString(v)) {
3670
- if (typeof v === "bigint") {
3671
- v = v.toString() + "n";
3672
- } else {
3673
- v = JSON.stringify(v);
3674
- }
3675
- }
3676
- const vLower = v.toLowerCase();
3677
- const vLowerTrimmed = vLower.trim();
3678
- if (nullValues.indexOf(vLowerTrimmed) > -1) {
3679
- return "null";
3680
- }
3681
- if (booleanValues.indexOf(vLowerTrimmed) > -1) {
3682
- return "boolean";
3683
- }
3684
- try {
3685
- if (v.match(/^-?\d+n$/g)) {
3686
- return "bigint";
3687
- }
3688
- const vParsed = JSON.parse(v);
3689
- if (isNumber(vParsed)) {
3690
- return "number";
3691
- }
3692
- if (typeof vParsed === "object") {
3693
- if (isArray(vParsed))
3694
- return "string";
3695
- return "object";
3696
- }
3697
- return "string";
3698
- } catch (e) {
3699
- const vDate = new Date(v);
3700
- if (isDate(vDate)) {
3701
- return "date";
3702
- }
3703
- return "string";
3704
- }
3705
- });
3706
- const counts = count(types);
3707
- const sortedValues = counts.values.toSorted((a, b) => counts.get(b) - counts.get(a));
3708
- const primaryType = sortedValues[0];
3709
- return checkIfInteger({
3710
- type: primaryType,
3711
- values: vapply(arr, (v) => cast(v, primaryType))
3712
- });
3713
- }
3714
- function inverse(x) {
3715
- if (isDataFrame(x)) {
3716
- const out2 = x.copy();
3717
- out2.values = inverse(out2.values);
3718
- return out2;
3719
- }
3720
- assert(isArray(x), "The `inverse` function only works on square 2-dimensional arrays or DataFrames!");
3721
- const xShape = shape(x);
3722
- assert(xShape.length === 2, "The array passed into the `inverse` function must be exactly two-dimensional and square!");
3723
- assert(xShape[0] === xShape[1], "The array passed into the `inverse` function must be exactly two-dimensional and square!");
3724
- assert(xShape[0] >= 0, "The array passed into the `inverse` function must be exactly two-dimensional and square!");
3725
- if (xShape[0] === 0) {
3726
- return x;
3727
- } else if (xShape[0] === 1) {
3728
- assert(x[0][0] !== 0, "This matrix cannot be inverted!");
3729
- let v = x[0][0];
3730
- if (typeof v === "bigint")
3731
- v = Number(v);
3732
- return 1 / v;
3733
- } else if (xShape[0] === 2) {
3734
- let a = x[0][0];
3735
- let b = x[0][1];
3736
- let c = x[1][0];
3737
- let d = x[1][1];
3738
- if (typeof a === "bigint")
3739
- a = Number(a);
3740
- if (typeof b === "bigint")
3741
- b = Number(b);
3742
- if (typeof c === "bigint")
3743
- c = Number(c);
3744
- if (typeof d === "bigint")
3745
- d = Number(d);
3746
- const det = a * d - b * c;
3747
- assert(det !== 0, "This matrix cannot be inverted!");
3748
- const out2 = [
3749
- [d, -b],
3750
- [-c, a]
3751
- ];
3752
- return scale(out2, 1 / det);
3753
- } else if (xShape[0] > 1) {
3754
- const times = (a, b) => isNumber(a) || isNumber(b) ? scale(a, b) : dot(a, b);
3755
- for (let divider = 1; divider < xShape[0] - 1; divider++) {
3756
- try {
3757
- const A = x.slice(0, divider).map((row) => row.slice(0, divider));
3758
- const B = x.slice(0, divider).map((row) => row.slice(divider, xShape[0]));
3759
- const C = x.slice(divider, xShape[0]).map((row) => row.slice(0, divider));
3760
- const D = x.slice(divider, xShape[0]).map((row) => row.slice(divider, xShape[0]));
3761
- const AInv = inverse(A);
3762
- const CompInv = inverse(vadd(D, times(-1, times(times(C, AInv), B))));
3763
- const topLeft = vadd(AInv, times(times(times(times(AInv, B), CompInv), C), AInv));
3764
- const topRight = times(-1, times(times(AInv, B), CompInv));
3765
- const bottomLeft = times(-1, times(times(CompInv, C), AInv));
3766
- const bottomRight = CompInv;
3767
- const out2 = topLeft.map((row, i) => row.concat(topRight[i])).concat(bottomLeft.map((row, i) => row.concat(bottomRight[i])));
3768
- return out2;
3769
- } catch (e) {
3770
- }
3771
- }
3772
- assert(false, "This matrix cannot be inverted!");
3773
- }
3774
- }
3775
- var isBrowser2 = new Function(`
3776
- try {
3777
- return this === window
3778
- } catch(e) {}
3779
3402
 
3780
- try {
3781
- return !!importScripts
3782
- } catch(e){}
3783
-
3784
- return false
3785
- `);
3403
+ // node_modules/@jrc03c/js-math-tools/src/lerp.mjs
3786
3404
  function lerp(a, b, f) {
3787
3405
  try {
3788
3406
  if (!isNumber(a))
@@ -3792,11 +3410,11 @@
3792
3410
  if (!isNumber(f))
3793
3411
  return NaN;
3794
3412
  if (typeof a === "bigint" || typeof b === "bigint") {
3795
- const out2 = lerp(Number(a), Number(b), f);
3413
+ const out = lerp(Number(a), Number(b), f);
3796
3414
  try {
3797
- return BigInt(out2);
3415
+ return BigInt(out);
3798
3416
  } catch (e) {
3799
- return out2;
3417
+ return out;
3800
3418
  }
3801
3419
  }
3802
3420
  return f * (b - a) + a;
@@ -3805,6 +3423,8 @@
3805
3423
  }
3806
3424
  }
3807
3425
  var vlerp = vectorize(lerp);
3426
+
3427
+ // node_modules/@jrc03c/js-math-tools/src/log.mjs
3808
3428
  function log(x, base) {
3809
3429
  try {
3810
3430
  base = isUndefined(base) ? Math.E : base;
@@ -3813,11 +3433,11 @@
3813
3433
  if (!isNumber(base))
3814
3434
  return NaN;
3815
3435
  if (typeof x === "bigint" || typeof base === "bigint") {
3816
- const out2 = log(Number(x), Number(base));
3436
+ const out = log(Number(x), Number(base));
3817
3437
  try {
3818
- return BigInt(out2);
3438
+ return BigInt(out);
3819
3439
  } catch (e) {
3820
- return out2;
3440
+ return out;
3821
3441
  }
3822
3442
  }
3823
3443
  return Math.log(x) / Math.log(base);
@@ -3826,12 +3446,8 @@
3826
3446
  }
3827
3447
  }
3828
3448
  var vlog = vectorize(log);
3829
- function mean(arr, shouldDropNaNs) {
3830
- return stats(arr, { shouldDropNaNs }).mean;
3831
- }
3832
- function median(arr, shouldDropNaNs) {
3833
- return stats(arr, { shouldDropNaNs, median: true }).median;
3834
- }
3449
+
3450
+ // node_modules/@jrc03c/js-math-tools/src/mod.mjs
3835
3451
  function mod(a, b) {
3836
3452
  try {
3837
3453
  if (!isNumber(a))
@@ -3839,11 +3455,11 @@
3839
3455
  if (!isNumber(b))
3840
3456
  return NaN;
3841
3457
  if (typeof a === "bigint" || typeof b === "bigint") {
3842
- const out2 = mod(Number(a), Number(b));
3458
+ const out = mod(Number(a), Number(b));
3843
3459
  try {
3844
- return BigInt(out2);
3460
+ return BigInt(out);
3845
3461
  } catch (e) {
3846
- return out2;
3462
+ return out;
3847
3463
  }
3848
3464
  }
3849
3465
  return a % b;
@@ -3852,97 +3468,9 @@
3852
3468
  }
3853
3469
  }
3854
3470
  var vmod = vectorize(mod);
3855
- function mode(arr, shouldDropNaNs) {
3856
- return stats(arr, { shouldDropNaNs, mode: true }).mode;
3857
- }
3858
- function helper3() {
3859
- const u1 = random();
3860
- const u2 = random();
3861
- return Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
3862
- }
3863
- function normal(shape2) {
3864
- if (isUndefined(shape2))
3865
- return helper3();
3866
- return vapply(ndarray(shape2), helper3);
3867
- }
3868
- function ones(shape2) {
3869
- return vapply(ndarray(shape2), () => 1);
3870
- }
3871
- function permutationsIterator(x, r) {
3872
- function* helper5(x2, r2) {
3873
- r2 = r2 || x2.length;
3874
- if (x2.length === 1) {
3875
- yield [x2];
3876
- return;
3877
- }
3878
- for (const c of combinations(x2, r2)) {
3879
- if (!c.slice)
3880
- continue;
3881
- const state = zeros(c.length);
3882
- yield c;
3883
- let i = 1;
3884
- while (i < c.length) {
3885
- if (state[i] < i) {
3886
- if (i % 2 === 0) {
3887
- const buf = c[0];
3888
- c[0] = c[i];
3889
- c[i] = buf;
3890
- } else {
3891
- const buf = c[state[i]];
3892
- c[state[i]] = c[i];
3893
- c[i] = buf;
3894
- }
3895
- yield c;
3896
- state[i] += 1;
3897
- i = 1;
3898
- } else {
3899
- state[i] = 0;
3900
- i += 1;
3901
- }
3902
- }
3903
- }
3904
- }
3905
- if (isDataFrame(x) || isSeries(x)) {
3906
- return permutationsIterator(x.values, r);
3907
- }
3908
- assert(isArray(x), "The `permutations` function only works on arrays, Series, and DataFrames!");
3909
- if (isUndefined(r)) {
3910
- r = x.length;
3911
- }
3912
- assert(isNumber(r) && vint(r) === r && r >= 0, "`r` must be a non-negative integer!");
3913
- return helper5(flatten(x), r);
3914
- }
3915
- function permutations(x, r) {
3916
- const out2 = [];
3917
- for (const perm of permutationsIterator(x, r)) {
3918
- out2.push(perm.slice());
3919
- }
3920
- return out2;
3921
- }
3922
- function print() {
3923
- Object.keys(arguments).forEach((key) => {
3924
- const x = arguments[key];
3925
- if (isArray(x)) {
3926
- if (!isJagged(x)) {
3927
- const xShape = shape(x);
3928
- if (xShape.length === 1) {
3929
- new Series(x).print();
3930
- } else if (xShape.length == 2) {
3931
- new DataFrame(x).print();
3932
- } else {
3933
- console.log(x);
3934
- }
3935
- } else {
3936
- console.log(x);
3937
- }
3938
- } else if (isDataFrame(x) || isSeries(x)) {
3939
- x.print();
3940
- } else {
3941
- console.log(x);
3942
- }
3943
- });
3944
- }
3945
- var helper4 = vectorize((x, a, b, c, d) => {
3471
+
3472
+ // node_modules/@jrc03c/js-math-tools/src/remap.mjs
3473
+ var helper3 = vectorize((x, a, b, c, d) => {
3946
3474
  try {
3947
3475
  let resultShouldBeABigInt = false;
3948
3476
  for (const v of [x, a, b, c, d]) {
@@ -3964,28 +3492,20 @@
3964
3492
  const den = b - a;
3965
3493
  if (den === 0)
3966
3494
  return NaN;
3967
- const out2 = num / den + c;
3495
+ const out = num / den + c;
3968
3496
  if (resultShouldBeABigInt) {
3969
3497
  try {
3970
- return BigInt(out2);
3498
+ return BigInt(out);
3971
3499
  } catch (e) {
3972
3500
  }
3973
3501
  }
3974
- return out2;
3502
+ return out;
3975
3503
  } catch (e) {
3976
3504
  return NaN;
3977
3505
  }
3978
3506
  });
3979
- function remap(x, a, b, c, d) {
3980
- if (isArray(x) && isUndefined(c) && isUndefined(d)) {
3981
- c = a;
3982
- d = b;
3983
- const results = stats(x);
3984
- a = results.min;
3985
- b = results.max;
3986
- }
3987
- return helper4(x, a, b, c, d);
3988
- }
3507
+
3508
+ // node_modules/@jrc03c/js-math-tools/src/round.mjs
3989
3509
  function round(x) {
3990
3510
  try {
3991
3511
  if (!isNumber(x))
@@ -3998,6 +3518,8 @@
3998
3518
  }
3999
3519
  }
4000
3520
  var vround = vectorize(round);
3521
+
3522
+ // node_modules/@jrc03c/js-math-tools/src/sign.mjs
4001
3523
  function sign(x) {
4002
3524
  try {
4003
3525
  if (!isNumber(x))
@@ -4014,6 +3536,8 @@
4014
3536
  }
4015
3537
  }
4016
3538
  var vsign = vectorize(sign);
3539
+
3540
+ // node_modules/@jrc03c/js-math-tools/src/sin.mjs
4017
3541
  function sin(x) {
4018
3542
  try {
4019
3543
  if (!isNumber(x))
@@ -4027,31 +3551,8 @@
4027
3551
  }
4028
3552
  }
4029
3553
  var vsin = vectorize(sin);
4030
- function some(x, fn) {
4031
- if (isDataFrame(x) || isSeries(x)) {
4032
- return some(x.values, fn);
4033
- }
4034
- assert(isArray(x), "The first argument passed into the `some` function must be an array, Series, or DataFrame!");
4035
- assert(isFunction(fn), "The second argument passed into the `some` function must be a function!");
4036
- for (const v of x) {
4037
- if (isArray(v)) {
4038
- if (some(v, fn)) {
4039
- return true;
4040
- }
4041
- } else {
4042
- if (fn(v)) {
4043
- return true;
4044
- }
4045
- }
4046
- }
4047
- return false;
4048
- }
4049
- function std(arr, shouldDropNaNs) {
4050
- return stats(arr, { shouldDropNaNs, stdev: true }).stdev;
4051
- }
4052
- function stdev(x) {
4053
- return std(x);
4054
- }
3554
+
3555
+ // node_modules/@jrc03c/js-math-tools/src/tan.mjs
4055
3556
  function tan(x) {
4056
3557
  try {
4057
3558
  if (!isNumber(x))
@@ -4065,193 +3566,6 @@
4065
3566
  }
4066
3567
  }
4067
3568
  var vtan = vectorize(tan);
4068
- function timeSync(fn, args) {
4069
- assert(isFunction(fn), "`fn` must be a function!");
4070
- const start = /* @__PURE__ */ new Date();
4071
- if (args) {
4072
- fn(...args);
4073
- } else {
4074
- fn();
4075
- }
4076
- return /* @__PURE__ */ new Date() - start;
4077
- }
4078
- async function timeAsync(fn, args) {
4079
- assert(isFunction(fn), "`fn` must be a function!");
4080
- const start = /* @__PURE__ */ new Date();
4081
- if (args) {
4082
- await fn(...args);
4083
- } else {
4084
- await fn();
4085
- }
4086
- return /* @__PURE__ */ new Date() - start;
4087
- }
4088
- function union() {
4089
- return set([...arguments].map((v) => {
4090
- if (isArray(v))
4091
- return v;
4092
- if (isDataFrame(v))
4093
- return v.values;
4094
- if (isSeries(v))
4095
- return v.values;
4096
- return [v];
4097
- }));
4098
- }
4099
- function variance(arr, shouldDropNaNs) {
4100
- return stats(arr, { shouldDropNaNs, variance: true }).variance;
4101
- }
4102
- function zip() {
4103
- const out2 = [];
4104
- const arrays = Object.values(arguments).map((arr) => {
4105
- if (isDataFrame(arr) || isSeries(arr)) {
4106
- arr = arr.values;
4107
- }
4108
- assert(isArray(arr), "The `zip` function only works on arrays, Series, and DataFrames!");
4109
- return arr;
4110
- });
4111
- range(0, max(arrays.map((arr) => arr.length))).forEach((i) => {
4112
- const row = [];
4113
- arrays.forEach((arr) => {
4114
- const value = arr[i];
4115
- row.push(isUndefined(value) ? void 0 : value);
4116
- });
4117
- out2.push(row);
4118
- });
4119
- return out2;
4120
- }
4121
- var out = {
4122
- abs: vabs,
4123
- add: vadd,
4124
- apply: vapply,
4125
- arccos: varccos,
4126
- arcsin: varcsin,
4127
- arctan: varctan,
4128
- argmax,
4129
- argmin,
4130
- assert,
4131
- cast,
4132
- ceil: vceil,
4133
- chop: vchop,
4134
- clamp: vclamp,
4135
- combinations,
4136
- combinationsIterator,
4137
- copy,
4138
- correl,
4139
- cos: vcos,
4140
- count,
4141
- covariance,
4142
- DataFrame,
4143
- dataTypes,
4144
- decycle,
4145
- diff,
4146
- distance,
4147
- divide,
4148
- dot,
4149
- dropMissing,
4150
- dropMissingPairwise,
4151
- dropNaN,
4152
- dropNaNPairwise,
4153
- dropUndefined,
4154
- every,
4155
- exp: vexp,
4156
- factorial: vfactorial,
4157
- find,
4158
- findAll,
4159
- flatten,
4160
- float: vfloat,
4161
- floor: vfloor,
4162
- identity,
4163
- IndexMatcher,
4164
- indexOf,
4165
- inferType,
4166
- int: vint,
4167
- intersect,
4168
- inverse,
4169
- isArray,
4170
- isBoolean,
4171
- isBrowser: isBrowser2,
4172
- isDataFrame,
4173
- isDate,
4174
- isEqual,
4175
- isFunction,
4176
- isJagged,
4177
- isNested,
4178
- isNumber,
4179
- isObject,
4180
- isSeries,
4181
- isString,
4182
- isUndefined,
4183
- lerp: vlerp,
4184
- log: vlog,
4185
- MathError,
4186
- max,
4187
- mean,
4188
- median,
4189
- min,
4190
- mod: vmod,
4191
- mode,
4192
- multiply: vmultiply,
4193
- ndarray,
4194
- normal,
4195
- ones,
4196
- permutations,
4197
- permutationsIterator,
4198
- pow: vpow,
4199
- print,
4200
- product,
4201
- random,
4202
- range,
4203
- remap,
4204
- reshape,
4205
- reverse,
4206
- round: vround,
4207
- scale,
4208
- seed,
4209
- Series,
4210
- set,
4211
- shape,
4212
- shuffle,
4213
- sign: vsign,
4214
- sin: vsin,
4215
- some,
4216
- sort,
4217
- sqrt: vsqrt,
4218
- stats,
4219
- std,
4220
- stdev,
4221
- subtract,
4222
- sum,
4223
- tan: vtan,
4224
- timeAsync,
4225
- timeSync,
4226
- time: timeSync,
4227
- transpose,
4228
- union,
4229
- variance,
4230
- vectorize,
4231
- zeros,
4232
- zip,
4233
- dump() {
4234
- const context = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : void 0;
4235
- if (!context) {
4236
- throw new out.MathError("Cannot dump functions into global scope because none of `globalThis`, `global`, `window`, or `self` exist in the current context!");
4237
- }
4238
- Object.keys(out).forEach((key) => {
4239
- try {
4240
- Object.defineProperty(context, key, {
4241
- configurable: false,
4242
- enumerable: true,
4243
- writable: false,
4244
- value: out[key]
4245
- });
4246
- } catch (e) {
4247
- context[key] = out[key];
4248
- }
4249
- });
4250
- }
4251
- };
4252
- if (typeof window !== "undefined") {
4253
- window.JSMathTools = out;
4254
- }
4255
3569
 
4256
3570
  // src/index.mjs
4257
3571
  function makeKey4(keyLength, keySeed, charset) {
@@ -4277,12 +3591,12 @@
4277
3591
  if (charset) {
4278
3592
  assert(isString(charset), "`charset` must be a string!");
4279
3593
  }
4280
- let out2 = "";
3594
+ let out = "";
4281
3595
  charset = charset || "abcdefg1234567890";
4282
3596
  for (let i = 0; i < keyLength; i++) {
4283
- out2 += charset[vint(random() * charset.length)];
3597
+ out += charset[vint(random() * charset.length)];
4284
3598
  }
4285
- return out2;
3599
+ return out;
4286
3600
  }
4287
3601
 
4288
3602
  // src/iife.mjs