@dra2020/district-analytics 2.0.5 → 2.0.8

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
@@ -2,6 +2,10 @@
2
2
 
3
3
  Analytics for scoring congressional and legislative district maps.
4
4
 
5
+ ## Build Status
6
+
7
+ [![CircleCI](https://circleci.com/gh/dra2020/district-analytics.svg?style=svg&circle-token=c487b4ab53586db25961a9a48388b794020901d1)](https://circleci.com/gh/dra2020/district-analytics)
8
+
5
9
  ## Sample Code
6
10
 
7
11
  ```javascript
package/dist/cli.js CHANGED
@@ -8331,6 +8331,9 @@ class Districts {
8331
8331
  // 3 - MORE ...
8332
8332
  // HACK - Because "this" gets ghosted inside the forEach loop below
8333
8333
  let outerThis = this;
8334
+ // Default the pop dev % for the dummy Unassigned district to 0%.
8335
+ // Default the pop dev % for real (1–N) but empty districts to 100%.
8336
+ let popDevPct = (i > 0) ? (targetSize / targetSize) : 0 / targetSize;
8334
8337
  // Get the geoIDs assigned to the district
8335
8338
  // Guard against empty districts
8336
8339
  let geoIDs = this._session.plan.geoIDsForDistrictID(i);
@@ -8377,11 +8380,11 @@ class Districts {
8377
8380
  });
8378
8381
  // COMPUTE DERIVED VALUES
8379
8382
  // Population deviation % and equal population (boolean) by district.
8380
- // Default the value for the dummy unassigned district to 0%.
8381
- let popDevPct = 0 / targetSize;
8382
8383
  if (i > 0) {
8383
- popDevPct = (totalPop - targetSize) / targetSize;
8384
- bEqualPop = (popDevPct <= deviationThreshold);
8384
+ if (totalPop > 0) {
8385
+ popDevPct = (totalPop - targetSize) / targetSize;
8386
+ bEqualPop = (Math.abs(popDevPct) <= deviationThreshold);
8387
+ }
8385
8388
  }
8386
8389
  // Total two-party (not total total!) votes, Democratic and Republican vote
8387
8390
  // shares, and Democratic first-past-the-post win (= 1) or loss (= 0).
@@ -8470,7 +8473,7 @@ class Districts {
8470
8473
  }
8471
8474
  }
8472
8475
  else { // If a district is empty, zero these results (vs. null)
8473
- this.statistics[DistrictField.PopDevPct][i] = 0.0;
8476
+ this.statistics[DistrictField.PopDevPct][i] = popDevPct;
8474
8477
  this.statistics[DistrictField.DemVotes][i] = 0;
8475
8478
  this.statistics[DistrictField.RepVotes][i] = 0;
8476
8479
  this.statistics[DistrictField.TwoPartyVote][i] = 0;