-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Dynamically calculating columns on Math symbols #26191
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
Dynamically calculating columns on Math symbols #26191
Conversation
@oscargus can you check this pull request that doesn't have conflicts? |
This looks fine from that aspect. Still, there are some linting errors. |
|
You can view the linting errors by clicking the “files changed” tab at the top of this page and scrolling down to see the comments from “reviewdog”. |
All checks are passed! Can we merge it because I have deadline till today for a university project and I will enrich in the next days to be more efficient? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better than before and the code doesn't look too bad, though I'd prefer a comment on how it's making decisions.
Can we merge it because I have deadline till today for a university project
So I'm not gonna try and teach you a lesson by blocking for this, but you really should communicate this with us earlier since most of us aren't paid to work on this-I'm not and I hadn't been planning on doing matplotlib stuff today.
Edit: I cannot even get my head around what it does. But now I think I am correct after several attempts. If basically takes the smallest number between 4 and 9 such that the number is not a integer factor of the number of elements.
So putting 4 is also a quite good heuristic. |
@oscargus I think you're right that a better solution would take word and glyph length into account - there are still some lines that are not great-and use one or more of the dynamic reflow sphinx options. I also think this solution produces easier to read tables than what is already there & removes the need to manually specify columns and is therefore a good incremental solution. |
Better incremental solution that gives easier to read tables: 4. (I now got my head around the logic, so please reread the edited post.) |
The only table that has 5 is because there are 32 items in it. Adding one and it will be 4 as all the others. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @NikosNikolaidis02 I will block this change (the discussion made me look closer to the actual code).
- It uses an algorithm that is not related to the problem at hand (the problem is the width of the items, not the number of items).
- This means that the outcome of
columns_calculations
may just as well be constant 4 or selected at random between 4 and 5 (or some other distribution). Clearly those two approaches are not what we are looking for, but would be comparable. - The code quality is low.
remainder
is initialized, but value never used.max_remainder
is just a constant.len(my_list)
is computed in the loop.
If you want to try to finalize this, I'd suggest finding the longest string in the list/set in syms and then use that to figure out a suitable number of columns. (Basically some function that is non-increasing as the string length increases.) Even if it may take some time to find the "best" such function, a working one is OK for now, that will at least be a method that tries to approach the problem at hand.
Ok! I will look at it! Thank you! |
I was thinking about finding the sum of characters on each line and choose how many columns (from 4 to 7) will have the most equally distributed summary on each line. |
If you're gonna do this, you're gonna want to probably make the (latex, symbol) tuples and use that as longest symbol, and really this becomes an optimization problem & at that point it's likely easier to see if it's already solved by pretending it's a table of individual elements and using auto https://sphinx-design.readthedocs.io/en/latest/grids.html#item-level-column-width ETA: Honestly I also think @oscargus's set width to 4 solution - where you strip the function call out and replace it w/ 4 is an improvement. |
@NikosNikolaidis02 are you still interested in working on this? |
I am going to close this one as it has stalled for a while and comments above state that the current implementation is not what is wanted. @NikosNikolaidis02 please comment if you are still interested in working on this and we can re-open. |
PR summary
PR checklist