<commit_before>describe "plot", ->
  it 'should have user facing text defined', ->
    hx.userFacingText('plot','noData').should.equal('No Data')

  describe "Graph", ->

    describe 'util functions for plotting', ->
      s = hx._.plot
      array = [{x: 1, y: 2}, {x: 2, y: 3}, {x: 3, y: 4}]
      array2 = [{x: 1, y1: 4, y2: 3}, {x: 2, y1: 3, y2: 4}, {x: 3, y1: 5, y2: 5}]
      array3 = [{x: 1, y: 2}, {x: 2, y: 3}, {x: 3, y: 4}, {x: 4, y: 2}]

      it 'doCollisionDetection: should hide text that gets in the way of other text', ->
        widthPx = 200
        createSuspiciousElement = (i) ->
          hx.detached 'div'
            .text i
            .style 'left', "#{i * widthPx / 2}px"
            .style 'width', "#{widthPx}px"
            .style 'position', 'absolute'
            .node()
        suspiciousElements = hx.range(4).map createSuspiciousElement
        suspiciousElementsSel = hx.selectAll suspiciousElements
        suspiciousElementsSel.text().should.deep.equal ['0', '1', '2', '3']
        hx._.plot.doCollisionDetection suspiciousElements
        suspiciousElementsSel.text().should.deep.equal ['0', '', '2', '']


      it 'dataAverage: should return the average data point in an array', ->
        s.dataAverage(array).should.eql({x: 2, y: 3})
        s.dataAverage(array2).should.eql({x: 2, y1: 4, y2: 4})

      it 'maxTriangle: should return a data point', ->
        data1 = {x: 0, y: 0}
        data2 = {x: 4, y: 1}<commit_msg>extract magic numbers to variables<commit_after>describe "plot", ->
  it 'should have user facing text defined', ->
    hx.userFacingText('plot','noData').should.equal('No Data')

  describe "Graph", ->

    describe 'util functions for plotting', ->
      s = hx._.plot
      array = [{x: 1, y: 2}, {x: 2, y: 3}, {x: 3, y: 4}]
      array2 = [{x: 1, y1: 4, y2: 3}, {x: 2, y1: 3, y2: 4}, {x: 3, y1: 5, y2: 5}]
      array3 = [{x: 1, y: 2}, {x: 2, y: 3}, {x: 3, y: 4}, {x: 4, y: 2}]

      it 'doCollisionDetection: should hide text that gets in the way of other text', ->
        widthPx = 200
        intendedDistance = 2
        createSuspiciousElement = (i) ->
          hx.detached 'div'
            .text i
            .style 'left', "#{i * widthPx / intendedDistance}px"
            .style 'width', "#{widthPx}px"
            .style 'position', 'absolute'
            .node()

        suspiciousElements = hx.range(4).map createSuspiciousElement
        suspiciousElementsSel = hx.selectAll suspiciousElements

        expectedPrevText = ['0', '1', '2', '3']
        # Sense check
        suspiciousElementsSel.text().should.deep.equal expectedPrevText
        hx._.plot.doCollisionDetection suspiciousElements

        expectedCurrText = expectedPrevText.map (val, i) -> if i % intendedDistance then '' else val
        suspiciousElementsSel.text().should.deep.equal expectedCurrText


      it 'dataAverage: should return the average data point in an array', ->
        s.dataAverage(array).should.eql({x: 2, y: 3})
        s.dataAverage(array2).should.eql({x: 2, y1: 4, y2: 4})

      it 'maxTriangle: should return a data point', ->
        data1 = {x: 0, y: 0}
        data2 = {x: 4, y: 1}
{'fraction_non_alphanumeric': 0.16103568045468897, 'fraction_numerical': 0.03473318598042311, 'mean_word_length': 2.3991416309012874, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '6248624', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1067, 'n_words': 330}