@dra2020/district-analytics 3.2.0 → 3.3.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.
@@ -116,6 +116,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
116
116
  return result;
117
117
  };
118
118
  Object.defineProperty(exports, "__esModule", { value: true });
119
+ const Score = __importStar(__webpack_require__(/*! @dra2020/dra-score */ "@dra2020/dra-score"));
119
120
  const preprocess_1 = __webpack_require__(/*! ./preprocess */ "./src/preprocess.ts");
120
121
  const analyze_1 = __webpack_require__(/*! ./analyze */ "./src/analyze.ts");
121
122
  const score_1 = __webpack_require__(/*! ./score */ "./src/score.ts");
@@ -309,9 +310,13 @@ class AnalyticsSession {
309
310
  return 1 - this.testScales[4 /* PopulationDeviation */]['scale'][0];
310
311
  }
311
312
  else {
313
+ // NOTE - This assumes the plan has been profiled
314
+ const scorer = new Score.Scorer();
315
+ const popdev = scorer.populationDeviationThreshold(this.legislativeDistricts);
316
+ return popdev;
312
317
  // TODO - SCORE: Temporary HACK. Query dra-score for threshold.
313
318
  // NOTE - The plan may not have been scored yet, i.e., no scorecard yet.
314
- return 1 - this.testScales[4 /* PopulationDeviation */]['scale'][0];
319
+ // return 1 - this.testScales[T.Test.PopulationDeviation]['scale'][0];
315
320
  }
316
321
  }
317
322
  }
@@ -2545,7 +2550,9 @@ function doAnalyzePostProcessing(s, bLog = false) {
2545
2550
  // Just populate the normalized population deviation score in the test
2546
2551
  const scorecard = s._scorecard;
2547
2552
  let test = s.getTest(4 /* PopulationDeviation */);
2548
- test['normalizedScore'] = scorecard.best.populationDeviation.normalized;
2553
+ test['normalizedScore'] = scorecard.traditionalPrinciples.populationDeviation.normalized;
2554
+ // TODO - DELETE
2555
+ // test['normalizedScore'] = scorecard.best.populationDeviation.normalized;
2549
2556
  }
2550
2557
  // Derive secondary tests
2551
2558
  analyze_1.doDeriveSecondaryTests(s, bLog);
@@ -2591,7 +2598,7 @@ function profilePlan(s, bLog = false) {
2591
2598
  const geoPropsByDistrict = makeArrayOfGeoProps(s, bLog);
2592
2599
  const splits = makeNakedCxD(s);
2593
2600
  const summaryRow = s.districts.numberOfRows() - 1;
2594
- const statewideVf = s.districts.statistics[D.DistrictField.DemPct][summaryRow];
2601
+ const statewideVf = U.trim(s.districts.statistics[D.DistrictField.DemPct][summaryRow], 6);
2595
2602
  const vpiArray = U.deepCopy(s.districts.statistics[D.DistrictField.DemPct].slice(1, -1));
2596
2603
  const demographicsByDistrict = makeArrayOfDemographics(s);
2597
2604
  const profile = {
@@ -2675,11 +2682,14 @@ function scorePlan(s, p, bLog = false, overridesJSON) {
2675
2682
  // calling sequence.
2676
2683
  let test = s.getTest(4 /* PopulationDeviation */);
2677
2684
  // TODO - SCORE: U.trim(popDev)???
2685
+ // const popDev = scorecard.best.populationDeviation.raw;
2678
2686
  // Get the raw population deviation
2679
- const popDev = scorecard.best.populationDeviation.raw;
2687
+ const popDev = scorecard.traditionalPrinciples.populationDeviation.raw;
2680
2688
  // Populate the test entry
2681
2689
  test['score'] = popDev;
2682
- test['details'] = { 'maxDeviation': scorecard.best.populationDeviation.notes['maxDeviation'] };
2690
+ test['details'] = { 'maxDeviation': scorecard.traditionalPrinciples.populationDeviation.notes['maxDeviation'] };
2691
+ // TODO - DELETE
2692
+ // test['details'] = { 'maxDeviation': scorecard.best.populationDeviation.notes['maxDeviation'] };
2683
2693
  // Populate the N+1 summary "district" in district.statistics
2684
2694
  let totalPop = s.districts.statistics[D.DistrictField.TotalPop];
2685
2695
  let popDevPct = s.districts.statistics[D.DistrictField.PopDevPct];