MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / test_compare

Function test_compare

Wrapping/Python/tests/sitkImageIndexingTest.py:504–546  ·  view source on GitHub ↗

Test comparison operators

()

Source from the content-addressed store, hash-verified

502 assert_image_ndarray_equals(img[...], nda[...])
503
504def test_compare():
505 """Test comparison operators"""
506
507 img = sitk.Image(1, 1, sitk.sitkFloat32)
508 assert img.GetPixel(0, 0) == 0.0
509
510 assert (img < 0).GetPixel(0, 0) == 0
511 assert (img <= 0).GetPixel(0, 0) == 1
512
513 assert (0 > img).GetPixel(0, 0) == 0
514 assert (0 >= img).GetPixel(0, 0) == 1
515
516 assert (img > 0).GetPixel(0, 0) == 0
517 assert (img >= 0).GetPixel(0, 0) == 1
518
519 assert (0 < img).GetPixel(0, 0) == 0
520 assert (0 <= img).GetPixel(0, 0) == 1
521
522 img.SetPixel(0, 0, 0.5)
523
524 assert (img < 0.5).GetPixel(0, 0) == 0
525 assert (img <= 0.5).GetPixel(0, 0) == 1
526
527 assert (0.5 > img).GetPixel(0, 0) == 0
528 assert (0.5 >= img).GetPixel(0, 0) == 1
529
530 assert (img > 0.5).GetPixel(0, 0) == 0
531 assert (img >= 0.5).GetPixel(0, 0) == 1
532
533 assert (0.5 < img).GetPixel(0, 0) == 0
534 assert (0.5 <= img).GetPixel(0, 0) == 1
535
536 assert (img < -1).GetPixel(0, 0) == 0
537 assert (img <= -1).GetPixel(0, 0) == 0
538
539 assert (-1 > img).GetPixel(0, 0) == 0
540 assert (-1 >= img).GetPixel(0, 0) == 0
541
542 assert (img > -1).GetPixel(0, 0) == 1
543 assert (img >= -1).GetPixel(0, 0) == 1
544
545 assert (-1 < img).GetPixel(0, 0) == 1
546 assert (-1 <= img).GetPixel(0, 0) == 1
547
548
549if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

ImageMethod · 0.80

Tested by

no test coverage detected