Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion geist/backends/fake.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import numpy as np
from six import string_types

from ..finders import Location, LocationList


Expand All @@ -14,7 +16,7 @@ def __init__(self, **kwargs):
[Location(0, 0, w=w, h=h, image=self.image)]
)
else:
if isinstance(image, basestring):
if isinstance(image, string_types):
image = np.load(image)
self.image = image
h, w, _ = image.shape
Expand Down
6 changes: 3 additions & 3 deletions geist/backends/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import json
import base64
import StringIO
from six import StringIO
import wrapt
from PIL import Image
from . import get_platform_backend
Expand Down Expand Up @@ -119,7 +119,7 @@ def capture_locations(self):
location_list = LocationList()
for b64_location in b64_locations:
base64_png = b64_location['base64_png']
string_file = StringIO.StringIO(
string_file = StringIO(
base64.b64decode(base64_png)
)
x, y, w, h = (
Expand Down Expand Up @@ -191,7 +191,7 @@ def _write_action(self, funcname, *args, **kwargs):
def _write_capture_locations(self, locations):
b64_locations = []
for location in locations:
string_file = StringIO.StringIO()
string_file = StringIO()
Image.fromarray(location.image).save(string_file, 'png')
b64_png = base64.b64encode(string_file.getvalue())
b64_locations.append({
Expand Down
2 changes: 1 addition & 1 deletion geist/backends/xvfb.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, **kwargs):

display = ":%d" % (self.display_num, )
self._display_dir = XVFB_PATH % (self.display_num,)
os.makedirs(self._display_dir, 0700)
os.makedirs(self._display_dir, 0o700)
dev_null = open('/dev/null', 'w')
self._xvfb_proc = subprocess.Popen(
[
Expand Down
1 change: 0 additions & 1 deletion geist/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def _get_colour(self, numpy_array):
smax = sat.max()
vmin = val.min()
vmax = val.max()
print hmin, hmax, smin, smax, vmin, vmax
return hsv(lambda h, s, v: (
(h >= hmin) & (h <= hmax)) &
((s >= smin) & (s <= smax)) &
Expand Down
9 changes: 5 additions & 4 deletions geist/vision.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import division
from __future__ import print_function, division
from numpy.fft import irfft2, rfft2
import numpy
import itertools
from six import iteritems
import operator


Expand Down Expand Up @@ -84,10 +85,10 @@ def best_convolution(bin_template, bin_image,
max_hor_cells = iw // th

# Try to work out how many times we can stack the image
usable_factors = {n: factors for n, factors in overlap_table.iteritems()
usable_factors = {n: factors for n, factors in iteritems(overlap_table)
if ((template_sum + 1) ** (n)) < ACCURACY_LIMIT}
overlap_options = [(factor, n // factor)
for n, factors in usable_factors.iteritems()
for n, factors in iteritems(usable_factors)
for factor in factors
if (factor <= max_vert_cells and
n // factor <= max_hor_cells)]
Expand Down Expand Up @@ -526,5 +527,5 @@ def correlation_coefficient_normed(template, image):
(template_distance ** 2).sum() *
(image_distance_of_template_area ** 2).sum()
)
print y
print(y)
return corr_num / corr_denum
8 changes: 8 additions & 0 deletions geist_tests/test_finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ def test_filter(self):
result = self.gui.wait_find_one(finder)
self.assertEqual(parent_x + child_x, result.x)
self.assertEqual(parent_y + child_y, result.y)


location_finder_filter_suite = unittest.TestLoader().loadTestsFromTestCase(
TestLocationFinderFilter)
all_tests = unittest.TestSuite([location_finder_filter_suite])
if __name__ == "__main__":
runner = unittest.TextTestRunner(verbosity=1)
runner.run(all_tests)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'pillow',
'wrapt',
'mock',
'six',
],
description='Visual Automation Library',
classifiers=[
Expand Down