# Author: Gael Varoquaux
# License: simplified BSD


import numpy as np

from nibabel import Nifti1Image

from ..nifti_masker import NiftiMasker

def test_auto_mask():
    data = np.ones((9, 9, 9))
    data[3:-3, 3:-3, 3:-3] = 10
    img = Nifti1Image(data, np.eye(4))
    masker = NiftiMasker()
    masker.fit(img)


# Author: Gael Varoquaux
# License: simplified BSD

from nose.tools import assert_true, assert_false
import numpy as np

from nibabel import Nifti1Image

from ..nifti_masker import NiftiMasker

def test_auto_mask():
    data = np.ones((9, 9, 9))
    data[3:-3, 3:-3, 3:-3] = 10
    img = Nifti1Image(data, np.eye(4))
    masker = NiftiMasker()
    masker.fit(img)

def test_nan():
    data = np.ones((9, 9, 9))
    data[0] = np.nan
    data[:, 0] = np.nan
    data[:, :, 0] = np.nan
    data[-1] = np.nan
    data[:, -1] = np.nan
    data[:, :, -1] = np.nan
    data[3:-3, 3:-3, 3:-3] = 10
    img = Nifti1Image(data, np.eye(4))
    masker = NiftiMasker()
    masker.fit(img)
    mask = masker.mask_.get_data()
    assert_true(mask[1:-1, 1:-1, 1:-1].all())
    assert_false(mask[0].any())
    assert_false(mask[:, 0].any())
    assert_false(mask[:, :, 0].any())
    assert_false(mask[-1].any())
    assert_false(mask[:, -1].any())
    assert_false(mask[:, :, -1].any())

Add test for NaN input values
Add test for NaN input values

  # Author: Gael Varoquaux
  # License: simplified BSD
  
- 
+ from nose.tools import assert_true, assert_false
  import numpy as np
  
  from nibabel import Nifti1Image
  
  from ..nifti_masker import NiftiMasker
  
  def test_auto_mask():
      data = np.ones((9, 9, 9))
      data[3:-3, 3:-3, 3:-3] = 10
      img = Nifti1Image(data, np.eye(4))
      masker = NiftiMasker()
      masker.fit(img)
  
+ def test_nan():
+     data = np.ones((9, 9, 9))
+     data[0] = np.nan
+     data[:, 0] = np.nan
+     data[:, :, 0] = np.nan
+     data[-1] = np.nan
+     data[:, -1] = np.nan
+     data[:, :, -1] = np.nan
+     data[3:-3, 3:-3, 3:-3] = 10
+     img = Nifti1Image(data, np.eye(4))
+     masker = NiftiMasker()
+     masker.fit(img)
+     mask = masker.mask_.get_data()
+     assert_true(mask[1:-1, 1:-1, 1:-1].all())
+     assert_false(mask[0].any())
+     assert_false(mask[:, 0].any())
+     assert_false(mask[:, :, 0].any())
+     assert_false(mask[-1].any())
+     assert_false(mask[:, -1].any())
+     assert_false(mask[:, :, -1].any())
  
Add test for NaN input values
## Code Before:
# Author: Gael Varoquaux
# License: simplified BSD


import numpy as np

from nibabel import Nifti1Image

from ..nifti_masker import NiftiMasker

def test_auto_mask():
    data = np.ones((9, 9, 9))
    data[3:-3, 3:-3, 3:-3] = 10
    img = Nifti1Image(data, np.eye(4))
    masker = NiftiMasker()
    masker.fit(img)


## Instruction:
Add test for NaN input values
## Code After:
# Author: Gael Varoquaux
# License: simplified BSD

from nose.tools import assert_true, assert_false
import numpy as np

from nibabel import Nifti1Image

from ..nifti_masker import NiftiMasker

def test_auto_mask():
    data = np.ones((9, 9, 9))
    data[3:-3, 3:-3, 3:-3] = 10
    img = Nifti1Image(data, np.eye(4))
    masker = NiftiMasker()
    masker.fit(img)

def test_nan():
    data = np.ones((9, 9, 9))
    data[0] = np.nan
    data[:, 0] = np.nan
    data[:, :, 0] = np.nan
    data[-1] = np.nan
    data[:, -1] = np.nan
    data[:, :, -1] = np.nan
    data[3:-3, 3:-3, 3:-3] = 10
    img = Nifti1Image(data, np.eye(4))
    masker = NiftiMasker()
    masker.fit(img)
    mask = masker.mask_.get_data()
    assert_true(mask[1:-1, 1:-1, 1:-1].all())
    assert_false(mask[0].any())
    assert_false(mask[:, 0].any())
    assert_false(mask[:, :, 0].any())
    assert_false(mask[-1].any())
    assert_false(mask[:, -1].any())
    assert_false(mask[:, :, -1].any())
