Skip to content

Commit

Permalink
Revert use of box drawing glyphs for monospace consistency with more …
Browse files Browse the repository at this point in the history
…fonts

Fixes mhostetter#267
  • Loading branch information
mhostetter committed Mar 2, 2022
1 parent aaebb3d commit 5553d0f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
30 changes: 14 additions & 16 deletions galois/_fields/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,18 @@ def repr_table(
N_vec = max([len(print_vec(e)) for e in x] + [len("Vector")]) + 2
N_int = max([len(print_int(e)) for e in x] + [len("Integer")]) + 2

# Useful characters: https://www.utf8-chartable.de/unicode-utf8-table.pl?start=9472
string = "╔" + "═"*N_power + "╤" + "═"*N_poly + "╤" + "═"*N_vec + "╤" + "═"*N_int + "╗"
string += "\n║" + "Power".center(N_power) + "│" + "Polynomial".center(N_poly) + "│" + "Vector".center(N_vec) + "│" + "Integer".center(N_int) + "║"
string += "\n║" + "═"*N_power + "╪" + "═"*N_poly + "╪" + "═"*N_vec + "╪" + "═"*N_int + "║"
string = "+" + "-"*N_power + "+" + "-"*N_poly + "+" + "-"*N_vec + "+" + "-"*N_int + "+"
string += "\n|" + "Power".center(N_power) + "|" + "Polynomial".center(N_poly) + "|" + "Vector".center(N_vec) + "|" + "Integer".center(N_int) + "|"
string += "\n+" + "-"*N_power + "+" + "-"*N_poly + "+" + "-"*N_vec + "+" + "-"*N_int + "+"

for i in range(x.size):
d = None if i == 0 else degrees[i - 1]
string += "\n" + print_power(d).center(N_power) + "" + poly_to_str(integer_to_poly(x[i], cls.characteristic)).center(N_poly) + "" + str(integer_to_poly(x[i], cls.characteristic, degree=cls.degree-1)).center(N_vec) + "" + cls._print_int(x[i]).center(N_int) + ""
string += "\n|" + print_power(d).center(N_power) + "|" + poly_to_str(integer_to_poly(x[i], cls.characteristic)).center(N_poly) + "|" + str(integer_to_poly(x[i], cls.characteristic, degree=cls.degree-1)).center(N_vec) + "|" + cls._print_int(x[i]).center(N_int) + "|"

if i < x.size - 1:
string += "\n" + ""*N_power + "" + ""*N_poly + "" + ""*N_vec + "" + ""*N_int + ""
string += "\n+" + "-"*N_power + "+" + "-"*N_poly + "+" + "-"*N_vec + "+" + "-"*N_int + "+"

string += "\n" + ""*N_power + "" + ""*N_poly + ""+ ""*N_vec + "" + ""*N_int + ""
string += "\n+" + "-"*N_power + "+" + "-"*N_poly + "+"+ "-"*N_vec + "+" + "-"*N_int + "+"

return string

Expand Down Expand Up @@ -419,24 +418,23 @@ def arithmetic_table(
N = max([len(print_element(e)) for e in x]) + 2
N_left = max(N, len(operation_str) + 2)

# Useful characters: https://www.utf8-chartable.de/unicode-utf8-table.pl?start=9472
string = "╔" + "═"*N_left + "╦" + ("═"*N + "╤")*(y.size - 1) + "═"*N + "╗"
string += "\n║" + operation_str.rjust(N_left - 1) + " ║"
string = "+" + "-"*N_left + "+" + ("-"*N + "+")*(y.size - 1) + "-"*N + "+"
string += "\n|" + operation_str.rjust(N_left - 1) + " |"
for j in range(y.size):
string += print_element(y[j]).rjust(N - 1) + " "
string += "" if j < y.size - 1 else ""
string += "\n" + ""*N_left + "" + (""*N + "")*(y.size - 1) + ""*N + ""
string += "|" if j < y.size - 1 else "|"
string += "\n+" + "-"*N_left + "+" + ("-"*N + "+")*(y.size - 1) + "-"*N + "+"

for i in range(x.size):
string += "\n" + print_element(x[i]).rjust(N_left - 1) + " "
string += "\n|" + print_element(x[i]).rjust(N_left - 1) + " |"
for j in range(y.size):
string += print_element(Z[i,j]).rjust(N - 1) + " "
string += "" if j < y.size - 1 else ""
string += "|" if j < y.size - 1 else "|"

if i < x.size - 1:
string += "\n" + ""*N_left + "" + (""*N + "")*(y.size - 1) + ""*N + ""
string += "\n+" + "-"*N_left + "+" + ("-"*N + "+")*(y.size - 1) + "-"*N + "+"

string += "\n" + ""*N_left + "" + (""*N + "")*(y.size - 1) + ""*N + ""
string += "\n+" + "-"*N_left + "+" + ("-"*N + "+")*(y.size - 1) + "-"*N + "+"

return string

Expand Down
Loading

0 comments on commit 5553d0f

Please sign in to comment.