@dra2020/district-analytics 7.1.0 → 7.1.3
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 +10 -47
- package/dist/cli.js.map +1 -1
- package/dist/district-analytics.js +9 -4
- package/dist/district-analytics.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -89649,11 +89649,8 @@ const C = __importStar(__webpack_require__(/*! ./config */ "./src/config.ts"));
|
|
|
89649
89649
|
const normalize_1 = __webpack_require__(/*! ./normalize */ "./src/normalize.ts");
|
|
89650
89650
|
// NOTE - I'm passing T.VfArray's into everything. District indices = array indices.
|
|
89651
89651
|
// NOTE - I do not (cannot) assume that the values are sorted.
|
|
89652
|
-
// TODO - Revise this.
|
|
89653
89652
|
// SCORE BIAS & COMPETITIVENESS
|
|
89654
|
-
/*
|
|
89655
|
-
|
|
89656
|
-
* ??? [statewideV] (V) = the average statewide two-party vote for Democrats
|
|
89653
|
+
/* Report fields:
|
|
89657
89654
|
|
|
89658
89655
|
* ^S# [bestS] = the Democratic seats closest to proportional
|
|
89659
89656
|
* ^S% [bestSf] = the corresponding Democratic seat share
|
|
@@ -89712,7 +89709,6 @@ function scorePartisan(Vf, VfArray, options) {
|
|
|
89712
89709
|
// Calculate additional alternate metrics for reference
|
|
89713
89710
|
const dSVpoints = inferSVpoints(Vf, VfArray, shift);
|
|
89714
89711
|
const rSVpoints = invertSVPoints(dSVpoints);
|
|
89715
|
-
// const dSVpoints = bAdvanced ? inferSVpoints(Vf, VfArray, shift) : undefined;
|
|
89716
89712
|
const TOf = bAdvanced ? calcTurnoutBias(Vf, VfArray) : undefined;
|
|
89717
89713
|
const Bs50 = bAdvanced ? estPartisanBias(dSVpoints, N) : undefined;
|
|
89718
89714
|
const Bs50f = (!(Bs50 === undefined)) ? U.trim(Bs50 / N) : undefined;
|
|
@@ -89885,44 +89881,6 @@ function scoreCompetitiveness(Cdf) {
|
|
|
89885
89881
|
return score;
|
|
89886
89882
|
}
|
|
89887
89883
|
exports.scoreCompetitiveness = scoreCompetitiveness;
|
|
89888
|
-
/* NOTE - Original version:
|
|
89889
|
-
export function scoreCompetitiveness(rawMarginal: number, rawOverall: number): number
|
|
89890
|
-
{
|
|
89891
|
-
// Normalize overall competitiveness - Raw values are in the range [0.0–1.0].
|
|
89892
|
-
// But the practical max is more like 2/3's, so unitize that range to [0.0–1.0].
|
|
89893
|
-
// Then scale the values to [0–100].
|
|
89894
|
-
const _overall = new Normalizer(rawOverall);
|
|
89895
|
-
|
|
89896
|
-
let worst = C.overallCompetitivenessRange()[C.BEG];
|
|
89897
|
-
let best = C.overallCompetitivenessRange()[C.END];
|
|
89898
|
-
|
|
89899
|
-
_overall.clip(worst, best);
|
|
89900
|
-
_overall.unitize(worst, best);
|
|
89901
|
-
_overall.rescale();
|
|
89902
|
-
|
|
89903
|
-
const ocS = _overall.normalizedNum as number;
|
|
89904
|
-
|
|
89905
|
-
|
|
89906
|
-
// Normalize marginal competitiveness
|
|
89907
|
-
const _marginal = new Normalizer(rawMarginal);
|
|
89908
|
-
|
|
89909
|
-
worst = C.marginalCompetitivenessRange()[C.BEG];
|
|
89910
|
-
best = C.marginalCompetitivenessRange()[C.END];
|
|
89911
|
-
|
|
89912
|
-
_marginal.clip(worst, best);
|
|
89913
|
-
_marginal.unitize(worst, best);
|
|
89914
|
-
_marginal.rescale();
|
|
89915
|
-
const mcS = _marginal.normalizedNum as number;
|
|
89916
|
-
|
|
89917
|
-
const mcW = C.marginalCompetitivenessWeight();
|
|
89918
|
-
const ocW = C.overallCompetitivenessWeight();
|
|
89919
|
-
|
|
89920
|
-
// Then combine the results
|
|
89921
|
-
const score = ((mcW + ocW) > 0) ? Math.round(((mcW * mcS) + (ocW * ocS)) / (mcW + ocW)) : 0;
|
|
89922
|
-
|
|
89923
|
-
return score;
|
|
89924
|
-
}
|
|
89925
|
-
*/
|
|
89926
89884
|
// CORE CAPABILITIES FROM JOHN NAGLE'S METHOD
|
|
89927
89885
|
const { erf } = __webpack_require__(/*! mathjs */ "./node_modules/mathjs/main/esm/index.js");
|
|
89928
89886
|
// console.log("erf(0.2) =", erf(0.2)); // returns 0.22270258921047847
|
|
@@ -103705,7 +103663,12 @@ function doFindCountiesSplitUnexpectedly(s, bLog = false) {
|
|
|
103705
103663
|
}
|
|
103706
103664
|
// ... and convert the FIPS codes to county names.
|
|
103707
103665
|
for (let fips of countiesSplitUnexpectedlyFIPS) {
|
|
103708
|
-
|
|
103666
|
+
const name = s.counties.nameFromFIPS(fips);
|
|
103667
|
+
// 07-06-20 - Guard in case the FIPS code isn't in the county name lookup
|
|
103668
|
+
if (name)
|
|
103669
|
+
countiesSplitUnexpectedly.push(name);
|
|
103670
|
+
else
|
|
103671
|
+
console.log("County is not in the FIPS-to-name lookup table: ", fips);
|
|
103709
103672
|
}
|
|
103710
103673
|
countiesSplitUnexpectedly = countiesSplitUnexpectedly.sort();
|
|
103711
103674
|
test['score'] = U.trim(unexpectedAffected);
|
|
@@ -104321,9 +104284,9 @@ function doAnalyzePostProcessing(s, bLog = false) {
|
|
|
104321
104284
|
scorecard.details['shapes'] = datasets.shapes;
|
|
104322
104285
|
scorecard.details['census'] = datasets.census;
|
|
104323
104286
|
const simpleSplits = s.getTest(5 /* UnexpectedCountySplits */);
|
|
104324
|
-
scorecard.
|
|
104325
|
-
scorecard.
|
|
104326
|
-
scorecard.
|
|
104287
|
+
scorecard.splitting.details['unexpectedAffected'] = simpleSplits['score'];
|
|
104288
|
+
scorecard.splitting.details['nSplits'] = simpleSplits['details']['nSplits'];
|
|
104289
|
+
scorecard.splitting.details['countiesSplitUnexpectedly'] = U.deepCopy(simpleSplits['details']['countiesSplitUnexpectedly']);
|
|
104327
104290
|
// NOTE - Add split precincts in dra-client directly
|
|
104328
104291
|
// Derive secondary tests
|
|
104329
104292
|
analyze_1.doDeriveSecondaryTests(s, bLog);
|