import menpo
from numpy.testing import assert_equal
from menpo.transform.piecewiseaffine.base import (CythonPWA, CachedPWA,
                                                  PythonPWA)

b = menpo.io.import_builtin_asset('breakingbad.jpg').as_masked()
b = b.crop_to_landmarks_proportion(0.1)
b = b.rescale_landmarks_to_diagonal_range(120)
b = b.constrain_mask_to_landmarks()
points = b.mask.true_indices()
src = b.landmarks['PTS']
tgt = src.copy()


def test_cached_pwa_same_as_python_pwa():
    cached_pwa = CythonPWA(src, tgt)
    python_pwa = PythonPWA(src, tgt)
    assert_equal(python_pwa.apply(points), cached_pwa.apply(points))


def test_cython_pwa_batch_same():
    cached_pwa = CythonPWA(src, tgt)
    assert_equal(cached_pwa.apply(points),
                 cached_pwa.apply(points, batch_size=10))


def test_python_pwa_batch_same():
    cached_pwa = PythonPWA(src, tgt)
    assert_equal(cached_pwa.apply(points),
                 cached_pwa.apply(points, batch_size=10))


def test_cython_pwa_same_as_python_pwa():
    python = PythonPWA(src, tgt)
    cython = CythonPWA(src, tgt)
    assert_equal(python.apply(points), cython.apply(points))


def test_cached_pwa_same_twice():
    cached_pwa = CachedPWA(src, tgt)
    r1 = cached_pwa.apply(points)
    # now using cache
    r2 = cached_pwa.apply(points)
    assert_equal(r1, r2)


def test_cached_pwa_forgets_cache():
    cached_pwa = CachedPWA(src, tgt)
    r1 = cached_pwa.apply(points)
    cached_pwa.apply(points[40:60])
    # cache is now set to something other than points
    # should clear cache and be fine
    r2 = cached_pwa.apply(points)
    assert_equal(r1, r2)

@@ -98,80 +98,18 @@
 ort 
-(CythonPWA, CachedPWA,%0A                                                 
+CachedPWA,
  Pyt
@@ -114,17 +114,16 @@
 ythonPWA
-)
 %0A%0Ab = me
@@ -431,37 +431,37 @@
   cached_pwa = C
-ython
+ached
 PWA(src, tgt)%0A  
@@ -567,33 +567,33 @@
 ts))%0A%0A%0Adef test_
-c
+p
 ython_pwa_batch_
@@ -608,188 +608,14 @@
     
-cached_pwa = CythonPWA(src, tgt)%0A    assert_equal(cached_pwa.apply(points),%0A                 cached_pwa.apply(points, batch_size=10))%0A%0A%0Adef test_python_pwa_batch_same():%0A    cached
+python
 _pwa
@@ -654,22 +654,22 @@
 t_equal(
-cached
+python
 _pwa.app
@@ -693,30 +693,30 @@
             
-cached
+python
 _pwa.apply(p
@@ -744,179 +744,8 @@
 )%0A%0A%0A
-def test_cython_pwa_same_as_python_pwa():%0A    python = PythonPWA(src, tgt)%0A    cython = CythonPWA(src, tgt)%0A    assert_equal(python.apply(points), cython.apply(points))%0A%0A%0A
 def 

remove Cython PWA from PWA tests