Skip to content

Commit

Permalink
test with rgb images and test_arrays_to_structures_single
Browse files Browse the repository at this point in the history
  • Loading branch information
sgbaird committed Jun 3, 2022
1 parent 23c8ceb commit 35543b2
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions tests/xtal2png_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ def test_arrays_to_structures():
return structures


def test_arrays_to_structures_single():
xc = XtalConverter()
data, _, _ = xc.structures_to_arrays([example_structures[0]])
structures = xc.arrays_to_structures(data)
assert_structures_approximate_match([example_structures[0]], structures)
return structures


def test_xtal2png():
xc = XtalConverter()
imgs = xc.xtal2png(example_structures, show=False, save=True)
Expand All @@ -114,14 +122,24 @@ def test_xtal2png_single():
def test_png2xtal():
xc = XtalConverter()
imgs = xc.xtal2png(example_structures, show=True, save=True)
structures = xc.png2xtal(imgs)
assert_structures_approximate_match(example_structures, structures)
decoded_structures = xc.png2xtal(imgs)
assert_structures_approximate_match(example_structures, decoded_structures)


def test_png2xtal_single():
xc = XtalConverter()
imgs = xc.xtal2png([example_structures[0]], show=True, save=True)
decoded_structures = xc.png2xtal(imgs, save=False)
assert_structures_approximate_match([example_structures[0]], decoded_structures)
return decoded_structures


def test_png2xtal_rgb_image():
xc = XtalConverter()
imgs = xc.xtal2png(example_structures, show=False, save=False)
imgs = [img.convert("RGB") for img in imgs]
decoded_structures = xc.png2xtal(imgs)
assert_structures_approximate_match(example_structures, decoded_structures)
return decoded_structures


Expand Down Expand Up @@ -168,6 +186,7 @@ def test_plot_and_save():


if __name__ == "__main__":
test_png2xtal_rgb_image()
test_element_wise_scaler_unscaler()
test_rgb_scaler_unscaler()
structures = test_arrays_to_structures()
Expand All @@ -176,7 +195,10 @@ def test_plot_and_save():
decoded_structures = test_png2xtal()
decoded_structures = test_png2xtal_single()
test_structures_to_arrays_single()
test_arrays_to_structures_single()
test_xtal2png_single()
test_png2xtal()
test_png2xtal_single()

1 + 1

Expand Down

0 comments on commit 35543b2

Please sign in to comment.