@dra2020/district-analytics 6.0.1 → 6.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/dist/cli.js +20 -18
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -89739,23 +89739,25 @@ function scorePartisan(Vf, VfArray, options) {
|
|
|
89739
89739
|
const impactScore = scoreImpact(unearnedS, Vf, estSf, N);
|
|
89740
89740
|
// Calculate additional alternate metrics for reference
|
|
89741
89741
|
// NOTE - Use the uncompressed seat probability function
|
|
89742
|
-
const
|
|
89742
|
+
const dSVpoints = inferSVpoints(Vf, VfArray, shift);
|
|
89743
|
+
const rSVpoints = invertSVPoints(dSVpoints);
|
|
89744
|
+
// const dSVpoints = bAlternateMetrics ? inferSVpoints(Vf, VfArray, shift) : undefined;
|
|
89743
89745
|
const TOf = bAlternateMetrics ? calcTurnoutBias(Vf, VfArray) : undefined;
|
|
89744
|
-
const Bs50 = bAlternateMetrics ? estPartisanBias(
|
|
89746
|
+
const Bs50 = bAlternateMetrics ? estPartisanBias(dSVpoints, N) : undefined;
|
|
89745
89747
|
const Bs50f = (!(Bs50 === undefined)) ? U.trim(Bs50 / N) : undefined;
|
|
89746
|
-
const Bv50f = bAlternateMetrics ? estVotesBias(
|
|
89748
|
+
const Bv50f = bAlternateMetrics ? estVotesBias(dSVpoints, N) : undefined;
|
|
89747
89749
|
const rvPoints = bAlternateMetrics ? keyRVpoints(VfArray) : undefined;
|
|
89748
89750
|
const decl = bAlternateMetrics ? calcDeclination(VfArray) : undefined;
|
|
89749
|
-
const gSym = bAlternateMetrics ? calcGlobalSymmetry(
|
|
89751
|
+
const gSym = bAlternateMetrics ? calcGlobalSymmetry(dSVpoints, rSVpoints, Bs50f) : undefined;
|
|
89750
89752
|
const EG = bAlternateMetrics ? calcEfficiencyGap(Vf, estSf) : undefined;
|
|
89751
|
-
const BsGf = bAlternateMetrics ? estGeometricSeatsBias(Vf,
|
|
89753
|
+
const BsGf = bAlternateMetrics ? estGeometricSeatsBias(Vf, dSVpoints, rSVpoints) : undefined;
|
|
89752
89754
|
const prop = bAlternateMetrics ? calcDisproportionality(Vf, estSf) : undefined;
|
|
89753
89755
|
const mMs = bAlternateMetrics ? estMeanMedianDifference(VfArray, Vf) : undefined;
|
|
89754
89756
|
const mMd = bAlternateMetrics ? estMeanMedianDifference(VfArray) : undefined;
|
|
89755
89757
|
const LO = bAlternateMetrics ? calcLopsidedOutcomes(VfArray) : undefined;
|
|
89756
89758
|
// Calculate alternate responsiveness metrics for reference
|
|
89757
89759
|
const bigR = bAlternateMetrics ? calcBigR(Vf, estSf) : undefined;
|
|
89758
|
-
const littleR = bAlternateMetrics ? estResponsiveness(Vf,
|
|
89760
|
+
const littleR = bAlternateMetrics ? estResponsiveness(Vf, dSVpoints) : undefined;
|
|
89759
89761
|
const MIR = (bAlternateMetrics && littleR) ? calcMinimalInverseResponsiveness(Vf, littleR) : undefined;
|
|
89760
89762
|
const rD = (!bConstrained || bAlternateMetrics) ? estResponsiveDistricts(VfArray) : undefined;
|
|
89761
89763
|
const rDf = bAlternateMetrics ? estResponsiveDistrictsShare(rD, N) : undefined;
|
|
@@ -89821,6 +89823,8 @@ function scorePartisan(Vf, VfArray, options) {
|
|
|
89821
89823
|
bias: biasScoring,
|
|
89822
89824
|
impact: impactScoring,
|
|
89823
89825
|
competitiveness: competitiveScoring,
|
|
89826
|
+
dSVpoints: dSVpoints,
|
|
89827
|
+
rSVpoints: rSVpoints,
|
|
89824
89828
|
score: acrossStatesPartisanScore,
|
|
89825
89829
|
score2: withinStatesPartisanScore,
|
|
89826
89830
|
details: {}
|
|
@@ -90292,9 +90296,9 @@ function estVotesBias(inferredSVpoints, nDistricts) {
|
|
|
90292
90296
|
}
|
|
90293
90297
|
exports.estVotesBias = estVotesBias;
|
|
90294
90298
|
// GEOMETRIC SEATS BIAS (@ V = statewide vote share)
|
|
90295
|
-
function estGeometricSeatsBias(Vf,
|
|
90299
|
+
function estGeometricSeatsBias(Vf, dSVpoints, rSVpoints) {
|
|
90296
90300
|
let BsGf = undefined;
|
|
90297
|
-
const bgsSVpoints = inferGeometricSeatsBiasPoints(
|
|
90301
|
+
const bgsSVpoints = inferGeometricSeatsBiasPoints(dSVpoints, rSVpoints);
|
|
90298
90302
|
// Interpolate the seat fraction @ Vf
|
|
90299
90303
|
const lowerPt = findBracketingLowerVf(Vf, bgsSVpoints);
|
|
90300
90304
|
const upperPt = findBracketingUpperVf(Vf, bgsSVpoints);
|
|
@@ -90307,14 +90311,13 @@ function estGeometricSeatsBias(Vf, inferredSVpoints) {
|
|
|
90307
90311
|
return BsGf;
|
|
90308
90312
|
}
|
|
90309
90313
|
exports.estGeometricSeatsBias = estGeometricSeatsBias;
|
|
90310
|
-
function inferGeometricSeatsBiasPoints(
|
|
90311
|
-
const nPoints =
|
|
90312
|
-
const inverseSVpoints = invertSVPoints(inferredSVpoints);
|
|
90314
|
+
function inferGeometricSeatsBiasPoints(dSVpoints, rSVpoints) {
|
|
90315
|
+
const nPoints = dSVpoints.length;
|
|
90313
90316
|
let bgsSVpoints = [];
|
|
90314
90317
|
for (let i = 0; i < nPoints; i++) {
|
|
90315
|
-
const Vf =
|
|
90316
|
-
const sD =
|
|
90317
|
-
const sR =
|
|
90318
|
+
const Vf = dSVpoints[i].v;
|
|
90319
|
+
const sD = dSVpoints[i].s;
|
|
90320
|
+
const sR = rSVpoints[i].s;
|
|
90318
90321
|
const BsGf = 0.5 * (sR - sD);
|
|
90319
90322
|
bgsSVpoints.push({ v: Vf, s: BsGf });
|
|
90320
90323
|
}
|
|
@@ -90473,11 +90476,10 @@ function calcLopsidedOutcomes(VfArray) {
|
|
|
90473
90476
|
}
|
|
90474
90477
|
exports.calcLopsidedOutcomes = calcLopsidedOutcomes;
|
|
90475
90478
|
// GLOBAL SYMMETRY - Fig. 17 in Section 5.1
|
|
90476
|
-
function calcGlobalSymmetry(
|
|
90477
|
-
const invertedSVpoints = invertSVPoints(inferredSVpoints);
|
|
90479
|
+
function calcGlobalSymmetry(dSVpoints, rSVpoints, S50V) {
|
|
90478
90480
|
let gSym = 0.0;
|
|
90479
|
-
for (let i in
|
|
90480
|
-
gSym += Math.abs(
|
|
90481
|
+
for (let i in dSVpoints) {
|
|
90482
|
+
gSym += Math.abs(dSVpoints[i].s - rSVpoints[i].s) / 2;
|
|
90481
90483
|
}
|
|
90482
90484
|
const sign = (S50V < 0) ? -1 : 1;
|
|
90483
90485
|
gSym *= sign;
|