@dra2020/dra-analytics 4.1.2 → 4.1.5

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.
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  Object.defineProperty(exports, "__esModule", ({ value: true }));
46
56
  exports.Utils = exports.Types = exports.Splitting = exports.Rate = exports.Partisan = exports.Minority = exports.Graph = exports.Equal = exports.Compactness = void 0;
47
57
  const Compactness = __importStar(__webpack_require__(/*! ./compactness */ "./lib/all/compactness.ts"));
@@ -299,10 +309,28 @@ __exportStar(__webpack_require__(/*! ./kiwysi */ "./lib/compactness/kiwysi.ts"),
299
309
  // COMPACTNESS
300
310
  //
301
311
  Object.defineProperty(exports, "__esModule", ({ value: true }));
302
- exports.calcCompactness = exports.makeCompactnessScorecard = void 0;
312
+ exports.excessivelyFragmented = excessivelyFragmented;
313
+ exports.makeCompactnessScorecard = makeCompactnessScorecard;
314
+ exports.calcCompactness = calcCompactness;
303
315
  const features_1 = __webpack_require__(/*! ./features */ "./lib/compactness/features.ts");
304
316
  const kiwysi_1 = __webpack_require__(/*! ./kiwysi */ "./lib/compactness/kiwysi.ts");
305
317
  const dra_ratings_1 = __webpack_require__(/*! ../rate/dra-ratings */ "./lib/rate/dra-ratings.ts");
318
+ function excessivelyFragmented(shapes) {
319
+ const threshold = 20;
320
+ let fragments = 0;
321
+ for (let i = 0; i < shapes.features.length; i++) {
322
+ const f = shapes.features[i];
323
+ if (f.geometry.type == 'MultiPolygon') {
324
+ fragments += f.geometry.coordinates.length;
325
+ }
326
+ }
327
+ const avgFragmentation = fragments / shapes.features.length;
328
+ if (avgFragmentation > threshold) {
329
+ console.log(`Average fragmentation (${avgFragmentation}) exceeds threshold (${threshold}).`);
330
+ return true;
331
+ }
332
+ return false;
333
+ }
306
334
  // Use this to get average Reock, Polsby-Popper, and KIWYSI compactness and by district for a set of shapes
307
335
  // This is used by DRA
308
336
  function makeCompactnessScorecard(shapes, bLog = false) {
@@ -312,11 +340,14 @@ function makeCompactnessScorecard(shapes, bLog = false) {
312
340
  let totReock = 0;
313
341
  let totPolsby = 0;
314
342
  let totKIWYSI = 0;
343
+ // 12-11-24: Skip featurization for KIWYSI compactness, when the districts in a map are too fragmented on average
344
+ const bKIWYSIFeatures = excessivelyFragmented(shapes) ? false : true;
315
345
  // For returning compactness by district to DRA
316
346
  // Note, these use the Cartesian (flat earth) measurements
317
347
  let byDistrict = [];
318
348
  for (let i = 0; i < shapes.features.length; i++) {
319
- const features = (0, features_1.featureizePoly)(shapes.features[i], options);
349
+ const f = shapes.features[i];
350
+ const features = (0, features_1.featureizePoly)(f, options, { bKIWYSIFeatures: bKIWYSIFeatures });
320
351
  const reockFlat = features.reockFlat;
321
352
  const polsbyFlat = features.polsbyFlat;
322
353
  // Note: In order to compute the by-district compactness that DRA needs,
@@ -324,7 +355,7 @@ function makeCompactnessScorecard(shapes, bLog = false) {
324
355
  // like the overall compactness rating.
325
356
  const normalizedReock = (0, dra_ratings_1.rateReock)(reockFlat);
326
357
  const normalizedPolsby = (0, dra_ratings_1.ratePolsby)(polsbyFlat);
327
- let kiwysiRank = (0, kiwysi_1.scoreFeatureSet)(features, pca);
358
+ let kiwysiRank = bKIWYSIFeatures ? (0, kiwysi_1.scoreFeatureSet)(features, pca) : 100;
328
359
  // Constrain values to the range [1–100]
329
360
  kiwysiRank = Math.min(Math.max(kiwysiRank, 1), 100);
330
361
  // Raw KIWYSI scores ("ranks") are 1–100 where smaller is better
@@ -344,18 +375,17 @@ function makeCompactnessScorecard(shapes, bLog = false) {
344
375
  }
345
376
  const avgReock = totReock / shapes.features.length;
346
377
  const avgPolsby = totPolsby / shapes.features.length;
347
- const avgKWIWYSI = Math.round(totKIWYSI / shapes.features.length);
378
+ const avgKIWYSI = Math.round(totKIWYSI / shapes.features.length);
348
379
  const s = {
349
380
  avgReock: avgReock,
350
381
  avgPolsby: avgPolsby,
351
- avgKWIWYSI: avgKWIWYSI,
352
- byDistrict: byDistrict,
382
+ avgKIWYSI: avgKIWYSI,
383
+ byDistrict: byDistrict, // Legacy format
353
384
  details: {}, // None
354
385
  // score?:
355
386
  };
356
387
  return s;
357
388
  }
358
- exports.makeCompactnessScorecard = makeCompactnessScorecard;
359
389
  // CLI
360
390
  // Calculate Reock & Polsby–Popper for a shape using the typical Cartesian (flat earth) calculations.
361
391
  // Also calculate the "know it when you see it" rank (smaller is better) that models human perceptions of compactness.
@@ -387,16 +417,15 @@ function calcCompactness(shapes) {
387
417
  }
388
418
  const avgReock = totReock / shapes.features.length;
389
419
  const avgPolsby = totPolsby / shapes.features.length;
390
- const avgKWIWYSI = Math.round(totKIWYSI / shapes.features.length);
420
+ const avgKIWYSI = Math.round(totKIWYSI / shapes.features.length);
391
421
  const out = {
392
422
  avgReock: avgReock,
393
423
  avgPolsby: avgPolsby,
394
- avgKWIWYSI: avgKWIWYSI,
424
+ avgKIWYSI: avgKIWYSI,
395
425
  byDistrict: byDistrict
396
426
  };
397
427
  return out;
398
428
  }
399
- exports.calcCompactness = calcCompactness;
400
429
 
401
430
 
402
431
  /***/ }),
@@ -414,7 +443,14 @@ exports.calcCompactness = calcCompactness;
414
443
  // Measures of compactness compare district shapes to various ideally compact
415
444
  // benchmarks, such as circles. All else equal, more compact districts are better.
416
445
  Object.defineProperty(exports, "__esModule", ({ value: true }));
417
- exports.featureizePoly = exports.calcSchwartzberg = exports.calcConvexHullFeature = exports.calcPolsbyPopper = exports.calcBoundingBox = exports.calcReock = exports.calcYSymmetry = exports.calcXSymmetry = void 0;
446
+ exports.calcXSymmetry = calcXSymmetry;
447
+ exports.calcYSymmetry = calcYSymmetry;
448
+ exports.calcReock = calcReock;
449
+ exports.calcBoundingBox = calcBoundingBox;
450
+ exports.calcPolsbyPopper = calcPolsbyPopper;
451
+ exports.calcConvexHullFeature = calcConvexHullFeature;
452
+ exports.calcSchwartzberg = calcSchwartzberg;
453
+ exports.featureizePoly = featureizePoly;
418
454
  const baseclient_1 = __webpack_require__(/*! @dra2020/baseclient */ "@dra2020/baseclient");
419
455
  // FEATURES (FOR AN ML MODEL)
420
456
  //
@@ -435,7 +471,6 @@ function calcXSymmetry(poly) {
435
471
  const sym_x = calcSymmetry(poly, reflectOverX(cx));
436
472
  return sym_x;
437
473
  }
438
- exports.calcXSymmetry = calcXSymmetry;
439
474
  // FEATURE 2: Y-SYMMETRY - The area of a district overlapping with its
440
475
  // reflection around a vertical line going through the centroid, divided by
441
476
  // the area of the district. Values range [1–2].
@@ -449,7 +484,6 @@ function calcYSymmetry(poly) {
449
484
  const sym_y = calcSymmetry(poly, reflectOverY(cy));
450
485
  return sym_y;
451
486
  }
452
- exports.calcYSymmetry = calcYSymmetry;
453
487
  function calcSymmetry(poly, transformFn) {
454
488
  const polyarrPoints = poly.geometry.coordinates;
455
489
  let transformedPoly = baseclient_1.Poly.polyTransform(poly, transformFn);
@@ -512,7 +546,6 @@ function reflectOverY(y0) {
512
546
  function calcReock(area, diameter) {
513
547
  return (4 * area) / (Math.PI * Math.pow(diameter, 2));
514
548
  }
515
- exports.calcReock = calcReock;
516
549
  // FEATURE 4: "BOUNDING-BOX" is shorthand here for the ratio of the area of the
517
550
  // district to the area of the minimum bounding box of the district. It's not a
518
551
  // simple bounding box.
@@ -522,7 +555,6 @@ function calcBoundingBox(poly) {
522
555
  const bboxArea = baseclient_1.Poly.polyArea(MBR);
523
556
  return polyArea / bboxArea;
524
557
  }
525
- exports.calcBoundingBox = calcBoundingBox;
526
558
  // FEATURE 5: POLSBYPOPPER - Polsby-Popper is the primary measure of the indendentation
527
559
  // of district shapes, calculated as the “the ratio of the area of the district to
528
560
  // the area of a circle whose circumference is equal to the perimeter of the district.”
@@ -541,7 +573,6 @@ exports.calcBoundingBox = calcBoundingBox;
541
573
  function calcPolsbyPopper(area, perimeter) {
542
574
  return (4 * Math.PI) * (area / Math.pow(perimeter, 2));
543
575
  }
544
- exports.calcPolsbyPopper = calcPolsbyPopper;
545
576
  // FEATURE 6: Hull(D) - Convex Hull is a secondary measure of the dispersion of
546
577
  // district shapes, calculated as “the ratio of the district area to the area of
547
578
  // the minimum convex bounding polygon(also known as a convex hull) enclosing the
@@ -555,7 +586,6 @@ exports.calcPolsbyPopper = calcPolsbyPopper;
555
586
  function calcConvexHullFeature(area, chArea) {
556
587
  return area / chArea;
557
588
  }
558
- exports.calcConvexHullFeature = calcConvexHullFeature;
559
589
  // FEATURE 7: SCHWARTZBERG - Schwartzberg is a secondary measure of the degree of
560
590
  // indentation of district shapes, calculated as “the ratio of the perimeter of the
561
591
  // district to the circumference of a circle whose area is equal to the area of the
@@ -585,9 +615,8 @@ exports.calcConvexHullFeature = calcConvexHullFeature;
585
615
  function calcSchwartzberg(area, perimeter) {
586
616
  return perimeter / ((2 * Math.PI) * Math.sqrt(area / Math.PI));
587
617
  }
588
- exports.calcSchwartzberg = calcSchwartzberg;
589
618
  // CALCULATE THE 7 COMPACTNESS "FEATURES" FOR A POLYGON FOR THE KIWYSI COMPACTNESS MODEL
590
- function featureizePoly(poly, options) {
619
+ function featureizePoly(poly, options, { bKIWYSIFeatures = true } = {}) {
591
620
  if (options === undefined)
592
621
  options = baseclient_1.Poly.DefaultOptions;
593
622
  const area = baseclient_1.Poly.polyArea(poly);
@@ -599,21 +628,22 @@ function featureizePoly(poly, options) {
599
628
  const ch = baseclient_1.Poly.polyConvexHull(poly);
600
629
  const hullArea = baseclient_1.Poly.polyArea(ch);
601
630
  const result = {
631
+ // 12-10-24: Skip featurization for KIWYSI compactness, when MultiPolygons are too fragmented
602
632
  // For the "correct" geodesic calculations that the KIWYSI AI uses
603
- sym_x: calcXSymmetry(poly),
604
- sym_y: calcYSymmetry(poly),
605
- reock: calcReock(area, diameter),
606
- bbox: calcBoundingBox(poly),
607
- polsby: calcPolsbyPopper(area, perimeter),
608
- hull: calcConvexHullFeature(area, hullArea),
609
- schwartzberg: calcSchwartzberg(area, perimeter),
633
+ sym_x: bKIWYSIFeatures ? calcXSymmetry(poly) : 0.0,
634
+ sym_y: bKIWYSIFeatures ? calcYSymmetry(poly) : 0.0,
635
+ reock: bKIWYSIFeatures ? calcReock(area, diameter) : 0.0,
636
+ bbox: bKIWYSIFeatures ? calcBoundingBox(poly) : 0.0,
637
+ polsby: bKIWYSIFeatures ? calcPolsbyPopper(area, perimeter) : 0.0,
638
+ hull: bKIWYSIFeatures ? calcConvexHullFeature(area, hullArea) : 0.0,
639
+ schwartzberg: bKIWYSIFeatures ? calcSchwartzberg(area, perimeter) : 0.0,
640
+ // But still do the basic calculations for Reock and Polsby-Popper
610
641
  // For the Cartesian (flat earth) calculations that are typically done
611
642
  reockFlat: calcReock(areaFlat, diameterFlat),
612
643
  polsbyFlat: calcPolsbyPopper(areaFlat, perimeterFlat)
613
644
  };
614
645
  return result;
615
646
  }
616
- exports.featureizePoly = featureizePoly;
617
647
 
618
648
 
619
649
  /***/ }),
@@ -644,15 +674,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
644
674
  }) : function(o, v) {
645
675
  o["default"] = v;
646
676
  });
647
- var __importStar = (this && this.__importStar) || function (mod) {
648
- if (mod && mod.__esModule) return mod;
649
- var result = {};
650
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
651
- __setModuleDefault(result, mod);
652
- return result;
653
- };
677
+ var __importStar = (this && this.__importStar) || (function () {
678
+ var ownKeys = function(o) {
679
+ ownKeys = Object.getOwnPropertyNames || function (o) {
680
+ var ar = [];
681
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
682
+ return ar;
683
+ };
684
+ return ownKeys(o);
685
+ };
686
+ return function (mod) {
687
+ if (mod && mod.__esModule) return mod;
688
+ var result = {};
689
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
690
+ __setModuleDefault(result, mod);
691
+ return result;
692
+ };
693
+ })();
654
694
  Object.defineProperty(exports, "__esModule", ({ value: true }));
655
- exports.scoreFeatureSet = exports.calcKIWYSICompactness = exports.kiwysiScoreShapes = exports.kiwysiScoreShape = exports.kiwysiScoreShapeRAW = void 0;
695
+ exports.kiwysiScoreShapeRAW = kiwysiScoreShapeRAW;
696
+ exports.kiwysiScoreShape = kiwysiScoreShape;
697
+ exports.kiwysiScoreShapes = kiwysiScoreShapes;
698
+ exports.calcKIWYSICompactness = calcKIWYSICompactness;
699
+ exports.scoreFeatureSet = scoreFeatureSet;
656
700
  const features_1 = __webpack_require__(/*! ./features */ "./lib/compactness/features.ts");
657
701
  const M = __importStar(__webpack_require__(/*! ./matrix */ "./lib/compactness/matrix.ts"));
658
702
  // For verifying replication w/ Aaron Kaufman & Gary King's results
@@ -664,14 +708,12 @@ function kiwysiScoreShapeRAW(poly, pca, options) {
664
708
  const score = scoreFeatureSet(features, pca);
665
709
  return score;
666
710
  }
667
- exports.kiwysiScoreShapeRAW = kiwysiScoreShapeRAW;
668
711
  // Note: These scores are still smaller is better (ranks)
669
712
  function kiwysiScoreShape(poly, pca, options) {
670
713
  const rawScore = kiwysiScoreShapeRAW(poly, pca, options);
671
714
  const rangedScore = Math.min(Math.max(rawScore, 1), 100);
672
715
  return rangedScore;
673
716
  }
674
- exports.kiwysiScoreShape = kiwysiScoreShape;
675
717
  // Use this to get KIWYSI compactness scores ("ranks") for a set of shapes
676
718
  function kiwysiScoreShapes(shapes, pca, options) {
677
719
  let scores = [];
@@ -681,7 +723,6 @@ function kiwysiScoreShapes(shapes, pca, options) {
681
723
  }
682
724
  return scores;
683
725
  }
684
- exports.kiwysiScoreShapes = kiwysiScoreShapes;
685
726
  // CLI
686
727
  // Use this to get KIWYSI compactness features and scores ("ranks") for a set of shapes
687
728
  // Note - These calculations use the geodesic (curved earth) model
@@ -709,14 +750,13 @@ function calcKIWYSICompactness(shapes) {
709
750
  };
710
751
  byDistrict.push(entry);
711
752
  }
712
- const avgKWIWYSI = Math.round(totKIWYSI / shapes.features.length);
753
+ const avgKIWYSI = Math.round(totKIWYSI / shapes.features.length);
713
754
  const out = {
714
- avgKWIWYSI: avgKWIWYSI,
755
+ avgKIWYSI: avgKIWYSI,
715
756
  byDistrict: byDistrict
716
757
  };
717
758
  return out;
718
759
  }
719
- exports.calcKIWYSICompactness = calcKIWYSICompactness;
720
760
  // KIWYSI SCORE THE FEATURES FROM A FEATURE-IZED SHAPE
721
761
  function scoreFeatureSet(features, pca) {
722
762
  if (pca == 0 /* T.PCAModel.Revised */)
@@ -724,16 +764,15 @@ function scoreFeatureSet(features, pca) {
724
764
  else
725
765
  return applyPCAModel_ORIGINAL(features);
726
766
  }
727
- exports.scoreFeatureSet = scoreFeatureSet;
728
767
  // Revised 01/25/21
729
768
  function applyPCAModel(features) {
730
769
  const model = [
731
- 3.0428861122,
732
- 4.5060390447,
733
- -22.7768820155,
734
- -24.1176096770,
735
- -107.9434473497,
736
- -67.1088897240,
770
+ 3.0428861122, // sym_x
771
+ 4.5060390447, // sym_y
772
+ -22.7768820155, // reock
773
+ -24.1176096770, // bbox
774
+ -107.9434473497, // polsby
775
+ -67.1088897240, // hull
737
776
  -1.2981693414 // schwartzberg
738
777
  ];
739
778
  const intercept = 145.6420811716;
@@ -753,12 +792,12 @@ function applyPCAModel(features) {
753
792
  // The original, INCORRECT, model
754
793
  function applyPCAModel_ORIGINAL(features) {
755
794
  const model = [
756
- 0.317566717356693,
757
- 0.32545234315137,
758
- 0.32799567316863,
759
- 0.411560782484889,
760
- 0.412187169816954,
761
- 0.420085928286392,
795
+ 0.317566717356693, // sym_x
796
+ 0.32545234315137, // sym_y
797
+ 0.32799567316863, // reock
798
+ 0.411560782484889, // bbox
799
+ 0.412187169816954, // polsby
800
+ 0.420085928286392, // hull
762
801
  0.412187169816954 // schwartzberg
763
802
  ];
764
803
  const v = [
@@ -789,12 +828,11 @@ function applyPCAModel_ORIGINAL(features) {
789
828
  // dotProduct - cloned from poly/matrix.ts, to avoid needing mathjs
790
829
  //
791
830
  Object.defineProperty(exports, "__esModule", ({ value: true }));
792
- exports.dotProduct = void 0;
831
+ exports.dotProduct = dotProduct;
793
832
  function dotProduct(a, b) {
794
833
  protect((a.length > 0) && (a.length == b.length), "In dotProduct, the vectors aren't the same length. ");
795
834
  return a.map((value, i) => value * b[i]).reduce((acc, val) => acc + val, 0);
796
835
  }
797
- exports.dotProduct = dotProduct;
798
836
  ;
799
837
  function protect(condition, message) {
800
838
  if (!condition)
@@ -858,27 +896,37 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
858
896
  }) : function(o, v) {
859
897
  o["default"] = v;
860
898
  });
861
- var __importStar = (this && this.__importStar) || function (mod) {
862
- if (mod && mod.__esModule) return mod;
863
- var result = {};
864
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
865
- __setModuleDefault(result, mod);
866
- return result;
867
- };
899
+ var __importStar = (this && this.__importStar) || (function () {
900
+ var ownKeys = function(o) {
901
+ ownKeys = Object.getOwnPropertyNames || function (o) {
902
+ var ar = [];
903
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
904
+ return ar;
905
+ };
906
+ return ownKeys(o);
907
+ };
908
+ return function (mod) {
909
+ if (mod && mod.__esModule) return mod;
910
+ var result = {};
911
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
912
+ __setModuleDefault(result, mod);
913
+ return result;
914
+ };
915
+ })();
868
916
  Object.defineProperty(exports, "__esModule", ({ value: true }));
869
- exports.makePopulationScorecard = exports.isRoughlyEqual = exports.calcPopulationDeviation = void 0;
917
+ exports.calcPopulationDeviation = calcPopulationDeviation;
918
+ exports.isRoughlyEqual = isRoughlyEqual;
919
+ exports.makePopulationScorecard = makePopulationScorecard;
870
920
  const C = __importStar(__webpack_require__(/*! ../rate/dra-config */ "./lib/rate/dra-config.ts"));
871
921
  const U = __importStar(__webpack_require__(/*! ../utils/all */ "./lib/utils/all.ts"));
872
922
  // MMD - This is the same for SMD & MMD. It's the calculation of min, max, and target size that differs.
873
923
  function calcPopulationDeviation(max, min, targetSize) {
874
924
  return (max - min) / targetSize; // Don't trim the result here!
875
925
  }
876
- exports.calcPopulationDeviation = calcPopulationDeviation;
877
926
  function isRoughlyEqual(devation, bLegislative) {
878
927
  const threshold = C.popdevThreshold(bLegislative);
879
928
  return (devation <= threshold) ? true : false;
880
929
  }
881
- exports.isRoughlyEqual = isRoughlyEqual;
882
930
  // MMD
883
931
  // - Add optional # of reps per district.
884
932
  // - Assume targetSize has been calculated correctly per # of reps not districts.
@@ -929,7 +977,6 @@ function makePopulationScorecard(totPopByDistrict, targetSize, bLegislative, rep
929
977
  };
930
978
  return s;
931
979
  }
932
- exports.makePopulationScorecard = makePopulationScorecard;
933
980
 
934
981
 
935
982
  /***/ }),
@@ -989,15 +1036,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
989
1036
  }) : function(o, v) {
990
1037
  o["default"] = v;
991
1038
  });
992
- var __importStar = (this && this.__importStar) || function (mod) {
993
- if (mod && mod.__esModule) return mod;
994
- var result = {};
995
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
996
- __setModuleDefault(result, mod);
997
- return result;
998
- };
1039
+ var __importStar = (this && this.__importStar) || (function () {
1040
+ var ownKeys = function(o) {
1041
+ ownKeys = Object.getOwnPropertyNames || function (o) {
1042
+ var ar = [];
1043
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
1044
+ return ar;
1045
+ };
1046
+ return ownKeys(o);
1047
+ };
1048
+ return function (mod) {
1049
+ if (mod && mod.__esModule) return mod;
1050
+ var result = {};
1051
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1052
+ __setModuleDefault(result, mod);
1053
+ return result;
1054
+ };
1055
+ })();
999
1056
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1000
- exports.isConnected = void 0;
1057
+ exports.isConnected = isConnected;
1001
1058
  const G = __importStar(__webpack_require__(/*! ./utils */ "./lib/graph/utils.ts"));
1002
1059
  function isConnected(featureIDs, graph, bLog = false) {
1003
1060
  let visited = new Set();
@@ -1025,7 +1082,6 @@ function isConnected(featureIDs, graph, bLog = false) {
1025
1082
  }
1026
1083
  return bConnected;
1027
1084
  }
1028
- exports.isConnected = isConnected;
1029
1085
 
1030
1086
 
1031
1087
  /***/ }),
@@ -1056,15 +1112,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1056
1112
  }) : function(o, v) {
1057
1113
  o["default"] = v;
1058
1114
  });
1059
- var __importStar = (this && this.__importStar) || function (mod) {
1060
- if (mod && mod.__esModule) return mod;
1061
- var result = {};
1062
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1063
- __setModuleDefault(result, mod);
1064
- return result;
1065
- };
1115
+ var __importStar = (this && this.__importStar) || (function () {
1116
+ var ownKeys = function(o) {
1117
+ ownKeys = Object.getOwnPropertyNames || function (o) {
1118
+ var ar = [];
1119
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
1120
+ return ar;
1121
+ };
1122
+ return ownKeys(o);
1123
+ };
1124
+ return function (mod) {
1125
+ if (mod && mod.__esModule) return mod;
1126
+ var result = {};
1127
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1128
+ __setModuleDefault(result, mod);
1129
+ return result;
1130
+ };
1131
+ })();
1066
1132
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1067
- exports.isEmbedded = void 0;
1133
+ exports.isEmbedded = isEmbedded;
1068
1134
  const U = __importStar(__webpack_require__(/*! ../utils/all */ "./lib/utils/all.ts"));
1069
1135
  const G = __importStar(__webpack_require__(/*! ./utils */ "./lib/graph/utils.ts"));
1070
1136
  //
@@ -1098,7 +1164,6 @@ function isEmbedded(districtID, featureIDs, plan, graph, bLog = false) {
1098
1164
  }
1099
1165
  return true;
1100
1166
  }
1101
- exports.isEmbedded = isEmbedded;
1102
1167
 
1103
1168
 
1104
1169
  /***/ }),
@@ -1149,15 +1214,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1149
1214
  }) : function(o, v) {
1150
1215
  o["default"] = v;
1151
1216
  });
1152
- var __importStar = (this && this.__importStar) || function (mod) {
1153
- if (mod && mod.__esModule) return mod;
1154
- var result = {};
1155
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1156
- __setModuleDefault(result, mod);
1157
- return result;
1158
- };
1217
+ var __importStar = (this && this.__importStar) || (function () {
1218
+ var ownKeys = function(o) {
1219
+ ownKeys = Object.getOwnPropertyNames || function (o) {
1220
+ var ar = [];
1221
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
1222
+ return ar;
1223
+ };
1224
+ return ownKeys(o);
1225
+ };
1226
+ return function (mod) {
1227
+ if (mod && mod.__esModule) return mod;
1228
+ var result = {};
1229
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1230
+ __setModuleDefault(result, mod);
1231
+ return result;
1232
+ };
1233
+ })();
1159
1234
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1160
- exports.invertPlan = exports.isOutOfBounds = exports.neighbors = exports.getDistrict = void 0;
1235
+ exports.getDistrict = getDistrict;
1236
+ exports.neighbors = neighbors;
1237
+ exports.isOutOfBounds = isOutOfBounds;
1238
+ exports.invertPlan = invertPlan;
1161
1239
  const S = __importStar(__webpack_require__(/*! ./settings */ "./lib/graph/settings.ts"));
1162
1240
  const U = __importStar(__webpack_require__(/*! ../utils/all */ "./lib/utils/all.ts"));
1163
1241
  function getDistrict(geoID, plan) {
@@ -1165,7 +1243,6 @@ function getDistrict(geoID, plan) {
1165
1243
  return plan[geoID];
1166
1244
  return undefined;
1167
1245
  }
1168
- exports.getDistrict = getDistrict;
1169
1246
  function neighbors(node, graph) {
1170
1247
  if (!U.keyExists(node, graph))
1171
1248
  return [];
@@ -1174,11 +1251,9 @@ function neighbors(node, graph) {
1174
1251
  const l = (n instanceof Array) ? n : Object.keys(n);
1175
1252
  return l;
1176
1253
  }
1177
- exports.neighbors = neighbors;
1178
1254
  function isOutOfBounds(geoID) {
1179
1255
  return geoID == S.OUT_OF_BOUNDS;
1180
1256
  }
1181
- exports.isOutOfBounds = isOutOfBounds;
1182
1257
  // NOTE - This is only used in the CLI and Jest tests
1183
1258
  // Invert a plan by geoID to sets of geoIDs by districtID
1184
1259
  function invertPlan(plan) {
@@ -1191,7 +1266,6 @@ function invertPlan(plan) {
1191
1266
  }
1192
1267
  return invertedPlan;
1193
1268
  }
1194
- exports.invertPlan = invertPlan;
1195
1269
 
1196
1270
 
1197
1271
  /***/ }),
@@ -1251,15 +1325,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1251
1325
  }) : function(o, v) {
1252
1326
  o["default"] = v;
1253
1327
  });
1254
- var __importStar = (this && this.__importStar) || function (mod) {
1255
- if (mod && mod.__esModule) return mod;
1256
- var result = {};
1257
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1258
- __setModuleDefault(result, mod);
1259
- return result;
1260
- };
1328
+ var __importStar = (this && this.__importStar) || (function () {
1329
+ var ownKeys = function(o) {
1330
+ ownKeys = Object.getOwnPropertyNames || function (o) {
1331
+ var ar = [];
1332
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
1333
+ return ar;
1334
+ };
1335
+ return ownKeys(o);
1336
+ };
1337
+ return function (mod) {
1338
+ if (mod && mod.__esModule) return mod;
1339
+ var result = {};
1340
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1341
+ __setModuleDefault(result, mod);
1342
+ return result;
1343
+ };
1344
+ })();
1261
1345
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1262
- exports.calcProportionalDistricts = exports.estMinorityOpportunity = exports.calcDistrictsByDemo = exports.convertTableToArray = exports.makeMinorityScorecard = void 0;
1346
+ exports.makeMinorityScorecard = makeMinorityScorecard;
1347
+ exports.convertTableToArray = convertTableToArray;
1348
+ exports.calcDistrictsByDemo = calcDistrictsByDemo;
1349
+ exports.estMinorityOpportunity = estMinorityOpportunity;
1350
+ exports.calcProportionalDistricts = calcProportionalDistricts;
1263
1351
  const U = __importStar(__webpack_require__(/*! ../utils/all */ "./lib/utils/all.ts"));
1264
1352
  const C = __importStar(__webpack_require__(/*! ../rate/dra-config */ "./lib/rate/dra-config.ts"));
1265
1353
  const normalize_1 = __webpack_require__(/*! ../rate/normalize */ "./lib/rate/normalize.ts");
@@ -1319,7 +1407,6 @@ function makeMinorityScorecard(statewideDemos, demosByDistrict, bLog = false) {
1319
1407
  };
1320
1408
  return s;
1321
1409
  }
1322
- exports.makeMinorityScorecard = makeMinorityScorecard;
1323
1410
  // HELPERS
1324
1411
  // Convert the 2D working array to a fixed table, so the rows & columns can be
1325
1412
  // addressed logically by name as opposed to using array indices.
@@ -1459,12 +1546,10 @@ function convertTableToArray(t) {
1459
1546
  const a = [minority, black, hispanic, pacific, asian, native];
1460
1547
  return a;
1461
1548
  }
1462
- exports.convertTableToArray = convertTableToArray;
1463
1549
  function calcDistrictsByDemo(MfArray, N) {
1464
1550
  const districtsByDemo = MfArray.map(v => calcProportionalDistricts(v, N));
1465
1551
  return districtsByDemo;
1466
1552
  }
1467
- exports.calcDistrictsByDemo = calcDistrictsByDemo;
1468
1553
  // NOTE - Shift minority proportions up, so 37% minority scores like 52% share,
1469
1554
  // but use the uncompressed seat probability distribution. This makes a 37%
1470
1555
  // district have a ~70% chance of winning, and a 50% district have a >99% chance.
@@ -1487,7 +1572,6 @@ function estMinorityOpportunity(Mf, demo) {
1487
1572
  const oppty = (Mf < range[C.BEG]) ? 0.0 : Math.min((0, method_1.estSeatProbability)(_normalizer.wipNum, dist), 1.0);
1488
1573
  return oppty;
1489
1574
  }
1490
- exports.estMinorityOpportunity = estMinorityOpportunity;
1491
1575
  // HELPERS
1492
1576
  function bucketVAPPct(Mf) {
1493
1577
  if (Mf < 0.35)
@@ -1511,7 +1595,6 @@ function calcProportionalDistricts(proportion, nDistricts) {
1511
1595
  const integral = Math.round(fractional + roundUp);
1512
1596
  return integral;
1513
1597
  }
1514
- exports.calcProportionalDistricts = calcProportionalDistricts;
1515
1598
  /* Sources for majority-minority info:
1516
1599
  - https://en.wikipedia.org/wiki/List_of_majority-minority_United_States_congressional_districts
1517
1600
  - http://www.ncsl.org/Portals/1/Documents/Redistricting/Redistricting_2010.pdf
@@ -1531,7 +1614,7 @@ exports.calcProportionalDistricts = calcProportionalDistricts;
1531
1614
  // RACIALLY POLARIZED VOTING
1532
1615
  //
1533
1616
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1534
- exports.analyzeRacialVoting = void 0;
1617
+ exports.analyzeRacialVoting = analyzeRacialVoting;
1535
1618
  // Analyze the degree of racially polarized voting for a district
1536
1619
  function analyzeRacialVoting(dictPoints /* | undefined */, districtID, groups) {
1537
1620
  // 12-29-2020 - Moved these guards up into district-analytics
@@ -1554,7 +1637,6 @@ function analyzeRacialVoting(dictPoints /* | undefined */, districtID, groups) {
1554
1637
  };
1555
1638
  return result;
1556
1639
  }
1557
- exports.analyzeRacialVoting = analyzeRacialVoting;
1558
1640
  // https://trentrichardson.com/compute-linear-regressions-in-javascript.html
1559
1641
  // https://www2.isye.gatech.edu/~yxie77/isye2028/lecture12.pdf
1560
1642
  function linearRegression(dictPoints) {
@@ -1649,15 +1731,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1649
1731
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
1650
1732
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1651
1733
  };
1652
- var __importStar = (this && this.__importStar) || function (mod) {
1653
- if (mod && mod.__esModule) return mod;
1654
- var result = {};
1655
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1656
- __setModuleDefault(result, mod);
1657
- return result;
1658
- };
1734
+ var __importStar = (this && this.__importStar) || (function () {
1735
+ var ownKeys = function(o) {
1736
+ ownKeys = Object.getOwnPropertyNames || function (o) {
1737
+ var ar = [];
1738
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
1739
+ return ar;
1740
+ };
1741
+ return ownKeys(o);
1742
+ };
1743
+ return function (mod) {
1744
+ if (mod && mod.__esModule) return mod;
1745
+ var result = {};
1746
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1747
+ __setModuleDefault(result, mod);
1748
+ return result;
1749
+ };
1750
+ })();
1659
1751
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1660
- exports.calcPartisanMetrics = exports.makePartisanScorecard = void 0;
1752
+ exports.makePartisanScorecard = makePartisanScorecard;
1753
+ exports.calcPartisanMetrics = calcPartisanMetrics;
1661
1754
  __exportStar(__webpack_require__(/*! ./erf */ "./lib/partisan/erf.ts"), exports);
1662
1755
  __exportStar(__webpack_require__(/*! ./method */ "./lib/partisan/method.ts"), exports);
1663
1756
  __exportStar(__webpack_require__(/*! ./bias */ "./lib/partisan/bias.ts"), exports);
@@ -1769,7 +1862,6 @@ function makePartisanScorecard(Vf, VfArray, bLog = false) {
1769
1862
  };
1770
1863
  return s;
1771
1864
  }
1772
- exports.makePartisanScorecard = makePartisanScorecard;
1773
1865
  function calcPartisanMetrics(Vf, VfArray) {
1774
1866
  const s = makePartisanScorecard(Vf, VfArray);
1775
1867
  let out = all_1.Utils.deepCopy(s);
@@ -1777,7 +1869,6 @@ function calcPartisanMetrics(Vf, VfArray) {
1777
1869
  delete out.details;
1778
1870
  return out;
1779
1871
  }
1780
- exports.calcPartisanMetrics = calcPartisanMetrics;
1781
1872
 
1782
1873
 
1783
1874
  /***/ }),
@@ -1808,15 +1899,57 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1808
1899
  }) : function(o, v) {
1809
1900
  o["default"] = v;
1810
1901
  });
1811
- var __importStar = (this && this.__importStar) || function (mod) {
1812
- if (mod && mod.__esModule) return mod;
1813
- var result = {};
1814
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1815
- __setModuleDefault(result, mod);
1816
- return result;
1817
- };
1902
+ var __importStar = (this && this.__importStar) || (function () {
1903
+ var ownKeys = function(o) {
1904
+ ownKeys = Object.getOwnPropertyNames || function (o) {
1905
+ var ar = [];
1906
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
1907
+ return ar;
1908
+ };
1909
+ return ownKeys(o);
1910
+ };
1911
+ return function (mod) {
1912
+ if (mod && mod.__esModule) return mod;
1913
+ var result = {};
1914
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1915
+ __setModuleDefault(result, mod);
1916
+ return result;
1917
+ };
1918
+ })();
1818
1919
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1819
- exports.rangeUnearnedSeats = exports.estLocalUnearnedSeats = exports.rangeDisproportionalityAlt = exports.estLocalDisproportionalityAlt = exports.rangeDisproportionality = exports.estLocalDisproportionality = exports.rangeAsymmetry = exports.estLocalAsymmetry = exports.calcGamma = exports.calcMinimalInverseResponsiveness = exports.calcBigR = exports.calcDisproportionality = exports.calcGlobalSymmetry = exports.calcLopsidedOutcomes = exports.calcDeclination = exports.radiansToDegrees = exports.isASweep = exports.keyRVpoints = exports.calcMeanMedianDifference = exports.calcEfficiencyGapPrime = exports.calcEfficiencyGap = exports.invertSVPoints = exports.inferGeometricSeatsBiasPoints = exports.estGeometricSeatsBias = exports.estVotesBias = exports.estSeatBias = exports.estPartisanBias = exports.calcTurnoutBias = exports.estUnearnedSeats = exports.calcDisproportionalityFromBest = exports.estSeatShare = exports.bestSeatShare = exports.bestSeats = void 0;
1920
+ exports.bestSeats = bestSeats;
1921
+ exports.bestSeatShare = bestSeatShare;
1922
+ exports.estSeatShare = estSeatShare;
1923
+ exports.calcDisproportionalityFromBest = calcDisproportionalityFromBest;
1924
+ exports.estUnearnedSeats = estUnearnedSeats;
1925
+ exports.calcTurnoutBias = calcTurnoutBias;
1926
+ exports.estPartisanBias = estPartisanBias;
1927
+ exports.estSeatBias = estSeatBias;
1928
+ exports.estVotesBias = estVotesBias;
1929
+ exports.estGeometricSeatsBias = estGeometricSeatsBias;
1930
+ exports.inferGeometricSeatsBiasPoints = inferGeometricSeatsBiasPoints;
1931
+ exports.invertSVPoints = invertSVPoints;
1932
+ exports.calcEfficiencyGap = calcEfficiencyGap;
1933
+ exports.calcEfficiencyGapPrime = calcEfficiencyGapPrime;
1934
+ exports.calcMeanMedianDifference = calcMeanMedianDifference;
1935
+ exports.keyRVpoints = keyRVpoints;
1936
+ exports.isASweep = isASweep;
1937
+ exports.radiansToDegrees = radiansToDegrees;
1938
+ exports.calcDeclination = calcDeclination;
1939
+ exports.calcLopsidedOutcomes = calcLopsidedOutcomes;
1940
+ exports.calcGlobalSymmetry = calcGlobalSymmetry;
1941
+ exports.calcDisproportionality = calcDisproportionality;
1942
+ exports.calcBigR = calcBigR;
1943
+ exports.calcMinimalInverseResponsiveness = calcMinimalInverseResponsiveness;
1944
+ exports.calcGamma = calcGamma;
1945
+ exports.estLocalAsymmetry = estLocalAsymmetry;
1946
+ exports.rangeAsymmetry = rangeAsymmetry;
1947
+ exports.estLocalDisproportionality = estLocalDisproportionality;
1948
+ exports.rangeDisproportionality = rangeDisproportionality;
1949
+ exports.estLocalDisproportionalityAlt = estLocalDisproportionalityAlt;
1950
+ exports.rangeDisproportionalityAlt = rangeDisproportionalityAlt;
1951
+ exports.estLocalUnearnedSeats = estLocalUnearnedSeats;
1952
+ exports.rangeUnearnedSeats = rangeUnearnedSeats;
1820
1953
  const U = __importStar(__webpack_require__(/*! ../utils/all */ "./lib/utils/all.ts"));
1821
1954
  const C = __importStar(__webpack_require__(/*! ../rate/dra-config */ "./lib/rate/dra-config.ts"));
1822
1955
  const method_1 = __webpack_require__(/*! ./method */ "./lib/partisan/method.ts");
@@ -1854,36 +1987,30 @@ const method_1 = __webpack_require__(/*! ./method */ "./lib/partisan/method.ts")
1854
1987
  function bestSeats(N, Vf) {
1855
1988
  return Math.round((N * Vf) - U.EPSILON);
1856
1989
  }
1857
- exports.bestSeats = bestSeats;
1858
1990
  // ^S% - The corresponding Democratic seat share
1859
1991
  function bestSeatShare(bestS, N) {
1860
1992
  return bestS / N;
1861
1993
  }
1862
- exports.bestSeatShare = bestSeatShare;
1863
1994
  // S% - The estimated Democratic seat share fraction
1864
1995
  function estSeatShare(estS, N) {
1865
1996
  return estS / N;
1866
1997
  }
1867
- exports.estSeatShare = estSeatShare;
1868
1998
  // B% - The deviation from proportionality calculated as ^S% — S%
1869
1999
  function calcDisproportionalityFromBest(estSf, bestSf) {
1870
2000
  return bestSf - estSf;
1871
2001
  }
1872
- exports.calcDisproportionalityFromBest = calcDisproportionalityFromBest;
1873
2002
  // NOTE - Not used.
1874
2003
  // UE# - The estimated # of unearned seats
1875
2004
  // UE_# from http://bit.ly/2Fcuf4q
1876
2005
  function estUnearnedSeats(proportional, probable) {
1877
2006
  return proportional - probable;
1878
2007
  }
1879
- exports.estUnearnedSeats = estUnearnedSeats;
1880
2008
  // ADVANCED/ALTERNATE METRICS FOR REFERENCE
1881
2009
  function calcTurnoutBias(statewide, VfArray) {
1882
2010
  const districtAvg = U.avgArray(VfArray);
1883
2011
  const turnoutBias = statewide - districtAvg;
1884
2012
  return turnoutBias;
1885
2013
  }
1886
- exports.calcTurnoutBias = calcTurnoutBias;
1887
2014
  // PARTISAN BIAS - I'm using John Nagle's simple seat bias below, which is what
1888
2015
  // PlanScore is doing:
1889
2016
  //
@@ -1901,7 +2028,6 @@ exports.calcTurnoutBias = calcTurnoutBias;
1901
2028
  function estPartisanBias(inferredSVpoints, nDistricts) {
1902
2029
  return estSeatBias(inferredSVpoints, nDistricts);
1903
2030
  }
1904
- exports.estPartisanBias = estPartisanBias;
1905
2031
  // SEATS BIAS -- John Nagle's simple seat bias @ 50% (alpha), a fractional # of seats.
1906
2032
  function estSeatBias(inferredSVpoints, nDistricts) {
1907
2033
  const half = 0.5;
@@ -1919,7 +2045,6 @@ function estSeatBias(inferredSVpoints, nDistricts) {
1919
2045
  // const BsAlt = (nDistricts / 2.0) - dSeats;
1920
2046
  return Bs;
1921
2047
  }
1922
- exports.estSeatBias = estSeatBias;
1923
2048
  // VOTES BIAS -- John Nagle's simple vote bias @ 50% (alpha2), a percentage.
1924
2049
  function estVotesBias(inferredSVpoints, nDistricts) {
1925
2050
  let extraVf = undefined;
@@ -1936,7 +2061,6 @@ function estVotesBias(inferredSVpoints, nDistricts) {
1936
2061
  }
1937
2062
  return extraVf;
1938
2063
  }
1939
- exports.estVotesBias = estVotesBias;
1940
2064
  // GEOMETRIC SEATS BIAS (@ V = statewide vote share)
1941
2065
  function estGeometricSeatsBias(Vf, dSVpoints, rSVpoints) {
1942
2066
  let BsGf = undefined;
@@ -1952,7 +2076,6 @@ function estGeometricSeatsBias(Vf, dSVpoints, rSVpoints) {
1952
2076
  }
1953
2077
  return BsGf;
1954
2078
  }
1955
- exports.estGeometricSeatsBias = estGeometricSeatsBias;
1956
2079
  // The actual formula
1957
2080
  function calcGeometricSeatsBias(sD, sR) {
1958
2081
  const BsGf = 0.5 * (sR - sD);
@@ -1968,7 +2091,6 @@ function inferGeometricSeatsBiasPoints(dSVpoints, rSVpoints) {
1968
2091
  }
1969
2092
  return bgsSVpoints;
1970
2093
  }
1971
- exports.inferGeometricSeatsBiasPoints = inferGeometricSeatsBiasPoints;
1972
2094
  function invertSVPoints(inferredSVpoints) {
1973
2095
  let invertedSVpoints = [];
1974
2096
  for (let pt of inferredSVpoints) {
@@ -1983,7 +2105,6 @@ function invertSVPoints(inferredSVpoints) {
1983
2105
  });
1984
2106
  return invertedSVpoints;
1985
2107
  }
1986
- exports.invertSVPoints = invertSVPoints;
1987
2108
  // EFFICIENCY GAP -- note the formulation used. Also, to accommodate turnout bias,
1988
2109
  // we would need to have D & R votes, not just shares.
1989
2110
  function calcEfficiencyGap(Vf, Sf, shareType = 0 /* T.Party.Democratic */) {
@@ -2003,7 +2124,6 @@ function calcEfficiencyGap(Vf, Sf, shareType = 0 /* T.Party.Democratic */) {
2003
2124
  }
2004
2125
  return efficiencyGap;
2005
2126
  }
2006
- exports.calcEfficiencyGap = calcEfficiencyGap;
2007
2127
  // For illustration purposes only
2008
2128
  // Assumes Democratic vote shares
2009
2129
  // Alternate specification with winner's bonus (R) heuristic built in:
@@ -2015,7 +2135,6 @@ function calcEfficiencyGapPrime(Vf, Sf, R) {
2015
2135
  EG = (2.0 * (Vf - 0.5)) - (Sf - 0.5);
2016
2136
  return EG;
2017
2137
  }
2018
- exports.calcEfficiencyGapPrime = calcEfficiencyGapPrime;
2019
2138
  // MEAN–MEDIAN DIFFERENCE
2020
2139
  //
2021
2140
  // From PlanScore.org: "The mean-median difference is a party’s median vote share
@@ -2043,7 +2162,6 @@ function calcMeanMedianDifference(VfArray, Vf) {
2043
2162
  // const difference: number = medianVf - meanVf;
2044
2163
  return difference;
2045
2164
  }
2046
- exports.calcMeanMedianDifference = calcMeanMedianDifference;
2047
2165
  // HELPERS FOR DECLINATION & LOPSIDED OUTCOMES
2048
2166
  // Key r(v) points, defined in Fig. 16:
2049
2167
  // * VfArray are Democratic seat shares (by convention).
@@ -2070,18 +2188,15 @@ function keyRVpoints(VfArray) {
2070
2188
  };
2071
2189
  return keyPoints;
2072
2190
  }
2073
- exports.keyRVpoints = keyRVpoints;
2074
2191
  function isASweep(Sf, nDistricts) {
2075
2192
  const oneDistrict = 1 / nDistricts;
2076
2193
  const bSweep = ((Sf > (1 - oneDistrict)) || (Sf < oneDistrict)) ? true : false;
2077
2194
  return bSweep;
2078
2195
  }
2079
- exports.isASweep = isASweep;
2080
2196
  function radiansToDegrees(radians) {
2081
2197
  const degrees = radians * (180 / Math.PI);
2082
2198
  return degrees;
2083
2199
  }
2084
- exports.radiansToDegrees = radiansToDegrees;
2085
2200
  // DECLINATION
2086
2201
  //
2087
2202
  // Declination is calculated using the key r(v) points, defined in Fig. 16.
@@ -2106,7 +2221,6 @@ function calcDeclination(VfArray) {
2106
2221
  }
2107
2222
  return decl;
2108
2223
  }
2109
- exports.calcDeclination = calcDeclination;
2110
2224
  // LOPSIDED OUTCOMES
2111
2225
  //
2112
2226
  // This is a measure of packing bias is:
@@ -2130,7 +2244,6 @@ function calcLopsidedOutcomes(VfArray) {
2130
2244
  }
2131
2245
  return LO;
2132
2246
  }
2133
- exports.calcLopsidedOutcomes = calcLopsidedOutcomes;
2134
2247
  // GLOBAL SYMMETRY - Fig. 17 in Section 5.1
2135
2248
  //
2136
2249
  // * gSym is the area of asymmetry between the two curves.
@@ -2146,7 +2259,6 @@ function calcGlobalSymmetry(dSVpoints, rSVpoints, S50V) {
2146
2259
  gSym *= sign;
2147
2260
  return gSym / 100;
2148
2261
  }
2149
- exports.calcGlobalSymmetry = calcGlobalSymmetry;
2150
2262
  // RAW DISPROPORTIONALITY
2151
2263
  //
2152
2264
  // PR = Sf – Vf : Eq.C.1.1 on P. 42
@@ -2154,7 +2266,6 @@ function calcDisproportionality(Vf, Sf) {
2154
2266
  const disProp = calcProp(Vf, Sf);
2155
2267
  return disProp;
2156
2268
  }
2157
- exports.calcDisproportionality = calcDisproportionality;
2158
2269
  // The actual formula
2159
2270
  function calcProp(Vf, Sf) {
2160
2271
  const prop = Vf - Sf;
@@ -2168,7 +2279,6 @@ function calcBigR(Vf, Sf) {
2168
2279
  }
2169
2280
  return bigR;
2170
2281
  }
2171
- exports.calcBigR = calcBigR;
2172
2282
  // MINIMAL INVERSE RESPONSIVENESS
2173
2283
  //
2174
2284
  // zeta = (1 / r) - (1 / r_sub_max) : Eq. 5.2.1
@@ -2184,7 +2294,6 @@ function calcMinimalInverseResponsiveness(Vf, r) {
2184
2294
  }
2185
2295
  return MIR;
2186
2296
  }
2187
- exports.calcMinimalInverseResponsiveness = calcMinimalInverseResponsiveness;
2188
2297
  function isBalanced(Vf) {
2189
2298
  const [lower, upper] = C.competitiveRange();
2190
2299
  const bBalanced = ((Vf > upper) || (Vf < lower)) ? false : true;
@@ -2200,7 +2309,6 @@ function calcGamma(Vf, Sf, r) {
2200
2309
  const g = 0.5 + (r * (Vf - 0.5)) - Sf;
2201
2310
  return g;
2202
2311
  }
2203
- exports.calcGamma = calcGamma;
2204
2312
  // EXPERIMENTAL
2205
2313
  const pctWidth = 5; // The size in % points of the 'local' window to bracket <V>
2206
2314
  // Average local asymmetry
@@ -2218,7 +2326,6 @@ function estLocalAsymmetry(Vf, dSVpoints, rSVpoints) {
2218
2326
  return undefined;
2219
2327
  }
2220
2328
  }
2221
- exports.estLocalAsymmetry = estLocalAsymmetry;
2222
2329
  function rangeAsymmetry(dSVpoints, rSVpoints) {
2223
2330
  const ndPts = dSVpoints.length;
2224
2331
  const nrPts = rSVpoints.length;
@@ -2229,7 +2336,6 @@ function rangeAsymmetry(dSVpoints, rSVpoints) {
2229
2336
  }
2230
2337
  return tot / ndPts;
2231
2338
  }
2232
- exports.rangeAsymmetry = rangeAsymmetry;
2233
2339
  // Average local disproportionality
2234
2340
  function estLocalDisproportionality(Vf, dSVpoints) {
2235
2341
  try {
@@ -2244,7 +2350,6 @@ function estLocalDisproportionality(Vf, dSVpoints) {
2244
2350
  return undefined;
2245
2351
  }
2246
2352
  }
2247
- exports.estLocalDisproportionality = estLocalDisproportionality;
2248
2353
  function rangeDisproportionality(dSVpoints) {
2249
2354
  const ndPts = dSVpoints.length;
2250
2355
  let tot = 0.0;
@@ -2253,7 +2358,6 @@ function rangeDisproportionality(dSVpoints) {
2253
2358
  }
2254
2359
  return tot / ndPts;
2255
2360
  }
2256
- exports.rangeDisproportionality = rangeDisproportionality;
2257
2361
  // Average local disproportionality from the best # of seats (closest to proportional)
2258
2362
  function estLocalDisproportionalityAlt(Vf, N, dSVpoints) {
2259
2363
  const dPts = svPointRange(Vf, dSVpoints);
@@ -2262,7 +2366,6 @@ function estLocalDisproportionalityAlt(Vf, N, dSVpoints) {
2262
2366
  const lPropAlt = rangeDisproportionalityAlt(N, dPts);
2263
2367
  return lPropAlt;
2264
2368
  }
2265
- exports.estLocalDisproportionalityAlt = estLocalDisproportionalityAlt;
2266
2369
  // Dynamically calculate the best # seats, so this is a step function
2267
2370
  function rangeDisproportionalityAlt(N, dSVpoints) {
2268
2371
  const ndPts = dSVpoints.length;
@@ -2274,7 +2377,6 @@ function rangeDisproportionalityAlt(N, dSVpoints) {
2274
2377
  }
2275
2378
  return tot / ndPts;
2276
2379
  }
2277
- exports.rangeDisproportionalityAlt = rangeDisproportionalityAlt;
2278
2380
  // Average local unearned seats from the best # of seats (closest to proportional)
2279
2381
  function estLocalUnearnedSeats(Vf, N, dSVpoints) {
2280
2382
  const dPts = svPointRange(Vf, dSVpoints);
@@ -2283,7 +2385,6 @@ function estLocalUnearnedSeats(Vf, N, dSVpoints) {
2283
2385
  const lUE = rangeUnearnedSeats(N, dPts);
2284
2386
  return lUE;
2285
2387
  }
2286
- exports.estLocalUnearnedSeats = estLocalUnearnedSeats;
2287
2388
  function rangeUnearnedSeats(N, dSVpoints) {
2288
2389
  const ndPts = dSVpoints.length;
2289
2390
  let tot = 0.0;
@@ -2294,7 +2395,6 @@ function rangeUnearnedSeats(N, dSVpoints) {
2294
2395
  }
2295
2396
  return tot / ndPts;
2296
2397
  }
2297
- exports.rangeUnearnedSeats = rangeUnearnedSeats;
2298
2398
  // Filter the full [0.25–0.75] range of S–V points down to the 'local' range.
2299
2399
  // Make sure that range is w/in the full range.
2300
2400
  function svPointRange(Vf, svPoints) {
@@ -2329,7 +2429,7 @@ const inRange = (pt, range) => { return (pt.v >= range[0]) && (pt.v <= range[1])
2329
2429
  // Approximate ERF - https://en.wikipedia.org/wiki/Error_function#Numerical_approximations
2330
2430
  //
2331
2431
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2332
- exports.approximateERF = void 0;
2432
+ exports.approximateERF = approximateERF;
2333
2433
  function approximateERF(x) {
2334
2434
  const n = Math.abs(x);
2335
2435
  const p = 0.3275911;
@@ -2342,7 +2442,6 @@ function approximateERF(x) {
2342
2442
  const erf = 1 - ((a1 * t) + (a2 * Math.pow(t, 2)) + (a3 * Math.pow(t, 3)) + (a4 * Math.pow(t, 4)) + (a5 * Math.pow(t, 5))) * Math.pow(Math.E, (-1 * Math.pow(n, 2)));
2343
2443
  return (x < 0) ? -erf : erf;
2344
2444
  }
2345
- exports.approximateERF = approximateERF;
2346
2445
  /* To validate this, you need to import mathjs.erf into a Jest test file and run these:
2347
2446
 
2348
2447
  const {erf} = require('mathjs');
@@ -2402,15 +2501,35 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
2402
2501
  }) : function(o, v) {
2403
2502
  o["default"] = v;
2404
2503
  });
2405
- var __importStar = (this && this.__importStar) || function (mod) {
2406
- if (mod && mod.__esModule) return mod;
2407
- var result = {};
2408
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2409
- __setModuleDefault(result, mod);
2410
- return result;
2411
- };
2504
+ var __importStar = (this && this.__importStar) || (function () {
2505
+ var ownKeys = function(o) {
2506
+ ownKeys = Object.getOwnPropertyNames || function (o) {
2507
+ var ar = [];
2508
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
2509
+ return ar;
2510
+ };
2511
+ return ownKeys(o);
2512
+ };
2513
+ return function (mod) {
2514
+ if (mod && mod.__esModule) return mod;
2515
+ var result = {};
2516
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
2517
+ __setModuleDefault(result, mod);
2518
+ return result;
2519
+ };
2520
+ })();
2412
2521
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2413
- exports.fptpWin = exports.estFPTPSeats = exports.findBracketingUpperSf = exports.findBracketingLowerSf = exports.findBracketingUpperVf = exports.findBracketingLowerVf = exports.inferSVpoints = exports.avgSVError = exports.estDistrictResponsiveness = exports.estSeats = exports.estSeatProbability = void 0;
2522
+ exports.avgSVError = void 0;
2523
+ exports.estSeatProbability = estSeatProbability;
2524
+ exports.estSeats = estSeats;
2525
+ exports.estDistrictResponsiveness = estDistrictResponsiveness;
2526
+ exports.inferSVpoints = inferSVpoints;
2527
+ exports.findBracketingLowerVf = findBracketingLowerVf;
2528
+ exports.findBracketingUpperVf = findBracketingUpperVf;
2529
+ exports.findBracketingLowerSf = findBracketingLowerSf;
2530
+ exports.findBracketingUpperSf = findBracketingUpperSf;
2531
+ exports.estFPTPSeats = estFPTPSeats;
2532
+ exports.fptpWin = fptpWin;
2414
2533
  const erf_1 = __webpack_require__(/*! ./erf */ "./lib/partisan/erf.ts");
2415
2534
  const normalize_1 = __webpack_require__(/*! ../rate/normalize */ "./lib/rate/normalize.ts");
2416
2535
  const U = __importStar(__webpack_require__(/*! ../utils/all */ "./lib/utils/all.ts"));
@@ -2434,7 +2553,6 @@ function estSeatProbability(Vf, range) {
2434
2553
  return seatProbabilityFn(Vf);
2435
2554
  }
2436
2555
  }
2437
- exports.estSeatProbability = estSeatProbability;
2438
2556
  // const {erf} = require('mathjs');
2439
2557
  // console.log("erf(0.2) =", erf(0.2)); // returns 0.22270258921047847
2440
2558
  // console.log("erf(-0.5) =", erf(-0.5)); // returns -0.5204998778130465
@@ -2448,13 +2566,11 @@ function estSeats(VfArray, range) {
2448
2566
  // Python: sum([est_seat_probability(vpi) for vpi in vpi_by_district])
2449
2567
  return U.sumArray(VfArray.map(v => estSeatProbability(v, range)));
2450
2568
  }
2451
- exports.estSeats = estSeats;
2452
2569
  // Estimate the number of responsive districts [R(d)], given a set of Vf's
2453
2570
  function estDistrictResponsiveness(Vf) {
2454
2571
  // Python: 1 - 4 * (est_seat_probability(vpi) - 0.5)**2
2455
2572
  return 1.0 - 4.0 * Math.pow((estSeatProbability(Vf) - 0.5), 2);
2456
2573
  }
2457
- exports.estDistrictResponsiveness = estDistrictResponsiveness;
2458
2574
  exports.avgSVError = 0.02;
2459
2575
  function inferSVpoints(Vf, VfArray, shift, range) {
2460
2576
  const nDistricts = VfArray.length;
@@ -2466,7 +2582,6 @@ function inferSVpoints(Vf, VfArray, shift, range) {
2466
2582
  }
2467
2583
  return SVpoints;
2468
2584
  }
2469
- exports.inferSVpoints = inferSVpoints;
2470
2585
  function shiftDistricts(Vf, VfArray, shiftedVf, shift) {
2471
2586
  if (shift == 0 /* T.Shift.Proportional */)
2472
2587
  return shiftProportionally(Vf, VfArray, shiftedVf);
@@ -2524,7 +2639,6 @@ function findBracketingLowerVf(Vf, inferredSVpoints) {
2524
2639
  lowerPt = smallerPoints.slice(-1)[0];
2525
2640
  return lowerPt;
2526
2641
  }
2527
- exports.findBracketingLowerVf = findBracketingLowerVf;
2528
2642
  // Find the S(V) point that brackets a Vf value on the upper end
2529
2643
  function findBracketingUpperVf(Vf, inferredSVpoints) {
2530
2644
  let upperPt = inferredSVpoints[-1];
@@ -2537,7 +2651,6 @@ function findBracketingUpperVf(Vf, inferredSVpoints) {
2537
2651
  }
2538
2652
  return upperPt;
2539
2653
  }
2540
- exports.findBracketingUpperVf = findBracketingUpperVf;
2541
2654
  // The corresponding functions via the Sf y-axis (vs. Vf x-axis)
2542
2655
  // Find the S(V) point that brackets a Sf value on the lower end
2543
2656
  function findBracketingLowerSf(Sf, inferredSVpoints) {
@@ -2555,7 +2668,6 @@ function findBracketingLowerSf(Sf, inferredSVpoints) {
2555
2668
  lowerPt = smallerPoints.slice(-1)[0];
2556
2669
  return lowerPt;
2557
2670
  }
2558
- exports.findBracketingLowerSf = findBracketingLowerSf;
2559
2671
  // Find the S(V) point that brackets a Sf value on the upper end
2560
2672
  function findBracketingUpperSf(Sf, inferredSVpoints) {
2561
2673
  let upperPt = inferredSVpoints[-1];
@@ -2568,20 +2680,17 @@ function findBracketingUpperSf(Sf, inferredSVpoints) {
2568
2680
  }
2569
2681
  return upperPt;
2570
2682
  }
2571
- exports.findBracketingUpperSf = findBracketingUpperSf;
2572
2683
  // HELPERS
2573
2684
  // The estimated number of Democratic seats using first past the post
2574
2685
  function estFPTPSeats(VfArray) {
2575
2686
  // Python: sum([1.0 for vpi in vpi_by_district if (vpi > 0.5)])
2576
2687
  return U.sumArray(VfArray.map(v => fptpWin(v)));
2577
2688
  }
2578
- exports.estFPTPSeats = estFPTPSeats;
2579
2689
  function fptpWin(demPct) {
2580
2690
  // Vote shares should be fractions in the range [0.0 – 1.0]
2581
2691
  //assert((demPct <= 1.0) && (demPct >= 0.0));
2582
2692
  return ((demPct > 0.5) ? 1 : 0);
2583
2693
  }
2584
- exports.fptpWin = fptpWin;
2585
2694
 
2586
2695
 
2587
2696
  /***/ }),
@@ -2612,15 +2721,34 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
2612
2721
  }) : function(o, v) {
2613
2722
  o["default"] = v;
2614
2723
  });
2615
- var __importStar = (this && this.__importStar) || function (mod) {
2616
- if (mod && mod.__esModule) return mod;
2617
- var result = {};
2618
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2619
- __setModuleDefault(result, mod);
2620
- return result;
2621
- };
2724
+ var __importStar = (this && this.__importStar) || (function () {
2725
+ var ownKeys = function(o) {
2726
+ ownKeys = Object.getOwnPropertyNames || function (o) {
2727
+ var ar = [];
2728
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
2729
+ return ar;
2730
+ };
2731
+ return ownKeys(o);
2732
+ };
2733
+ return function (mod) {
2734
+ if (mod && mod.__esModule) return mod;
2735
+ var result = {};
2736
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
2737
+ __setModuleDefault(result, mod);
2738
+ return result;
2739
+ };
2740
+ })();
2622
2741
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2623
- exports.findMarginalDistricts = exports.estMarginalCompetitiveShare = exports.estMarginalCompetitiveDistricts = exports.estCompetitiveDistrictsShare = exports.estDistrictCompetitiveness = exports.estCompetitiveDistricts = exports.countCompetitiveDistricts = exports.estResponsiveDistrictsShare = exports.estResponsiveDistricts = exports.estResponsiveness = void 0;
2742
+ exports.estResponsiveness = estResponsiveness;
2743
+ exports.estResponsiveDistricts = estResponsiveDistricts;
2744
+ exports.estResponsiveDistrictsShare = estResponsiveDistrictsShare;
2745
+ exports.countCompetitiveDistricts = countCompetitiveDistricts;
2746
+ exports.estCompetitiveDistricts = estCompetitiveDistricts;
2747
+ exports.estDistrictCompetitiveness = estDistrictCompetitiveness;
2748
+ exports.estCompetitiveDistrictsShare = estCompetitiveDistrictsShare;
2749
+ exports.estMarginalCompetitiveDistricts = estMarginalCompetitiveDistricts;
2750
+ exports.estMarginalCompetitiveShare = estMarginalCompetitiveShare;
2751
+ exports.findMarginalDistricts = findMarginalDistricts;
2624
2752
  const normalize_1 = __webpack_require__(/*! ../rate/normalize */ "./lib/rate/normalize.ts");
2625
2753
  const U = __importStar(__webpack_require__(/*! ../utils/all */ "./lib/utils/all.ts"));
2626
2754
  const C = __importStar(__webpack_require__(/*! ../rate/dra-config */ "./lib/rate/dra-config.ts"));
@@ -2656,24 +2784,20 @@ function estResponsiveness(Vf, inferredSVpoints) {
2656
2784
  }
2657
2785
  return r;
2658
2786
  }
2659
- exports.estResponsiveness = estResponsiveness;
2660
2787
  // rD - Estimate the number of responsive districts, given a set of Vf's
2661
2788
  function estResponsiveDistricts(VfArray) {
2662
2789
  // Python: sum([est_district_responsiveness(vpi) for vpi in vpi_by_district])
2663
2790
  return U.sumArray(VfArray.map(v => (0, method_1.estDistrictResponsiveness)(v)));
2664
2791
  }
2665
- exports.estResponsiveDistricts = estResponsiveDistricts;
2666
2792
  // rD% - The estimated # of responsive districts, as a fraction of N
2667
2793
  function estResponsiveDistrictsShare(rD, N) {
2668
2794
  return rD / N;
2669
2795
  }
2670
- exports.estResponsiveDistrictsShare = estResponsiveDistrictsShare;
2671
2796
  // ESTIMATE COMPETITIVENESS (ENHANCED)
2672
2797
  // C - Count the # of competitive districts, defined as v in [45–55%]
2673
2798
  function countCompetitiveDistricts(VfArray) {
2674
2799
  return U.sumArray(VfArray.map(v => isCompetitive(v)));
2675
2800
  }
2676
- exports.countCompetitiveDistricts = countCompetitiveDistricts;
2677
2801
  function isCompetitive(v) {
2678
2802
  return ((v >= C.competitiveRange()[C.BEG]) && (v <= C.competitiveRange()[C.END])) ? 1 : 0;
2679
2803
  }
@@ -2681,7 +2805,6 @@ function isCompetitive(v) {
2681
2805
  function estCompetitiveDistricts(VfArray, bCompress = false) {
2682
2806
  return U.sumArray(VfArray.map(v => estDistrictCompetitiveness(v, bCompress)));
2683
2807
  }
2684
- exports.estCompetitiveDistricts = estCompetitiveDistricts;
2685
2808
  function estDistrictCompetitiveness(Vf, bCompress = false) {
2686
2809
  const _normalizer = new normalize_1.Normalizer(Vf);
2687
2810
  // The end points of the probability distribution
@@ -2695,12 +2818,10 @@ function estDistrictCompetitiveness(Vf, bCompress = false) {
2695
2818
  const dC = (0, method_1.estDistrictResponsiveness)(_normalizer.wipNum);
2696
2819
  return dC;
2697
2820
  }
2698
- exports.estDistrictCompetitiveness = estDistrictCompetitiveness;
2699
2821
  // cD% - The estimated # of competitive districts, as a fraction of N
2700
2822
  function estCompetitiveDistrictsShare(cD, N) {
2701
2823
  return cD / N;
2702
2824
  }
2703
- exports.estCompetitiveDistrictsShare = estCompetitiveDistrictsShare;
2704
2825
  // Md - The estimated # of "marginal" districts in and around the likely FPTP
2705
2826
  // seats & the best seat split that are competitive.
2706
2827
  function estMarginalCompetitiveDistricts(Mrange, VfArray, bCompress = false) {
@@ -2713,7 +2834,6 @@ function estMarginalCompetitiveDistricts(Mrange, VfArray, bCompress = false) {
2713
2834
  const Md = U.sumArray(subsetVfArray.map((v) => estDistrictCompetitiveness(v, bCompress)));
2714
2835
  return Md;
2715
2836
  }
2716
- exports.estMarginalCompetitiveDistricts = estMarginalCompetitiveDistricts;
2717
2837
  // Md% - The estimated competitiveness of the "marginal" districts in and around
2718
2838
  // the likely FPTP seats & the best seat split as a fraction
2719
2839
  function estMarginalCompetitiveShare(Md, Mrange) {
@@ -2723,7 +2843,6 @@ function estMarginalCompetitiveShare(Md, Mrange) {
2723
2843
  const MdShare = estCompetitiveDistrictsShare(Md, maxId - minId + 1);
2724
2844
  return MdShare;
2725
2845
  }
2726
- exports.estMarginalCompetitiveShare = estMarginalCompetitiveShare;
2727
2846
  function findMarginalDistricts(Vf, VfArray, N) {
2728
2847
  const bestS = (0, bias_1.bestSeats)(N, Vf);
2729
2848
  const fptpS = (0, method_1.estFPTPSeats)(VfArray);
@@ -2745,7 +2864,6 @@ function findMarginalDistricts(Vf, VfArray, N) {
2745
2864
  }
2746
2865
  return [minId, maxId];
2747
2866
  }
2748
- exports.findMarginalDistricts = findMarginalDistricts;
2749
2867
 
2750
2868
 
2751
2869
  /***/ }),
@@ -2778,6 +2896,16 @@ __exportStar(__webpack_require__(/*! ./normalize */ "./lib/rate/normalize.ts"),
2778
2896
  __exportStar(__webpack_require__(/*! ./settings */ "./lib/rate/settings.ts"), exports);
2779
2897
 
2780
2898
 
2899
+ /***/ }),
2900
+
2901
+ /***/ "./lib/rate/dra-config.json":
2902
+ /*!**********************************!*\
2903
+ !*** ./lib/rate/dra-config.json ***!
2904
+ \**********************************/
2905
+ /***/ ((module) => {
2906
+
2907
+ module.exports = /*#__PURE__*/JSON.parse('{"partisan":{"bias":{"range":[0,0.2]},"competitiveness":{"range":[0,0.75],"distribution":[0.25,0.75],"simpleRange":[0.45,0.55],"weight":[0,20]},"bonus":2},"minority":{"range":[0.37,0.5],"distribution":[0.25,0.75],"shift":[0.15,0.5],"coalition":{"weight":0.5}},"compactness":{"reock":{"range":[0.25,0.5],"weight":50},"polsby":{"range":[0.1,0.5],"weight":50}},"splitting":{"county":{"range":[[1.26,1.68],[1.09,1.45]],"weight":50},"district":{"range":[[1.26,1.68],[1.09,1.45]],"weight":50}},"popdev":{"range":[[0.0075,0.002],[0.1,-1]]}}');
2908
+
2781
2909
  /***/ }),
2782
2910
 
2783
2911
  /***/ "./lib/rate/dra-config.ts":
@@ -2794,7 +2922,27 @@ __exportStar(__webpack_require__(/*! ./settings */ "./lib/rate/settings.ts"), ex
2794
2922
  // That is not implemented yet.
2795
2923
  //
2796
2924
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2797
- exports.popdevThreshold = exports.popdevRange = exports.districtSplittingRange = exports.districtSplittingWeight = exports.countySplittingRange = exports.countySplittingWeight = exports.polsbyRange = exports.polsbyWeight = exports.reockRange = exports.reockWeight = exports.coalitionDistrictWeight = exports.minorityShiftDilution = exports.minorityShift = exports.minorityOpportunityDistribution = exports.minorityOpportunityRange = exports.overallCompetitivenessRange = exports.competitiveDistribution = exports.competitiveRange = exports.winnerBonus = exports.biasRange = exports.END = exports.BEG = void 0;
2925
+ exports.END = exports.BEG = void 0;
2926
+ exports.biasRange = biasRange;
2927
+ exports.winnerBonus = winnerBonus;
2928
+ exports.competitiveRange = competitiveRange;
2929
+ exports.competitiveDistribution = competitiveDistribution;
2930
+ exports.overallCompetitivenessRange = overallCompetitivenessRange;
2931
+ exports.minorityOpportunityRange = minorityOpportunityRange;
2932
+ exports.minorityOpportunityDistribution = minorityOpportunityDistribution;
2933
+ exports.minorityShift = minorityShift;
2934
+ exports.minorityShiftDilution = minorityShiftDilution;
2935
+ exports.coalitionDistrictWeight = coalitionDistrictWeight;
2936
+ exports.reockWeight = reockWeight;
2937
+ exports.reockRange = reockRange;
2938
+ exports.polsbyWeight = polsbyWeight;
2939
+ exports.polsbyRange = polsbyRange;
2940
+ exports.countySplittingWeight = countySplittingWeight;
2941
+ exports.countySplittingRange = countySplittingRange;
2942
+ exports.districtSplittingWeight = districtSplittingWeight;
2943
+ exports.districtSplittingRange = districtSplittingRange;
2944
+ exports.popdevRange = popdevRange;
2945
+ exports.popdevThreshold = popdevThreshold;
2798
2946
  const config = __webpack_require__(/*! ./dra-config.json */ "./lib/rate/dra-config.json");
2799
2947
  exports.BEG = 0;
2800
2948
  exports.END = 1;
@@ -2803,23 +2951,19 @@ function biasRange(overridesJSON) {
2803
2951
  const range = config.partisan.bias.range;
2804
2952
  return range;
2805
2953
  }
2806
- exports.biasRange = biasRange;
2807
2954
  function winnerBonus(overridesJSON) {
2808
2955
  const bonus = config.partisan.bonus;
2809
2956
  return bonus;
2810
2957
  }
2811
- exports.winnerBonus = winnerBonus;
2812
2958
  // The simple user-facing range, i.e., 45–55%.
2813
2959
  function competitiveRange(overridesJSON) {
2814
2960
  const range = config.partisan.competitiveness.simpleRange;
2815
2961
  return range;
2816
2962
  }
2817
- exports.competitiveRange = competitiveRange;
2818
2963
  function competitiveDistribution(overridesJSON) {
2819
2964
  const dist = config.partisan.competitiveness.distribution;
2820
2965
  return dist;
2821
2966
  }
2822
- exports.competitiveDistribution = competitiveDistribution;
2823
2967
  // The more complex internal range for normalizing Cdf.
2824
2968
  // * 06/23/2020 - As part of relaxing the competitive range, I changed this max
2825
2969
  // from 0.67 to 0.75.
@@ -2827,7 +2971,6 @@ function overallCompetitivenessRange(overridesJSON) {
2827
2971
  const range = config.partisan.competitiveness.range;
2828
2972
  return range;
2829
2973
  }
2830
- exports.overallCompetitivenessRange = overallCompetitivenessRange;
2831
2974
  // export function marginalCompetitivenessRange(overridesJSON?: any): number[]
2832
2975
  // {
2833
2976
  // const range = config.partisan.responsiveness.marginal.range;
@@ -2848,73 +2991,60 @@ function minorityOpportunityRange(overridesJSON) {
2848
2991
  const range = config.minority.range;
2849
2992
  return range;
2850
2993
  }
2851
- exports.minorityOpportunityRange = minorityOpportunityRange;
2852
2994
  function minorityOpportunityDistribution(overridesJSON) {
2853
2995
  const dist = config.minority.distribution;
2854
2996
  return dist;
2855
2997
  }
2856
- exports.minorityOpportunityDistribution = minorityOpportunityDistribution;
2857
2998
  // For Black VAP %
2858
2999
  function minorityShift(overridesJSON) {
2859
3000
  const BLACK = 0;
2860
3001
  const shift = config.minority.shift[BLACK];
2861
3002
  return shift;
2862
3003
  }
2863
- exports.minorityShift = minorityShift;
2864
3004
  // Dilution for other demos
2865
3005
  function minorityShiftDilution(overridesJSON) {
2866
3006
  const DILUTION = 1;
2867
3007
  const shift = config.minority.shift[DILUTION];
2868
3008
  return shift;
2869
3009
  }
2870
- exports.minorityShiftDilution = minorityShiftDilution;
2871
3010
  function coalitionDistrictWeight(overridesJSON) {
2872
3011
  const weight = config.minority.coalition.weight;
2873
3012
  return weight;
2874
3013
  }
2875
- exports.coalitionDistrictWeight = coalitionDistrictWeight;
2876
3014
  // COMPACTNESS
2877
3015
  function reockWeight(overridesJSON) {
2878
3016
  const rW = config.compactness.reock.weight;
2879
3017
  return rW;
2880
3018
  }
2881
- exports.reockWeight = reockWeight;
2882
3019
  function reockRange(overridesJSON) {
2883
3020
  const range = config.compactness.reock.range;
2884
3021
  return range;
2885
3022
  }
2886
- exports.reockRange = reockRange;
2887
3023
  function polsbyWeight(overridesJSON) {
2888
3024
  const ppW = config.compactness.polsby.weight;
2889
3025
  return ppW;
2890
3026
  }
2891
- exports.polsbyWeight = polsbyWeight;
2892
3027
  function polsbyRange(overridesJSON) {
2893
3028
  const range = config.compactness.polsby.range;
2894
3029
  return range;
2895
3030
  }
2896
- exports.polsbyRange = polsbyRange;
2897
3031
  // SPLITTING
2898
3032
  function countySplittingWeight(overridesJSON) {
2899
3033
  const csW = config.splitting.county.weight;
2900
3034
  return csW;
2901
3035
  }
2902
- exports.countySplittingWeight = countySplittingWeight;
2903
3036
  function countySplittingRange(d, overridesJSON) {
2904
3037
  const range = config.splitting.county.range[d];
2905
3038
  return range;
2906
3039
  }
2907
- exports.countySplittingRange = countySplittingRange;
2908
3040
  function districtSplittingWeight(overridesJSON) {
2909
3041
  const dsW = config.splitting.district.weight;
2910
3042
  return dsW;
2911
3043
  }
2912
- exports.districtSplittingWeight = districtSplittingWeight;
2913
3044
  function districtSplittingRange(d, overridesJSON) {
2914
3045
  const range = config.splitting.district.range[d];
2915
3046
  return range;
2916
3047
  }
2917
- exports.districtSplittingRange = districtSplittingRange;
2918
3048
  // NOTE - Raw ranges, not inverted (i.e., smaller is better)
2919
3049
  // NOTE - This could be optimized to not calc LD values for CD's (or do it once)
2920
3050
  function popdevRange(bLegislative, overridesJSON) {
@@ -2928,13 +3058,11 @@ function popdevRange(bLegislative, overridesJSON) {
2928
3058
  // Invert the range, so bigger is better.
2929
3059
  return [worst, best];
2930
3060
  }
2931
- exports.popdevRange = popdevRange;
2932
3061
  // NOTE - Raw threshold, not inverted (i.e., smaller is better)
2933
3062
  function popdevThreshold(bLegislative, overridesJSON) {
2934
3063
  const threshold = popdevRange(bLegislative)[exports.BEG];
2935
3064
  return threshold;
2936
3065
  }
2937
- exports.popdevThreshold = popdevThreshold;
2938
3066
 
2939
3067
 
2940
3068
  /***/ }),
@@ -2965,15 +3093,47 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
2965
3093
  }) : function(o, v) {
2966
3094
  o["default"] = v;
2967
3095
  });
2968
- var __importStar = (this && this.__importStar) || function (mod) {
2969
- if (mod && mod.__esModule) return mod;
2970
- var result = {};
2971
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2972
- __setModuleDefault(result, mod);
2973
- return result;
2974
- };
3096
+ var __importStar = (this && this.__importStar) || (function () {
3097
+ var ownKeys = function(o) {
3098
+ ownKeys = Object.getOwnPropertyNames || function (o) {
3099
+ var ar = [];
3100
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
3101
+ return ar;
3102
+ };
3103
+ return ownKeys(o);
3104
+ };
3105
+ return function (mod) {
3106
+ if (mod && mod.__esModule) return mod;
3107
+ var result = {};
3108
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
3109
+ __setModuleDefault(result, mod);
3110
+ return result;
3111
+ };
3112
+ })();
2975
3113
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2976
- exports.adjustSplittingRating = exports.rateSplittingLegacy = exports.rateDistrictSplittingLegacy = exports.countySplitWorst = exports.countySplitBest = exports.rateCountySplittingLegacy = exports.rateSplitting = exports.rateDistrictSplitting = exports.rateCountySplitting = exports.bestTarget = exports.worstMultiplier = exports.minSplitting = exports.maxSplitting = exports.rateCompactness = exports.ratePolsby = exports.rateReock = exports.rateMinorityRepresentation = exports.rateCompetitiveness = exports.normalizePartisanBias = exports.ratePartisanBias = exports.isAntimajoritarian = exports.adjustDeviation = exports.extraBonus = exports.rateProportionality = exports.ratePopulationDeviation = void 0;
3114
+ exports.worstMultiplier = exports.minSplitting = exports.maxSplitting = void 0;
3115
+ exports.ratePopulationDeviation = ratePopulationDeviation;
3116
+ exports.rateProportionality = rateProportionality;
3117
+ exports.extraBonus = extraBonus;
3118
+ exports.adjustDeviation = adjustDeviation;
3119
+ exports.isAntimajoritarian = isAntimajoritarian;
3120
+ exports.ratePartisanBias = ratePartisanBias;
3121
+ exports.normalizePartisanBias = normalizePartisanBias;
3122
+ exports.rateCompetitiveness = rateCompetitiveness;
3123
+ exports.rateMinorityRepresentation = rateMinorityRepresentation;
3124
+ exports.rateReock = rateReock;
3125
+ exports.ratePolsby = ratePolsby;
3126
+ exports.rateCompactness = rateCompactness;
3127
+ exports.bestTarget = bestTarget;
3128
+ exports.rateCountySplitting = rateCountySplitting;
3129
+ exports.rateDistrictSplitting = rateDistrictSplitting;
3130
+ exports.rateSplitting = rateSplitting;
3131
+ exports.rateCountySplittingLegacy = rateCountySplittingLegacy;
3132
+ exports.countySplitBest = countySplitBest;
3133
+ exports.countySplitWorst = countySplitWorst;
3134
+ exports.rateDistrictSplittingLegacy = rateDistrictSplittingLegacy;
3135
+ exports.rateSplittingLegacy = rateSplittingLegacy;
3136
+ exports.adjustSplittingRating = adjustSplittingRating;
2977
3137
  const C = __importStar(__webpack_require__(/*! ./dra-config */ "./lib/rate/dra-config.ts"));
2978
3138
  const normalize_1 = __webpack_require__(/*! ../rate/normalize */ "./lib/rate/normalize.ts");
2979
3139
  const method_1 = __webpack_require__(/*! ../partisan/method */ "./lib/partisan/method.ts");
@@ -2990,7 +3150,6 @@ function ratePopulationDeviation(rawDeviation, bLegislative) {
2990
3150
  _normalizer.rescale();
2991
3151
  return _normalizer.normalizedNum;
2992
3152
  }
2993
- exports.ratePopulationDeviation = ratePopulationDeviation;
2994
3153
  // RATE PROPORTIONALITY
2995
3154
  function rateProportionality(rawDisproportionality, Vf, Sf) {
2996
3155
  if (isAntimajoritarian(Vf, Sf)) {
@@ -3013,13 +3172,11 @@ function rateProportionality(rawDisproportionality, Vf, Sf) {
3013
3172
  return rating;
3014
3173
  }
3015
3174
  }
3016
- exports.rateProportionality = rateProportionality;
3017
3175
  function extraBonus(Vf) {
3018
3176
  const over50Pct = (Vf > 0.5) ? (Vf - 0.5) : (0.5 - Vf);
3019
3177
  const okExtra = over50Pct * (C.winnerBonus() - 1.0);
3020
3178
  return okExtra; // No longer trimming the result here
3021
3179
  }
3022
- exports.extraBonus = extraBonus;
3023
3180
  // Adjust deviation from proportionality to account for a winner's bonus
3024
3181
  // * If the bias is in the *same* direction as the statewide vote %, then
3025
3182
  // discount the bias by the winner's bonus (extra).
@@ -3035,13 +3192,11 @@ function adjustDeviation(Vf, disproportionality, extra) {
3035
3192
  }
3036
3193
  return adjusted;
3037
3194
  }
3038
- exports.adjustDeviation = adjustDeviation;
3039
3195
  function isAntimajoritarian(Vf, Sf) {
3040
3196
  const bDem = ((Vf < (0.5 - method_1.avgSVError)) && (Sf > 0.5)) ? true : false;
3041
3197
  const bRep = (((1 - Vf) < (0.5 - method_1.avgSVError)) && ((1 - Sf) > 0.5)) ? true : false;
3042
3198
  return bDem || bRep;
3043
3199
  }
3044
- exports.isAntimajoritarian = isAntimajoritarian;
3045
3200
  // RATE Impact == "unearned seats" <<< DEPRECATED
3046
3201
  /*
3047
3202
  export function scoreImpact(rawUE: number, Vf: number, Sf: number, N: number): number
@@ -3083,14 +3238,12 @@ function ratePartisanBias(rawSeatsBias, rawVotesBias) {
3083
3238
  const partisanBiasRating = Math.round((seatsBiasRating + votesBiasRating) / 2);
3084
3239
  return partisanBiasRating;
3085
3240
  }
3086
- exports.ratePartisanBias = ratePartisanBias;
3087
3241
  // NOTE - John Nagle specified this function vs. simple linear normalization
3088
3242
  function normalizePartisanBias(biasPct, pctAt50) {
3089
3243
  const b = pctAt50 / Math.log(1 / 2);
3090
3244
  const rating = 100 * Math.exp(-Math.abs(biasPct / b));
3091
3245
  return Math.round(rating);
3092
3246
  }
3093
- exports.normalizePartisanBias = normalizePartisanBias;
3094
3247
  // RATE COMPETITIVENESS
3095
3248
  // Normalize overall competitiveness - Raw values are in the range [0.0–1.0].
3096
3249
  // But the practical max is more like 3/4's, so unitize that range to [0.0–1.0].
@@ -3105,7 +3258,6 @@ function rateCompetitiveness(rawCdf) {
3105
3258
  const rating = _normalizer.normalizedNum;
3106
3259
  return rating;
3107
3260
  }
3108
- exports.rateCompetitiveness = rateCompetitiveness;
3109
3261
  // RATE MINORITY REPRESENTATION
3110
3262
  // NOTE - The probable # of opportunity & coalition districts can be *larger* than
3111
3263
  // what would be a proportional # based on the statewide percentage, because of
@@ -3122,7 +3274,6 @@ function rateMinorityRepresentation(rawOd, pOd, rawCd, pCd) {
3122
3274
  const rating = Math.round(Math.min(opportunityScore + cDWeight * Math.max(coalitionScore - opportunityScore, 0), 100));
3123
3275
  return rating;
3124
3276
  }
3125
- exports.rateMinorityRepresentation = rateMinorityRepresentation;
3126
3277
  // RATE COMPACTNESS
3127
3278
  function rateReock(rawValue) {
3128
3279
  const _normalizer = new normalize_1.Normalizer(rawValue);
@@ -3133,7 +3284,6 @@ function rateReock(rawValue) {
3133
3284
  _normalizer.rescale();
3134
3285
  return _normalizer.normalizedNum;
3135
3286
  }
3136
- exports.rateReock = rateReock;
3137
3287
  function ratePolsby(rawValue) {
3138
3288
  const _normalizer = new normalize_1.Normalizer(rawValue);
3139
3289
  const worst = C.polsbyRange()[C.BEG];
@@ -3143,14 +3293,12 @@ function ratePolsby(rawValue) {
3143
3293
  _normalizer.rescale();
3144
3294
  return _normalizer.normalizedNum;
3145
3295
  }
3146
- exports.ratePolsby = ratePolsby;
3147
3296
  function rateCompactness(rS, ppS) {
3148
3297
  const rW = C.reockWeight();
3149
3298
  const ppW = C.polsbyWeight();
3150
3299
  const rating = Math.round(((rS * rW) + (ppS * ppW)) / (rW + ppW));
3151
3300
  return rating;
3152
3301
  }
3153
- exports.rateCompactness = rateCompactness;
3154
3302
  // RATE SPLITTING
3155
3303
  exports.maxSplitting = 1.20; // 90–10 => 95–5 splits
3156
3304
  exports.minSplitting = 1.00; // No splits still vs. 97–03 splits
@@ -3164,7 +3312,6 @@ function bestTarget(n, m) {
3164
3312
  const target = (w1 * exports.maxSplitting) + (w2 * exports.minSplitting);
3165
3313
  return target;
3166
3314
  }
3167
- exports.bestTarget = bestTarget;
3168
3315
  // Rating county- & district-splitting are inverses of each other.
3169
3316
  // Sometimes counties >> districts; sometimes counties << districts.
3170
3317
  function rateCountySplitting(rawCountySplitting, nCounties, nDistricts) {
@@ -3182,7 +3329,6 @@ function rateCountySplitting(rawCountySplitting, nCounties, nDistricts) {
3182
3329
  rating = 100 - 1;
3183
3330
  return rating;
3184
3331
  }
3185
- exports.rateCountySplitting = rateCountySplitting;
3186
3332
  function rateDistrictSplitting(rawDistrictSplitting, nCounties, nDistricts) {
3187
3333
  const _normalizer = new normalize_1.Normalizer(rawDistrictSplitting);
3188
3334
  // The practical ideal raw measurement depends on the # of counties & districts
@@ -3198,7 +3344,6 @@ function rateDistrictSplitting(rawDistrictSplitting, nCounties, nDistricts) {
3198
3344
  rating = 100 - 1;
3199
3345
  return rating;
3200
3346
  }
3201
- exports.rateDistrictSplitting = rateDistrictSplitting;
3202
3347
  function rateSplitting(csS, dsS) {
3203
3348
  const csW = C.countySplittingWeight();
3204
3349
  const dsW = C.districtSplittingWeight();
@@ -3209,7 +3354,6 @@ function rateSplitting(csS, dsS) {
3209
3354
  rating = 100 - 1;
3210
3355
  return rating;
3211
3356
  }
3212
- exports.rateSplitting = rateSplitting;
3213
3357
  // RATE SPLITTING - Legacy routines for original splitting ratings that didn't handle state legislative maps properly
3214
3358
  function rateCountySplittingLegacy(rawCountySplitting, nCounties, nDistricts, bLD = false) {
3215
3359
  const _normalizer = new normalize_1.Normalizer(rawCountySplitting);
@@ -3226,7 +3370,6 @@ function rateCountySplittingLegacy(rawCountySplitting, nCounties, nDistricts, bL
3226
3370
  rating = 100 - 1;
3227
3371
  return rating;
3228
3372
  }
3229
- exports.rateCountySplittingLegacy = rateCountySplittingLegacy;
3230
3373
  function countySplitBest(nCounties, nDistricts, bLD = false) {
3231
3374
  const districtType = (bLD) ? 1 /* T.DistrictType.StateLegislative */ : 0 /* T.DistrictType.Congressional */;
3232
3375
  const practicalBest = C.countySplittingRange(districtType)[C.BEG];
@@ -3234,7 +3377,6 @@ function countySplitBest(nCounties, nDistricts, bLD = false) {
3234
3377
  const threshold = ((nAllowableSplits * practicalBest) + ((nCounties - nAllowableSplits) * 1.0)) / nCounties;
3235
3378
  return threshold;
3236
3379
  }
3237
- exports.countySplitBest = countySplitBest;
3238
3380
  function countySplitWorst(avgBest, bLD = false) {
3239
3381
  const districtType = (bLD) ? 1 /* T.DistrictType.StateLegislative */ : 0 /* T.DistrictType.Congressional */;
3240
3382
  const singleBest = C.countySplittingRange(districtType)[C.BEG];
@@ -3243,7 +3385,6 @@ function countySplitWorst(avgBest, bLD = false) {
3243
3385
  const avgWorst = avgBest * (singleWorst / singleBest);
3244
3386
  return avgWorst;
3245
3387
  }
3246
- exports.countySplitWorst = countySplitWorst;
3247
3388
  function rateDistrictSplittingLegacy(rawDistrictSplitting, bLD = false) {
3248
3389
  const districtType = (bLD) ? 1 /* T.DistrictType.StateLegislative */ : 0 /* T.DistrictType.Congressional */;
3249
3390
  const _normalizer = new normalize_1.Normalizer(rawDistrictSplitting);
@@ -3259,21 +3400,18 @@ function rateDistrictSplittingLegacy(rawDistrictSplitting, bLD = false) {
3259
3400
  rating = 100 - 1;
3260
3401
  return rating;
3261
3402
  }
3262
- exports.rateDistrictSplittingLegacy = rateDistrictSplittingLegacy;
3263
3403
  function rateSplittingLegacy(csS, dsS) {
3264
3404
  const csW = C.countySplittingWeight();
3265
3405
  const dsW = C.districtSplittingWeight();
3266
3406
  const rating = Math.round(((csS * csW) + (dsS * dsW)) / (csW + dsW));
3267
3407
  return rating;
3268
3408
  }
3269
- exports.rateSplittingLegacy = rateSplittingLegacy;
3270
3409
  function adjustSplittingRating(rating, rawCountySplitting, rawDistrictSplitting) {
3271
3410
  // 09-07-21 - Preserve max value (100) for only when no districts are split
3272
3411
  if ((rating == 100) && ((rawCountySplitting > 1.0) || (rawDistrictSplitting > 1.0)))
3273
3412
  rating = 100 - 1;
3274
3413
  return rating;
3275
3414
  }
3276
- exports.adjustSplittingRating = adjustSplittingRating;
3277
3415
  // END
3278
3416
 
3279
3417
 
@@ -3305,13 +3443,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
3305
3443
  }) : function(o, v) {
3306
3444
  o["default"] = v;
3307
3445
  });
3308
- var __importStar = (this && this.__importStar) || function (mod) {
3309
- if (mod && mod.__esModule) return mod;
3310
- var result = {};
3311
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
3312
- __setModuleDefault(result, mod);
3313
- return result;
3314
- };
3446
+ var __importStar = (this && this.__importStar) || (function () {
3447
+ var ownKeys = function(o) {
3448
+ ownKeys = Object.getOwnPropertyNames || function (o) {
3449
+ var ar = [];
3450
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
3451
+ return ar;
3452
+ };
3453
+ return ownKeys(o);
3454
+ };
3455
+ return function (mod) {
3456
+ if (mod && mod.__esModule) return mod;
3457
+ var result = {};
3458
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
3459
+ __setModuleDefault(result, mod);
3460
+ return result;
3461
+ };
3462
+ })();
3315
3463
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3316
3464
  exports.Normalizer = void 0;
3317
3465
  const S = __importStar(__webpack_require__(/*! ./settings */ "./lib/rate/settings.ts"));
@@ -3463,15 +3611,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
3463
3611
  }) : function(o, v) {
3464
3612
  o["default"] = v;
3465
3613
  });
3466
- var __importStar = (this && this.__importStar) || function (mod) {
3467
- if (mod && mod.__esModule) return mod;
3468
- var result = {};
3469
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
3470
- __setModuleDefault(result, mod);
3471
- return result;
3472
- };
3614
+ var __importStar = (this && this.__importStar) || (function () {
3615
+ var ownKeys = function(o) {
3616
+ ownKeys = Object.getOwnPropertyNames || function (o) {
3617
+ var ar = [];
3618
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
3619
+ return ar;
3620
+ };
3621
+ return ownKeys(o);
3622
+ };
3623
+ return function (mod) {
3624
+ if (mod && mod.__esModule) return mod;
3625
+ var result = {};
3626
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
3627
+ __setModuleDefault(result, mod);
3628
+ return result;
3629
+ };
3630
+ })();
3473
3631
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3474
- exports.calcCOISplitting = exports.effectiveSplits = exports.uncertaintyOfMembership = void 0;
3632
+ exports.uncertaintyOfMembership = uncertaintyOfMembership;
3633
+ exports.effectiveSplits = effectiveSplits;
3634
+ exports.calcCOISplitting = calcCOISplitting;
3475
3635
  const U = __importStar(__webpack_require__(/*! ./utils */ "./lib/splitting/utils.ts"));
3476
3636
  function uncertaintyOfMembership(splits) {
3477
3637
  // 07-29-21 -- Filter out 0% splits
@@ -3481,7 +3641,6 @@ function uncertaintyOfMembership(splits) {
3481
3641
  result = 0;
3482
3642
  return result;
3483
3643
  }
3484
- exports.uncertaintyOfMembership = uncertaintyOfMembership;
3485
3644
  function effectiveSplits(splits) {
3486
3645
  // 07-29-21 -- Filter out 0% splits
3487
3646
  const intermediate = splits.filter(x => x > 0).map(x => Math.pow(x, 2));
@@ -3490,7 +3649,6 @@ function effectiveSplits(splits) {
3490
3649
  result = 0;
3491
3650
  return result;
3492
3651
  }
3493
- exports.effectiveSplits = effectiveSplits;
3494
3652
  // CLI & OTHER USERS
3495
3653
  function calcCOISplitting(communities) {
3496
3654
  let byCOI = [];
@@ -3509,7 +3667,6 @@ function calcCOISplitting(communities) {
3509
3667
  };
3510
3668
  return analysis;
3511
3669
  }
3512
- exports.calcCOISplitting = calcCOISplitting;
3513
3670
 
3514
3671
 
3515
3672
  /***/ }),
@@ -3540,15 +3697,43 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
3540
3697
  }) : function(o, v) {
3541
3698
  o["default"] = v;
3542
3699
  });
3543
- var __importStar = (this && this.__importStar) || function (mod) {
3544
- if (mod && mod.__esModule) return mod;
3545
- var result = {};
3546
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
3547
- __setModuleDefault(result, mod);
3548
- return result;
3549
- };
3700
+ var __importStar = (this && this.__importStar) || (function () {
3701
+ var ownKeys = function(o) {
3702
+ ownKeys = Object.getOwnPropertyNames || function (o) {
3703
+ var ar = [];
3704
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
3705
+ return ar;
3706
+ };
3707
+ return ownKeys(o);
3708
+ };
3709
+ return function (mod) {
3710
+ if (mod && mod.__esModule) return mod;
3711
+ var result = {};
3712
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
3713
+ __setModuleDefault(result, mod);
3714
+ return result;
3715
+ };
3716
+ })();
3550
3717
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3551
- exports.calcSplitting = exports.districtSplitting = exports.districtSplitScore = exports.countySplitting = exports.countySplitScore = exports.splitScore = exports.calcDistrictFractions = exports.calcCountyFractions = exports.calcDistrictWeights = exports.calcCountyWeights = exports.reduceDSplits = exports.reduceCSplits = exports.totalDistricts = exports.totalCounties = exports._calcDistrictSplitting = exports._calcDistrictSplittingReduced = exports._calcCountySplitting = exports._calcCountySplittingReduced = exports.makeSplittingScorecard = void 0;
3718
+ exports.makeSplittingScorecard = makeSplittingScorecard;
3719
+ exports._calcCountySplittingReduced = _calcCountySplittingReduced;
3720
+ exports._calcCountySplitting = _calcCountySplitting;
3721
+ exports._calcDistrictSplittingReduced = _calcDistrictSplittingReduced;
3722
+ exports._calcDistrictSplitting = _calcDistrictSplitting;
3723
+ exports.totalCounties = totalCounties;
3724
+ exports.totalDistricts = totalDistricts;
3725
+ exports.reduceCSplits = reduceCSplits;
3726
+ exports.reduceDSplits = reduceDSplits;
3727
+ exports.calcCountyWeights = calcCountyWeights;
3728
+ exports.calcDistrictWeights = calcDistrictWeights;
3729
+ exports.calcCountyFractions = calcCountyFractions;
3730
+ exports.calcDistrictFractions = calcDistrictFractions;
3731
+ exports.splitScore = splitScore;
3732
+ exports.countySplitScore = countySplitScore;
3733
+ exports.countySplitting = countySplitting;
3734
+ exports.districtSplitScore = districtSplitScore;
3735
+ exports.districtSplitting = districtSplitting;
3736
+ exports.calcSplitting = calcSplitting;
3552
3737
  const U = __importStar(__webpack_require__(/*! ../utils/all */ "./lib/utils/all.ts"));
3553
3738
  function makeSplittingScorecard(CxD, bLog = false) {
3554
3739
  const dT = totalDistricts(CxD);
@@ -3563,7 +3748,6 @@ function makeSplittingScorecard(CxD, bLog = false) {
3563
3748
  };
3564
3749
  return s;
3565
3750
  }
3566
- exports.makeSplittingScorecard = makeSplittingScorecard;
3567
3751
  // CALCULATE ENHANCED SQRT ENTROPY METRIC -- INTERNAL FUNCTIONS
3568
3752
  function _calcCountySplittingReduced(CxD, districtTotals, countyTotals, bLD = false) {
3569
3753
  const rC = reduceCSplits(CxD, districtTotals);
@@ -3572,14 +3756,12 @@ function _calcCountySplittingReduced(CxD, districtTotals, countyTotals, bLD = fa
3572
3756
  const rawSqEnt_DC = countySplitting(f, w);
3573
3757
  return rawSqEnt_DC;
3574
3758
  }
3575
- exports._calcCountySplittingReduced = _calcCountySplittingReduced;
3576
3759
  function _calcCountySplitting(CxD, countyTotals, bLog = false) {
3577
3760
  const f = calcCountyFractions(CxD, countyTotals);
3578
3761
  const w = calcCountyWeights(countyTotals);
3579
3762
  const SqEnt_DC = countySplitting(f, w, bLog);
3580
3763
  return SqEnt_DC;
3581
3764
  }
3582
- exports._calcCountySplitting = _calcCountySplitting;
3583
3765
  function _calcDistrictSplittingReduced(CxD, districtTotals, countyTotals, bLD = false) {
3584
3766
  const rD = reduceDSplits(CxD, countyTotals);
3585
3767
  const g = calcDistrictFractions(rD, districtTotals);
@@ -3587,14 +3769,12 @@ function _calcDistrictSplittingReduced(CxD, districtTotals, countyTotals, bLD =
3587
3769
  const rawSqEnt_CD = districtSplitting(g, x);
3588
3770
  return rawSqEnt_CD;
3589
3771
  }
3590
- exports._calcDistrictSplittingReduced = _calcDistrictSplittingReduced;
3591
3772
  function _calcDistrictSplitting(CxD, districtTotals, bLog = false) {
3592
3773
  const g = calcDistrictFractions(CxD, districtTotals);
3593
3774
  const x = calcDistrictWeights(districtTotals);
3594
3775
  const SqEnt_CD = districtSplitting(g, x, bLog);
3595
3776
  return SqEnt_CD;
3596
3777
  }
3597
- exports._calcDistrictSplitting = _calcDistrictSplitting;
3598
3778
  // HELPERS
3599
3779
  function totalCounties(CxD) {
3600
3780
  const nC = CxD[0].length;
@@ -3607,7 +3787,6 @@ function totalCounties(CxD) {
3607
3787
  }
3608
3788
  return cT;
3609
3789
  }
3610
- exports.totalCounties = totalCounties;
3611
3790
  function totalDistricts(CxD) {
3612
3791
  const nC = CxD[0].length;
3613
3792
  const nD = CxD.length;
@@ -3619,7 +3798,6 @@ function totalDistricts(CxD) {
3619
3798
  }
3620
3799
  return dT;
3621
3800
  }
3622
- exports.totalDistricts = totalDistricts;
3623
3801
  // NOTE - The county-district splits and the county & district totals may all,
3624
3802
  // in general, be fractional/decimal numbers as opposed to integers, due to
3625
3803
  // dissaggregation & re-aggregation. Hence, comparisons need to approximate
@@ -3647,7 +3825,6 @@ function reduceCSplits(CxD, districtTotals) {
3647
3825
  }
3648
3826
  return CxDreducedC;
3649
3827
  }
3650
- exports.reduceCSplits = reduceCSplits;
3651
3828
  // Consolidate *whole counties* (w/in one district) LEFT into the dummy county 0,
3652
3829
  // district by district.
3653
3830
  function reduceDSplits(CxD, countyTotals) {
@@ -3670,7 +3847,6 @@ function reduceDSplits(CxD, countyTotals) {
3670
3847
  }
3671
3848
  return CxDreducedD;
3672
3849
  }
3673
- exports.reduceDSplits = reduceDSplits;
3674
3850
  function calcCountyWeights(countyTotals) {
3675
3851
  let nC = countyTotals.length;
3676
3852
  let cTotal = U.sumArray(countyTotals);
@@ -3680,7 +3856,6 @@ function calcCountyWeights(countyTotals) {
3680
3856
  }
3681
3857
  return w;
3682
3858
  }
3683
- exports.calcCountyWeights = calcCountyWeights;
3684
3859
  function calcDistrictWeights(districtTotals) {
3685
3860
  let nD = districtTotals.length;
3686
3861
  let dTotal = U.sumArray(districtTotals);
@@ -3690,7 +3865,6 @@ function calcDistrictWeights(districtTotals) {
3690
3865
  }
3691
3866
  return x;
3692
3867
  }
3693
- exports.calcDistrictWeights = calcDistrictWeights;
3694
3868
  function calcCountyFractions(CxD, countyTotals) {
3695
3869
  let nD = CxD.length;
3696
3870
  let nC = CxD[0].length;
@@ -3707,7 +3881,6 @@ function calcCountyFractions(CxD, countyTotals) {
3707
3881
  }
3708
3882
  return f;
3709
3883
  }
3710
- exports.calcCountyFractions = calcCountyFractions;
3711
3884
  function calcDistrictFractions(CxD, districtTotals) {
3712
3885
  let nD = CxD.length;
3713
3886
  let nC = CxD[0].length;
@@ -3724,7 +3897,6 @@ function calcDistrictFractions(CxD, districtTotals) {
3724
3897
  }
3725
3898
  return g;
3726
3899
  }
3727
- exports.calcDistrictFractions = calcDistrictFractions;
3728
3900
  function splitScore(splits) {
3729
3901
  let e;
3730
3902
  if (splits.length > 0) {
@@ -3735,7 +3907,6 @@ function splitScore(splits) {
3735
3907
  }
3736
3908
  return e;
3737
3909
  }
3738
- exports.splitScore = splitScore;
3739
3910
  // For all districts in a county, sum the split score.
3740
3911
  function countySplitScore(j, f, bLog = false) {
3741
3912
  const numD = f.length;
@@ -3746,7 +3917,6 @@ function countySplitScore(j, f, bLog = false) {
3746
3917
  const score = splitScore(splits);
3747
3918
  return score;
3748
3919
  }
3749
- exports.countySplitScore = countySplitScore;
3750
3920
  // For all counties, sum the weighted county splits.
3751
3921
  function countySplitting(f, w, bLog = false) {
3752
3922
  const numC = f[0].length;
@@ -3759,7 +3929,6 @@ function countySplitting(f, w, bLog = false) {
3759
3929
  }
3760
3930
  return e;
3761
3931
  }
3762
- exports.countySplitting = countySplitting;
3763
3932
  // For all counties in a district, sum the split score.
3764
3933
  function districtSplitScore(i, g, bLog = false) {
3765
3934
  const numC = g[0].length;
@@ -3770,7 +3939,6 @@ function districtSplitScore(i, g, bLog = false) {
3770
3939
  const score = splitScore(splits);
3771
3940
  return score;
3772
3941
  }
3773
- exports.districtSplitScore = districtSplitScore;
3774
3942
  // For all districts, sum the weighted district splits.
3775
3943
  function districtSplitting(g, x, bLog = false) {
3776
3944
  const numD = g.length;
@@ -3783,7 +3951,6 @@ function districtSplitting(g, x, bLog = false) {
3783
3951
  }
3784
3952
  return e;
3785
3953
  }
3786
- exports.districtSplitting = districtSplitting;
3787
3954
  // CLI & OTHER USERS
3788
3955
  function calcSplitting(CxD) {
3789
3956
  const dT = totalDistricts(CxD);
@@ -3796,7 +3963,6 @@ function calcSplitting(CxD) {
3796
3963
  };
3797
3964
  return out;
3798
3965
  }
3799
- exports.calcSplitting = calcSplitting;
3800
3966
 
3801
3967
 
3802
3968
  /***/ }),
@@ -3809,11 +3975,10 @@ exports.calcSplitting = calcSplitting;
3809
3975
 
3810
3976
 
3811
3977
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3812
- exports.isMinusZero = void 0;
3978
+ exports.isMinusZero = isMinusZero;
3813
3979
  function isMinusZero(value) {
3814
3980
  return 1 / value === -Infinity;
3815
3981
  }
3816
- exports.isMinusZero = isMinusZero;
3817
3982
 
3818
3983
 
3819
3984
  /***/ }),
@@ -3873,32 +4038,46 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
3873
4038
  }) : function(o, v) {
3874
4039
  o["default"] = v;
3875
4040
  });
3876
- var __importStar = (this && this.__importStar) || function (mod) {
3877
- if (mod && mod.__esModule) return mod;
3878
- var result = {};
3879
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
3880
- __setModuleDefault(result, mod);
3881
- return result;
3882
- };
4041
+ var __importStar = (this && this.__importStar) || (function () {
4042
+ var ownKeys = function(o) {
4043
+ ownKeys = Object.getOwnPropertyNames || function (o) {
4044
+ var ar = [];
4045
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
4046
+ return ar;
4047
+ };
4048
+ return ownKeys(o);
4049
+ };
4050
+ return function (mod) {
4051
+ if (mod && mod.__esModule) return mod;
4052
+ var result = {};
4053
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
4054
+ __setModuleDefault(result, mod);
4055
+ return result;
4056
+ };
4057
+ })();
3883
4058
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3884
- exports.isObjectEmpty = exports.keyExists = exports.isArrayEmpty = exports.initArray = exports.medianArray = exports.maxArray = exports.minArray = exports.avgArray = exports.sumArray = void 0;
4059
+ exports.sumArray = sumArray;
4060
+ exports.avgArray = avgArray;
4061
+ exports.minArray = minArray;
4062
+ exports.maxArray = maxArray;
4063
+ exports.medianArray = medianArray;
4064
+ exports.initArray = initArray;
4065
+ exports.isArrayEmpty = isArrayEmpty;
4066
+ exports.keyExists = keyExists;
4067
+ exports.isObjectEmpty = isObjectEmpty;
3885
4068
  const U = __importStar(__webpack_require__(/*! ./general */ "./lib/utils/general.ts"));
3886
4069
  function sumArray(arr) {
3887
4070
  return arr.reduce((a, b) => a + b, 0);
3888
4071
  }
3889
- exports.sumArray = sumArray;
3890
4072
  function avgArray(arr) {
3891
4073
  return (arr.reduce((a, b) => a + b, 0)) / arr.length;
3892
4074
  }
3893
- exports.avgArray = avgArray;
3894
4075
  function minArray(arr) {
3895
4076
  return Math.min(...arr);
3896
4077
  }
3897
- exports.minArray = minArray;
3898
4078
  function maxArray(arr) {
3899
4079
  return Math.max(...arr);
3900
4080
  }
3901
- exports.maxArray = maxArray;
3902
4081
  // Modified from https://jsfiddle.net/Lucky500/3sy5au0c/
3903
4082
  // NOTE - Copy the array, because arr.sort() sorts in place!
3904
4083
  function medianArray(arr) {
@@ -3913,25 +4092,20 @@ function medianArray(arr) {
3913
4092
  return copyArr[half];
3914
4093
  return (copyArr[half - 1] + copyArr[half]) / 2.0;
3915
4094
  }
3916
- exports.medianArray = medianArray;
3917
4095
  function initArray(n, value) {
3918
4096
  return Array.from(Array(n), () => value);
3919
4097
  }
3920
- exports.initArray = initArray;
3921
4098
  function isArrayEmpty(a) {
3922
4099
  if (a === undefined || a.length == 0)
3923
4100
  return true;
3924
4101
  return false;
3925
4102
  }
3926
- exports.isArrayEmpty = isArrayEmpty;
3927
4103
  function keyExists(k, o) {
3928
4104
  return k in o;
3929
4105
  }
3930
- exports.keyExists = keyExists;
3931
4106
  function isObjectEmpty(o) {
3932
4107
  return Object.keys(o).length === 0;
3933
4108
  }
3934
- exports.isObjectEmpty = isObjectEmpty;
3935
4109
 
3936
4110
 
3937
4111
  /***/ }),
@@ -3947,14 +4121,14 @@ exports.isObjectEmpty = isObjectEmpty;
3947
4121
  // GENERAL UTILITIES
3948
4122
  //
3949
4123
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3950
- exports.deepCopy = exports.areRoughlyEqual = void 0;
4124
+ exports.areRoughlyEqual = areRoughlyEqual;
4125
+ exports.deepCopy = deepCopy;
3951
4126
  // Deal with decimal census "counts" due to disagg/re-agg
3952
4127
  function areRoughlyEqual(x, y, tolerance) {
3953
4128
  let delta = Math.abs(x - y);
3954
4129
  let result = (delta < tolerance) ? true : false;
3955
4130
  return result;
3956
4131
  }
3957
- exports.areRoughlyEqual = areRoughlyEqual;
3958
4132
  function deepCopy(src) {
3959
4133
  if (Array.isArray(src)) {
3960
4134
  let dst = [];
@@ -3972,7 +4146,6 @@ function deepCopy(src) {
3972
4146
  else
3973
4147
  return src;
3974
4148
  }
3975
- exports.deepCopy = deepCopy;
3976
4149
 
3977
4150
 
3978
4151
  /***/ }),
@@ -4006,16 +4179,6 @@ exports.EQUAL_TOLERANCE = exports.AVERAGE_BLOCK_SIZE / 2;
4006
4179
 
4007
4180
  module.exports = require("@dra2020/baseclient");
4008
4181
 
4009
- /***/ }),
4010
-
4011
- /***/ "./lib/rate/dra-config.json":
4012
- /*!**********************************!*\
4013
- !*** ./lib/rate/dra-config.json ***!
4014
- \**********************************/
4015
- /***/ ((module) => {
4016
-
4017
- module.exports = JSON.parse('{"partisan":{"bias":{"range":[0,0.2]},"competitiveness":{"range":[0,0.75],"distribution":[0.25,0.75],"simpleRange":[0.45,0.55],"weight":[0,20]},"bonus":2},"minority":{"range":[0.37,0.5],"distribution":[0.25,0.75],"shift":[0.15,0.5],"coalition":{"weight":0.5}},"compactness":{"reock":{"range":[0.25,0.5],"weight":50},"polsby":{"range":[0.1,0.5],"weight":50}},"splitting":{"county":{"range":[[1.26,1.68],[1.09,1.45]],"weight":50},"district":{"range":[[1.26,1.68],[1.09,1.45]],"weight":50}},"popdev":{"range":[[0.0075,0.002],[0.1,-1]]}}');
4018
-
4019
4182
  /***/ })
4020
4183
 
4021
4184
  /******/ });