<commit_before># Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import copy
import math
import os
import unittest

from telemetry import decorators
from telemetry.core import util
from telemetry.internal.util import external_modules

try:
  np = external_modules.ImportRequiredModule('numpy')
  cv2 = external_modules.ImportRequiredModule('cv2')
except (ImportError, NotImplementedError) as err:
  pass
else:
  # pylint: disable=protected-access
  class ScreenFinderTest(unittest.TestCase):
    def __init__(self, *args, **kwargs):
      super(ScreenFinderTest, self).__init__(*args, **kwargs)
      # Import modules with dependencies that may not be preset in test setup so
      # that importing this unit test doesn't cause the test runner to raise an
      # exception.
      from telemetry.internal.image_processing import fake_frame_generator
      from telemetry.internal.image_processing import screen_finder
      from telemetry.internal.image_processing import video_file_frame_generator
      self.FakeFrameGenerator = fake_frame_generator.FakeFrameGenerator
      self.VideoFileFrameGenerator = \
          video_file_frame_generator.VideoFileFrameGenerator
      self.ScreenFinder = screen_finder.ScreenFinder

    def _GetScreenFinder(self, video_filename):
      if not video_filename:
        fg = self.FakeFrameGenerator()
      else:
        vid = os.path.join(util.GetUnittestDataDir(), video_filename)
        fg = self.VideoFileFrameGenerator(vid)
      return self.ScreenFinder(fg)

    # https://github.com/catapult-project/catapult/issues/3510
    @decorators.Disabled('linux')
    @decorators.Isolated
    def testBasicFunctionality(self):
      def CheckCorners(corners, expected):
        for i in xrange(len(corners)):
          for j in xrange(len(corners[i])):
            self.assertAlmostEqual(corners[i][j], expected[i][j], delta=1.1)
      expected = [[314, 60], [168, 58], [162, 274], [311, 276]]
      sf = self._GetScreenFinder('screen_3_frames.mov')
      self.assertTrue(sf.HasNext())<commit_msg>Mac: disable one more formerly-skipped test that fails with numpy/cv2<commit_after># Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import copy
import math
import os
import unittest

from telemetry import decorators
from telemetry.core import util
from telemetry.internal.util import external_modules

try:
  np = external_modules.ImportRequiredModule('numpy')
  cv2 = external_modules.ImportRequiredModule('cv2')
except (ImportError, NotImplementedError) as err:
  pass
else:
  # pylint: disable=protected-access
  class ScreenFinderTest(unittest.TestCase):
    def __init__(self, *args, **kwargs):
      super(ScreenFinderTest, self).__init__(*args, **kwargs)
      # Import modules with dependencies that may not be preset in test setup so
      # that importing this unit test doesn't cause the test runner to raise an
      # exception.
      from telemetry.internal.image_processing import fake_frame_generator
      from telemetry.internal.image_processing import screen_finder
      from telemetry.internal.image_processing import video_file_frame_generator
      self.FakeFrameGenerator = fake_frame_generator.FakeFrameGenerator
      self.VideoFileFrameGenerator = \
          video_file_frame_generator.VideoFileFrameGenerator
      self.ScreenFinder = screen_finder.ScreenFinder

    def _GetScreenFinder(self, video_filename):
      if not video_filename:
        fg = self.FakeFrameGenerator()
      else:
        vid = os.path.join(util.GetUnittestDataDir(), video_filename)
        fg = self.VideoFileFrameGenerator(vid)
      return self.ScreenFinder(fg)

    # https://github.com/catapult-project/catapult/issues/3510
    @decorators.Disabled('mac', 'linux')
    @decorators.Isolated
    def testBasicFunctionality(self):
      def CheckCorners(corners, expected):
        for i in xrange(len(corners)):
          for j in xrange(len(corners[i])):
            self.assertAlmostEqual(corners[i][j], expected[i][j], delta=1.1)
      expected = [[314, 60], [168, 58], [162, 274], [311, 276]]
      sf = self._GetScreenFinder('screen_3_frames.mov')
      self.assertTrue(sf.HasNext())
{'fraction_non_alphanumeric': 0.0871359779867003, 'fraction_numerical': 0.016280669571199266, 'mean_word_length': 3.962457337883959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5045565', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1227, 'n_words': 335}