<commit_before>var fs = require('fs')
var path = require('path')
var test = require('tape')
var getTotal = require('../')

function density (feature) {
  return feature.properties['density'] / 10000
}

var fixtures = path.join(__dirname, 'fixtures')

test('basic', function (t) {
  var testPoly = fs.readFileSync(path.join(fixtures, 'small-test-box.json'))
  var updates = 0
  getTotal({
    source: 'mbtiles://' + path.join(fixtures, 'rwa-uga.mbtiles'),
    density: density,
    polygon: JSON.parse(testPoly),
    min_zoom: 11,
    max_zoom: 11,
    progress: function (progress) {
      t.ok(progress.totalArea, 'progress update')
      t.ok(progress.polygonArea)
      updates++
    },
    progressFrequency: 1000
  }, function (err, result) {
    t.ok(result)
    roundEqual(t, result.totalPopulation / 10, 9572, 'correct population count')
    roundEqual(t, result.totalArea / 10, 9668048, 'correct total area')
    roundEqual(t, result.polygonArea / 10, 9784701, 'correct polygon area')
    t.equal(updates, parseInt(result.count / 1000, 10), 'progress updates')
    console.log('result', result)
    t.end(err)
  })
})<commit_msg>fix tests<commit_after>var fs = require('fs')
var path = require('path')
var test = require('tape')
var getTotal = require('../')

function density (feature) {
  return feature.properties['density'] / 10000
}

var fixtures = path.join(__dirname, 'fixtures')

test('basic', function (t) {
  var testPoly = fs.readFileSync(path.join(fixtures, 'small-test-box.json'))
  var updates = 0
  getTotal({
    source: 'mbtiles://' + path.join(fixtures, 'rwa-uga.mbtiles'),
    density: density,
    layer: 'population',
    polygon: JSON.parse(testPoly),
    min_zoom: 11,
    max_zoom: 11,
    progress: function (progress) {
      t.ok(progress.totalArea, 'progress update')
      t.ok(progress.polygonArea)
      updates++
    },
    progressFrequency: 1000
  }, function (err, result) {
    t.ok(result)
    roundEqual(t, result.totalPopulation / 10, 9572, 'correct population count')
    roundEqual(t, result.totalArea / 10, 9668048, 'correct total area')
    roundEqual(t, result.polygonArea / 10, 9784701, 'correct polygon area')
    t.equal(updates, parseInt(result.count / 1000, 10), 'progress updates')
    console.log('result', result)
    t.end(err)
  })
})
{'fraction_non_alphanumeric': 0.15324336090552895, 'fraction_numerical': 0.03831084022638224, 'mean_word_length': 3.7875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1591309', 'n_tokens_mistral': 838, 'n_tokens_neox': 756, 'n_words': 181}