Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_subplot2():
grid = tpl.subplot_grid((1, 2), width=20, border_style="thick")
grid[0, 0].aprint("Some text")
grid[0, 1].aprint("Some more text\nand more")
string = grid.get_string()
assert (
string
== """┏━━━━━━━━━┳━━━━━━━━┓
┃ ┃ ┃
┃ Some ┃ Some ┃
┃ ┃ and ┃
┃ ┃ ┃
┗━━━━━━━━━┻━━━━━━━━┛"""
)
return
def _generate_content(*args, **kwargs):
grid = tpl.subplot_grid((2, 3), *args, **kwargs)
grid[0, 0].aprint("Some text")
grid[0, 1].aprint("Some more text\nand more")
grid[0, 2].aprint("Some more text\nand more\neven more")
grid[1, 0].aprint("Some more text\nand more\neven more")
grid[1, 1].aprint("Some more text\nand more")
grid[1, 2].aprint("Some text")
return grid
def test_subplot_custom_border():
grid = tpl.subplot_grid((1, 2), border_style="x", width=20)
grid[0, 0].aprint("Some text")
grid[0, 1].aprint("Some more text")
string = grid.get_string()
assert (
string
== """xxxxxxxxxxxxxxxxxxxx
x x x
x Some x Some x
x x x
xxxxxxxxxxxxxxxxxxxx"""
)
return
def test_subplot():
grid = tpl.subplot_grid((1, 2), width=20)
grid[0, 0].aprint("Some text")
grid[0, 1].aprint("Some more text")
string = grid.get_string()
assert (
string
== """┌─────────┬────────┐
│ │ │
│ Some │ Some │
│ │ │
└─────────┴────────┘"""
)
return
def test_subplot_padding():
grid = tpl.subplot_grid((1, 2), width=20, padding=2, border_style="double")
grid[0, 0].aprint("Some text")
grid[0, 1].aprint("Some more text\nand more")
string = grid.get_string()
assert (
string
== """╔═════════╦════════╗
║ ║ ║
║ ║ ║
║ Some ║ Some ║
║ ║ and ║
║ ║ ║
║ ║ ║
╚═════════╩════════╝"""
)
return
def print_stats(mesh, extra_cols=None):
extra_cols = [] if extra_cols is None else extra_cols
angles = mesh.angles / numpy.pi * 180
angles_hist, angles_bin_edges = numpy.histogram(
angles, bins=numpy.linspace(0.0, 180.0, num=73, endpoint=True)
)
q = mesh.cell_quality
q_hist, q_bin_edges = numpy.histogram(
q, bins=numpy.linspace(0.0, 1.0, num=41, endpoint=True)
)
grid = tpl.subplot_grid(
(1, 4 + len(extra_cols)), column_widths=None, border_style=None
)
grid[0, 0].hist(angles_hist, angles_bin_edges, grid=[24], bar_width=1, strip=True)
grid[0, 1].aprint("min angle: {:7.3f}".format(numpy.min(angles)))
grid[0, 1].aprint("avg angle: {:7.3f}".format(60))
grid[0, 1].aprint("max angle: {:7.3f}".format(numpy.max(angles)))
grid[0, 1].aprint("std dev angle: {:7.3f}".format(numpy.std(angles)))
grid[0, 2].hist(q_hist, q_bin_edges, bar_width=1, strip=True)
grid[0, 3].aprint("min quality: {:5.3f}".format(numpy.min(q)))
grid[0, 3].aprint("avg quality: {:5.3f}".format(numpy.average(q)))
grid[0, 3].aprint("max quality: {:5.3f}".format(numpy.max(q)))
for k, col in enumerate(extra_cols):
grid[0, 4 + k].aprint(col)
grid.show()