@dra2020/dra-analytics 4.1.8 → 5.0.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.
@@ -24,11 +24,3 @@ export declare function calcDisproportionality(Vf: number, Sf: number): number;
24
24
  export declare function calcBigR(Vf: number, Sf: number): number | undefined;
25
25
  export declare function calcMinimalInverseResponsiveness(Vf: number, r: number): number | undefined;
26
26
  export declare function calcGamma(Vf: number, Sf: number, r: number): number;
27
- export declare function estLocalAsymmetry(Vf: number, dSVpoints: T.SVpoint[], rSVpoints: T.SVpoint[]): number | undefined;
28
- export declare function rangeAsymmetry(dSVpoints: T.SVpoint[], rSVpoints: T.SVpoint[]): number;
29
- export declare function estLocalDisproportionality(Vf: number, dSVpoints: T.SVpoint[]): number | undefined;
30
- export declare function rangeDisproportionality(dSVpoints: T.SVpoint[]): number;
31
- export declare function estLocalDisproportionalityAlt(Vf: number, N: number, dSVpoints: T.SVpoint[]): number | undefined;
32
- export declare function rangeDisproportionalityAlt(N: number, dSVpoints: T.SVpoint[]): number;
33
- export declare function estLocalUnearnedSeats(Vf: number, N: number, dSVpoints: T.SVpoint[]): number | undefined;
34
- export declare function rangeUnearnedSeats(N: number, dSVpoints: T.SVpoint[]): number;
@@ -52,12 +52,6 @@ export type Responsiveness = {
52
52
  cDf: number;
53
53
  score?: number;
54
54
  };
55
- export type Experimental = {
56
- lSym?: number;
57
- lProp?: number;
58
- lPropAlt?: number;
59
- lUE?: number;
60
- };
61
55
  export type PartisanScorecard = {
62
56
  bias: Bias;
63
57
  impact: Impact;
@@ -66,7 +60,6 @@ export type PartisanScorecard = {
66
60
  rSVpoints: SVpoint[];
67
61
  averageDVf: number | undefined;
68
62
  averageRVf: number | undefined;
69
- experimental: Experimental;
70
63
  details: T.Dict;
71
64
  };
72
65
  export type PartisanJSONReady = {
@@ -33,8 +33,8 @@ import
33
33
  invertSVPoints, keyRVpoints, calcDeclination,
34
34
  calcGlobalSymmetry, estGeometricSeatsBias, calcDisproportionality, calcMeanMedianDifference, calcLopsidedOutcomes, calcBigR, calcGamma,
35
35
  calcMinimalInverseResponsiveness,
36
- // EXPERIMENTAL
37
- estLocalAsymmetry, estLocalDisproportionality, estLocalDisproportionalityAlt, estLocalUnearnedSeats
36
+ // // EXPERIMENTAL
37
+ // estLocalAsymmetry, estLocalDisproportionality, estLocalDisproportionalityAlt, estLocalUnearnedSeats
38
38
  } from '../../lib/partisan/bias'
39
39
 
40
40
  import
@@ -104,12 +104,12 @@ export function makePartisanScorecard(Vf: number, VfArray: T.VfArray, bLog: bool
104
104
  const cD = estCompetitiveDistricts(VfArray);
105
105
  const cDf = estCompetitiveDistrictsShare(cD, N);
106
106
 
107
- // EXPERIMENTAL
107
+ // // EXPERIMENTAL
108
108
 
109
- const lSym = estLocalAsymmetry(Vf, dSVpoints, rSVpoints);
110
- const lProp = estLocalDisproportionality(Vf, dSVpoints);
111
- const lPropAlt = estLocalDisproportionalityAlt(Vf, N, dSVpoints);
112
- const lUE = estLocalUnearnedSeats(Vf, N, dSVpoints);
109
+ // const lSym = estLocalAsymmetry(Vf, dSVpoints, rSVpoints);
110
+ // const lProp = estLocalDisproportionality(Vf, dSVpoints);
111
+ // const lPropAlt = estLocalDisproportionalityAlt(Vf, N, dSVpoints);
112
+ // const lUE = estLocalUnearnedSeats(Vf, N, dSVpoints);
113
113
 
114
114
  const biasMeasurements: T.Bias = {
115
115
  bestS: bestS,
@@ -156,12 +156,13 @@ export function makePartisanScorecard(Vf: number, VfArray: T.VfArray, bLog: bool
156
156
  const averageDVf = (DWins.length > 0) ? U.avgArray(DWins) : undefined;
157
157
  const averageRVf = (RWins.length > 0) ? U.avgArray(RWins) : undefined;
158
158
 
159
- const experimentalMetrics: T.Experimental = {
160
- lSym: lSym,
161
- lProp: lProp,
162
- lPropAlt: lPropAlt,
163
- lUE: lUE
164
- };
159
+ // // EXPERIMENTAL
160
+ // const experimentalMetrics: T.Experimental = {
161
+ // lSym: lSym,
162
+ // lProp: lProp,
163
+ // lPropAlt: lPropAlt,
164
+ // lUE: lUE
165
+ // };
165
166
 
166
167
  const s: T.PartisanScorecard = {
167
168
  bias: biasMeasurements,
@@ -171,7 +172,7 @@ export function makePartisanScorecard(Vf: number, VfArray: T.VfArray, bLog: bool
171
172
  rSVpoints: rSVpoints,
172
173
  averageDVf: averageDVf,
173
174
  averageRVf: averageRVf,
174
- experimental: experimentalMetrics,
175
+ // experimental: experimentalMetrics,
175
176
  details: {}
176
177
  };
177
178
 
@@ -518,163 +518,163 @@ export function calcGamma(Vf: number, Sf: number, r: number): number
518
518
  }
519
519
 
520
520
 
521
- // EXPERIMENTAL
521
+ // // EXPERIMENTAL
522
522
 
523
- const pctWidth = 5; // The size in % points of the 'local' window to bracket <V>
523
+ // const pctWidth = 5; // The size in % points of the 'local' window to bracket <V>
524
524
 
525
- // Average local asymmetry
526
- export function estLocalAsymmetry(Vf: number, dSVpoints: T.SVpoint[], rSVpoints: T.SVpoint[]): number | undefined
527
- {
528
- try
529
- {
530
- const dPts = svPointRange(Vf, dSVpoints);
531
- const rPts = svPointRange(Vf, rSVpoints);
525
+ // // Average local asymmetry
526
+ // export function estLocalAsymmetry(Vf: number, dSVpoints: T.SVpoint[], rSVpoints: T.SVpoint[]): number | undefined
527
+ // {
528
+ // try
529
+ // {
530
+ // const dPts = svPointRange(Vf, dSVpoints);
531
+ // const rPts = svPointRange(Vf, rSVpoints);
532
532
 
533
- if (!dPts || !rPts) return undefined;
533
+ // if (!dPts || !rPts) return undefined;
534
534
 
535
- const lSym: number = rangeAsymmetry(dPts, rPts);
535
+ // const lSym: number = rangeAsymmetry(dPts, rPts);
536
536
 
537
- return lSym;
538
- }
539
- catch (err)
540
- {
541
- console.log("Exception in estLocalAsymmetry ...");
542
- return undefined;
543
- }
544
- }
537
+ // return lSym;
538
+ // }
539
+ // catch (err)
540
+ // {
541
+ // console.log("Exception in estLocalAsymmetry ...");
542
+ // return undefined;
543
+ // }
544
+ // }
545
545
 
546
- export function rangeAsymmetry(dSVpoints: T.SVpoint[], rSVpoints: T.SVpoint[]): number
547
- {
548
- const ndPts: number = dSVpoints.length;
549
- const nrPts: number = rSVpoints.length;
546
+ // export function rangeAsymmetry(dSVpoints: T.SVpoint[], rSVpoints: T.SVpoint[]): number
547
+ // {
548
+ // const ndPts: number = dSVpoints.length;
549
+ // const nrPts: number = rSVpoints.length;
550
550
 
551
- console.assert(ndPts == nrPts, "# of D & R points don't match: ", ndPts, nrPts);
551
+ // console.assert(ndPts == nrPts, "# of D & R points don't match: ", ndPts, nrPts);
552
552
 
553
- let tot: number = 0.0;
553
+ // let tot: number = 0.0;
554
554
 
555
- for (let i in dSVpoints)
556
- {
557
- tot += calcGeometricSeatsBias(dSVpoints[i].s, rSVpoints[i].s);
558
- }
555
+ // for (let i in dSVpoints)
556
+ // {
557
+ // tot += calcGeometricSeatsBias(dSVpoints[i].s, rSVpoints[i].s);
558
+ // }
559
559
 
560
- return tot / ndPts;
561
- }
560
+ // return tot / ndPts;
561
+ // }
562
562
 
563
- // Average local disproportionality
564
- export function estLocalDisproportionality(Vf: number, dSVpoints: T.SVpoint[]): number | undefined
565
- {
566
- try
567
- {
568
- const dPts = svPointRange(Vf, dSVpoints);
563
+ // // Average local disproportionality
564
+ // export function estLocalDisproportionality(Vf: number, dSVpoints: T.SVpoint[]): number | undefined
565
+ // {
566
+ // try
567
+ // {
568
+ // const dPts = svPointRange(Vf, dSVpoints);
569
569
 
570
- if (!dPts) return undefined;
570
+ // if (!dPts) return undefined;
571
571
 
572
- const lProp: number = rangeDisproportionality(dPts);
572
+ // const lProp: number = rangeDisproportionality(dPts);
573
573
 
574
- return lProp;
575
- }
576
- catch (err)
577
- {
578
- console.log("Exception in estLocalDisproportionality ...");
579
- return undefined;
580
- }
581
- }
574
+ // return lProp;
575
+ // }
576
+ // catch (err)
577
+ // {
578
+ // console.log("Exception in estLocalDisproportionality ...");
579
+ // return undefined;
580
+ // }
581
+ // }
582
582
 
583
- export function rangeDisproportionality(dSVpoints: T.SVpoint[]): number
584
- {
585
- const ndPts: number = dSVpoints.length;
583
+ // export function rangeDisproportionality(dSVpoints: T.SVpoint[]): number
584
+ // {
585
+ // const ndPts: number = dSVpoints.length;
586
586
 
587
- let tot: number = 0.0;
587
+ // let tot: number = 0.0;
588
588
 
589
- for (let i in dSVpoints)
590
- {
591
- tot += calcProp(dSVpoints[i].v, dSVpoints[i].s);
592
- }
589
+ // for (let i in dSVpoints)
590
+ // {
591
+ // tot += calcProp(dSVpoints[i].v, dSVpoints[i].s);
592
+ // }
593
593
 
594
- return tot / ndPts;
595
- }
594
+ // return tot / ndPts;
595
+ // }
596
596
 
597
- // Average local disproportionality from the best # of seats (closest to proportional)
598
- export function estLocalDisproportionalityAlt(Vf: number, N: number, dSVpoints: T.SVpoint[]): number | undefined
599
- {
600
- const dPts = svPointRange(Vf, dSVpoints);
597
+ // // Average local disproportionality from the best # of seats (closest to proportional)
598
+ // export function estLocalDisproportionalityAlt(Vf: number, N: number, dSVpoints: T.SVpoint[]): number | undefined
599
+ // {
600
+ // const dPts = svPointRange(Vf, dSVpoints);
601
601
 
602
- if (!dPts) return undefined;
602
+ // if (!dPts) return undefined;
603
603
 
604
- const lPropAlt: number = rangeDisproportionalityAlt(N, dPts);
604
+ // const lPropAlt: number = rangeDisproportionalityAlt(N, dPts);
605
605
 
606
- return lPropAlt;
607
- }
606
+ // return lPropAlt;
607
+ // }
608
608
 
609
- // Dynamically calculate the best # seats, so this is a step function
610
- export function rangeDisproportionalityAlt(N: number, dSVpoints: T.SVpoint[]): number
611
- {
612
- const ndPts: number = dSVpoints.length;
609
+ // // Dynamically calculate the best # seats, so this is a step function
610
+ // export function rangeDisproportionalityAlt(N: number, dSVpoints: T.SVpoint[]): number
611
+ // {
612
+ // const ndPts: number = dSVpoints.length;
613
613
 
614
- let tot: number = 0.0;
614
+ // let tot: number = 0.0;
615
615
 
616
- for (let i in dSVpoints)
617
- {
618
- const bestS = bestSeats(N, dSVpoints[i].v);
619
- const bestSf = bestSeatShare(bestS, N);
616
+ // for (let i in dSVpoints)
617
+ // {
618
+ // const bestS = bestSeats(N, dSVpoints[i].v);
619
+ // const bestSf = bestSeatShare(bestS, N);
620
620
 
621
- tot += calcDisproportionalityFromBest(dSVpoints[i].s, bestSf);
622
- }
621
+ // tot += calcDisproportionalityFromBest(dSVpoints[i].s, bestSf);
622
+ // }
623
623
 
624
- return tot / ndPts;
625
- }
624
+ // return tot / ndPts;
625
+ // }
626
626
 
627
- // Average local unearned seats from the best # of seats (closest to proportional)
628
- export function estLocalUnearnedSeats(Vf: number, N: number, dSVpoints: T.SVpoint[]): number | undefined
629
- {
630
- const dPts = svPointRange(Vf, dSVpoints);
627
+ // // Average local unearned seats from the best # of seats (closest to proportional)
628
+ // export function estLocalUnearnedSeats(Vf: number, N: number, dSVpoints: T.SVpoint[]): number | undefined
629
+ // {
630
+ // const dPts = svPointRange(Vf, dSVpoints);
631
631
 
632
- if (!dPts) return undefined;
632
+ // if (!dPts) return undefined;
633
633
 
634
- const lUE: number = rangeUnearnedSeats(N, dPts);
634
+ // const lUE: number = rangeUnearnedSeats(N, dPts);
635
635
 
636
- return lUE;
637
- }
636
+ // return lUE;
637
+ // }
638
638
 
639
- export function rangeUnearnedSeats(N: number, dSVpoints: T.SVpoint[]): number
640
- {
641
- const ndPts: number = dSVpoints.length;
639
+ // export function rangeUnearnedSeats(N: number, dSVpoints: T.SVpoint[]): number
640
+ // {
641
+ // const ndPts: number = dSVpoints.length;
642
642
 
643
- let tot: number = 0.0;
643
+ // let tot: number = 0.0;
644
644
 
645
- for (let i in dSVpoints)
646
- {
647
- const estS: number = dSVpoints[i].s * N;
648
- const bestS = bestSeats(N, dSVpoints[i].v);
645
+ // for (let i in dSVpoints)
646
+ // {
647
+ // const estS: number = dSVpoints[i].s * N;
648
+ // const bestS = bestSeats(N, dSVpoints[i].v);
649
649
 
650
- tot += estUnearnedSeats(bestS, estS);
651
- }
650
+ // tot += estUnearnedSeats(bestS, estS);
651
+ // }
652
652
 
653
- return tot / ndPts;
654
- }
653
+ // return tot / ndPts;
654
+ // }
655
655
 
656
- // Filter the full [0.25–0.75] range of S–V points down to the 'local' range.
657
- // Make sure that range is w/in the full range.
658
- function svPointRange(Vf: number, svPoints: T.SVpoint[]): T.SVpoint[] | undefined
659
- {
660
- const svRange: number[] = [0.25, 0.75]; // The range over which we infer the S–V curve points
661
- const halfStep: number = (1 / 100) / 2; // The V point increments, i.e., every half a percent
662
- const localWindow: number = pctWidth / 100; // # of % points wide as a fraction
663
- const plusMinus: number = localWindow / 2; // +/– % as a fraction
664
- const delta: number = plusMinus + (halfStep / 2); // +/– % plus half a half step to deal w/ floating point precision
656
+ // // Filter the full [0.25–0.75] range of S–V points down to the 'local' range.
657
+ // // Make sure that range is w/in the full range.
658
+ // function svPointRange(Vf: number, svPoints: T.SVpoint[]): T.SVpoint[] | undefined
659
+ // {
660
+ // const svRange: number[] = [0.25, 0.75]; // The range over which we infer the S–V curve points
661
+ // const halfStep: number = (1 / 100) / 2; // The V point increments, i.e., every half a percent
662
+ // const localWindow: number = pctWidth / 100; // # of % points wide as a fraction
663
+ // const plusMinus: number = localWindow / 2; // +/– % as a fraction
664
+ // const delta: number = plusMinus + (halfStep / 2); // +/– % plus half a half step to deal w/ floating point precision
665
665
 
666
- if ((Vf < svRange[0]) || (Vf > svRange[1])) return undefined;
666
+ // if ((Vf < svRange[0]) || (Vf > svRange[1])) return undefined;
667
667
 
668
- const bracketingVs: number[] = [
669
- findBracketingLowerVf(Vf, svPoints).v,
670
- findBracketingUpperVf(Vf, svPoints).v
671
- ];
668
+ // const bracketingVs: number[] = [
669
+ // findBracketingLowerVf(Vf, svPoints).v,
670
+ // findBracketingUpperVf(Vf, svPoints).v
671
+ // ];
672
672
 
673
- const localRange: number[] = [bracketingVs[0] - delta, bracketingVs[1] + delta];
673
+ // const localRange: number[] = [bracketingVs[0] - delta, bracketingVs[1] + delta];
674
674
 
675
- const subsetPts: T.SVpoint[] = svPoints.filter(x => inRange(x, localRange));
675
+ // const subsetPts: T.SVpoint[] = svPoints.filter(x => inRange(x, localRange));
676
676
 
677
- return subsetPts;
678
- }
677
+ // return subsetPts;
678
+ // }
679
679
 
680
- const inRange = (pt: T.SVpoint, range: number[]): boolean => {return (pt.v >= range[0]) && (pt.v <= range[1]);}
680
+ // const inRange = (pt: T.SVpoint, range: number[]): boolean => {return (pt.v >= range[0]) && (pt.v <= range[1]);}
@@ -79,14 +79,14 @@ export type Responsiveness = {
79
79
  }
80
80
 
81
81
 
82
- // EXPERIMENTAL
82
+ // // EXPERIMENTAL
83
83
 
84
- export type Experimental = {
85
- lSym?: number,
86
- lProp?: number,
87
- lPropAlt?: number,
88
- lUE?: number
89
- }
84
+ // export type Experimental = {
85
+ // lSym?: number,
86
+ // lProp?: number,
87
+ // lPropAlt?: number,
88
+ // lUE?: number
89
+ // }
90
90
 
91
91
 
92
92
  // COMBINED SCORECARD
@@ -99,7 +99,7 @@ export type PartisanScorecard = {
99
99
  rSVpoints: SVpoint[],
100
100
  averageDVf: number | undefined,
101
101
  averageRVf: number | undefined,
102
- experimental: Experimental,
102
+ // experimental: Experimental,
103
103
  details: T.Dict
104
104
  }
105
105
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@dra2020/dra-analytics",
3
- "version": "4.1.8",
3
+ "version": "5.0.0",
4
4
  "description": "DRA analytics",
5
5
  "main": "dist/dra-analytics.js",
6
6
  "types": "./dist/lib/all/all.d.ts",
7
7
  "scripts": {
8
8
  "test": "jest",
9
9
  "build": "webpack",
10
- "webpack": "node_modules/.bin/webpack",
10
+ "webpack": "webpack",
11
11
  "buildpartisan": "webpack --config cli/partisan.config.js",
12
12
  "buildcompactness": "webpack --config cli/compactness.config.js",
13
13
  "buildsplitting": "webpack --config cli/splitting.config.js"