@dra2020/district-analytics 4.3.3 → 4.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +29 -24
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -89327,7 +89327,7 @@ exports.scoreCountySplitting = scoreCountySplitting;
|
|
|
89327
89327
|
function countySplitThreshold(nCounties, nDistricts) {
|
|
89328
89328
|
const m = C.allowableSplitsMultiplier();
|
|
89329
89329
|
const worst = C.countySplittingRange()[1];
|
|
89330
|
-
const nAllowableSplits = Math.min(m * (nDistricts - 1));
|
|
89330
|
+
const nAllowableSplits = Math.min(m * (nDistricts - 1), nCounties);
|
|
89331
89331
|
const threshold = ((nAllowableSplits * worst) + ((nCounties - nAllowableSplits) * 1.0)) / nCounties;
|
|
89332
89332
|
return threshold;
|
|
89333
89333
|
}
|
|
@@ -90217,7 +90217,7 @@ function exceedsMaximumThreshold(Mf) {
|
|
|
90217
90217
|
return Mf > threshold;
|
|
90218
90218
|
}
|
|
90219
90219
|
function calcProportionalDistricts(proportion, nDistricts) {
|
|
90220
|
-
// TODO -
|
|
90220
|
+
// TODO - Maybe bump up to get a statewide proportion on the bubble to rate one district?
|
|
90221
90221
|
const roundUp = 0.0;
|
|
90222
90222
|
const fractional = proportion * nDistricts;
|
|
90223
90223
|
const integral = Math.round(fractional + roundUp);
|
|
@@ -90366,14 +90366,14 @@ const normalize_1 = __webpack_require__(/*! ./normalize */ "./src/normalize.ts")
|
|
|
90366
90366
|
* S# [estS] (S_V) = the estimated Democratic seats, using seat probabilities
|
|
90367
90367
|
* S% [estSf] = the estimated Democratic seat share fraction, calculated as S# / N
|
|
90368
90368
|
|
|
90369
|
-
* BS_50 [bS50] = Seat bias as a fraction of N
|
|
90370
|
-
* BV_50 [bV50] = Votes bias as a fraction
|
|
90369
|
+
* BS_50 [bS50] = Seat bias as a fraction of N
|
|
90370
|
+
* BV_50 [bV50] = Votes bias as a fraction
|
|
90371
90371
|
* decl [decl] = Declination
|
|
90372
|
-
* GS [gSym] = Global symmetry
|
|
90372
|
+
* GS [gSym] = Global symmetry
|
|
90373
90373
|
|
|
90374
90374
|
* EG [EG] = Efficiency gap as a fraction
|
|
90375
|
-
* BS_V [bSV] = Seats bias @ <V> (geometric)
|
|
90376
|
-
* PR [prop] = Disproportionality
|
|
90375
|
+
* BS_V [bSV] = Seats bias @ <V> (geometric)
|
|
90376
|
+
* PR [prop] = Disproportionality
|
|
90377
90377
|
* MM [mMs] = Mean – median difference using statewide Vf
|
|
90378
90378
|
* TO [tOf] = Turnout bias
|
|
90379
90379
|
* MM' [mMd] = Mean – median difference using average district v
|
|
@@ -90417,7 +90417,7 @@ function scorePartisan(Vf, VfArray, options) {
|
|
|
90417
90417
|
const bias = estBias(estSf, bestSf);
|
|
90418
90418
|
const biasScore = scorebias(bias, Vf, estSf);
|
|
90419
90419
|
const unearnedS = estUnearnedSeats(bestS, estS);
|
|
90420
|
-
const impactScore = scoreImpact(unearnedS, Vf, N);
|
|
90420
|
+
const impactScore = scoreImpact(unearnedS, Vf, estSf, N);
|
|
90421
90421
|
// Calculate additional alternate metrics for reference
|
|
90422
90422
|
// NOTE - Use the uncompressed seat probability function
|
|
90423
90423
|
const inferredSVpoints = bAlternateMetrics ? inferSVpoints(Vf, VfArray, shift) : undefined;
|
|
@@ -90549,22 +90549,27 @@ function adjustBias(Vf, bias, extra) {
|
|
|
90549
90549
|
}
|
|
90550
90550
|
exports.adjustBias = adjustBias;
|
|
90551
90551
|
// Normalize unearned seats
|
|
90552
|
-
function scoreImpact(rawUE, Vf, N) {
|
|
90553
|
-
|
|
90554
|
-
|
|
90555
|
-
|
|
90556
|
-
|
|
90557
|
-
|
|
90558
|
-
|
|
90559
|
-
|
|
90560
|
-
|
|
90561
|
-
|
|
90562
|
-
|
|
90563
|
-
|
|
90564
|
-
|
|
90565
|
-
|
|
90566
|
-
|
|
90567
|
-
|
|
90552
|
+
function scoreImpact(rawUE, Vf, Sf, N) {
|
|
90553
|
+
if (isAntimajoritarian(Vf, Sf)) {
|
|
90554
|
+
return 0;
|
|
90555
|
+
}
|
|
90556
|
+
else {
|
|
90557
|
+
// Adjust impact to incorporate an acceptable winner's bonus based on Vf
|
|
90558
|
+
const extra = extraBonus(Vf);
|
|
90559
|
+
const adjustedBias = adjustBias(Vf, rawUE / N, extra);
|
|
90560
|
+
const adjustedImpact = adjustedBias * N;
|
|
90561
|
+
// Then normalize
|
|
90562
|
+
const _normalizer = new normalize_1.Normalizer(adjustedImpact);
|
|
90563
|
+
const worst = C.unearnedThreshold();
|
|
90564
|
+
const best = 0.0;
|
|
90565
|
+
_normalizer.positive();
|
|
90566
|
+
_normalizer.clip(worst, best);
|
|
90567
|
+
_normalizer.unitize(worst, best);
|
|
90568
|
+
_normalizer.invert();
|
|
90569
|
+
_normalizer.rescale();
|
|
90570
|
+
const score = _normalizer.normalizedNum;
|
|
90571
|
+
return score;
|
|
90572
|
+
}
|
|
90568
90573
|
}
|
|
90569
90574
|
exports.scoreImpact = scoreImpact;
|
|
90570
90575
|
function isAntimajoritarian(Vf, Sf) {
|