@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.
Files changed (72) hide show
  1. package/dist/dra-analytics.js +23 -10
  2. package/dist/dra-analytics.js.map +1 -1
  3. package/lib/partisan/bias.ts +28 -10
  4. package/package.json +1 -1
  5. package/dist/all/all.d.ts +0 -18
  6. package/dist/all/compactness.d.ts +0 -1
  7. package/dist/all/equal.d.ts +0 -1
  8. package/dist/all/graph.d.ts +0 -1
  9. package/dist/all/minority.d.ts +0 -1
  10. package/dist/all/partisan.d.ts +0 -1
  11. package/dist/all/rate.d.ts +0 -1
  12. package/dist/all/splitting.d.ts +0 -1
  13. package/dist/all/types.d.ts +0 -1
  14. package/dist/all/utils.d.ts +0 -1
  15. package/dist/cli/hello.d.ts +0 -1
  16. package/dist/compactness/all.d.ts +0 -3
  17. package/dist/compactness/compactness.d.ts +0 -4
  18. package/dist/compactness/features.d.ts +0 -10
  19. package/dist/compactness/kiwysi.d.ts +0 -7
  20. package/dist/compactness/matrix.d.ts +0 -2
  21. package/dist/compactness/types.d.ts +0 -19
  22. package/dist/equal/all.d.ts +0 -1
  23. package/dist/equal/population.d.ts +0 -4
  24. package/dist/graph/all.d.ts +0 -2
  25. package/dist/graph/connected.d.ts +0 -2
  26. package/dist/graph/embedded.d.ts +0 -2
  27. package/dist/graph/settings.d.ts +0 -2
  28. package/dist/graph/types.d.ts +0 -14
  29. package/dist/graph/utils.d.ts +0 -5
  30. package/dist/hello/all.d.ts +0 -1
  31. package/dist/hello/hello.d.ts +0 -1
  32. package/dist/minority/all.d.ts +0 -2
  33. package/dist/minority/minority.d.ts +0 -15
  34. package/dist/minority/rpv.d.ts +0 -2
  35. package/dist/minority/settings.d.ts +0 -0
  36. package/dist/minority/types.d.ts +0 -53
  37. package/dist/minority/utils.d.ts +0 -0
  38. package/dist/partisan/all.d.ts +0 -6
  39. package/dist/partisan/altogether.d.ts +0 -1
  40. package/dist/partisan/bias.d.ts +0 -25
  41. package/dist/partisan/erf.d.ts +0 -1
  42. package/dist/partisan/method.d.ts +0 -11
  43. package/dist/partisan/responsiveness.d.ts +0 -11
  44. package/dist/rate/all.d.ts +0 -4
  45. package/dist/rate/dra-config.d.ts +0 -23
  46. package/dist/rate/dra-ratings.d.ts +0 -25
  47. package/dist/rate/normalize.d.ts +0 -17
  48. package/dist/rate/settings.d.ts +0 -3
  49. package/dist/score/all.d.ts +0 -1
  50. package/dist/score/config.d.ts +0 -24
  51. package/dist/score/dra-config.d.ts +0 -23
  52. package/dist/score/dra-ratings.d.ts +0 -18
  53. package/dist/score/normalize.d.ts +0 -17
  54. package/dist/score/settings.d.ts +0 -6
  55. package/dist/splitting/all.d.ts +0 -3
  56. package/dist/splitting/coi.d.ts +0 -2
  57. package/dist/splitting/county-district.d.ts +0 -19
  58. package/dist/splitting/utils.d.ts +0 -1
  59. package/dist/types/all.d.ts +0 -22
  60. package/dist/types/compactness.d.ts +0 -47
  61. package/dist/types/general.d.ts +0 -11
  62. package/dist/types/graph.d.ts +0 -14
  63. package/dist/types/minority.d.ts +0 -90
  64. package/dist/types/misc.d.ts +0 -4
  65. package/dist/types/partisan.d.ts +0 -64
  66. package/dist/types/population.d.ts +0 -7
  67. package/dist/types/responsiveness.d.ts +0 -11
  68. package/dist/types/splitting.d.ts +0 -9
  69. package/dist/utils/all.d.ts +0 -3
  70. package/dist/utils/array.d.ts +0 -9
  71. package/dist/utils/general.d.ts +0 -2
  72. package/dist/utils/settings.d.ts +0 -3
@@ -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
- const dPts = svPointRange(Vf, dSVpoints);
2115
- const rPts = svPointRange(Vf, rSVpoints);
2116
- if (!dPts || !rPts)
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
- const lSym = rangeAsymmetry(dPts, rPts);
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
- const dPts = svPointRange(Vf, dSVpoints);
2136
- if (!dPts)
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
- const lProp = rangeDisproportionality(dPts);
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 = 5 / 100; // # of % points wide as a fraction - more than 2x avgSVError
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]))