@dra2020/dra-analytics 4.0.0 → 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 +1 -1
- package/dist/dra-analytics.js +180 -88
- package/dist/dra-analytics.js.map +1 -1
- package/dist/lib/compactness/matrix.d.ts +1 -1
- package/dist/lib/types/all.d.ts +1 -1
- package/dist/lib/types/compactness.d.ts +10 -10
- package/dist/lib/types/general.d.ts +1 -1
- package/dist/lib/types/graph.d.ts +6 -6
- package/dist/lib/types/minority.d.ts +11 -11
- package/dist/lib/types/partisan.d.ts +9 -9
- package/dist/lib/types/population.d.ts +1 -1
- package/dist/lib/types/splitting.d.ts +7 -7
- package/package.json +18 -18
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/dist/dra-analytics.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
exports["dra-analytics"] = factory();
|
|
8
8
|
else
|
|
9
9
|
root["dra-analytics"] = factory();
|
|
10
|
-
})(global,
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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];
|
|
@@ -876,7 +896,7 @@ function makePopulationScorecard(totPopByDistrict, targetSize, bLegislative, rep
|
|
|
876
896
|
// MMD - Figure out the type of districts, SMD or MMD.
|
|
877
897
|
const nReps = (repsByDistrict) ? repsByDistrict.reduce((a, b) => a + b, 0) : nDistricts;
|
|
878
898
|
const bSMD = (!repsByDistrict || (nReps == nDistricts)) ? true : false;
|
|
879
|
-
// MMD - Generalize populations for non-empty districts
|
|
899
|
+
// MMD - Generalize populations for non-empty districts to be per rep.
|
|
880
900
|
// const nonEmptyDistricts = totPopByDistrict.filter(x => x > 0);
|
|
881
901
|
let popPerRep = U.deepCopy(totPopByDistrict);
|
|
882
902
|
if (!bSMD && repsByDistrict) {
|
|
@@ -924,7 +944,11 @@ exports.makePopulationScorecard = makePopulationScorecard;
|
|
|
924
944
|
// Export everything here -- restrict package exports in all/graph.ts
|
|
925
945
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
926
946
|
if (k2 === undefined) k2 = k;
|
|
927
|
-
Object.
|
|
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);
|
|
928
952
|
}) : (function(o, m, k, k2) {
|
|
929
953
|
if (k2 === undefined) k2 = k;
|
|
930
954
|
o[k2] = m[k];
|
|
@@ -951,7 +975,11 @@ __exportStar(__webpack_require__(/*! ./embedded */ "./lib/graph/embedded.ts"), e
|
|
|
951
975
|
//
|
|
952
976
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
953
977
|
if (k2 === undefined) k2 = k;
|
|
954
|
-
Object.
|
|
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);
|
|
955
983
|
}) : (function(o, m, k, k2) {
|
|
956
984
|
if (k2 === undefined) k2 = k;
|
|
957
985
|
o[k2] = m[k];
|
|
@@ -1014,7 +1042,11 @@ exports.isConnected = isConnected;
|
|
|
1014
1042
|
//
|
|
1015
1043
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1016
1044
|
if (k2 === undefined) k2 = k;
|
|
1017
|
-
Object.
|
|
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);
|
|
1018
1050
|
}) : (function(o, m, k, k2) {
|
|
1019
1051
|
if (k2 === undefined) k2 = k;
|
|
1020
1052
|
o[k2] = m[k];
|
|
@@ -1103,7 +1135,11 @@ exports.NOT_ASSIGNED = 0;
|
|
|
1103
1135
|
//
|
|
1104
1136
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1105
1137
|
if (k2 === undefined) k2 = k;
|
|
1106
|
-
Object.
|
|
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);
|
|
1107
1143
|
}) : (function(o, m, k, k2) {
|
|
1108
1144
|
if (k2 === undefined) k2 = k;
|
|
1109
1145
|
o[k2] = m[k];
|
|
@@ -1170,7 +1206,11 @@ exports.invertPlan = invertPlan;
|
|
|
1170
1206
|
// Export everything here -- restrict package exports in all/
|
|
1171
1207
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1172
1208
|
if (k2 === undefined) k2 = k;
|
|
1173
|
-
Object.
|
|
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);
|
|
1174
1214
|
}) : (function(o, m, k, k2) {
|
|
1175
1215
|
if (k2 === undefined) k2 = k;
|
|
1176
1216
|
o[k2] = m[k];
|
|
@@ -1197,7 +1237,11 @@ __exportStar(__webpack_require__(/*! ./rpv */ "./lib/minority/rpv.ts"), exports)
|
|
|
1197
1237
|
//
|
|
1198
1238
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1199
1239
|
if (k2 === undefined) k2 = k;
|
|
1200
|
-
Object.
|
|
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);
|
|
1201
1245
|
}) : (function(o, m, k, k2) {
|
|
1202
1246
|
if (k2 === undefined) k2 = k;
|
|
1203
1247
|
o[k2] = m[k];
|
|
@@ -1281,64 +1325,64 @@ exports.makeMinorityScorecard = makeMinorityScorecard;
|
|
|
1281
1325
|
// addressed logically by name as opposed to using array indices.
|
|
1282
1326
|
function convertArrayToTable(a) {
|
|
1283
1327
|
const minority = {
|
|
1284
|
-
pct35_40: a[0 /* Minority */][0 /* L35_40 */],
|
|
1285
|
-
pct40_45: a[0 /* Minority */][1 /* L40_45 */],
|
|
1286
|
-
pct45_50: a[0 /* Minority */][2 /* L45_50 */],
|
|
1287
|
-
pct50_55: a[0 /* Minority */][3 /* L50_55 */],
|
|
1288
|
-
pct55_60: a[0 /* Minority */][4 /* L55_60 */],
|
|
1289
|
-
pct60Plus: a[0 /* Minority */][5 /* L60Plus */],
|
|
1290
|
-
vapPct: a[0 /* Minority */][6 /* VAPPct */],
|
|
1291
|
-
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 */]
|
|
1292
1336
|
};
|
|
1293
1337
|
const black = {
|
|
1294
|
-
pct35_40: a[1 /* Black */][0 /* L35_40 */],
|
|
1295
|
-
pct40_45: a[1 /* Black */][1 /* L40_45 */],
|
|
1296
|
-
pct45_50: a[1 /* Black */][2 /* L45_50 */],
|
|
1297
|
-
pct50_55: a[1 /* Black */][3 /* L50_55 */],
|
|
1298
|
-
pct55_60: a[1 /* Black */][4 /* L55_60 */],
|
|
1299
|
-
pct60Plus: a[1 /* Black */][5 /* L60Plus */],
|
|
1300
|
-
vapPct: a[1 /* Black */][6 /* VAPPct */],
|
|
1301
|
-
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 */]
|
|
1302
1346
|
};
|
|
1303
1347
|
const hispanic = {
|
|
1304
|
-
pct35_40: a[2 /* Hispanic */][0 /* L35_40 */],
|
|
1305
|
-
pct40_45: a[2 /* Hispanic */][1 /* L40_45 */],
|
|
1306
|
-
pct45_50: a[2 /* Hispanic */][2 /* L45_50 */],
|
|
1307
|
-
pct50_55: a[2 /* Hispanic */][3 /* L50_55 */],
|
|
1308
|
-
pct55_60: a[2 /* Hispanic */][4 /* L55_60 */],
|
|
1309
|
-
pct60Plus: a[2 /* Hispanic */][5 /* L60Plus */],
|
|
1310
|
-
vapPct: a[2 /* Hispanic */][6 /* VAPPct */],
|
|
1311
|
-
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 */]
|
|
1312
1356
|
};
|
|
1313
1357
|
const pacific = {
|
|
1314
|
-
pct35_40: a[3 /* Pacific */][0 /* L35_40 */],
|
|
1315
|
-
pct40_45: a[3 /* Pacific */][1 /* L40_45 */],
|
|
1316
|
-
pct45_50: a[3 /* Pacific */][2 /* L45_50 */],
|
|
1317
|
-
pct50_55: a[3 /* Pacific */][3 /* L50_55 */],
|
|
1318
|
-
pct55_60: a[3 /* Pacific */][4 /* L55_60 */],
|
|
1319
|
-
pct60Plus: a[3 /* Pacific */][5 /* L60Plus */],
|
|
1320
|
-
vapPct: a[3 /* Pacific */][6 /* VAPPct */],
|
|
1321
|
-
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 */]
|
|
1322
1366
|
};
|
|
1323
1367
|
const asian = {
|
|
1324
|
-
pct35_40: a[4 /* Asian */][0 /* L35_40 */],
|
|
1325
|
-
pct40_45: a[4 /* Asian */][1 /* L40_45 */],
|
|
1326
|
-
pct45_50: a[4 /* Asian */][2 /* L45_50 */],
|
|
1327
|
-
pct50_55: a[4 /* Asian */][3 /* L50_55 */],
|
|
1328
|
-
pct55_60: a[4 /* Asian */][4 /* L55_60 */],
|
|
1329
|
-
pct60Plus: a[4 /* Asian */][5 /* L60Plus */],
|
|
1330
|
-
vapPct: a[4 /* Asian */][6 /* VAPPct */],
|
|
1331
|
-
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 */]
|
|
1332
1376
|
};
|
|
1333
1377
|
const native = {
|
|
1334
|
-
pct35_40: a[5 /* Native */][0 /* L35_40 */],
|
|
1335
|
-
pct40_45: a[5 /* Native */][1 /* L40_45 */],
|
|
1336
|
-
pct45_50: a[5 /* Native */][2 /* L45_50 */],
|
|
1337
|
-
pct50_55: a[5 /* Native */][3 /* L50_55 */],
|
|
1338
|
-
pct55_60: a[5 /* Native */][4 /* L55_60 */],
|
|
1339
|
-
pct60Plus: a[5 /* Native */][5 /* L60Plus */],
|
|
1340
|
-
vapPct: a[5 /* Native */][6 /* VAPPct */],
|
|
1341
|
-
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 */]
|
|
1342
1386
|
};
|
|
1343
1387
|
const t = {
|
|
1344
1388
|
minority: minority,
|
|
@@ -1588,7 +1632,11 @@ const invertX = (pt) => { return { x: 1 - pt.x, y: pt.y }; };
|
|
|
1588
1632
|
// Export everything here -- restrict package exports in all/partisan.ts
|
|
1589
1633
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1590
1634
|
if (k2 === undefined) k2 = k;
|
|
1591
|
-
Object.
|
|
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);
|
|
1592
1640
|
}) : (function(o, m, k, k2) {
|
|
1593
1641
|
if (k2 === undefined) k2 = k;
|
|
1594
1642
|
o[k2] = m[k];
|
|
@@ -1620,7 +1668,7 @@ const bias_1 = __webpack_require__(/*! ../../lib/partisan/bias */ "./lib/partisa
|
|
|
1620
1668
|
const responsiveness_1 = __webpack_require__(/*! ../../lib/partisan/responsiveness */ "./lib/partisan/responsiveness.ts");
|
|
1621
1669
|
const all_1 = __webpack_require__(/*! ../all/all */ "./lib/all/all.ts");
|
|
1622
1670
|
function makePartisanScorecard(Vf, VfArray, bLog = false) {
|
|
1623
|
-
const shift = 0 /* Proportional */;
|
|
1671
|
+
const shift = 0 /* T.Shift.Proportional */;
|
|
1624
1672
|
const N = VfArray.length;
|
|
1625
1673
|
const bestS = (0, bias_1.bestSeats)(N, Vf);
|
|
1626
1674
|
const bestSf = (0, bias_1.bestSeatShare)(bestS, N);
|
|
@@ -1746,7 +1794,11 @@ exports.calcPartisanMetrics = calcPartisanMetrics;
|
|
|
1746
1794
|
//
|
|
1747
1795
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1748
1796
|
if (k2 === undefined) k2 = k;
|
|
1749
|
-
Object.
|
|
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);
|
|
1750
1802
|
}) : (function(o, m, k, k2) {
|
|
1751
1803
|
if (k2 === undefined) k2 = k;
|
|
1752
1804
|
o[k2] = m[k];
|
|
@@ -1934,9 +1986,9 @@ function invertSVPoints(inferredSVpoints) {
|
|
|
1934
1986
|
exports.invertSVPoints = invertSVPoints;
|
|
1935
1987
|
// EFFICIENCY GAP -- note the formulation used. Also, to accommodate turnout bias,
|
|
1936
1988
|
// we would need to have D & R votes, not just shares.
|
|
1937
|
-
function calcEfficiencyGap(Vf, Sf, shareType = 0 /* Democratic */) {
|
|
1989
|
+
function calcEfficiencyGap(Vf, Sf, shareType = 0 /* T.Party.Democratic */) {
|
|
1938
1990
|
let efficiencyGap;
|
|
1939
|
-
if (shareType == 1 /* Republican */) {
|
|
1991
|
+
if (shareType == 1 /* T.Party.Republican */) {
|
|
1940
1992
|
// NOTE - This is the common formulation:
|
|
1941
1993
|
//
|
|
1942
1994
|
// EG = (Sf – 0.5) – (2 × (Vf – 0.5))
|
|
@@ -2336,7 +2388,11 @@ describe('erf approximation', () =>
|
|
|
2336
2388
|
//
|
|
2337
2389
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2338
2390
|
if (k2 === undefined) k2 = k;
|
|
2339
|
-
Object.
|
|
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);
|
|
2340
2396
|
}) : (function(o, m, k, k2) {
|
|
2341
2397
|
if (k2 === undefined) k2 = k;
|
|
2342
2398
|
o[k2] = m[k];
|
|
@@ -2412,7 +2468,7 @@ function inferSVpoints(Vf, VfArray, shift, range) {
|
|
|
2412
2468
|
}
|
|
2413
2469
|
exports.inferSVpoints = inferSVpoints;
|
|
2414
2470
|
function shiftDistricts(Vf, VfArray, shiftedVf, shift) {
|
|
2415
|
-
if (shift == 0 /* Proportional */)
|
|
2471
|
+
if (shift == 0 /* T.Shift.Proportional */)
|
|
2416
2472
|
return shiftProportionally(Vf, VfArray, shiftedVf);
|
|
2417
2473
|
else
|
|
2418
2474
|
return shiftUniformly(Vf, VfArray, shiftedVf);
|
|
@@ -2542,7 +2598,11 @@ exports.fptpWin = fptpWin;
|
|
|
2542
2598
|
//
|
|
2543
2599
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2544
2600
|
if (k2 === undefined) k2 = k;
|
|
2545
|
-
Object.
|
|
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);
|
|
2546
2606
|
}) : (function(o, m, k, k2) {
|
|
2547
2607
|
if (k2 === undefined) k2 = k;
|
|
2548
2608
|
o[k2] = m[k];
|
|
@@ -2699,7 +2759,11 @@ exports.findMarginalDistricts = findMarginalDistricts;
|
|
|
2699
2759
|
|
|
2700
2760
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2701
2761
|
if (k2 === undefined) k2 = k;
|
|
2702
|
-
Object.
|
|
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);
|
|
2703
2767
|
}) : (function(o, m, k, k2) {
|
|
2704
2768
|
if (k2 === undefined) k2 = k;
|
|
2705
2769
|
o[k2] = m[k];
|
|
@@ -2854,10 +2918,10 @@ exports.districtSplittingRange = districtSplittingRange;
|
|
|
2854
2918
|
// NOTE - Raw ranges, not inverted (i.e., smaller is better)
|
|
2855
2919
|
// NOTE - This could be optimized to not calc LD values for CD's (or do it once)
|
|
2856
2920
|
function popdevRange(bLegislative, overridesJSON) {
|
|
2857
|
-
const cdRange = config.popdev.range[0 /* Congressional */];
|
|
2921
|
+
const cdRange = config.popdev.range[0 /* T.DistrictType.Congressional */];
|
|
2858
2922
|
const worstCD = cdRange[exports.BEG];
|
|
2859
2923
|
const bestCD = cdRange[exports.END];
|
|
2860
|
-
const ldRange = config.popdev.range[1 /* StateLegislative */];
|
|
2924
|
+
const ldRange = config.popdev.range[1 /* T.DistrictType.StateLegislative */];
|
|
2861
2925
|
const iRange = bLegislative ? ldRange : cdRange;
|
|
2862
2926
|
const worst = iRange[exports.BEG];
|
|
2863
2927
|
const best = bLegislative ? (bestCD / worstCD) * iRange[exports.BEG] : iRange[exports.END];
|
|
@@ -2887,7 +2951,11 @@ exports.popdevThreshold = popdevThreshold;
|
|
|
2887
2951
|
//
|
|
2888
2952
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2889
2953
|
if (k2 === undefined) k2 = k;
|
|
2890
|
-
Object.
|
|
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);
|
|
2891
2959
|
}) : (function(o, m, k, k2) {
|
|
2892
2960
|
if (k2 === undefined) k2 = k;
|
|
2893
2961
|
o[k2] = m[k];
|
|
@@ -3160,7 +3228,7 @@ function rateCountySplittingLegacy(rawCountySplitting, nCounties, nDistricts, bL
|
|
|
3160
3228
|
}
|
|
3161
3229
|
exports.rateCountySplittingLegacy = rateCountySplittingLegacy;
|
|
3162
3230
|
function countySplitBest(nCounties, nDistricts, bLD = false) {
|
|
3163
|
-
const districtType = (bLD) ? 1 /* StateLegislative */ : 0 /* Congressional */;
|
|
3231
|
+
const districtType = (bLD) ? 1 /* T.DistrictType.StateLegislative */ : 0 /* T.DistrictType.Congressional */;
|
|
3164
3232
|
const practicalBest = C.countySplittingRange(districtType)[C.BEG];
|
|
3165
3233
|
const nAllowableSplits = Math.min(nDistricts - 1, nCounties);
|
|
3166
3234
|
const threshold = ((nAllowableSplits * practicalBest) + ((nCounties - nAllowableSplits) * 1.0)) / nCounties;
|
|
@@ -3168,7 +3236,7 @@ function countySplitBest(nCounties, nDistricts, bLD = false) {
|
|
|
3168
3236
|
}
|
|
3169
3237
|
exports.countySplitBest = countySplitBest;
|
|
3170
3238
|
function countySplitWorst(avgBest, bLD = false) {
|
|
3171
|
-
const districtType = (bLD) ? 1 /* StateLegislative */ : 0 /* Congressional */;
|
|
3239
|
+
const districtType = (bLD) ? 1 /* T.DistrictType.StateLegislative */ : 0 /* T.DistrictType.Congressional */;
|
|
3172
3240
|
const singleBest = C.countySplittingRange(districtType)[C.BEG];
|
|
3173
3241
|
const singleWorst = C.countySplittingRange(districtType)[C.END];
|
|
3174
3242
|
// The practical ideal score depends on the # of counties & districts
|
|
@@ -3177,7 +3245,7 @@ function countySplitWorst(avgBest, bLD = false) {
|
|
|
3177
3245
|
}
|
|
3178
3246
|
exports.countySplitWorst = countySplitWorst;
|
|
3179
3247
|
function rateDistrictSplittingLegacy(rawDistrictSplitting, bLD = false) {
|
|
3180
|
-
const districtType = (bLD) ? 1 /* StateLegislative */ : 0 /* Congressional */;
|
|
3248
|
+
const districtType = (bLD) ? 1 /* T.DistrictType.StateLegislative */ : 0 /* T.DistrictType.Congressional */;
|
|
3181
3249
|
const _normalizer = new normalize_1.Normalizer(rawDistrictSplitting);
|
|
3182
3250
|
const best = C.districtSplittingRange(districtType)[C.BEG];
|
|
3183
3251
|
const worst = C.districtSplittingRange(districtType)[C.END];
|
|
@@ -3223,7 +3291,11 @@ exports.adjustSplittingRating = adjustSplittingRating;
|
|
|
3223
3291
|
//
|
|
3224
3292
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3225
3293
|
if (k2 === undefined) k2 = k;
|
|
3226
|
-
Object.
|
|
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);
|
|
3227
3299
|
}) : (function(o, m, k, k2) {
|
|
3228
3300
|
if (k2 === undefined) k2 = k;
|
|
3229
3301
|
o[k2] = m[k];
|
|
@@ -3289,10 +3361,10 @@ class Normalizer {
|
|
|
3289
3361
|
// Decay a value in the unit range [0.0–1.0] by its distance from zero.
|
|
3290
3362
|
// NOTE - If the range is already such that "bigger is better," then the closer
|
|
3291
3363
|
// the value is to 1.0 (the best) the *less* it will decay.
|
|
3292
|
-
decay(fn = 0 /* Gravity */) {
|
|
3364
|
+
decay(fn = 0 /* DecayFn.Gravity */) {
|
|
3293
3365
|
console.assert(((this.wipNum >= 0.0) && (this.wipNum <= 1.0)), "Decaying: " + S.OUT_OF_RANGE_MSG, this.wipNum);
|
|
3294
3366
|
switch (fn) {
|
|
3295
|
-
case 0 /* Gravity */: {
|
|
3367
|
+
case 0 /* DecayFn.Gravity */: {
|
|
3296
3368
|
this.wipNum = Math.pow(this.wipNum, S.DISTANCE_WEIGHT);
|
|
3297
3369
|
return this.wipNum;
|
|
3298
3370
|
}
|
|
@@ -3345,7 +3417,11 @@ exports.OUT_OF_RANGE_MSG = "%f out of range";
|
|
|
3345
3417
|
// Export everything here -- restrict package exports in all/splitting.ts
|
|
3346
3418
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3347
3419
|
if (k2 === undefined) k2 = k;
|
|
3348
|
-
Object.
|
|
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);
|
|
3349
3425
|
}) : (function(o, m, k, k2) {
|
|
3350
3426
|
if (k2 === undefined) k2 = k;
|
|
3351
3427
|
o[k2] = m[k];
|
|
@@ -3373,7 +3449,11 @@ __exportStar(__webpack_require__(/*! ./utils */ "./lib/splitting/utils.ts"), exp
|
|
|
3373
3449
|
//
|
|
3374
3450
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3375
3451
|
if (k2 === undefined) k2 = k;
|
|
3376
|
-
Object.
|
|
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);
|
|
3377
3457
|
}) : (function(o, m, k, k2) {
|
|
3378
3458
|
if (k2 === undefined) k2 = k;
|
|
3379
3459
|
o[k2] = m[k];
|
|
@@ -3446,7 +3526,11 @@ exports.calcCOISplitting = calcCOISplitting;
|
|
|
3446
3526
|
//
|
|
3447
3527
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3448
3528
|
if (k2 === undefined) k2 = k;
|
|
3449
|
-
Object.
|
|
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);
|
|
3450
3534
|
}) : (function(o, m, k, k2) {
|
|
3451
3535
|
if (k2 === undefined) k2 = k;
|
|
3452
3536
|
o[k2] = m[k];
|
|
@@ -3743,7 +3827,11 @@ exports.isMinusZero = isMinusZero;
|
|
|
3743
3827
|
|
|
3744
3828
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3745
3829
|
if (k2 === undefined) k2 = k;
|
|
3746
|
-
Object.
|
|
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);
|
|
3747
3835
|
}) : (function(o, m, k, k2) {
|
|
3748
3836
|
if (k2 === undefined) k2 = k;
|
|
3749
3837
|
o[k2] = m[k];
|
|
@@ -3771,7 +3859,11 @@ __exportStar(__webpack_require__(/*! ./settings */ "./lib/utils/settings.ts"), e
|
|
|
3771
3859
|
//
|
|
3772
3860
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3773
3861
|
if (k2 === undefined) k2 = k;
|
|
3774
|
-
Object.
|
|
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);
|
|
3775
3867
|
}) : (function(o, m, k, k2) {
|
|
3776
3868
|
if (k2 === undefined) k2 = k;
|
|
3777
3869
|
o[k2] = m[k];
|