@dra2020/district-analytics 14.1.2 → 14.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.
@@ -5,3 +5,18 @@ export * from './minority';
5
5
  export * from './partisan';
6
6
  export * from './population';
7
7
  export * from './splitting';
8
+ import { PartisanScorecard } from './partisan';
9
+ import { MinorityScorecard } from './minority';
10
+ import { CompactnessScorecard } from './compactness';
11
+ import { SplittingScorecard } from './splitting';
12
+ import { PopulationScorecard } from './population';
13
+ import { Dict } from './general';
14
+ export declare type Scorecard = {
15
+ partisan: PartisanScorecard;
16
+ minority: MinorityScorecard;
17
+ compactness: CompactnessScorecard;
18
+ splitting: SplittingScorecard;
19
+ populationDeviation: PopulationScorecard;
20
+ details: Dict;
21
+ scratchpad: Dict;
22
+ };
@@ -8,6 +8,8 @@ export declare type CompactnessFeatures = {
8
8
  polsby: number;
9
9
  hull: number;
10
10
  schwartzberg: number;
11
+ reockFlat: number;
12
+ polsbyFlat: number;
11
13
  };
12
14
  export declare type FeaturesEntry = {
13
15
  n: number;
@@ -29,7 +31,7 @@ export declare type CompactnessScorecard = {
29
31
  avgKWIWYSI: number;
30
32
  byDistrict: CompactnessByDistrict[];
31
33
  details: T.Dict;
32
- rating?: number;
34
+ score?: number;
33
35
  };
34
36
  export declare type CompactnessByDistrict = {
35
37
  rawReock: number;
@@ -1,9 +1,3 @@
1
- export declare type Measurement = {
2
- raw: number;
3
- normalized?: number;
4
- byDistrict?: any[];
5
- notes: Dict;
6
- };
7
1
  export declare type Dict = {
8
2
  [key: string]: any;
9
3
  };
@@ -40,7 +40,7 @@ export declare type RPVFactor = {
40
40
  r2: number;
41
41
  demPct: number;
42
42
  sterr: number;
43
- dictPoints: dictPoint[];
43
+ points: dictPoint[];
44
44
  };
45
45
  export declare type RPVAnalysis = {
46
46
  ids: string[] | undefined;
@@ -82,9 +82,9 @@ export declare type DemographicPivot = {
82
82
  export declare type MinorityScorecard = {
83
83
  pivotByDemographic: DemographicPivot;
84
84
  opportunityDistricts: number;
85
- proportionalOpportunities: number;
86
85
  coalitionDistricts: number;
86
+ proportionalOpportunities: number;
87
87
  proportionalCoalitions: number;
88
- rating?: number;
89
88
  details: T.Dict;
89
+ score?: number;
90
90
  };
@@ -21,7 +21,7 @@ export declare type Bias = {
21
21
  estS: number;
22
22
  estSf: number;
23
23
  deviation: number;
24
- rating?: number;
24
+ score?: number;
25
25
  tOf: number;
26
26
  fptpS: number;
27
27
  bS50: number;
@@ -39,7 +39,7 @@ export declare type Bias = {
39
39
  };
40
40
  export declare type Impact = {
41
41
  unearnedS: number;
42
- rating?: number;
42
+ score?: number;
43
43
  };
44
44
  export declare type Responsiveness = {
45
45
  bigR?: number;
@@ -50,7 +50,7 @@ export declare type Responsiveness = {
50
50
  cSimple: number;
51
51
  cD: number;
52
52
  cDf: number;
53
- rating?: number;
53
+ score?: number;
54
54
  };
55
55
  export declare type PartisanScorecard = {
56
56
  bias: Bias;
@@ -2,6 +2,6 @@ import * as T from './general';
2
2
  export declare type PopulationScorecard = {
3
3
  deviation: number;
4
4
  roughlyEqual: boolean;
5
- rating?: number;
5
+ score?: number;
6
6
  notes: T.Dict;
7
7
  };
@@ -2,8 +2,8 @@ import * as T from './general';
2
2
  export declare type CountyProfile = CxD;
3
3
  export declare type CxD = number[][];
4
4
  export declare type SplittingScorecard = {
5
- county: T.Measurement;
6
- district: T.Measurement;
5
+ county: number;
6
+ district: number;
7
7
  details: T.Dict;
8
- rating?: number;
8
+ score?: number;
9
9
  };
@@ -23,6 +23,7 @@ export declare class AnalyticsSession {
23
23
  constructor(SessionRequest: T.SessionRequest);
24
24
  processConfig(config: T.Dict): T.Dict;
25
25
  analyzePlan(bLog?: boolean, overridesJSON?: any): boolean;
26
+ getGoodShapes(): T.GeoFeatureCollection;
26
27
  analyzeRacialPolarization(districtID: number, groups: Types.MinorityFilter, bLog?: boolean): Types.RPVAnalysis | undefined;
27
28
  getDistrictStatistics(bLog?: boolean): DistrictStatistics;
28
29
  getPlanProfile(bLog?: boolean): Score.Profile;
@@ -3,12 +3,13 @@ export { geoIDForFeature, fieldForFeature, inferSelectedMinority } from './_data
3
3
  export * from './results';
4
4
  export * from './types';
5
5
  export * from './utils';
6
- import { Rate, Splitting, Types } from '@dra2020/dra-analytics';
6
+ import { Partisan, Rate, Splitting, Types } from '@dra2020/dra-analytics';
7
7
  export declare type MinorityFilter = Types.MinorityFilter;
8
8
  export declare type Point = Types.dictPoint;
9
9
  export declare type DemographicVotingByFeature = Types.DemographicVotingByFeature;
10
10
  export declare type RPVFactor = Types.RPVFactor;
11
11
  export declare type RPVAnalysis = Types.RPVAnalysis;
12
+ export declare const estSeatProbability: typeof Partisan.estSeatProbability;
12
13
  export declare const ratePartisanBias: typeof Rate.ratePartisanBias;
13
14
  export declare const isAntimajoritarian: typeof Rate.isAntimajoritarian;
14
15
  export declare const avgSVError = 0.02;
@@ -0,0 +1,163 @@
1
+ export declare type Profile = {
2
+ state: string;
3
+ name: string;
4
+ nDistricts: number;
5
+ nCounties: number;
6
+ bStateLeg: boolean;
7
+ population: PopulationProfile;
8
+ shapes: ShapeProfile;
9
+ counties: CountyProfile;
10
+ partisanship: PartisanProfile;
11
+ demographics: DemographicProfile;
12
+ };
13
+ export declare type Scorecard = {
14
+ partisan: PartisanScorecard;
15
+ minority: MinorityScorecard;
16
+ compactness: CompactnessScorecard;
17
+ splitting: SplittingScorecard;
18
+ populationDeviation: PopulationScorecard;
19
+ details: Dict;
20
+ };
21
+ export declare type PartisanProfile = {
22
+ statewide: number;
23
+ byDistrict: VfArray;
24
+ };
25
+ export declare type VfArray = number[];
26
+ export declare type PartisanScorecard = {
27
+ bias: Bias;
28
+ impact: Impact;
29
+ responsiveness: Responsiveness;
30
+ dSVpoints: SVpoint[];
31
+ rSVpoints: SVpoint[];
32
+ averageDVf: number | undefined;
33
+ averageRVf: number | undefined;
34
+ details: Dict;
35
+ };
36
+ export declare type rVpoints = {
37
+ Sb: number;
38
+ Ra: number;
39
+ Rb: number;
40
+ Va: number;
41
+ Vb: number;
42
+ };
43
+ export declare type Bias = {
44
+ bestS: number;
45
+ bestSf: number;
46
+ estS: number;
47
+ estSf: number;
48
+ deviation: number;
49
+ score: number;
50
+ tOf?: number;
51
+ fptpS?: number;
52
+ bS50?: number;
53
+ bV50?: number;
54
+ decl?: number | undefined;
55
+ rvPoints?: rVpoints;
56
+ gSym?: number;
57
+ gamma?: number;
58
+ eG?: number;
59
+ bSV?: number;
60
+ prop?: number;
61
+ mMs?: number;
62
+ mMd?: number;
63
+ lO?: number | undefined;
64
+ };
65
+ export declare type Impact = {
66
+ unearnedS: number;
67
+ score: number;
68
+ };
69
+ export declare type Responsiveness = {
70
+ bigR?: number | undefined;
71
+ littleR?: number | undefined;
72
+ mIR?: number | undefined;
73
+ rD?: number;
74
+ rDf?: number;
75
+ cSimple: number;
76
+ cD: number;
77
+ cDf: number;
78
+ score: number;
79
+ };
80
+ export declare type PopulationProfile = {
81
+ byDistrict: totalPopByDistrict;
82
+ targetSize: number;
83
+ };
84
+ export declare type totalPopByDistrict = number[];
85
+ export declare type PopulationScorecard = Measurement;
86
+ export declare type GeoProperties = {
87
+ area: number;
88
+ perimeter: number;
89
+ diameter: number;
90
+ };
91
+ export declare type ShapeProfile = GeoProperties[];
92
+ export declare type CompactnessScorecard = {
93
+ score: number;
94
+ reock: Measurement;
95
+ polsby: Measurement;
96
+ details: Dict;
97
+ };
98
+ export declare type CompactnessByDistrict = {
99
+ rawReock: number;
100
+ normalizedReock: number;
101
+ rawPolsby: number;
102
+ normalizedPolsby: number;
103
+ kiwysiScore?: number;
104
+ };
105
+ export declare type CountyProfile = CxD;
106
+ export declare type CxD = number[][];
107
+ export declare type SplittingScorecard = {
108
+ score: number;
109
+ county: Measurement;
110
+ district: Measurement;
111
+ details: Dict;
112
+ };
113
+ export declare type Demographics = {
114
+ white: number;
115
+ minority: number;
116
+ black: number;
117
+ hispanic: number;
118
+ pacific: number;
119
+ asian: number;
120
+ native: number;
121
+ };
122
+ export declare type DemographicProfile = {
123
+ statewide: Demographics;
124
+ byDistrict: Demographics[];
125
+ };
126
+ export declare type DemoBreakdown = {
127
+ pct35_40: number;
128
+ pct40_45: number;
129
+ pct45_50: number;
130
+ pct50_55: number;
131
+ pct55_60: number;
132
+ pct60Plus: number;
133
+ vapPct: number;
134
+ propSeats: number;
135
+ };
136
+ export declare type DemographicPivot = {
137
+ minority: DemoBreakdown;
138
+ black: DemoBreakdown;
139
+ hispanic: DemoBreakdown;
140
+ pacific: DemoBreakdown;
141
+ asian: DemoBreakdown;
142
+ native: DemoBreakdown;
143
+ };
144
+ export declare type MinorityScorecard = {
145
+ pivotByDemographic: DemographicPivot;
146
+ opportunityDistricts: number;
147
+ coalitionDistricts: number;
148
+ score: number;
149
+ details: Dict;
150
+ };
151
+ export declare type Measurement = {
152
+ raw: number;
153
+ normalized: number;
154
+ byDistrict?: any[];
155
+ notes: Dict;
156
+ };
157
+ export declare type SVpoint = {
158
+ v: number;
159
+ s: number;
160
+ };
161
+ export declare type Dict = {
162
+ [key: string]: any;
163
+ };
@@ -1,5 +1,12 @@
1
1
  import * as Score from '@dra2020/dra-score';
2
+ import * as T from './types';
2
3
  import { AnalyticsSession } from './_api';
4
+ import { Types } from '@dra2020/dra-analytics';
5
+ import * as L from './legacy-types';
3
6
  export declare function profilePlan(s: AnalyticsSession, bLog?: boolean): Score.Profile;
4
7
  export declare function getStatewideDemographics(s: AnalyticsSession, bLog?: boolean): Score.Demographics;
5
8
  export declare function scorePlan(s: AnalyticsSession, p: Score.Profile, bLog?: boolean, overridesJSON?: any): Score.Scorecard;
9
+ export declare function computeMetrics(p: Score.Profile, districtShapes: T.GeoFeatureCollection, bLog?: boolean): Types.Scorecard;
10
+ export declare function rateKeyDimensions(scorecard: Types.Scorecard, p: Score.Profile, bLog?: boolean): Types.Scorecard;
11
+ export declare function thunkScorecard(newScorecard: Types.Scorecard, bLog?: boolean): L.Scorecard;
12
+ export declare function compareScorecards(altLegacyScorecard: Score.Scorecard, legacyScorecard: Score.Scorecard, bLog?: boolean): void;
@@ -1,8 +1,4 @@
1
1
  export declare const PRECISION: number;
2
- export declare const NORMALIZED_RANGE: number;
3
2
  export declare const NOT_ASSIGNED: number;
4
3
  export declare const NUMBER_OF_ITEMS_TO_REPORT: number;
5
4
  export declare const OUT_OF_STATE: string;
6
- export declare const EQUAL_TOLERANCE: number;
7
- export declare const COUNTY_SPLITTING_WEIGHT = 0.8;
8
- export declare const DISTRICT_SPLITTING_WEIGHT: number;
@@ -68,11 +68,6 @@ export declare type WeightedNeighbors = {
68
68
  [geoID: string]: number;
69
69
  };
70
70
  export declare type UnweightedNeighbors = string[];
71
- export declare type TestScale = {
72
- scale: Array<number>;
73
- bInvertRaw?: boolean;
74
- bInvertScaled?: boolean;
75
- };
76
71
  export declare type TestEntry = {
77
72
  score?: number | boolean;
78
73
  details: Dict;
@@ -127,4 +122,4 @@ export declare type Ratings = {
127
122
  compactness: number;
128
123
  splitting: number;
129
124
  };
130
- export { Profile, Scorecard, estSeatProbability } from '@dra2020/dra-score';
125
+ export { Profile, Scorecard, } from '@dra2020/dra-score';
@@ -1,7 +1,5 @@
1
1
  import { AnalyticsSession } from './_api';
2
2
  import * as T from './types';
3
- export declare function isInState(geoID: string): boolean;
4
- export declare function isOutOfState(geoID: string): boolean;
5
3
  export declare function getDistrict(plan: T.PlanByGeoID, geoID: string): number | undefined;
6
4
  export declare function parseGeoID(geoID: string): T.GeoIDParts;
7
5
  export declare function isWaterOnly(geoID: string, s?: AnalyticsSession): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/district-analytics",
3
- "version": "14.1.2",
3
+ "version": "14.1.3",
4
4
  "description": "District analytics TypeScript package",
5
5
  "main": "dist/district-analytics.js",
6
6
  "files": [
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@dra2020/baseclient": "^1.0.38",
51
- "@dra2020/dra-analytics": "^0.5.6",
51
+ "@dra2020/dra-analytics": "^0.5.20",
52
52
  "@dra2020/dra-score": "^11.1.3",
53
53
  "@dra2020/dra-types": "^1.8.28",
54
54
  "geojson": "^0.5.0"