<commit_before>import { createSelector } from 'reselect'
import {
  transformShapes,
  patternImport
} from './computer'

const getApp = state => state.app
const getShapes = state => state.shapes
const getTransforms = state => state.transforms
const getFile = state => state.file
const getGCode = state => state.gcode
const getMachine = state => state.machine

export const getVertices = createSelector(
  [
      getApp,
      getShapes,
      getTransforms,
      getFile,
      getGCode,
      getMachine,
  ],
  (app, shapes, transforms, file, gcode, machine) => {
    let state = {
      app: app,
      shapes: shapes,
      shape: shapes.byId[shapes.currentId],
      transforms: transforms,
      transform: transforms.byId[shapes.currentId],
      file: file,
      gcode: gcode,
      machine: machine
    }

    if (state.app.input === 'shape') {
      return transformShapes(state)
    } else if (state.app.input === 'code') {
      return patternImport(state)
    } else {
      return transformShapes(state)
    }
  }
)

export const getVerticesStats = createSelector(
  [
      getVertices
  ],
  (vertices) => {
    let distance = 0.0
    var previous = null

    vertices.forEach( (vertex) => {
      if (previous) {
        distance += Math.sqrt(Math.pow(vertex.x - previous.x, 2.0) +
                              Math.pow(vertex.y - previous.y, 2.0))
      }
      previous = vertex
    })

    return {
      numPoints: vertices.length,
      distance: Math.floor(distance)
    }
  }
)
<commit_msg>Change the selector to prefer imported files in the machine or about tabs.<commit_after>import { createSelector } from 'reselect'
import {
  transformShapes,
  patternImport
} from './computer'

const getApp = state => state.app
const getShapes = state => state.shapes
const getTransforms = state => state.transforms
const getFile = state => state.file
const getGCode = state => state.gcode
const getMachine = state => state.machine

export const getVertices = createSelector(
  [
      getApp,
      getShapes,
      getTransforms,
      getFile,
      getGCode,
      getMachine,
  ],
  (app, shapes, transforms, file, gcode, machine) => {
    let state = {
      app: app,
      shapes: shapes,
      shape: shapes.byId[shapes.currentId],
      transforms: transforms,
      transform: transforms.byId[shapes.currentId],
      file: file,
      gcode: gcode,
      machine: machine
    }

    if (state.app.input === 'shapes') {
      return transformShapes(state)
    } else if (state.app.input === 'code') {
      return patternImport(state)
    } else {
      if (state.file.name) {
        return patternImport(state)
      } else {
        return transformShapes(state)
      }
    }
  }
)

export const getVerticesStats = createSelector(
  [
      getVertices
  ],
  (vertices) => {
    let distance = 0.0
    var previous = null

    vertices.forEach( (vertex) => {
      if (previous) {
        distance += Math.sqrt(Math.pow(vertex.x - previous.x, 2.0) +
                              Math.pow(vertex.y - previous.y, 2.0))
      }
      previous = vertex
    })

    return {
      numPoints: vertices.length,
      distance: Math.floor(distance)
    }
  }
)

{'fraction_non_alphanumeric': 0.11442006269592477, 'fraction_numerical': 0.003761755485893417, 'mean_word_length': 2.3695881731784585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '1988169', 'n_tokens_mistral': 998, 'n_tokens_neox': 980, 'n_words': 239}