<commit_before>require File.dirname(__FILE__) + '/../helper'

class PFTrackImportTest < Test::Unit::TestCase
  DELTA = 0.1 
  
  def test_introspects_properly
    i = Tracksperanto::Import::PFTrack
    assert_equal "PFTrack .2dt file", i.human_name
    assert !i.autodetects_size?
  end
  
  def test_parsing_from_pftrack5_second_file
    fixture = File.open(File.dirname(__FILE__) + '/samples/pftrack5/apft.2dt')
    parser = Tracksperanto::Import::PFTrack.new(:width => 1920, :height => 1080)
    
    trackers = parser.parse(fixture)
    assert_equal 4, trackers.length
    second_tracker = trackers[1]
    assert_equal "1015", second_tracker.name
  end
  
  def test_parsing_from_importable_pftrack_4
    
    fixture = File.open(File.dirname(__FILE__) + '/samples/pftrack4/sourcefile_pftrack.2dt')
    
    parser = Tracksperanto::Import::PFTrack.new
    parser.width = 2560
    parser.height = 1080
    
    trackers = parser.parse(fixture)
    assert_equal 43, trackers.length
    
    first_kf = trackers[0].keyframes[0]
    last_kf = trackers[0].keyframes[-1]
    
    assert_equal "Tracker1", trackers[0].name
    assert_equal 341, trackers[0].keyframes.length
    
    assert_equal 41, first_kf.frame
    assert_in_delta 984.611, first_kf.abs_x, DELTA
    assert_in_delta 30.220, first_kf.abs_y, DELTA<commit_msg>Rename the import test to better reflect, well, test<commit_after>require File.dirname(__FILE__) + '/../helper'

class PFTrackImportTest < Test::Unit::TestCase
  DELTA = 0.1 
  
  def test_introspects_properly
    i = Tracksperanto::Import::PFTrack
    assert_equal "PFTrack .2dt file", i.human_name
    assert !i.autodetects_size?
  end
  
  def test_parsing_from_pftrack5_with_digit_names
    fixture = File.open(File.dirname(__FILE__) + '/samples/pftrack5/apft.2dt')
    parser = Tracksperanto::Import::PFTrack.new(:width => 1920, :height => 1080)
    
    trackers = parser.parse(fixture)
    assert_equal 4, trackers.length
    second_tracker = trackers[1]
    assert_equal "1015", second_tracker.name
  end
  
  def test_parsing_from_importable_pftrack_4
    
    fixture = File.open(File.dirname(__FILE__) + '/samples/pftrack4/sourcefile_pftrack.2dt')
    
    parser = Tracksperanto::Import::PFTrack.new
    parser.width = 2560
    parser.height = 1080
    
    trackers = parser.parse(fixture)
    assert_equal 43, trackers.length
    
    first_kf = trackers[0].keyframes[0]
    last_kf = trackers[0].keyframes[-1]
    
    assert_equal "Tracker1", trackers[0].name
    assert_equal 341, trackers[0].keyframes.length
    
    assert_equal 41, first_kf.frame
    assert_in_delta 984.611, first_kf.abs_x, DELTA
    assert_in_delta 30.220, first_kf.abs_y, DELTA
{'fraction_non_alphanumeric': 0.10401188707280833, 'fraction_numerical': 0.041604754829123326, 'mean_word_length': 3.683478260869565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3204374', 'n_tokens_mistral': 1031, 'n_tokens_neox': 961, 'n_words': 163}