@dra2020/dra-analytics 3.3.5 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Dave's Redistricting
3
+ Copyright (c) 2021-2022 Dave's Redistricting, LLC.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -44,6 +44,10 @@ The analytics in DRA include metrics favored by [many scholars](./docs/attributi
44
44
 
45
45
  A [command-line interface](./docs/cli.md) (CLI) was added in v3.
46
46
 
47
+ ## Updates
48
+
49
+ - 12/18/21 -- Added multi-member district (MMD) support to makePopulationScorecard().
50
+
47
51
  ## Build status for master branch
48
52
 
49
53
  [![CircleCI](https://circleci.com/gh/dra2020/dra-graph.svg?style=svg&circle-token=5c5fdd1ea8b6aa5fc80ec7657b805b3953c58e00)](https://circleci.com/gh/dra2020/dra-analytics)
@@ -7,7 +7,7 @@
7
7
  exports["dra-analytics"] = factory();
8
8
  else
9
9
  root["dra-analytics"] = factory();
10
- })(global, function() {
10
+ })(global, () => {
11
11
  return /******/ (() => { // webpackBootstrap
12
12
  /******/ "use strict";
13
13
  /******/ var __webpack_modules__ = ({
@@ -21,7 +21,11 @@ return /******/ (() => { // webpackBootstrap
21
21
 
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];
@@ -263,7 +267,11 @@ Object.defineProperty(exports, "deepCopy", ({ enumerable: true, get: function ()
263
267
 
264
268
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
265
269
  if (k2 === undefined) k2 = k;
266
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
270
+ var desc = Object.getOwnPropertyDescriptor(m, k);
271
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
272
+ desc = { enumerable: true, get: function() { return m[k]; } };
273
+ }
274
+ Object.defineProperty(o, k2, desc);
267
275
  }) : (function(o, m, k, k2) {
268
276
  if (k2 === undefined) k2 = k;
269
277
  o[k2] = m[k];
@@ -298,7 +306,7 @@ const dra_ratings_1 = __webpack_require__(/*! ../rate/dra-ratings */ "./lib/rate
298
306
  // Use this to get average Reock, Polsby-Popper, and KIWYSI compactness and by district for a set of shapes
299
307
  // This is used by DRA
300
308
  function makeCompactnessScorecard(shapes, bLog = false) {
301
- const pca = 0 /* Revised */;
309
+ const pca = 0 /* T.PCAModel.Revised */;
302
310
  const options = undefined;
303
311
  // For calculating averages of by-district values
304
312
  let totReock = 0;
@@ -352,7 +360,7 @@ exports.makeCompactnessScorecard = makeCompactnessScorecard;
352
360
  // Calculate Reock & Polsby–Popper for a shape using the typical Cartesian (flat earth) calculations.
353
361
  // Also calculate the "know it when you see it" rank (smaller is better) that models human perceptions of compactness.
354
362
  function calcCompactness(shapes) {
355
- const pca = 0 /* Revised */;
363
+ const pca = 0 /* T.PCAModel.Revised */;
356
364
  const options = undefined;
357
365
  // For calculating averages of by-district values
358
366
  let totReock = 0;
@@ -622,7 +630,11 @@ exports.featureizePoly = featureizePoly;
622
630
  //
623
631
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
624
632
  if (k2 === undefined) k2 = k;
625
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
633
+ var desc = Object.getOwnPropertyDescriptor(m, k);
634
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
635
+ desc = { enumerable: true, get: function() { return m[k]; } };
636
+ }
637
+ Object.defineProperty(o, k2, desc);
626
638
  }) : (function(o, m, k, k2) {
627
639
  if (k2 === undefined) k2 = k;
628
640
  o[k2] = m[k];
@@ -674,7 +686,7 @@ exports.kiwysiScoreShapes = kiwysiScoreShapes;
674
686
  // Use this to get KIWYSI compactness features and scores ("ranks") for a set of shapes
675
687
  // Note - These calculations use the geodesic (curved earth) model
676
688
  function calcKIWYSICompactness(shapes) {
677
- const pca = 0 /* Revised */;
689
+ const pca = 0 /* T.PCAModel.Revised */;
678
690
  const options = undefined;
679
691
  let totKIWYSI = 0;
680
692
  let byDistrict = [];
@@ -707,7 +719,7 @@ function calcKIWYSICompactness(shapes) {
707
719
  exports.calcKIWYSICompactness = calcKIWYSICompactness;
708
720
  // KIWYSI SCORE THE FEATURES FROM A FEATURE-IZED SHAPE
709
721
  function scoreFeatureSet(features, pca) {
710
- if (pca == 0 /* Revised */)
722
+ if (pca == 0 /* T.PCAModel.Revised */)
711
723
  return applyPCAModel(features);
712
724
  else
713
725
  return applyPCAModel_ORIGINAL(features);
@@ -801,7 +813,11 @@ function protect(condition, message) {
801
813
 
802
814
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
803
815
  if (k2 === undefined) k2 = k;
804
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
816
+ var desc = Object.getOwnPropertyDescriptor(m, k);
817
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
818
+ desc = { enumerable: true, get: function() { return m[k]; } };
819
+ }
820
+ Object.defineProperty(o, k2, desc);
805
821
  }) : (function(o, m, k, k2) {
806
822
  if (k2 === undefined) k2 = k;
807
823
  o[k2] = m[k];
@@ -828,7 +844,11 @@ __exportStar(__webpack_require__(/*! ./population */ "./lib/equal/population.ts"
828
844
  //
829
845
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
830
846
  if (k2 === undefined) k2 = k;
831
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
847
+ var desc = Object.getOwnPropertyDescriptor(m, k);
848
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
849
+ desc = { enumerable: true, get: function() { return m[k]; } };
850
+ }
851
+ Object.defineProperty(o, k2, desc);
832
852
  }) : (function(o, m, k, k2) {
833
853
  if (k2 === undefined) k2 = k;
834
854
  o[k2] = m[k];
@@ -849,6 +869,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
849
869
  exports.makePopulationScorecard = exports.isRoughlyEqual = exports.calcPopulationDeviation = void 0;
850
870
  const C = __importStar(__webpack_require__(/*! ../rate/dra-config */ "./lib/rate/dra-config.ts"));
851
871
  const U = __importStar(__webpack_require__(/*! ../utils/all */ "./lib/utils/all.ts"));
872
+ // MMD - This is the same for SMD & MMD. It's the calculation of min, max, and target size that differs.
852
873
  function calcPopulationDeviation(max, min, targetSize) {
853
874
  return (max - min) / targetSize; // Don't trim the result here!
854
875
  }
@@ -858,10 +879,35 @@ function isRoughlyEqual(devation, bLegislative) {
858
879
  return (devation <= threshold) ? true : false;
859
880
  }
860
881
  exports.isRoughlyEqual = isRoughlyEqual;
861
- function makePopulationScorecard(totPopByDistrict, targetSize, bLegislative, bLog = false) {
862
- const nonEmptyDistricts = totPopByDistrict.filter(x => x > 0);
882
+ // MMD
883
+ // - Add optional # of reps per district.
884
+ // - Assume targetSize has been calculated correctly per # of reps not districts.
885
+ // - If it exists, handle the MMD-specific calculations.
886
+ function makePopulationScorecard(totPopByDistrict, targetSize, bLegislative, repsByDistrict, bLog = false) {
887
+ const nDistricts = totPopByDistrict.length;
888
+ // MMD - Validate reps per district input
889
+ if (repsByDistrict) {
890
+ if (repsByDistrict.length != nDistricts)
891
+ throw new Error("Mismatched #'s of districts passed to makePopulationScorecard()!");
892
+ if (repsByDistrict.includes(0))
893
+ throw new Error("Zero reps for a district passed to makePopulationScorecard()!");
894
+ // Assume a positive integer # of reps per district
895
+ }
896
+ // MMD - Figure out the type of districts, SMD or MMD.
897
+ const nReps = (repsByDistrict) ? repsByDistrict.reduce((a, b) => a + b, 0) : nDistricts;
898
+ const bSMD = (!repsByDistrict || (nReps == nDistricts)) ? true : false;
899
+ // MMD - Generalize populations for non-empty districts to be per rep.
900
+ // const nonEmptyDistricts = totPopByDistrict.filter(x => x > 0);
901
+ let popPerRep = U.deepCopy(totPopByDistrict);
902
+ if (!bSMD && repsByDistrict) {
903
+ for (let i = 0; i < nDistricts; i += 1) {
904
+ popPerRep[i] = totPopByDistrict[i] / repsByDistrict[i];
905
+ }
906
+ }
907
+ const nonEmptyDistricts = popPerRep.filter(x => x > 0);
863
908
  let min = 0;
864
909
  let max = 0;
910
+ // MMD - This is already generalized, because nonEmptyDistricts is generalized.
865
911
  if (nonEmptyDistricts.length > 1) {
866
912
  min = U.minArray(nonEmptyDistricts);
867
913
  max = U.maxArray(nonEmptyDistricts);
@@ -898,7 +944,11 @@ exports.makePopulationScorecard = makePopulationScorecard;
898
944
  // Export everything here -- restrict package exports in all/graph.ts
899
945
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
900
946
  if (k2 === undefined) k2 = k;
901
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
947
+ var desc = Object.getOwnPropertyDescriptor(m, k);
948
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
949
+ desc = { enumerable: true, get: function() { return m[k]; } };
950
+ }
951
+ Object.defineProperty(o, k2, desc);
902
952
  }) : (function(o, m, k, k2) {
903
953
  if (k2 === undefined) k2 = k;
904
954
  o[k2] = m[k];
@@ -925,7 +975,11 @@ __exportStar(__webpack_require__(/*! ./embedded */ "./lib/graph/embedded.ts"), e
925
975
  //
926
976
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
927
977
  if (k2 === undefined) k2 = k;
928
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
978
+ var desc = Object.getOwnPropertyDescriptor(m, k);
979
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
980
+ desc = { enumerable: true, get: function() { return m[k]; } };
981
+ }
982
+ Object.defineProperty(o, k2, desc);
929
983
  }) : (function(o, m, k, k2) {
930
984
  if (k2 === undefined) k2 = k;
931
985
  o[k2] = m[k];
@@ -988,7 +1042,11 @@ exports.isConnected = isConnected;
988
1042
  //
989
1043
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
990
1044
  if (k2 === undefined) k2 = k;
991
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1045
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1046
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1047
+ desc = { enumerable: true, get: function() { return m[k]; } };
1048
+ }
1049
+ Object.defineProperty(o, k2, desc);
992
1050
  }) : (function(o, m, k, k2) {
993
1051
  if (k2 === undefined) k2 = k;
994
1052
  o[k2] = m[k];
@@ -1077,7 +1135,11 @@ exports.NOT_ASSIGNED = 0;
1077
1135
  //
1078
1136
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1079
1137
  if (k2 === undefined) k2 = k;
1080
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1138
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1139
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1140
+ desc = { enumerable: true, get: function() { return m[k]; } };
1141
+ }
1142
+ Object.defineProperty(o, k2, desc);
1081
1143
  }) : (function(o, m, k, k2) {
1082
1144
  if (k2 === undefined) k2 = k;
1083
1145
  o[k2] = m[k];
@@ -1144,7 +1206,11 @@ exports.invertPlan = invertPlan;
1144
1206
  // Export everything here -- restrict package exports in all/
1145
1207
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1146
1208
  if (k2 === undefined) k2 = k;
1147
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1209
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1210
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1211
+ desc = { enumerable: true, get: function() { return m[k]; } };
1212
+ }
1213
+ Object.defineProperty(o, k2, desc);
1148
1214
  }) : (function(o, m, k, k2) {
1149
1215
  if (k2 === undefined) k2 = k;
1150
1216
  o[k2] = m[k];
@@ -1171,7 +1237,11 @@ __exportStar(__webpack_require__(/*! ./rpv */ "./lib/minority/rpv.ts"), exports)
1171
1237
  //
1172
1238
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1173
1239
  if (k2 === undefined) k2 = k;
1174
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1240
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1241
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1242
+ desc = { enumerable: true, get: function() { return m[k]; } };
1243
+ }
1244
+ Object.defineProperty(o, k2, desc);
1175
1245
  }) : (function(o, m, k, k2) {
1176
1246
  if (k2 === undefined) k2 = k;
1177
1247
  o[k2] = m[k];
@@ -1255,64 +1325,64 @@ exports.makeMinorityScorecard = makeMinorityScorecard;
1255
1325
  // addressed logically by name as opposed to using array indices.
1256
1326
  function convertArrayToTable(a) {
1257
1327
  const minority = {
1258
- pct35_40: a[0 /* Minority */][0 /* L35_40 */],
1259
- pct40_45: a[0 /* Minority */][1 /* L40_45 */],
1260
- pct45_50: a[0 /* Minority */][2 /* L45_50 */],
1261
- pct50_55: a[0 /* Minority */][3 /* L50_55 */],
1262
- pct55_60: a[0 /* Minority */][4 /* L55_60 */],
1263
- pct60Plus: a[0 /* Minority */][5 /* L60Plus */],
1264
- vapPct: a[0 /* Minority */][6 /* VAPPct */],
1265
- propSeats: a[0 /* Minority */][7 /* PropSeats */]
1328
+ pct35_40: a[0 /* Demographic.Minority */][0 /* PivotField.L35_40 */],
1329
+ pct40_45: a[0 /* Demographic.Minority */][1 /* PivotField.L40_45 */],
1330
+ pct45_50: a[0 /* Demographic.Minority */][2 /* PivotField.L45_50 */],
1331
+ pct50_55: a[0 /* Demographic.Minority */][3 /* PivotField.L50_55 */],
1332
+ pct55_60: a[0 /* Demographic.Minority */][4 /* PivotField.L55_60 */],
1333
+ pct60Plus: a[0 /* Demographic.Minority */][5 /* PivotField.L60Plus */],
1334
+ vapPct: a[0 /* Demographic.Minority */][6 /* PivotField.VAPPct */],
1335
+ propSeats: a[0 /* Demographic.Minority */][7 /* PivotField.PropSeats */]
1266
1336
  };
1267
1337
  const black = {
1268
- pct35_40: a[1 /* Black */][0 /* L35_40 */],
1269
- pct40_45: a[1 /* Black */][1 /* L40_45 */],
1270
- pct45_50: a[1 /* Black */][2 /* L45_50 */],
1271
- pct50_55: a[1 /* Black */][3 /* L50_55 */],
1272
- pct55_60: a[1 /* Black */][4 /* L55_60 */],
1273
- pct60Plus: a[1 /* Black */][5 /* L60Plus */],
1274
- vapPct: a[1 /* Black */][6 /* VAPPct */],
1275
- propSeats: a[1 /* Black */][7 /* PropSeats */]
1338
+ pct35_40: a[1 /* Demographic.Black */][0 /* PivotField.L35_40 */],
1339
+ pct40_45: a[1 /* Demographic.Black */][1 /* PivotField.L40_45 */],
1340
+ pct45_50: a[1 /* Demographic.Black */][2 /* PivotField.L45_50 */],
1341
+ pct50_55: a[1 /* Demographic.Black */][3 /* PivotField.L50_55 */],
1342
+ pct55_60: a[1 /* Demographic.Black */][4 /* PivotField.L55_60 */],
1343
+ pct60Plus: a[1 /* Demographic.Black */][5 /* PivotField.L60Plus */],
1344
+ vapPct: a[1 /* Demographic.Black */][6 /* PivotField.VAPPct */],
1345
+ propSeats: a[1 /* Demographic.Black */][7 /* PivotField.PropSeats */]
1276
1346
  };
1277
1347
  const hispanic = {
1278
- pct35_40: a[2 /* Hispanic */][0 /* L35_40 */],
1279
- pct40_45: a[2 /* Hispanic */][1 /* L40_45 */],
1280
- pct45_50: a[2 /* Hispanic */][2 /* L45_50 */],
1281
- pct50_55: a[2 /* Hispanic */][3 /* L50_55 */],
1282
- pct55_60: a[2 /* Hispanic */][4 /* L55_60 */],
1283
- pct60Plus: a[2 /* Hispanic */][5 /* L60Plus */],
1284
- vapPct: a[2 /* Hispanic */][6 /* VAPPct */],
1285
- propSeats: a[2 /* Hispanic */][7 /* PropSeats */]
1348
+ pct35_40: a[2 /* Demographic.Hispanic */][0 /* PivotField.L35_40 */],
1349
+ pct40_45: a[2 /* Demographic.Hispanic */][1 /* PivotField.L40_45 */],
1350
+ pct45_50: a[2 /* Demographic.Hispanic */][2 /* PivotField.L45_50 */],
1351
+ pct50_55: a[2 /* Demographic.Hispanic */][3 /* PivotField.L50_55 */],
1352
+ pct55_60: a[2 /* Demographic.Hispanic */][4 /* PivotField.L55_60 */],
1353
+ pct60Plus: a[2 /* Demographic.Hispanic */][5 /* PivotField.L60Plus */],
1354
+ vapPct: a[2 /* Demographic.Hispanic */][6 /* PivotField.VAPPct */],
1355
+ propSeats: a[2 /* Demographic.Hispanic */][7 /* PivotField.PropSeats */]
1286
1356
  };
1287
1357
  const pacific = {
1288
- pct35_40: a[3 /* Pacific */][0 /* L35_40 */],
1289
- pct40_45: a[3 /* Pacific */][1 /* L40_45 */],
1290
- pct45_50: a[3 /* Pacific */][2 /* L45_50 */],
1291
- pct50_55: a[3 /* Pacific */][3 /* L50_55 */],
1292
- pct55_60: a[3 /* Pacific */][4 /* L55_60 */],
1293
- pct60Plus: a[3 /* Pacific */][5 /* L60Plus */],
1294
- vapPct: a[3 /* Pacific */][6 /* VAPPct */],
1295
- propSeats: a[3 /* Pacific */][7 /* PropSeats */]
1358
+ pct35_40: a[3 /* Demographic.Pacific */][0 /* PivotField.L35_40 */],
1359
+ pct40_45: a[3 /* Demographic.Pacific */][1 /* PivotField.L40_45 */],
1360
+ pct45_50: a[3 /* Demographic.Pacific */][2 /* PivotField.L45_50 */],
1361
+ pct50_55: a[3 /* Demographic.Pacific */][3 /* PivotField.L50_55 */],
1362
+ pct55_60: a[3 /* Demographic.Pacific */][4 /* PivotField.L55_60 */],
1363
+ pct60Plus: a[3 /* Demographic.Pacific */][5 /* PivotField.L60Plus */],
1364
+ vapPct: a[3 /* Demographic.Pacific */][6 /* PivotField.VAPPct */],
1365
+ propSeats: a[3 /* Demographic.Pacific */][7 /* PivotField.PropSeats */]
1296
1366
  };
1297
1367
  const asian = {
1298
- pct35_40: a[4 /* Asian */][0 /* L35_40 */],
1299
- pct40_45: a[4 /* Asian */][1 /* L40_45 */],
1300
- pct45_50: a[4 /* Asian */][2 /* L45_50 */],
1301
- pct50_55: a[4 /* Asian */][3 /* L50_55 */],
1302
- pct55_60: a[4 /* Asian */][4 /* L55_60 */],
1303
- pct60Plus: a[4 /* Asian */][5 /* L60Plus */],
1304
- vapPct: a[4 /* Asian */][6 /* VAPPct */],
1305
- propSeats: a[4 /* Asian */][7 /* PropSeats */]
1368
+ pct35_40: a[4 /* Demographic.Asian */][0 /* PivotField.L35_40 */],
1369
+ pct40_45: a[4 /* Demographic.Asian */][1 /* PivotField.L40_45 */],
1370
+ pct45_50: a[4 /* Demographic.Asian */][2 /* PivotField.L45_50 */],
1371
+ pct50_55: a[4 /* Demographic.Asian */][3 /* PivotField.L50_55 */],
1372
+ pct55_60: a[4 /* Demographic.Asian */][4 /* PivotField.L55_60 */],
1373
+ pct60Plus: a[4 /* Demographic.Asian */][5 /* PivotField.L60Plus */],
1374
+ vapPct: a[4 /* Demographic.Asian */][6 /* PivotField.VAPPct */],
1375
+ propSeats: a[4 /* Demographic.Asian */][7 /* PivotField.PropSeats */]
1306
1376
  };
1307
1377
  const native = {
1308
- pct35_40: a[5 /* Native */][0 /* L35_40 */],
1309
- pct40_45: a[5 /* Native */][1 /* L40_45 */],
1310
- pct45_50: a[5 /* Native */][2 /* L45_50 */],
1311
- pct50_55: a[5 /* Native */][3 /* L50_55 */],
1312
- pct55_60: a[5 /* Native */][4 /* L55_60 */],
1313
- pct60Plus: a[5 /* Native */][5 /* L60Plus */],
1314
- vapPct: a[5 /* Native */][6 /* VAPPct */],
1315
- propSeats: a[5 /* Native */][7 /* PropSeats */]
1378
+ pct35_40: a[5 /* Demographic.Native */][0 /* PivotField.L35_40 */],
1379
+ pct40_45: a[5 /* Demographic.Native */][1 /* PivotField.L40_45 */],
1380
+ pct45_50: a[5 /* Demographic.Native */][2 /* PivotField.L45_50 */],
1381
+ pct50_55: a[5 /* Demographic.Native */][3 /* PivotField.L50_55 */],
1382
+ pct55_60: a[5 /* Demographic.Native */][4 /* PivotField.L55_60 */],
1383
+ pct60Plus: a[5 /* Demographic.Native */][5 /* PivotField.L60Plus */],
1384
+ vapPct: a[5 /* Demographic.Native */][6 /* PivotField.VAPPct */],
1385
+ propSeats: a[5 /* Demographic.Native */][7 /* PivotField.PropSeats */]
1316
1386
  };
1317
1387
  const t = {
1318
1388
  minority: minority,
@@ -1562,7 +1632,11 @@ const invertX = (pt) => { return { x: 1 - pt.x, y: pt.y }; };
1562
1632
  // Export everything here -- restrict package exports in all/partisan.ts
1563
1633
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1564
1634
  if (k2 === undefined) k2 = k;
1565
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1635
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1636
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1637
+ desc = { enumerable: true, get: function() { return m[k]; } };
1638
+ }
1639
+ Object.defineProperty(o, k2, desc);
1566
1640
  }) : (function(o, m, k, k2) {
1567
1641
  if (k2 === undefined) k2 = k;
1568
1642
  o[k2] = m[k];
@@ -1594,7 +1668,7 @@ const bias_1 = __webpack_require__(/*! ../../lib/partisan/bias */ "./lib/partisa
1594
1668
  const responsiveness_1 = __webpack_require__(/*! ../../lib/partisan/responsiveness */ "./lib/partisan/responsiveness.ts");
1595
1669
  const all_1 = __webpack_require__(/*! ../all/all */ "./lib/all/all.ts");
1596
1670
  function makePartisanScorecard(Vf, VfArray, bLog = false) {
1597
- const shift = 0 /* Proportional */;
1671
+ const shift = 0 /* T.Shift.Proportional */;
1598
1672
  const N = VfArray.length;
1599
1673
  const bestS = (0, bias_1.bestSeats)(N, Vf);
1600
1674
  const bestSf = (0, bias_1.bestSeatShare)(bestS, N);
@@ -1720,7 +1794,11 @@ exports.calcPartisanMetrics = calcPartisanMetrics;
1720
1794
  //
1721
1795
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1722
1796
  if (k2 === undefined) k2 = k;
1723
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1797
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1798
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1799
+ desc = { enumerable: true, get: function() { return m[k]; } };
1800
+ }
1801
+ Object.defineProperty(o, k2, desc);
1724
1802
  }) : (function(o, m, k, k2) {
1725
1803
  if (k2 === undefined) k2 = k;
1726
1804
  o[k2] = m[k];
@@ -1908,9 +1986,9 @@ function invertSVPoints(inferredSVpoints) {
1908
1986
  exports.invertSVPoints = invertSVPoints;
1909
1987
  // EFFICIENCY GAP -- note the formulation used. Also, to accommodate turnout bias,
1910
1988
  // we would need to have D & R votes, not just shares.
1911
- function calcEfficiencyGap(Vf, Sf, shareType = 0 /* Democratic */) {
1989
+ function calcEfficiencyGap(Vf, Sf, shareType = 0 /* T.Party.Democratic */) {
1912
1990
  let efficiencyGap;
1913
- if (shareType == 1 /* Republican */) {
1991
+ if (shareType == 1 /* T.Party.Republican */) {
1914
1992
  // NOTE - This is the common formulation:
1915
1993
  //
1916
1994
  // EG = (Sf – 0.5) – (2 × (Vf – 0.5))
@@ -2310,7 +2388,11 @@ describe('erf approximation', () =>
2310
2388
  //
2311
2389
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2312
2390
  if (k2 === undefined) k2 = k;
2313
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
2391
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2392
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2393
+ desc = { enumerable: true, get: function() { return m[k]; } };
2394
+ }
2395
+ Object.defineProperty(o, k2, desc);
2314
2396
  }) : (function(o, m, k, k2) {
2315
2397
  if (k2 === undefined) k2 = k;
2316
2398
  o[k2] = m[k];
@@ -2386,7 +2468,7 @@ function inferSVpoints(Vf, VfArray, shift, range) {
2386
2468
  }
2387
2469
  exports.inferSVpoints = inferSVpoints;
2388
2470
  function shiftDistricts(Vf, VfArray, shiftedVf, shift) {
2389
- if (shift == 0 /* Proportional */)
2471
+ if (shift == 0 /* T.Shift.Proportional */)
2390
2472
  return shiftProportionally(Vf, VfArray, shiftedVf);
2391
2473
  else
2392
2474
  return shiftUniformly(Vf, VfArray, shiftedVf);
@@ -2516,7 +2598,11 @@ exports.fptpWin = fptpWin;
2516
2598
  //
2517
2599
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2518
2600
  if (k2 === undefined) k2 = k;
2519
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
2601
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2602
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2603
+ desc = { enumerable: true, get: function() { return m[k]; } };
2604
+ }
2605
+ Object.defineProperty(o, k2, desc);
2520
2606
  }) : (function(o, m, k, k2) {
2521
2607
  if (k2 === undefined) k2 = k;
2522
2608
  o[k2] = m[k];
@@ -2673,7 +2759,11 @@ exports.findMarginalDistricts = findMarginalDistricts;
2673
2759
 
2674
2760
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2675
2761
  if (k2 === undefined) k2 = k;
2676
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
2762
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2763
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2764
+ desc = { enumerable: true, get: function() { return m[k]; } };
2765
+ }
2766
+ Object.defineProperty(o, k2, desc);
2677
2767
  }) : (function(o, m, k, k2) {
2678
2768
  if (k2 === undefined) k2 = k;
2679
2769
  o[k2] = m[k];
@@ -2828,10 +2918,10 @@ exports.districtSplittingRange = districtSplittingRange;
2828
2918
  // NOTE - Raw ranges, not inverted (i.e., smaller is better)
2829
2919
  // NOTE - This could be optimized to not calc LD values for CD's (or do it once)
2830
2920
  function popdevRange(bLegislative, overridesJSON) {
2831
- const cdRange = config.popdev.range[0 /* Congressional */];
2921
+ const cdRange = config.popdev.range[0 /* T.DistrictType.Congressional */];
2832
2922
  const worstCD = cdRange[exports.BEG];
2833
2923
  const bestCD = cdRange[exports.END];
2834
- const ldRange = config.popdev.range[1 /* StateLegislative */];
2924
+ const ldRange = config.popdev.range[1 /* T.DistrictType.StateLegislative */];
2835
2925
  const iRange = bLegislative ? ldRange : cdRange;
2836
2926
  const worst = iRange[exports.BEG];
2837
2927
  const best = bLegislative ? (bestCD / worstCD) * iRange[exports.BEG] : iRange[exports.END];
@@ -2861,7 +2951,11 @@ exports.popdevThreshold = popdevThreshold;
2861
2951
  //
2862
2952
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2863
2953
  if (k2 === undefined) k2 = k;
2864
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
2954
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2955
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2956
+ desc = { enumerable: true, get: function() { return m[k]; } };
2957
+ }
2958
+ Object.defineProperty(o, k2, desc);
2865
2959
  }) : (function(o, m, k, k2) {
2866
2960
  if (k2 === undefined) k2 = k;
2867
2961
  o[k2] = m[k];
@@ -2883,6 +2977,7 @@ exports.adjustSplittingRating = exports.rateSplittingLegacy = exports.rateDistri
2883
2977
  const C = __importStar(__webpack_require__(/*! ./dra-config */ "./lib/rate/dra-config.ts"));
2884
2978
  const normalize_1 = __webpack_require__(/*! ../rate/normalize */ "./lib/rate/normalize.ts");
2885
2979
  const method_1 = __webpack_require__(/*! ../partisan/method */ "./lib/partisan/method.ts");
2980
+ // MMD - This is already generalized, if deviations have been calculated based on # of reps instead of districts.
2886
2981
  // RATE POPULATION DEVIATION
2887
2982
  function ratePopulationDeviation(rawDeviation, bLegislative) {
2888
2983
  const _normalizer = new normalize_1.Normalizer(rawDeviation);
@@ -3133,7 +3228,7 @@ function rateCountySplittingLegacy(rawCountySplitting, nCounties, nDistricts, bL
3133
3228
  }
3134
3229
  exports.rateCountySplittingLegacy = rateCountySplittingLegacy;
3135
3230
  function countySplitBest(nCounties, nDistricts, bLD = false) {
3136
- const districtType = (bLD) ? 1 /* StateLegislative */ : 0 /* Congressional */;
3231
+ const districtType = (bLD) ? 1 /* T.DistrictType.StateLegislative */ : 0 /* T.DistrictType.Congressional */;
3137
3232
  const practicalBest = C.countySplittingRange(districtType)[C.BEG];
3138
3233
  const nAllowableSplits = Math.min(nDistricts - 1, nCounties);
3139
3234
  const threshold = ((nAllowableSplits * practicalBest) + ((nCounties - nAllowableSplits) * 1.0)) / nCounties;
@@ -3141,7 +3236,7 @@ function countySplitBest(nCounties, nDistricts, bLD = false) {
3141
3236
  }
3142
3237
  exports.countySplitBest = countySplitBest;
3143
3238
  function countySplitWorst(avgBest, bLD = false) {
3144
- const districtType = (bLD) ? 1 /* StateLegislative */ : 0 /* Congressional */;
3239
+ const districtType = (bLD) ? 1 /* T.DistrictType.StateLegislative */ : 0 /* T.DistrictType.Congressional */;
3145
3240
  const singleBest = C.countySplittingRange(districtType)[C.BEG];
3146
3241
  const singleWorst = C.countySplittingRange(districtType)[C.END];
3147
3242
  // The practical ideal score depends on the # of counties & districts
@@ -3150,7 +3245,7 @@ function countySplitWorst(avgBest, bLD = false) {
3150
3245
  }
3151
3246
  exports.countySplitWorst = countySplitWorst;
3152
3247
  function rateDistrictSplittingLegacy(rawDistrictSplitting, bLD = false) {
3153
- const districtType = (bLD) ? 1 /* StateLegislative */ : 0 /* Congressional */;
3248
+ const districtType = (bLD) ? 1 /* T.DistrictType.StateLegislative */ : 0 /* T.DistrictType.Congressional */;
3154
3249
  const _normalizer = new normalize_1.Normalizer(rawDistrictSplitting);
3155
3250
  const best = C.districtSplittingRange(districtType)[C.BEG];
3156
3251
  const worst = C.districtSplittingRange(districtType)[C.END];
@@ -3196,7 +3291,11 @@ exports.adjustSplittingRating = adjustSplittingRating;
3196
3291
  //
3197
3292
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3198
3293
  if (k2 === undefined) k2 = k;
3199
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
3294
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3295
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3296
+ desc = { enumerable: true, get: function() { return m[k]; } };
3297
+ }
3298
+ Object.defineProperty(o, k2, desc);
3200
3299
  }) : (function(o, m, k, k2) {
3201
3300
  if (k2 === undefined) k2 = k;
3202
3301
  o[k2] = m[k];
@@ -3262,10 +3361,10 @@ class Normalizer {
3262
3361
  // Decay a value in the unit range [0.0–1.0] by its distance from zero.
3263
3362
  // NOTE - If the range is already such that "bigger is better," then the closer
3264
3363
  // the value is to 1.0 (the best) the *less* it will decay.
3265
- decay(fn = 0 /* Gravity */) {
3364
+ decay(fn = 0 /* DecayFn.Gravity */) {
3266
3365
  console.assert(((this.wipNum >= 0.0) && (this.wipNum <= 1.0)), "Decaying: " + S.OUT_OF_RANGE_MSG, this.wipNum);
3267
3366
  switch (fn) {
3268
- case 0 /* Gravity */: {
3367
+ case 0 /* DecayFn.Gravity */: {
3269
3368
  this.wipNum = Math.pow(this.wipNum, S.DISTANCE_WEIGHT);
3270
3369
  return this.wipNum;
3271
3370
  }
@@ -3318,7 +3417,11 @@ exports.OUT_OF_RANGE_MSG = "%f out of range";
3318
3417
  // Export everything here -- restrict package exports in all/splitting.ts
3319
3418
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3320
3419
  if (k2 === undefined) k2 = k;
3321
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
3420
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3421
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3422
+ desc = { enumerable: true, get: function() { return m[k]; } };
3423
+ }
3424
+ Object.defineProperty(o, k2, desc);
3322
3425
  }) : (function(o, m, k, k2) {
3323
3426
  if (k2 === undefined) k2 = k;
3324
3427
  o[k2] = m[k];
@@ -3346,7 +3449,11 @@ __exportStar(__webpack_require__(/*! ./utils */ "./lib/splitting/utils.ts"), exp
3346
3449
  //
3347
3450
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3348
3451
  if (k2 === undefined) k2 = k;
3349
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
3452
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3453
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3454
+ desc = { enumerable: true, get: function() { return m[k]; } };
3455
+ }
3456
+ Object.defineProperty(o, k2, desc);
3350
3457
  }) : (function(o, m, k, k2) {
3351
3458
  if (k2 === undefined) k2 = k;
3352
3459
  o[k2] = m[k];
@@ -3419,7 +3526,11 @@ exports.calcCOISplitting = calcCOISplitting;
3419
3526
  //
3420
3527
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3421
3528
  if (k2 === undefined) k2 = k;
3422
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
3529
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3530
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3531
+ desc = { enumerable: true, get: function() { return m[k]; } };
3532
+ }
3533
+ Object.defineProperty(o, k2, desc);
3423
3534
  }) : (function(o, m, k, k2) {
3424
3535
  if (k2 === undefined) k2 = k;
3425
3536
  o[k2] = m[k];
@@ -3716,7 +3827,11 @@ exports.isMinusZero = isMinusZero;
3716
3827
 
3717
3828
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3718
3829
  if (k2 === undefined) k2 = k;
3719
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
3830
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3831
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3832
+ desc = { enumerable: true, get: function() { return m[k]; } };
3833
+ }
3834
+ Object.defineProperty(o, k2, desc);
3720
3835
  }) : (function(o, m, k, k2) {
3721
3836
  if (k2 === undefined) k2 = k;
3722
3837
  o[k2] = m[k];
@@ -3744,7 +3859,11 @@ __exportStar(__webpack_require__(/*! ./settings */ "./lib/utils/settings.ts"), e
3744
3859
  //
3745
3860
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3746
3861
  if (k2 === undefined) k2 = k;
3747
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
3862
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3863
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3864
+ desc = { enumerable: true, get: function() { return m[k]; } };
3865
+ }
3866
+ Object.defineProperty(o, k2, desc);
3748
3867
  }) : (function(o, m, k, k2) {
3749
3868
  if (k2 === undefined) k2 = k;
3750
3869
  o[k2] = m[k];