@dra2020/district-analytics 16.1.14 → 17.0.2

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 CHANGED
@@ -1,6 +1,9 @@
1
1
  # District Analytics
2
2
 
3
- Type definitions and code used by dra-client and fn-all (lambdas), and which invokes dra-analytics
3
+ A layer between dra-client and fn-all (scoring lambda) that knows enough about DRA and analytics proper (in dra-analytics)
4
+ to take data in, compose the various analytics calls, and return the scorecards, etc. that they want. This allows the callers
5
+ to remain high-level and agnostic of the analytics specifics, on the one hand, and the analytics proper to no nothing about
6
+ DRA, on the other.
4
7
 
5
8
  ## Build Status
6
9
 
@@ -12,9 +15,9 @@ Type definitions and code used by dra-client and fn-all (lambdas), and which inv
12
15
  import * as DA from 'district-analytics';
13
16
 
14
17
  let sr = {} as DA.SessionRequest;
15
- sr['title'] = "NC 2016 Contingent Corrected Map";
18
+ sr['title'] = "NC 2020 Congress";
16
19
  sr['stateXX'] = "NC";
17
- sr['nDistricts'] = 13;
20
+ sr['nDistricts'] = 14;
18
21
  sr['planType'] = PlanType.congress; // One or ...
19
22
  sr['legislativeDistricts'] = false; // ... the other
20
23
  sr['data'] = data as T.GeoFeatureCollection;
@@ -22,6 +25,8 @@ sr['counties'] = counties as T.GeoFeatureCollection;
22
25
  sr['graph'] = graph as T.ContiguityGraph;
23
26
  sr['plan'] = planByGeoID as DA.PlanByGeoID;
24
27
  sr['districtShapes'] = districtShapes as T.GeoFeatureCollection;
28
+ sr['aggregates'] = aggregates as PF.PackedFields[];
29
+ sr['datasetsMeta'] = datasetsMeta as DT.DatasetsMeta;
25
30
  sr['config'] = config as T.Dict;
26
31
 
27
32
  let s = new DA.AnalyticsSession(sr);
@@ -29,15 +34,8 @@ let s = new DA.AnalyticsSession(sr);
29
34
  let bLog = false;
30
35
  s.analyzePlan(bLog);
31
36
 
32
- const statistics: DA.DistrictStatistics = s.getDistrictStatistics();
33
37
  const requirements: DA.RequirementsChecklist = s.getRequirementsChecklist();
34
38
  const scorecard: DA.Scorecard = s.getPlanScorecard();
35
39
  const ratings: DA.Ratings = s.getRatings();
36
-
37
- const discontiguous = DA.GeoFeatureCollection = s.getDiscontiguousDistrictFeatures();
38
-
39
40
  ```
40
41
 
41
- ## License
42
-
43
- Distributed under the [The MIT License (MIT)](https://github.com/alecramsay/district-analytics/blob/master/LICENSE) Copyright © 2019 Alec Ramsay
package/dist/_api.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { DT, PF } from '@dra2020/dra-types';
1
2
  import { Types } from '@dra2020/dra-analytics';
2
3
  import { RequirementsChecklist } from './results';
3
4
  import { DistrictStatistics } from './results';
@@ -20,6 +21,8 @@ export declare class AnalyticsSession {
20
21
  features: D.Features;
21
22
  plan: D.Plan;
22
23
  districts: D.Districts;
24
+ aggregates: PF.PackedFields[];
25
+ datasetsMeta: DT.DatasetsMeta;
23
26
  repsByDistrict?: number[];
24
27
  constructor(SessionRequest: T.SessionRequest);
25
28
  processConfig(config: T.Dict): T.Dict;
package/dist/data.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ import * as T from './types';
2
+ import { AnalyticsSession } from './_api';
3
+ export declare class Districts {
4
+ _session: AnalyticsSession;
5
+ _shapes: T.GeoFeatureCollection;
6
+ _geoProperties: T.DistrictProperties;
7
+ constructor(s: AnalyticsSession, ds: T.GeoFeatureCollection);
8
+ getDistrictShapes(): T.GeoFeatureCollection;
9
+ getDistrictShapeByID(id: number): T.GeoFeature | undefined;
10
+ getCountyIndex(geoID: string): number;
11
+ }
12
+ export declare class Features {
13
+ _session: AnalyticsSession;
14
+ _data: T.GeoFeatureCollection;
15
+ _keys: T.DatasetKeys;
16
+ _featureIDs: T.FeaturesByGeoID;
17
+ constructor(s: AnalyticsSession, data: T.GeoFeatureCollection, keys: T.DatasetKeys);
18
+ nFeatures(): number;
19
+ featureByIndex(i: number): T.GeoFeature;
20
+ resetDataset(d: T.Dataset, k: string): void;
21
+ mapGeoIDsToFeatureIDs(): void;
22
+ featureID(i: string): number;
23
+ }
24
+ export declare function geoIDForFeature(f: any): string;
25
+ export declare function fieldForFeature(f: any, dk: string, ff: T.FeatureField): any;
26
+ export declare class Counties {
27
+ _session: AnalyticsSession;
28
+ _data: T.GeoFeatureCollection;
29
+ _countyNameLookup: T.FIPSCodeToCountyNameMap;
30
+ nCounties: number;
31
+ index: T.FIPSToOrdinalMap;
32
+ fips: T.OrdinalToFIPSlMap;
33
+ totalPopulation: number[];
34
+ constructor(s: AnalyticsSession, data: T.GeoFeatureCollection);
35
+ countyByIndex(i: number): T.GeoFeature;
36
+ propertyForCounty(f: any, pk: string): any;
37
+ mapFIPSToName(fips: string, name: string): void;
38
+ nameFromFIPS(fips: string): string;
39
+ indexFromFIPS(fips: string): number;
40
+ }
41
+ export declare class State {
42
+ _session: AnalyticsSession;
43
+ xx: string;
44
+ nDistricts: number;
45
+ nReps: number;
46
+ totalPop: number;
47
+ targetSize: number;
48
+ tooBigFIPS: string[];
49
+ tooBigName: string[];
50
+ singleCountyDistrictMax: number;
51
+ expectedSplits: number;
52
+ expectedAffected: number;
53
+ constructor(s: AnalyticsSession, xx: string, n: number);
54
+ }
55
+ export declare class Plan {
56
+ _session: AnalyticsSession;
57
+ _planByGeoID: T.PlanByGeoID;
58
+ _planByDistrictID: T.PlanByDistrictID;
59
+ districtIDs: number[];
60
+ constructor(s: AnalyticsSession, p: T.PlanByGeoID);
61
+ invertPlan(bLog?: boolean): void;
62
+ initializeDistrict(i: number): void;
63
+ byGeoID(): T.PlanByGeoID;
64
+ byDistrictID(): T.PlanByDistrictID;
65
+ districtForGeoID(i: string): number;
66
+ geoIDsForDistrictID(i: number): Set<string>;
67
+ }
68
+ export declare function invertPlan(plan: T.PlanByGeoID, s?: AnalyticsSession, bLog?: boolean): T.PlanByDistrictID;
@@ -105,6 +105,8 @@ class AnalyticsSession {
105
105
  this.features = new D.Features(this, SessionRequest['data'], this.config['datasets']);
106
106
  this.plan = new D.Plan(this, SessionRequest['plan']);
107
107
  this.districts = new D.Districts(this, SessionRequest['districtShapes']);
108
+ this.aggregates = SessionRequest['aggregates'];
109
+ this.datasetsMeta = SessionRequest['datasetsMeta'];
108
110
  }
109
111
  processConfig(config) {
110
112
  // Default the Census & redistricting cycle to 2010