@dra2020/district-analytics 16.1.2 → 16.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.
@@ -0,0 +1,3 @@
1
+ import * as T from './types';
2
+ import { AnalyticsSession } from './_api';
3
+ export declare function doHasEqualPopulations(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
@@ -0,0 +1,19 @@
1
+ export * from './_api';
2
+ export { geoIDForFeature, fieldForFeature, inferSelectedMinority } from './_data';
3
+ export * from './results';
4
+ export * from './types';
5
+ export { Profile, Scorecard, SplittingScorecard, Measurement } from './legacy-types';
6
+ export * from './utils';
7
+ import { Partisan, Rate, Splitting, Types } from '@dra2020/dra-analytics';
8
+ export type MinorityFilter = Types.MinorityFilter;
9
+ export type Point = Types.dictPoint;
10
+ export type DemographicVotingByFeature = Types.DemographicVotingByFeature;
11
+ export type RPVFactor = Types.RPVFactor;
12
+ export type RPVAnalysis = Types.RPVAnalysis;
13
+ export declare const estSeatProbability: typeof Partisan.estSeatProbability;
14
+ export declare const ratePartisanBias: typeof Rate.ratePartisanBias;
15
+ export declare const normalizePartisanBias: typeof Rate.normalizePartisanBias;
16
+ export declare const isAntimajoritarian: typeof Rate.isAntimajoritarian;
17
+ export declare const avgSVError = 0.02;
18
+ export declare const effectiveSplits: typeof Splitting.effectiveSplits;
19
+ export declare const uncertaintyOfMembership: typeof Splitting.uncertaintyOfMembership;
@@ -0,0 +1,164 @@
1
+ export type Profile = {
2
+ state: string;
3
+ name: string;
4
+ nDistricts: number;
5
+ repsByDistrict?: number[];
6
+ nCounties: number;
7
+ bStateLeg: boolean;
8
+ population: PopulationProfile;
9
+ shapes: ShapeProfile;
10
+ counties: CountyProfile;
11
+ partisanship: PartisanProfile;
12
+ demographics: DemographicProfile;
13
+ };
14
+ export type Scorecard = {
15
+ partisan: PartisanScorecard;
16
+ minority: MinorityScorecard;
17
+ compactness: CompactnessScorecard;
18
+ splitting: SplittingScorecard;
19
+ populationDeviation: PopulationScorecard;
20
+ details: Dict;
21
+ };
22
+ export type PartisanProfile = {
23
+ statewide: number;
24
+ byDistrict: VfArray;
25
+ };
26
+ export type VfArray = number[];
27
+ export type PartisanScorecard = {
28
+ bias: Bias;
29
+ impact: Impact;
30
+ responsiveness: Responsiveness;
31
+ dSVpoints: SVpoint[];
32
+ rSVpoints: SVpoint[];
33
+ averageDVf: number | undefined;
34
+ averageRVf: number | undefined;
35
+ details: Dict;
36
+ };
37
+ export type rVpoints = {
38
+ Sb: number;
39
+ Ra: number;
40
+ Rb: number;
41
+ Va: number;
42
+ Vb: number;
43
+ };
44
+ export type Bias = {
45
+ bestS: number;
46
+ bestSf: number;
47
+ estS: number;
48
+ estSf: number;
49
+ deviation: number;
50
+ score: number;
51
+ tOf?: number;
52
+ fptpS?: number;
53
+ bS50?: number;
54
+ bV50?: number;
55
+ decl?: number | undefined;
56
+ rvPoints?: rVpoints;
57
+ gSym?: number;
58
+ gamma?: number;
59
+ eG?: number;
60
+ bSV?: number;
61
+ prop?: number;
62
+ mMs?: number;
63
+ mMd?: number;
64
+ lO?: number | undefined;
65
+ };
66
+ export type Impact = {
67
+ unearnedS: number;
68
+ score: number;
69
+ };
70
+ export type Responsiveness = {
71
+ bigR?: number | undefined;
72
+ littleR?: number | undefined;
73
+ mIR?: number | undefined;
74
+ rD?: number;
75
+ rDf?: number;
76
+ cSimple: number;
77
+ cD: number;
78
+ cDf: number;
79
+ score: number;
80
+ };
81
+ export type PopulationProfile = {
82
+ byDistrict: totalPopByDistrict;
83
+ targetSize: number;
84
+ };
85
+ export type totalPopByDistrict = number[];
86
+ export type PopulationScorecard = Measurement;
87
+ export type GeoProperties = {
88
+ area: number;
89
+ perimeter: number;
90
+ diameter: number;
91
+ };
92
+ export type ShapeProfile = GeoProperties[];
93
+ export type CompactnessScorecard = {
94
+ score: number;
95
+ reock: Measurement;
96
+ polsby: Measurement;
97
+ details: Dict;
98
+ };
99
+ export type CompactnessByDistrict = {
100
+ rawReock: number;
101
+ normalizedReock: number;
102
+ rawPolsby: number;
103
+ normalizedPolsby: number;
104
+ kiwysiScore?: number;
105
+ };
106
+ export type CountyProfile = CxD;
107
+ export type CxD = number[][];
108
+ export type SplittingScorecard = {
109
+ score: number;
110
+ county: Measurement;
111
+ district: Measurement;
112
+ details: Dict;
113
+ };
114
+ export type Demographics = {
115
+ white: number;
116
+ minority: number;
117
+ black: number;
118
+ hispanic: number;
119
+ pacific: number;
120
+ asian: number;
121
+ native: number;
122
+ };
123
+ export type DemographicProfile = {
124
+ statewide: Demographics;
125
+ byDistrict: Demographics[];
126
+ };
127
+ export type DemoBreakdown = {
128
+ pct35_40: number;
129
+ pct40_45: number;
130
+ pct45_50: number;
131
+ pct50_55: number;
132
+ pct55_60: number;
133
+ pct60Plus: number;
134
+ vapPct: number;
135
+ propSeats: number;
136
+ };
137
+ export type DemographicPivot = {
138
+ minority: DemoBreakdown;
139
+ black: DemoBreakdown;
140
+ hispanic: DemoBreakdown;
141
+ pacific: DemoBreakdown;
142
+ asian: DemoBreakdown;
143
+ native: DemoBreakdown;
144
+ };
145
+ export type MinorityScorecard = {
146
+ pivotByDemographic: DemographicPivot;
147
+ opportunityDistricts: number;
148
+ coalitionDistricts: number;
149
+ score: number;
150
+ details: Dict;
151
+ };
152
+ export type Measurement = {
153
+ raw: number;
154
+ normalized: number;
155
+ byDistrict?: any[];
156
+ notes: Dict;
157
+ };
158
+ export type SVpoint = {
159
+ v: number;
160
+ s: number;
161
+ };
162
+ export type Dict = {
163
+ [key: string]: any;
164
+ };
@@ -0,0 +1,6 @@
1
+ import { Types } from '@dra2020/dra-analytics';
2
+ import * as T from './types';
3
+ import { AnalyticsSession } from './_api';
4
+ export declare function getMajorityMinority(s: AnalyticsSession): T.Dict;
5
+ export declare function getVRASection5(s: AnalyticsSession): string;
6
+ export declare function doAnalyzeRacialPolarization(s: AnalyticsSession, districtID: number, groups: Types.MinorityFilter, bLog?: boolean): Types.RPVAnalysis | undefined;
@@ -0,0 +1,2 @@
1
+ import { AnalyticsSession } from './_api';
2
+ export declare function doPreprocessData(s: AnalyticsSession, bLog?: boolean): void;
@@ -0,0 +1,50 @@
1
+ import * as T from './types';
2
+ import { AnalyticsSession } from './_api';
3
+ export type RequirementsChecklist = {
4
+ score: boolean;
5
+ metrics: {
6
+ complete: boolean;
7
+ contiguous: boolean;
8
+ freeOfHoles: boolean;
9
+ equalPopulation: boolean;
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
+ };
22
+ export declare function prepareRequirementsChecklist(s: AnalyticsSession, bLog?: boolean): RequirementsChecklist;
23
+ export type DistrictRow = {
24
+ districtID: number;
25
+ totalPop: number;
26
+ popDevPct: number;
27
+ bEqualPop: boolean;
28
+ bNotEmpty: boolean;
29
+ bContiguous: boolean;
30
+ bNotEmbedded: boolean;
31
+ demPct: number;
32
+ repPct: number;
33
+ othPct: number;
34
+ totalVAP: number;
35
+ whitePct: number;
36
+ minorityPct: number;
37
+ blackPct: number;
38
+ hispanicPct: number;
39
+ pacificPct: number;
40
+ asianPct: number;
41
+ nativePct: number;
42
+ };
43
+ export type DistrictStatistics = {
44
+ table: DistrictRow[];
45
+ details: {};
46
+ datasets: T.Datasets;
47
+ resources: {};
48
+ };
49
+ export declare function prepareDistrictStatistics(s: AnalyticsSession, bLog?: boolean): DistrictStatistics;
50
+ export declare function doAnalyzePostProcessing(s: AnalyticsSession, bLog?: boolean): void;
@@ -0,0 +1,9 @@
1
+ import * as L from './legacy-types';
2
+ import * as T from './types';
3
+ import { AnalyticsSession } from './_api';
4
+ import { Types } from '@dra2020/dra-analytics';
5
+ export declare function profilePlan(s: AnalyticsSession, bLog?: boolean): L.Profile;
6
+ export declare function getStatewideDemographics(s: AnalyticsSession, bLog?: boolean): L.Demographics;
7
+ export declare function computeMetrics(p: L.Profile, districtShapes: T.GeoFeatureCollection, bLog?: boolean): Types.Scorecard;
8
+ export declare function rateKeyDimensions(scorecard: Types.Scorecard, p: L.Profile, bLog?: boolean): Types.Scorecard;
9
+ export declare function thunkScorecard(newScorecard: Types.Scorecard, bLog?: boolean): L.Scorecard;
@@ -0,0 +1,4 @@
1
+ export declare const PRECISION: number;
2
+ export declare const NOT_ASSIGNED: number;
3
+ export declare const NUMBER_OF_ITEMS_TO_REPORT: number;
4
+ export declare const OUT_OF_STATE: string;
@@ -1,5 +1,5 @@
1
1
  import * as geojson from 'geojson';
2
- import * as DT from '@dra2020/dra-types';
2
+ import { DT } from '@dra2020/dra-types';
3
3
  export type SessionRequest = {
4
4
  title: string;
5
5
  stateXX: string;
@@ -82,8 +82,8 @@ export declare const enum Test {
82
82
  Complete = 0,
83
83
  Contiguous = 1,
84
84
  FreeOfHoles = 2,
85
- EqualPopulation = 3,
86
- PopulationDeviation = 4,
85
+ EqualPopulation = 3,// This is the legal/not legal assessment of the population
86
+ PopulationDeviation = 4,// deviation % (when legal, less is still better).
87
87
  UnexpectedCountySplits = 5,
88
88
  VTDSplits = 6
89
89
  }
@@ -0,0 +1,126 @@
1
+ import * as geojson from 'geojson';
2
+ import { DT } from '@dra2020/dra-types';
3
+ export type SessionRequest = {
4
+ title: string;
5
+ stateXX: string;
6
+ nDistricts: number;
7
+ repsByDistrict?: number[];
8
+ planType?: DT.PlanType;
9
+ legislativeDistricts?: boolean;
10
+ plan: PlanByGeoID;
11
+ data: GeoFeatureCollection;
12
+ districtShapes: GeoFeatureCollection;
13
+ graph: ContiguityGraph;
14
+ counties: GeoFeatureCollection;
15
+ config: {};
16
+ };
17
+ export declare const enum Dataset {
18
+ SHAPES = "SHAPES",
19
+ CENSUS = "CENSUS",
20
+ VAP = "VAP",
21
+ ELECTION = "ELECTION"
22
+ }
23
+ export type DatasetKeys = {
24
+ SHAPES: string;
25
+ CENSUS: string;
26
+ VAP: string;
27
+ ELECTION: string;
28
+ };
29
+ export declare const enum FeatureField {
30
+ TotalPop = 0,
31
+ WhitePop = 1,
32
+ BlackPop = 2,
33
+ HispanicPop = 3,
34
+ AsianPop = 4,
35
+ PacificPop = 5,
36
+ NativePop = 6,
37
+ DemVotes = 7,
38
+ RepVotes = 8,
39
+ TotalVotes = 9
40
+ }
41
+ export declare function fieldFromFeatureField(ds: string, ff: FeatureField): string;
42
+ export type PlanByGeoID = {
43
+ [geoID: string]: number;
44
+ };
45
+ export type PlanByDistrictID = {
46
+ [districtID: number]: Set<string>;
47
+ };
48
+ export type FeaturesByGeoID = {
49
+ [geoID: string]: number;
50
+ };
51
+ export type FIPSCodeToCountyNameMap = {
52
+ [FIPSCode: string]: string;
53
+ };
54
+ export type FIPSToOrdinalMap = {
55
+ [FIPSCode: string]: number;
56
+ };
57
+ export type OrdinalToFIPSlMap = {
58
+ [index: number]: string;
59
+ };
60
+ export type GeoFeature = geojson.Feature;
61
+ export type GeoFeatureArray = GeoFeature[];
62
+ export type GeoFeatureCollection = geojson.FeatureCollection;
63
+ export interface GeoFeatureMap {
64
+ [geoID: string]: GeoFeature;
65
+ }
66
+ export type ContiguityGraph = {
67
+ [geoID: string]: UnweightedNeighbors | WeightedNeighbors;
68
+ };
69
+ export type WeightedNeighbors = {
70
+ [geoID: string]: number;
71
+ };
72
+ export type UnweightedNeighbors = string[];
73
+ export type TestEntry = {
74
+ score?: number | boolean;
75
+ details: Dict;
76
+ normalizedScore?: number;
77
+ };
78
+ export type DistrictWIP = {
79
+ [districtID: number]: any;
80
+ };
81
+ export declare const enum Test {
82
+ Complete = 0,
83
+ Contiguous = 1,
84
+ FreeOfHoles = 2,
85
+ EqualPopulation = 3,// This is the legal/not legal assessment of the population
86
+ PopulationDeviation = 4,// deviation % (when legal, less is still better).
87
+ UnexpectedCountySplits = 5,
88
+ VTDSplits = 6
89
+ }
90
+ export type TestEntries = {
91
+ [test: number]: TestEntry;
92
+ };
93
+ export type DistrictProperties = {
94
+ [districtID: number]: any;
95
+ };
96
+ export type DistrictShapeProperties = [number, number, number];
97
+ export declare const enum DistrictShapeProperty {
98
+ Area = 0,
99
+ Diameter = 1,
100
+ Perimeter = 2
101
+ }
102
+ export type GeoIDParts = {
103
+ vfeature?: boolean;
104
+ state: string;
105
+ county: string;
106
+ rest: string;
107
+ };
108
+ export type GeoIDTotal = {
109
+ [geoID: string]: number;
110
+ };
111
+ export type Dict = {
112
+ [key: string]: any;
113
+ };
114
+ export type Datasets = {
115
+ shapes?: string;
116
+ census?: string;
117
+ vap?: string;
118
+ election?: string;
119
+ };
120
+ export type Ratings = {
121
+ proportionality: number;
122
+ competitiveness: number;
123
+ minorityRights: number;
124
+ compactness: number;
125
+ splitting: number;
126
+ };
@@ -0,0 +1,26 @@
1
+ import { AnalyticsSession } from './_api';
2
+ import * as T from './types';
3
+ export declare function getDistrict(plan: T.PlanByGeoID, geoID: string): number | undefined;
4
+ export declare function parseGeoID(geoID: string): T.GeoIDParts;
5
+ export declare function isWaterOnly(geoID: string, s?: AnalyticsSession): boolean;
6
+ export declare function isUninhabited(geoID: string, s: AnalyticsSession): boolean;
7
+ export declare function trim(fullFraction: number, digits?: number | undefined): number;
8
+ export declare function sumArray(arr: number[]): number;
9
+ export declare function avgArray(arr: number[]): number;
10
+ export declare function minArray(arr: number[]): number;
11
+ export declare function maxArray(arr: number[]): number;
12
+ export declare function initArray(n: number, value: any): any[];
13
+ export declare function andArray(arr: boolean[]): boolean;
14
+ export declare function keyExists(k: string, o: object): boolean;
15
+ export declare function isObjectEmpty(o: object): boolean;
16
+ export declare function isSetEmpty(s: any): boolean;
17
+ export declare function isArrayEmpty(a: any[]): boolean;
18
+ export declare function getObjectKeys(o: object): string[];
19
+ export declare function getNumericObjectKeys(o: object): number[];
20
+ export declare function getSelectObjectKeys(o: T.Dict, v: any[]): string[];
21
+ export declare function arrayContains(a: any[], item: any): boolean;
22
+ export declare function objectContains(o: object, key: any): boolean;
23
+ export declare function countEnumValues(enumName: any): number;
24
+ export declare function shallowCopy(src: any): any;
25
+ export declare function deepCopy(src: any): any;
26
+ export declare function depthof(a: any): number;
@@ -0,0 +1,5 @@
1
+ import * as T from './types';
2
+ import { AnalyticsSession } from './_api';
3
+ export declare function doIsComplete(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
4
+ export declare function doIsContiguous(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
5
+ export declare function doIsFreeOfHoles(s: AnalyticsSession, bLog?: boolean): T.TestEntry;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/district-analytics",
3
- "version": "16.1.2",
3
+ "version": "16.1.4",
4
4
  "description": "District analytics TypeScript package",
5
5
  "main": "dist/district-analytics.js",
6
6
  "files": [
@@ -30,24 +30,24 @@
30
30
  "homepage": "https://github.com/dra2020/district-analytics#readme",
31
31
  "devDependencies": {
32
32
  "@types/geojson": "^7946.0.10",
33
- "@types/node": "^12.20.23",
33
+ "@types/node": "^20.11.30",
34
34
  "@types/yargs": "^12.0.20",
35
35
  "json-loader": "^0.5.7",
36
36
  "prettier": "^2.7.1",
37
- "source-map-loader": "^3.0.0",
38
- "ts-loader": "^9.4.1",
37
+ "source-map-loader": "^5.0.0",
38
+ "ts-loader": "^9.5.1",
39
39
  "tsify": "^5.0.4",
40
40
  "tslint": "^6.1.3",
41
41
  "tslint-config-prettier": "^1.18.0",
42
- "typescript": "^4.9.3",
43
- "webpack": "^5.75.0",
44
- "webpack-cli": "^4.10.0",
42
+ "typescript": "^5.4.3",
43
+ "webpack": "^5.91.0",
44
+ "webpack-cli": "^5.1.4",
45
45
  "yargs": "^12.0.5"
46
46
  },
47
47
  "dependencies": {
48
- "@dra2020/baseclient": "^1.0.90",
48
+ "@dra2020/baseclient": "^1.0.127",
49
49
  "@dra2020/dra-analytics": "^4.1.2",
50
- "@dra2020/dra-types": "^1.8.71",
50
+ "@dra2020/dra-types": "^1.8.89",
51
51
  "geojson": "^0.5.0"
52
52
  }
53
53
  }