old_contents: import unittest
  import nose.tools
  import numpy as np
  
  import skimage.io as io
  from scipy.ndimage.filters import gaussian_filter
  
  from mammogram.orientated_bins import orientated_bins
  
  class OrientatedBinsTest(unittest.TestCase):
  
      def test_with_pure_structure(self):
          size = 20
          linear_structure = np.zeros(shape=(size,size))
          linear_structure[:,size/2] = np.ones(size)
  
          line_strength = orientated_bins(linear_structure, 7)
          # line_strength[line_strength<0.15] = 0 #threshold
          io.imshow(line_strength)
          io.show()
          nose.tools.assert_equal(np.count_nonzero(line_strength), size)
  
      def test_with_burred_structure(self):
          linear_structure = np.identity(20)
          img = gaussian_filter(linear_structure, 0.8)
  
          line_strength = orientated_bins(img, 10)
          line_strength[line_strength<0.15] = 0 #threshold
  
          nose.tools.assert_equal(np.count_nonzero(line_strength), 20)
  
      def test_with_multiple_windows(self):
          size = 100
          linear_structure = np.zeros(shape=(size,size))
          linear_structure[:,15] = np.ones(size)
  
          linear_structure = np.identity(size)
          noise = np.random.rand(size, size) * 0.5
          linear_structure += noise
          img = gaussian_filter(linear_structure, 1.5)
  
          line_strength = orientated_bins(img, 10)
  
      def test_with_more_bins(self):
          size = 100
          linear_structure = np.zeros(shape=(size,size))
          linear_structure[:,15] = np.ones(size)
  
          linear_structure = np.identity(size)
          noise = np.random.rand(size, size) * 0.5
          linear_structure += noise
          img = gaussian_filter(linear_structure, 1.5)
  
          line_strength = orientated_bins(img, 5, nbins=8)
  
      # def test_real(self):
      #     path="../../data/p214-010-60001-cl.png"
      #     mask="../../data/f214-010-60001-cl_mask.png"
      #
      #     img = io.imread(path)
      #     msk = io.imread(mask, as_grey=True)
      #
      #     pyramid = pyramid_gaussian(img, downscale=4)
      #     pyramid.next()
      #     img = pyramid.next()
      #
      #     img = img * msk
      #
      #     line_strength = orientated_bins(img, 5, nbins=12)
      #
      #     # io.imshow(line_strength)
      #     # io.show()
  
new_contents: import unittest
  import nose.tools
  import numpy as np
  from skimage import filters, io, transform
  
  from mammogram.orientated_bins import orientated_bins
  
  class OrientatedBinsTest(unittest.TestCase):
  
      def test_with_pure_structure(self):
          linear_structure = generate_linear_structure(20)
          line_strength, line_orinetation = orientated_bins(linear_structure, 7)
          line_strength[line_strength<0.15] = 0
  
          nose.tools.assert_equal(np.count_nonzero(line_strength), 20)
          nose.tools.assert_equal(np.count_nonzero(line_orinetation), 60)
  
      def test_with_noisy_structure(self):
          linear_structure = generate_linear_structure(100, with_noise=True)
          line_strength, line_orinetation = orientated_bins(linear_structure, 10)
          line_strength[line_strength<0.05] = 0
          nose.tools.assert_almost_equal(np.count_nonzero(line_strength), 7, delta=2)
  
      def test_with_multiple_many_bins(self):
          linear_structure = generate_linear_structure(100, with_noise=True)
          line_strength, line_orinetation = orientated_bins(linear_structure, 10)
          line_strength[line_strength<0.05] = 0
          nose.tools.assert_almost_equal(np.count_nonzero(line_strength), 7, delta=2)
  
  
  def generate_linear_structure(size, with_noise=False):
      """Generate a basic linear structure, possibly with noise"""
      linear_structure = np.zeros(shape=(size,size))
      linear_structure[:,size/2] = np.ones(size)
  
      if with_noise:
          linear_structure = np.identity(size)
          noise = np.random.rand(size, size) * 0.1
          linear_structure += noise
          linear_structure = filters.gaussian_filter(linear_structure, 1.5)
  
      return linear_structure
  
subject: Update with slightly better testing