@dra2020/dra-analytics 3.1.0 → 3.1.4
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/dra-analytics.js +23 -10
- package/dist/dra-analytics.js.map +1 -1
- package/lib/partisan/bias.ts +28 -10
- package/package.json +1 -1
- package/dist/all/all.d.ts +0 -18
- package/dist/all/compactness.d.ts +0 -1
- package/dist/all/equal.d.ts +0 -1
- package/dist/all/graph.d.ts +0 -1
- package/dist/all/minority.d.ts +0 -1
- package/dist/all/partisan.d.ts +0 -1
- package/dist/all/rate.d.ts +0 -1
- package/dist/all/splitting.d.ts +0 -1
- package/dist/all/types.d.ts +0 -1
- package/dist/all/utils.d.ts +0 -1
- package/dist/cli/hello.d.ts +0 -1
- package/dist/compactness/all.d.ts +0 -3
- package/dist/compactness/compactness.d.ts +0 -4
- package/dist/compactness/features.d.ts +0 -10
- package/dist/compactness/kiwysi.d.ts +0 -7
- package/dist/compactness/matrix.d.ts +0 -2
- package/dist/compactness/types.d.ts +0 -19
- package/dist/equal/all.d.ts +0 -1
- package/dist/equal/population.d.ts +0 -4
- package/dist/graph/all.d.ts +0 -2
- package/dist/graph/connected.d.ts +0 -2
- package/dist/graph/embedded.d.ts +0 -2
- package/dist/graph/settings.d.ts +0 -2
- package/dist/graph/types.d.ts +0 -14
- package/dist/graph/utils.d.ts +0 -5
- package/dist/hello/all.d.ts +0 -1
- package/dist/hello/hello.d.ts +0 -1
- package/dist/minority/all.d.ts +0 -2
- package/dist/minority/minority.d.ts +0 -15
- package/dist/minority/rpv.d.ts +0 -2
- package/dist/minority/settings.d.ts +0 -0
- package/dist/minority/types.d.ts +0 -53
- package/dist/minority/utils.d.ts +0 -0
- package/dist/partisan/all.d.ts +0 -6
- package/dist/partisan/altogether.d.ts +0 -1
- package/dist/partisan/bias.d.ts +0 -25
- package/dist/partisan/erf.d.ts +0 -1
- package/dist/partisan/method.d.ts +0 -11
- package/dist/partisan/responsiveness.d.ts +0 -11
- package/dist/rate/all.d.ts +0 -4
- package/dist/rate/dra-config.d.ts +0 -23
- package/dist/rate/dra-ratings.d.ts +0 -25
- package/dist/rate/normalize.d.ts +0 -17
- package/dist/rate/settings.d.ts +0 -3
- package/dist/score/all.d.ts +0 -1
- package/dist/score/config.d.ts +0 -24
- package/dist/score/dra-config.d.ts +0 -23
- package/dist/score/dra-ratings.d.ts +0 -18
- package/dist/score/normalize.d.ts +0 -17
- package/dist/score/settings.d.ts +0 -6
- package/dist/splitting/all.d.ts +0 -3
- package/dist/splitting/coi.d.ts +0 -2
- package/dist/splitting/county-district.d.ts +0 -19
- package/dist/splitting/utils.d.ts +0 -1
- package/dist/types/all.d.ts +0 -22
- package/dist/types/compactness.d.ts +0 -47
- package/dist/types/general.d.ts +0 -11
- package/dist/types/graph.d.ts +0 -14
- package/dist/types/minority.d.ts +0 -90
- package/dist/types/misc.d.ts +0 -4
- package/dist/types/partisan.d.ts +0 -64
- package/dist/types/population.d.ts +0 -7
- package/dist/types/responsiveness.d.ts +0 -11
- package/dist/types/splitting.d.ts +0 -9
- package/dist/utils/all.d.ts +0 -3
- package/dist/utils/array.d.ts +0 -9
- package/dist/utils/general.d.ts +0 -2
- package/dist/utils/settings.d.ts +0 -3
package/dist/dra-analytics.js
CHANGED
|
@@ -2109,14 +2109,21 @@ function calcGamma(Vf, Sf, r) {
|
|
|
2109
2109
|
}
|
|
2110
2110
|
exports.calcGamma = calcGamma;
|
|
2111
2111
|
// EXPERIMENTAL
|
|
2112
|
+
const pctWidth = 5; // The size in % points of the 'local' window to bracket <V>
|
|
2112
2113
|
// Average local asymmetry
|
|
2113
2114
|
function estLocalAsymmetry(Vf, dSVpoints, rSVpoints) {
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2115
|
+
try {
|
|
2116
|
+
const dPts = svPointRange(Vf, dSVpoints);
|
|
2117
|
+
const rPts = svPointRange(Vf, rSVpoints);
|
|
2118
|
+
if (!dPts || !rPts)
|
|
2119
|
+
return undefined;
|
|
2120
|
+
const lSym = rangeAsymmetry(dPts, rPts);
|
|
2121
|
+
return lSym;
|
|
2122
|
+
}
|
|
2123
|
+
catch (err) {
|
|
2124
|
+
console.log("Exception in estLocalAsymmetry ...");
|
|
2117
2125
|
return undefined;
|
|
2118
|
-
|
|
2119
|
-
return lSym;
|
|
2126
|
+
}
|
|
2120
2127
|
}
|
|
2121
2128
|
exports.estLocalAsymmetry = estLocalAsymmetry;
|
|
2122
2129
|
function rangeAsymmetry(dSVpoints, rSVpoints) {
|
|
@@ -2132,11 +2139,17 @@ function rangeAsymmetry(dSVpoints, rSVpoints) {
|
|
|
2132
2139
|
exports.rangeAsymmetry = rangeAsymmetry;
|
|
2133
2140
|
// Average local disproportionality
|
|
2134
2141
|
function estLocalDisproportionality(Vf, dSVpoints) {
|
|
2135
|
-
|
|
2136
|
-
|
|
2142
|
+
try {
|
|
2143
|
+
const dPts = svPointRange(Vf, dSVpoints);
|
|
2144
|
+
if (!dPts)
|
|
2145
|
+
return undefined;
|
|
2146
|
+
const lProp = rangeDisproportionality(dPts);
|
|
2147
|
+
return lProp;
|
|
2148
|
+
}
|
|
2149
|
+
catch (err) {
|
|
2150
|
+
console.log("Exception in estLocalDisproportionality ...");
|
|
2137
2151
|
return undefined;
|
|
2138
|
-
|
|
2139
|
-
return lProp;
|
|
2152
|
+
}
|
|
2140
2153
|
}
|
|
2141
2154
|
exports.estLocalDisproportionality = estLocalDisproportionality;
|
|
2142
2155
|
function rangeDisproportionality(dSVpoints) {
|
|
@@ -2187,7 +2200,7 @@ exports.rangeDisproportionalityAlt = rangeDisproportionalityAlt;
|
|
|
2187
2200
|
function svPointRange(Vf, svPoints) {
|
|
2188
2201
|
const svRange = [0.25, 0.75]; // The range over which we infer the S–V curve points
|
|
2189
2202
|
const halfStep = (1 / 100) / 2; // The V point increments, i.e., every half a percent
|
|
2190
|
-
const localWindow =
|
|
2203
|
+
const localWindow = pctWidth / 100; // # of % points wide as a fraction
|
|
2191
2204
|
const plusMinus = localWindow / 2; // +/– % as a fraction
|
|
2192
2205
|
const delta = plusMinus + (halfStep / 2); // +/– % plus half a half step to deal w/ floating point precision
|
|
2193
2206
|
if ((Vf < svRange[0]) || (Vf > svRange[1]))
|