@dra2020/district-analytics 1.0.10 → 2.0.1
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/README.md +5 -5
- package/dist/cli.js +1686 -1354
- package/dist/cli.js.map +1 -1
- package/dist/district-analytics.js +1334 -1214
- package/dist/district-analytics.js.map +1 -1
- package/dist/src/_api.d.ts +4 -4
- package/dist/src/_data.d.ts +5 -3
- package/dist/src/analyze.d.ts +1 -1
- package/dist/src/cohesive.d.ts +4 -2
- package/dist/src/equal.d.ts +2 -2
- package/dist/src/index.d.ts +2 -0
- package/dist/src/minority.d.ts +1 -1
- package/dist/src/political.d.ts +5 -5
- package/dist/src/preprocess.d.ts +1 -1
- package/dist/src/report.d.ts +0 -15
- package/dist/src/results.d.ts +141 -0
- package/dist/src/settings.d.ts +3 -0
- package/dist/src/types.d.ts +27 -13
- package/dist/src/utils.d.ts +4 -3
- package/dist/src/valid.d.ts +3 -3
- package/dist/test/_cli.d.ts +2 -0
- package/package.json +6 -4
- package/dist/_api.d.ts +0 -27
- package/dist/_data.d.ts +0 -130
- package/dist/analyze.d.ts +0 -4
- package/dist/cohesive.d.ts +0 -4
- package/dist/compact.d.ts +0 -5
- package/dist/constants.d.ts +0 -6
- package/dist/equal.d.ts +0 -4
- package/dist/geofeature.d.ts +0 -3
- package/dist/index.d.ts +0 -2
- package/dist/minority.d.ts +0 -3
- package/dist/political.d.ts +0 -8
- package/dist/preprocess.d.ts +0 -2
- package/dist/report.d.ts +0 -15
- package/dist/settings.d.ts +0 -5
- package/dist/types.d.ts +0 -110
- package/dist/utils.d.ts +0 -28
- package/dist/valid.d.ts +0 -8
package/dist/src/_api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlanAnalytics, DistrictStatistics } from './results';
|
|
2
2
|
import * as D from './_data';
|
|
3
3
|
import * as T from './types';
|
|
4
4
|
export declare class AnalyticsSession {
|
|
@@ -10,7 +10,6 @@ export declare class AnalyticsSession {
|
|
|
10
10
|
bPostProcessingDone: boolean;
|
|
11
11
|
testScales: T.TestScales;
|
|
12
12
|
tests: T.TestEntries;
|
|
13
|
-
scorecard: Scorecard;
|
|
14
13
|
state: D.State;
|
|
15
14
|
counties: D.Counties;
|
|
16
15
|
graph: D.Graph;
|
|
@@ -20,8 +19,9 @@ export declare class AnalyticsSession {
|
|
|
20
19
|
constructor(SessionRequest: T.SessionRequest);
|
|
21
20
|
processConfig(config: T.Dict): T.Dict;
|
|
22
21
|
analyzePlan(bLog?: boolean): boolean;
|
|
22
|
+
getPlanAnalytics(bLog?: boolean): PlanAnalytics;
|
|
23
|
+
getDistrictStatistics(bLog?: boolean): DistrictStatistics;
|
|
24
|
+
getDiscontiguousDistrictFeatures(bLog?: boolean): T.GeoFeatureCollection;
|
|
23
25
|
getTest(testID: T.Test): T.TestEntry;
|
|
24
|
-
prepareScorecard(): any;
|
|
25
|
-
prepareTestLog(): any;
|
|
26
26
|
populationDeviationThreshold(): number;
|
|
27
27
|
}
|
package/dist/src/_data.d.ts
CHANGED
|
@@ -30,14 +30,13 @@ export declare enum DistrictField {
|
|
|
30
30
|
AsianPct = 26,
|
|
31
31
|
NativePct = 27
|
|
32
32
|
}
|
|
33
|
-
export declare const DisplayFields: DistrictField[];
|
|
34
33
|
export declare class Districts {
|
|
35
34
|
_session: AnalyticsSession;
|
|
36
35
|
_shapes: T.GeoFeatureCollection;
|
|
37
36
|
_geoProperties: T.DistrictProperties;
|
|
38
37
|
statistics: any[][];
|
|
39
38
|
constructor(s: AnalyticsSession, ds: T.GeoFeatureCollection);
|
|
40
|
-
|
|
39
|
+
getDistrictShapeByID(id: number): T.GeoFeature | undefined;
|
|
41
40
|
getGeoProperties(i: number): any;
|
|
42
41
|
setGeoProperties(i: number, p: T.DistrictShapeProperties): void;
|
|
43
42
|
numberOfColumns(): number;
|
|
@@ -49,16 +48,17 @@ export declare class Districts {
|
|
|
49
48
|
getCountyIndex(geoID: string): number;
|
|
50
49
|
}
|
|
51
50
|
export declare const enum Dataset {
|
|
51
|
+
SHAPES = "SHAPES",
|
|
52
52
|
CENSUS = "CENSUS",
|
|
53
53
|
VAP = "VAP",
|
|
54
54
|
ELECTION = "ELECTION"
|
|
55
55
|
}
|
|
56
56
|
export declare type DatasetKeys = {
|
|
57
|
+
SHAPES: string;
|
|
57
58
|
CENSUS: string;
|
|
58
59
|
VAP: string;
|
|
59
60
|
ELECTION: string;
|
|
60
61
|
};
|
|
61
|
-
export declare const DatasetDescriptions: any;
|
|
62
62
|
export declare const enum FeatureField {
|
|
63
63
|
TotalPop = "Tot",
|
|
64
64
|
WhitePop = "Wh",
|
|
@@ -91,6 +91,7 @@ export declare class Counties {
|
|
|
91
91
|
_countyNameLookup: T.FIPSCodeToCountyNameMap;
|
|
92
92
|
nCounties: number;
|
|
93
93
|
index: T.FIPSToOrdinalMap;
|
|
94
|
+
totalPopulation: number[];
|
|
94
95
|
constructor(s: AnalyticsSession, data: T.GeoFeatureCollection);
|
|
95
96
|
countyByIndex(i: number): T.GeoFeature;
|
|
96
97
|
propertyForCounty(f: any, pk: string): any;
|
|
@@ -122,6 +123,7 @@ export declare class Plan {
|
|
|
122
123
|
districtForGeoID(i: string): number;
|
|
123
124
|
geoIDsForDistrictID(i: number): Set<string>;
|
|
124
125
|
}
|
|
126
|
+
export declare function invertPlan(plan: T.PlanByGeoID, s?: AnalyticsSession): T.PlanByDistrictID;
|
|
125
127
|
export declare class Graph {
|
|
126
128
|
_session: AnalyticsSession;
|
|
127
129
|
_graph: T.ContiguityGraph;
|
package/dist/src/analyze.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AnalyticsSession } from './_api';
|
|
2
2
|
export declare function doAnalyzeDistricts(s: AnalyticsSession, bLog?: boolean): void;
|
|
3
3
|
export declare function doAnalyzePlan(s: AnalyticsSession, bLog?: boolean): void;
|
|
4
|
-
export declare function doDeriveSecondaryTests(s: AnalyticsSession): void;
|
|
4
|
+
export declare function doDeriveSecondaryTests(s: AnalyticsSession, bLog?: boolean): void;
|
package/dist/src/cohesive.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as T from './types';
|
|
2
2
|
import { AnalyticsSession } from './_api';
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
3
|
+
export declare function doCountySplitting(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
4
|
+
export declare function doDistrictSplitting(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
5
|
+
export declare function doFindCountiesSplitUnexpectedly(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
6
|
+
export declare function doFindSplitVTDs(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
package/dist/src/equal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as T from './types';
|
|
2
2
|
import { AnalyticsSession } from './_api';
|
|
3
|
-
export declare function doPopulationDeviation(s: AnalyticsSession): T.TestEntry;
|
|
4
|
-
export declare function doHasEqualPopulations(s: AnalyticsSession): T.TestEntry;
|
|
3
|
+
export declare function doPopulationDeviation(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
4
|
+
export declare function doHasEqualPopulations(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/minority.d.ts
CHANGED
package/dist/src/political.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as T from './types';
|
|
2
2
|
import { AnalyticsSession } from './_api';
|
|
3
|
-
export declare function doSeatsBias(s: AnalyticsSession): T.TestEntry;
|
|
4
|
-
export declare function doVotesBias(s: AnalyticsSession): T.TestEntry;
|
|
5
|
-
export declare function doResponsiveness(s: AnalyticsSession): T.TestEntry;
|
|
6
|
-
export declare function doResponsiveDistricts(s: AnalyticsSession): T.TestEntry;
|
|
7
|
-
export declare function doEfficiencyGap(s: AnalyticsSession): T.TestEntry;
|
|
3
|
+
export declare function doSeatsBias(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
4
|
+
export declare function doVotesBias(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
5
|
+
export declare function doResponsiveness(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
6
|
+
export declare function doResponsiveDistricts(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
7
|
+
export declare function doEfficiencyGap(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
8
8
|
export declare function fptpWin(demPct: number): number;
|
package/dist/src/preprocess.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnalyticsSession } from './_api';
|
|
2
|
-
export declare function doPreprocessData(s: AnalyticsSession): void;
|
|
2
|
+
export declare function doPreprocessData(s: AnalyticsSession, bLog?: boolean): void;
|
package/dist/src/report.d.ts
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as T from './types';
|
|
2
|
-
import { AnalyticsSession } from './_api';
|
|
3
|
-
export declare type Scorecard = {
|
|
4
|
-
[category: number]: ScorecardCategoryEntry;
|
|
5
|
-
};
|
|
6
|
-
declare type ScorecardCategoryEntry = {
|
|
7
|
-
catName: string;
|
|
8
|
-
catScore?: number | boolean;
|
|
9
|
-
catTests: T.TestEntries;
|
|
10
|
-
};
|
|
11
|
-
export declare function doConfigureScales(s: AnalyticsSession): void;
|
|
12
|
-
export declare function doAnalyzePostProcessing(s: AnalyticsSession): void;
|
|
13
|
-
export declare function doPrepareScorecard(s: AnalyticsSession): any;
|
|
14
|
-
export declare function doPrepareTestLog(s: AnalyticsSession): any;
|
|
15
|
-
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import * as T from './types';
|
|
2
|
+
import { AnalyticsSession } from './_api';
|
|
3
|
+
export declare type RequirementsCategory = {
|
|
4
|
+
score: T.TriState;
|
|
5
|
+
metrics: {
|
|
6
|
+
complete: T.TriState;
|
|
7
|
+
contiguous: T.TriState;
|
|
8
|
+
freeOfHoles: T.TriState;
|
|
9
|
+
equalPopulation: T.TriState;
|
|
10
|
+
};
|
|
11
|
+
details: {
|
|
12
|
+
unassignedFeatures: string[];
|
|
13
|
+
emptyDistricts: number[];
|
|
14
|
+
discontiguousDistricts: number[];
|
|
15
|
+
embeddedDistricts: number[];
|
|
16
|
+
populationDeviation: number;
|
|
17
|
+
deviationThreshold: number;
|
|
18
|
+
};
|
|
19
|
+
datasets: T.Datasets;
|
|
20
|
+
resources: {
|
|
21
|
+
stateReqs: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare type CompactnessCategory = {
|
|
25
|
+
score: number;
|
|
26
|
+
metrics: {
|
|
27
|
+
reock: number;
|
|
28
|
+
polsby: number;
|
|
29
|
+
};
|
|
30
|
+
details: {};
|
|
31
|
+
datasets: T.Datasets;
|
|
32
|
+
resources: {};
|
|
33
|
+
};
|
|
34
|
+
export declare type SplittingCategory = {
|
|
35
|
+
score: number;
|
|
36
|
+
metrics: {
|
|
37
|
+
sqEnt_DCreduced: number;
|
|
38
|
+
sqEnt_CDreduced: number;
|
|
39
|
+
};
|
|
40
|
+
details: {
|
|
41
|
+
countiesSplitUnexpectedly: string[];
|
|
42
|
+
unexpectedAffected: number;
|
|
43
|
+
nSplitVTDs: number;
|
|
44
|
+
splitVTDs: string[];
|
|
45
|
+
};
|
|
46
|
+
datasets: T.Datasets;
|
|
47
|
+
resources: {};
|
|
48
|
+
};
|
|
49
|
+
export declare type PartisanCategory = {
|
|
50
|
+
score: number;
|
|
51
|
+
metrics: {
|
|
52
|
+
partisanBias: 0.15;
|
|
53
|
+
responsiveness: 2.0;
|
|
54
|
+
};
|
|
55
|
+
details: {};
|
|
56
|
+
datasets: T.Datasets;
|
|
57
|
+
resources: {
|
|
58
|
+
planScore?: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare type MinorityCategory = {
|
|
62
|
+
score: null;
|
|
63
|
+
metrics: {
|
|
64
|
+
nBlack37to50: number;
|
|
65
|
+
nBlackMajority: number;
|
|
66
|
+
nHispanic37to50: number;
|
|
67
|
+
nHispanicMajority: number;
|
|
68
|
+
nPacific37to50: number;
|
|
69
|
+
nPacificMajority: number;
|
|
70
|
+
nAsian37to50: number;
|
|
71
|
+
nAsianMajority: number;
|
|
72
|
+
nNative37to50: number;
|
|
73
|
+
nNativeMajority: number;
|
|
74
|
+
nMinority37to50: number;
|
|
75
|
+
nMinorityMajority: number;
|
|
76
|
+
averageDVoteShare: number;
|
|
77
|
+
};
|
|
78
|
+
details: {
|
|
79
|
+
vap: true;
|
|
80
|
+
comboCategories: true;
|
|
81
|
+
};
|
|
82
|
+
datasets: T.Datasets;
|
|
83
|
+
resources: {};
|
|
84
|
+
};
|
|
85
|
+
export declare type PlanAnalytics = {
|
|
86
|
+
requirements: RequirementsCategory;
|
|
87
|
+
compactness: CompactnessCategory;
|
|
88
|
+
splitting: SplittingCategory;
|
|
89
|
+
partisan: PartisanCategory;
|
|
90
|
+
minority: MinorityCategory;
|
|
91
|
+
};
|
|
92
|
+
export declare const samplePlanAnalytics: PlanAnalytics;
|
|
93
|
+
export declare function preparePlanAnalytics(s: AnalyticsSession, bLog?: boolean): PlanAnalytics;
|
|
94
|
+
export declare const enum DistrictColumn {
|
|
95
|
+
DistrictID = 0,
|
|
96
|
+
TotalPop = 1,
|
|
97
|
+
PopDevPct = 2,
|
|
98
|
+
bEqualPop = 3,
|
|
99
|
+
bNotEmpty = 4,
|
|
100
|
+
bContiguous = 5,
|
|
101
|
+
bNotEmbedded = 6,
|
|
102
|
+
DemPct = 7,
|
|
103
|
+
RepPct = 8,
|
|
104
|
+
WhitePct = 9,
|
|
105
|
+
MinorityPct = 10,
|
|
106
|
+
BlackPct = 11,
|
|
107
|
+
HispanicPct = 12,
|
|
108
|
+
PacificPct = 13,
|
|
109
|
+
AsianPct = 14,
|
|
110
|
+
NativePct = 15
|
|
111
|
+
}
|
|
112
|
+
export declare type DistrictRow = [number, // DistrictID
|
|
113
|
+
number, // TotalPop
|
|
114
|
+
number, // PopDevPct
|
|
115
|
+
// PopDevPct
|
|
116
|
+
T.TriState | null, // bEqualPop
|
|
117
|
+
// bEqualPop
|
|
118
|
+
T.TriState | null, // bNotEmpty
|
|
119
|
+
// bNotEmpty
|
|
120
|
+
T.TriState | null, // bContiguous
|
|
121
|
+
// bContiguous
|
|
122
|
+
T.TriState | null, // bNotEmbedded
|
|
123
|
+
number, // DemPct
|
|
124
|
+
number, // RepPct
|
|
125
|
+
number, // WhitePct
|
|
126
|
+
number, // MinorityPct
|
|
127
|
+
number, // BlackPct
|
|
128
|
+
number, // HispanicPct
|
|
129
|
+
number, // PacificPct
|
|
130
|
+
number, // AsianPct
|
|
131
|
+
number];
|
|
132
|
+
export declare type DistrictStatistics = {
|
|
133
|
+
table: DistrictRow[];
|
|
134
|
+
details: {};
|
|
135
|
+
datasets: T.Datasets;
|
|
136
|
+
resources: {};
|
|
137
|
+
};
|
|
138
|
+
export declare const sampleDistrictStatistics: DistrictStatistics;
|
|
139
|
+
export declare function prepareDistrictStatistics(s: AnalyticsSession, bLog?: boolean): DistrictStatistics;
|
|
140
|
+
export declare function doConfigureScales(s: AnalyticsSession): void;
|
|
141
|
+
export declare function doAnalyzePostProcessing(s: AnalyticsSession, bLog?: boolean): void;
|
package/dist/src/settings.d.ts
CHANGED
|
@@ -3,3 +3,6 @@ export declare const NORMALIZED_RANGE: number;
|
|
|
3
3
|
export declare const NOT_ASSIGNED: number;
|
|
4
4
|
export declare const NUMBER_OF_ITEMS_TO_REPORT: number;
|
|
5
5
|
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;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export declare type SessionRequest = {
|
|
|
14
14
|
districtShapes: GeoFeatureCollection;
|
|
15
15
|
districtProperties: DistrictProperties;
|
|
16
16
|
graph: ContiguityGraph;
|
|
17
|
-
countyNameLookup: FIPSCodeToCountyNameMap;
|
|
18
17
|
counties: GeoFeatureCollection;
|
|
19
18
|
config: {};
|
|
20
19
|
};
|
|
@@ -40,11 +39,12 @@ export interface GeoFeatureMap {
|
|
|
40
39
|
[geoID: string]: GeoFeature;
|
|
41
40
|
}
|
|
42
41
|
export declare type ContiguityGraph = {
|
|
43
|
-
[geoID: string]:
|
|
42
|
+
[geoID: string]: UnweightedNeighbors | WeightedNeighbors;
|
|
44
43
|
};
|
|
45
|
-
export declare type
|
|
44
|
+
export declare type WeightedNeighbors = {
|
|
46
45
|
[geoID: string]: number;
|
|
47
46
|
};
|
|
47
|
+
export declare type UnweightedNeighbors = string[];
|
|
48
48
|
export declare type VoteTriple = [number, number, number];
|
|
49
49
|
export declare const enum VoteType {
|
|
50
50
|
Democratic = 0,
|
|
@@ -52,8 +52,9 @@ export declare const enum VoteType {
|
|
|
52
52
|
Total = 2
|
|
53
53
|
}
|
|
54
54
|
export declare type TestScale = {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
scale: Array<number>;
|
|
56
|
+
bInvertRaw?: boolean;
|
|
57
|
+
bInvertScaled?: boolean;
|
|
57
58
|
};
|
|
58
59
|
export declare type TestScales = {
|
|
59
60
|
[test: number]: TestScale;
|
|
@@ -74,14 +75,16 @@ export declare const enum Test {
|
|
|
74
75
|
PopulationDeviation = 4,
|
|
75
76
|
Reock = 5,
|
|
76
77
|
PolsbyPopper = 6,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
UnexpectedCountySplits = 7,
|
|
79
|
+
CountySplitting = 8,
|
|
80
|
+
DistrictSplitting = 9,
|
|
81
|
+
VTDSplits = 10,
|
|
82
|
+
SeatsBias = 11,
|
|
83
|
+
VotesBias = 12,
|
|
84
|
+
Responsiveness = 13,
|
|
85
|
+
ResponsiveDistricts = 14,
|
|
86
|
+
EfficiencyGap = 15,
|
|
87
|
+
MajorityMinorityDistricts = 16
|
|
85
88
|
}
|
|
86
89
|
export declare type TestEntries = {
|
|
87
90
|
[test: number]: TestEntry;
|
|
@@ -108,3 +111,14 @@ export declare type GeoIDTotal = {
|
|
|
108
111
|
export declare type Dict = {
|
|
109
112
|
[key: string]: any;
|
|
110
113
|
};
|
|
114
|
+
export declare const enum TriState {
|
|
115
|
+
Green = 0,
|
|
116
|
+
Yellow = 1,
|
|
117
|
+
Red = 2
|
|
118
|
+
}
|
|
119
|
+
export declare type Datasets = {
|
|
120
|
+
shapes?: string;
|
|
121
|
+
census?: string;
|
|
122
|
+
vap?: string;
|
|
123
|
+
election?: string;
|
|
124
|
+
};
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import * as T from './types';
|
|
|
2
2
|
export declare function isInState(geoID: string): boolean;
|
|
3
3
|
export declare function isOutOfState(geoID: string): boolean;
|
|
4
4
|
export declare function getDistrict(plan: T.PlanByGeoID, geoID: string): number | undefined;
|
|
5
|
-
export declare function invertPlan(plan: T.PlanByGeoID): T.PlanByDistrictID;
|
|
6
5
|
export declare function parseGeoID(geoID: string): T.GeoIDParts;
|
|
7
6
|
export declare function getFIPSFromCountyGeoID(geoID: string): string;
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
7
|
+
export declare function isWaterOnly(geoID: string): boolean;
|
|
8
|
+
export declare function normalize(rawScore: number, testScale: T.TestScale): number;
|
|
9
|
+
export declare function trim(fullFraction: number, digits?: number | undefined): number;
|
|
10
10
|
export declare function sumArray(arr: number[]): number;
|
|
11
11
|
export declare function avgArray(arr: number[]): number;
|
|
12
12
|
export declare function minArray(arr: number[]): number;
|
|
@@ -25,4 +25,5 @@ export declare function objectContains(o: object, key: any): boolean;
|
|
|
25
25
|
export declare function countEnumValues(enumName: any): number;
|
|
26
26
|
export declare function shallowCopy(src: any): any;
|
|
27
27
|
export declare function deepCopy(src: any): any;
|
|
28
|
+
export declare function mapBooleanToTriState(bool: boolean): T.TriState;
|
|
28
29
|
export { depthof } from '@dra2020/util';
|
package/dist/src/valid.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as T from './types';
|
|
2
2
|
import * as D from './_data';
|
|
3
3
|
import { AnalyticsSession } from './_api';
|
|
4
|
-
export declare function doIsComplete(s: AnalyticsSession): T.TestEntry;
|
|
5
|
-
export declare function doIsContiguous(s: AnalyticsSession): T.TestEntry;
|
|
4
|
+
export declare function doIsComplete(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
5
|
+
export declare function doIsContiguous(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
6
6
|
export declare function isConnected(districtGeos: Set<string>, graph: D.Graph): boolean;
|
|
7
|
-
export declare function doIsFreeOfHoles(s: AnalyticsSession): T.TestEntry;
|
|
7
|
+
export declare function doIsFreeOfHoles(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
8
8
|
export declare function isEmbedded(districtID: number, geoIDs: Set<string>, plan: D.Plan, graph: D.Graph): boolean;
|
package/dist/test/_cli.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { DistrictStatistics } from '../src/results';
|
|
1
2
|
import * as T from '../src/types';
|
|
3
|
+
export declare function echoDistrictStatistics(ds: DistrictStatistics): void;
|
|
2
4
|
export declare function readJSONcareful(file: string): any;
|
|
3
5
|
export declare function readJSON(file: string): any;
|
|
4
6
|
export declare function readCSV(file: string): any;
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dra2020/district-analytics",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "District analytics TypeScript package",
|
|
5
5
|
"main": "dist/district-analytics.js",
|
|
6
|
-
"
|
|
7
|
-
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/"
|
|
8
|
+
],
|
|
9
|
+
"types": "dist/src/index.d.ts",
|
|
8
10
|
"scripts": {
|
|
9
11
|
"test": "echo test not configured",
|
|
10
12
|
"build": "webpack",
|
|
@@ -50,7 +52,7 @@
|
|
|
50
52
|
"@dra2020/util": "^1.0.24",
|
|
51
53
|
"csv-parse": "^4.4.5",
|
|
52
54
|
"geojson": "^0.5.0",
|
|
53
|
-
"polygon-clipping": "^0.14.
|
|
55
|
+
"polygon-clipping": "^0.14.0",
|
|
54
56
|
"simple-statistics": "^7.0.5"
|
|
55
57
|
}
|
|
56
58
|
}
|
package/dist/_api.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Scorecard } from './report';
|
|
2
|
-
import * as D from './_data';
|
|
3
|
-
import * as T from './types';
|
|
4
|
-
export declare class AnalyticsSession {
|
|
5
|
-
title: string;
|
|
6
|
-
legislativeDistricts: boolean;
|
|
7
|
-
config: T.Dict;
|
|
8
|
-
bOneTimeProcessingDone: boolean;
|
|
9
|
-
bPlanAnalyzed: boolean;
|
|
10
|
-
bPostProcessingDone: boolean;
|
|
11
|
-
testScales: T.TestScales;
|
|
12
|
-
tests: T.TestEntries;
|
|
13
|
-
scorecard: Scorecard;
|
|
14
|
-
state: D.State;
|
|
15
|
-
counties: D.Counties;
|
|
16
|
-
graph: D.Graph;
|
|
17
|
-
features: D.Features;
|
|
18
|
-
plan: D.Plan;
|
|
19
|
-
districts: D.Districts;
|
|
20
|
-
constructor(SessionRequest: T.SessionRequest);
|
|
21
|
-
processConfig(config: T.Dict): T.Dict;
|
|
22
|
-
analyzePlan(bLog?: boolean): boolean;
|
|
23
|
-
getTest(testID: T.Test): T.TestEntry;
|
|
24
|
-
prepareScorecard(): any;
|
|
25
|
-
prepareTestLog(): any;
|
|
26
|
-
populationDeviationThreshold(): number;
|
|
27
|
-
}
|
package/dist/_data.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import * as T from './types';
|
|
2
|
-
import { AnalyticsSession } from './_api';
|
|
3
|
-
export declare enum DistrictField {
|
|
4
|
-
TotalPop = 0,
|
|
5
|
-
PopDevPct = 1,
|
|
6
|
-
bEqualPop = 2,
|
|
7
|
-
bNotEmpty = 3,
|
|
8
|
-
bContiguous = 4,
|
|
9
|
-
bNotEmbedded = 5,
|
|
10
|
-
CountySplits = 6,
|
|
11
|
-
DemVotes = 7,
|
|
12
|
-
RepVotes = 8,
|
|
13
|
-
TwoPartyVote = 9,
|
|
14
|
-
DemPct = 10,
|
|
15
|
-
RepPct = 11,
|
|
16
|
-
DemSeat = 12,
|
|
17
|
-
TotalVAP = 13,
|
|
18
|
-
MinorityPop = 14,
|
|
19
|
-
WhitePop = 15,
|
|
20
|
-
BlackPop = 16,
|
|
21
|
-
HispanicPop = 17,
|
|
22
|
-
PacificPop = 18,
|
|
23
|
-
AsianPop = 19,
|
|
24
|
-
NativePop = 20,
|
|
25
|
-
WhitePct = 21,
|
|
26
|
-
MinorityPct = 22,
|
|
27
|
-
BlackPct = 23,
|
|
28
|
-
HispanicPct = 24,
|
|
29
|
-
PacificPct = 25,
|
|
30
|
-
AsianPct = 26,
|
|
31
|
-
NativePct = 27
|
|
32
|
-
}
|
|
33
|
-
export declare const DisplayFields: DistrictField[];
|
|
34
|
-
export declare class Districts {
|
|
35
|
-
_session: AnalyticsSession;
|
|
36
|
-
_shapes: T.GeoFeatureCollection;
|
|
37
|
-
_geoProperties: T.DistrictProperties;
|
|
38
|
-
statistics: any[][];
|
|
39
|
-
constructor(s: AnalyticsSession, ds: T.GeoFeatureCollection);
|
|
40
|
-
getShape(i: number): T.GeoFeature;
|
|
41
|
-
getGeoProperties(i: number): any;
|
|
42
|
-
setGeoProperties(i: number, p: T.DistrictShapeProperties): void;
|
|
43
|
-
numberOfColumns(): number;
|
|
44
|
-
numberOfRows(): number;
|
|
45
|
-
numberOfWorkingDistricts(): number;
|
|
46
|
-
initStatistics(): any[][];
|
|
47
|
-
recalcStatistics(bLog?: boolean): void;
|
|
48
|
-
extractDistrictShapeProperties(bLog?: boolean): void;
|
|
49
|
-
getCountyIndex(geoID: string): number;
|
|
50
|
-
}
|
|
51
|
-
export declare const enum Dataset {
|
|
52
|
-
CENSUS = "CENSUS",
|
|
53
|
-
VAP = "VAP",
|
|
54
|
-
ELECTION = "ELECTION"
|
|
55
|
-
}
|
|
56
|
-
export declare type DatasetKeys = {
|
|
57
|
-
CENSUS: string;
|
|
58
|
-
VAP: string;
|
|
59
|
-
ELECTION: string;
|
|
60
|
-
};
|
|
61
|
-
export declare const DatasetDescriptions: any;
|
|
62
|
-
export declare const enum FeatureField {
|
|
63
|
-
TotalPop = "Tot",
|
|
64
|
-
WhitePop = "Wh",
|
|
65
|
-
BlackPop = "BlC",
|
|
66
|
-
HispanicPop = "His",
|
|
67
|
-
AsianPop = "AsnC",
|
|
68
|
-
PacificPop = "PacC",
|
|
69
|
-
NativePop = "NatC",
|
|
70
|
-
DemVotes = "D",
|
|
71
|
-
RepVotes = "R",
|
|
72
|
-
TotalVotes = "Tot"
|
|
73
|
-
}
|
|
74
|
-
export declare class Features {
|
|
75
|
-
_session: AnalyticsSession;
|
|
76
|
-
_data: T.GeoFeatureCollection;
|
|
77
|
-
_keys: DatasetKeys;
|
|
78
|
-
_featureIDs: T.FeaturesByGeoID;
|
|
79
|
-
constructor(s: AnalyticsSession, data: T.GeoFeatureCollection, keys: DatasetKeys);
|
|
80
|
-
nFeatures(): number;
|
|
81
|
-
featureByIndex(i: number): T.GeoFeature;
|
|
82
|
-
geoIDForFeature(f: any): string;
|
|
83
|
-
fieldForFeature(f: any, dt: Dataset, fk: string): any;
|
|
84
|
-
resetDataset(d: Dataset, k: string): void;
|
|
85
|
-
mapGeoIDsToFeatureIDs(): void;
|
|
86
|
-
featureID(i: string): number;
|
|
87
|
-
}
|
|
88
|
-
export declare class Counties {
|
|
89
|
-
_session: AnalyticsSession;
|
|
90
|
-
_data: T.GeoFeatureCollection;
|
|
91
|
-
_countyNameLookup: T.FIPSCodeToCountyNameMap;
|
|
92
|
-
nCounties: number;
|
|
93
|
-
index: T.FIPSToOrdinalMap;
|
|
94
|
-
constructor(s: AnalyticsSession, data: T.GeoFeatureCollection);
|
|
95
|
-
countyByIndex(i: number): T.GeoFeature;
|
|
96
|
-
propertyForCounty(f: any, pk: string): any;
|
|
97
|
-
mapFIPSToName(fips: string, name: string): void;
|
|
98
|
-
nameFromFIPS(fips: string): string;
|
|
99
|
-
indexFromFIPS(fips: string): number;
|
|
100
|
-
}
|
|
101
|
-
export declare class State {
|
|
102
|
-
_session: AnalyticsSession;
|
|
103
|
-
xx: string;
|
|
104
|
-
nDistricts: number;
|
|
105
|
-
totalPop: number;
|
|
106
|
-
tooBigFIPS: string[];
|
|
107
|
-
tooBigName: string[];
|
|
108
|
-
expectedSplits: number;
|
|
109
|
-
expectedAffected: number;
|
|
110
|
-
constructor(s: AnalyticsSession, xx: string, n: number);
|
|
111
|
-
}
|
|
112
|
-
export declare class Plan {
|
|
113
|
-
_session: AnalyticsSession;
|
|
114
|
-
_planByGeoID: T.PlanByGeoID;
|
|
115
|
-
_planByDistrictID: T.PlanByDistrictID;
|
|
116
|
-
districtIDs: number[];
|
|
117
|
-
constructor(s: AnalyticsSession, p: T.PlanByGeoID);
|
|
118
|
-
invertPlan(): void;
|
|
119
|
-
initializeDistrict(i: number): void;
|
|
120
|
-
byGeoID(): T.PlanByGeoID;
|
|
121
|
-
byDistrictID(): T.PlanByDistrictID;
|
|
122
|
-
districtForGeoID(i: string): number;
|
|
123
|
-
geoIDsForDistrictID(i: number): Set<string>;
|
|
124
|
-
}
|
|
125
|
-
export declare class Graph {
|
|
126
|
-
_session: AnalyticsSession;
|
|
127
|
-
_graph: T.ContiguityGraph;
|
|
128
|
-
constructor(s: AnalyticsSession, graph: T.ContiguityGraph);
|
|
129
|
-
peerNeighbors(node: string): string[];
|
|
130
|
-
}
|
package/dist/analyze.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { AnalyticsSession } from './_api';
|
|
2
|
-
export declare function doAnalyzeDistricts(s: AnalyticsSession, bLog?: boolean): void;
|
|
3
|
-
export declare function doAnalyzePlan(s: AnalyticsSession, bLog?: boolean): void;
|
|
4
|
-
export declare function doDeriveSecondaryTests(s: AnalyticsSession): void;
|
package/dist/cohesive.d.ts
DELETED
package/dist/compact.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as T from './types';
|
|
2
|
-
import { AnalyticsSession } from './_api';
|
|
3
|
-
export declare function doReock(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
4
|
-
export declare function doPolsbyPopper(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
|
|
5
|
-
export declare function extractDistrictProperties(s: AnalyticsSession, bLog?: boolean): void;
|
package/dist/constants.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const StateXXToName: any;
|
|
2
|
-
export declare const StateRequirements: any;
|
|
3
|
-
export declare const MinorityDemographicDefns: any;
|
|
4
|
-
export declare const VRASection5Preclearance: any;
|
|
5
|
-
export declare const MajorityMinorityDistricts: any;
|
|
6
|
-
export declare const StateMinorityContacts: any;
|
package/dist/equal.d.ts
DELETED
package/dist/geofeature.d.ts
DELETED
package/dist/index.d.ts
DELETED
package/dist/minority.d.ts
DELETED
package/dist/political.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as T from './types';
|
|
2
|
-
import { AnalyticsSession } from './_api';
|
|
3
|
-
export declare function doSeatsBias(s: AnalyticsSession): T.TestEntry;
|
|
4
|
-
export declare function doVotesBias(s: AnalyticsSession): T.TestEntry;
|
|
5
|
-
export declare function doResponsiveness(s: AnalyticsSession): T.TestEntry;
|
|
6
|
-
export declare function doResponsiveDistricts(s: AnalyticsSession): T.TestEntry;
|
|
7
|
-
export declare function doEfficiencyGap(s: AnalyticsSession): T.TestEntry;
|
|
8
|
-
export declare function fptpWin(demPct: number): number;
|
package/dist/preprocess.d.ts
DELETED