Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize print matrix as string #449

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

rosaigor138
Copy link
Member

Closes #422

@rosaigor138 rosaigor138 added the enhancement New feature or request label Nov 22, 2023
@rosaigor138 rosaigor138 self-assigned this Nov 22, 2023
Copy link
Contributor

@atilaajones atilaajones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The printout is better, but there is still distortion of the column in the case of negative numbers. I think this can be fixed, even if only with white space in front of positive numbers.

Another detail is that when the matrix is made up only of integers, then 5 should appear instead of 5.0000, as it was before (branch main). It may be necessary to separate the print handling for each of these cases.

Matrices with integer entries only

  • Adjacency Matrix
  • Laplacian
  • Signless Laplacian Matrix
  • Incidence Matrix
  • Distance Matrix
  • Seidel Matrix
  • Laplacian Distance Matrix
  • Signless Laplacian Distance Matrix
  • Eccentricity matrix

Matrices with non-integer entries

  • Normalized Laplacian Matrix
  • Randic Matrix

print

Copy link
Contributor

@atilaajones atilaajones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alignment is correct. The printing of integers and irrational numbers still needs to be improved.

@fsoupimenta fsoupimenta removed the enhancement New feature or request label May 8, 2024
@fsoupimenta
Copy link
Member

fsoupimenta commented May 24, 2024

The problem wasn't formatting the array, as the pythonnp.array2string method already performs this task efficiently.

What was happening was that PyQt was using a proportional font in each cell of the table. This means that each character has a size according to its proportion, making it impossible to compensate for the difference in size with white space, especially in the case of negative numbers, as in the example.

To solve the problem, the Courier New font was used, which is a monospaced font, i.e. all characters have a fixed size, resulting in the following alignment:

Screenshot_93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize print matrix as string
3 participants