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

Table add_highlighted_cell fails if one cell is empty #3396

Open
JasonMendoza2008 opened this issue Oct 9, 2023 · 7 comments
Open

Table add_highlighted_cell fails if one cell is empty #3396

JasonMendoza2008 opened this issue Oct 9, 2023 · 7 comments
Assignees

Comments

@JasonMendoza2008
Copy link

JasonMendoza2008 commented Oct 9, 2023

This works (from the documentation):

from manim import *

class TableExamples(Scene):
    def construct(self):
        t0 = Table(
            [["This", "is a"],
            ["simple", "Table in \n Manim."]]
        )
        t0.add_highlighted_cell((2,2), color=YELLOW)
        self.add(t0)

But this doesn't

from manim import *

class TableExamples(Scene):
    def construct(self):
        t0 = Table(
            [["", "is a"],
            ["simple", "Table in \n Manim."]]
        )
        t0.add_highlighted_cell((2,2), color=YELLOW)
        self.add(t0)

It raises the error:
IndexError: list index out of range

Python 3.11.1. manim 0.17.3.

@uwezi
Copy link
Contributor

uwezi commented Oct 9, 2023

Interesting, especially since the function .get_highlighted_cell() which is used by .add_highlighted_cell() does still work, even with empty cells:

class TableExamples(Scene):
    def construct(self):
        t0 = Table(
            [["", "is a"],
            ["simple", "Table in \n Manim."]]
        )
        a = t0.get_highlighted_cell((2,2), color=YELLOW)
        self.add(t0, a)

@uwezi
Copy link
Contributor

uwezi commented Oct 9, 2023

The problem lies in the method .get_entries()

@AR4152
Copy link

AR4152 commented Oct 16, 2023

I'm happy to help with this! Could I please be assigned to work on this issue?

@Miffyyy-huahua
Copy link

Hi, I'm interested in this issue. My thought is an edge case should be implemented on .get_entries() so when .get_highlighted_cell calls this method there won't be error. Can I be assigned to this issue? thanks!

@Miffyyy-huahua
Copy link

If you input
class TableExamples(Scene):
def construct(self):
t0 = Table(
[["", "is a"],
["simple", "Table in \n Manim."]]
)
t0.add_highlighted_cell((0,0), color=YELLOW)
self.add(t0)

you can get the result you want

@JasonMendoza2008
Copy link
Author

JasonMendoza2008 commented Oct 21, 2023

If you input class TableExamples(Scene): def construct(self): t0 = Table( [["", "is a"], ["simple", "Table in \n Manim."]] ) t0.add_highlighted_cell((0,0), color=YELLOW) self.add(t0) you can get the result you want

I'd argue that's unintuitive and shouldn't be considered a feature, but good point.

@AR4152
Copy link

AR4152 commented Oct 21, 2023

I believe I've found the root cause of the issue and the solution. I'm currently creating robust test cases for add_highlighted_cell function and will update the details here in sometime.

Briefly speaking, I think the issue is caused by trying to handle the case when the program assumes row/column labels are added and the top left cell (top_left_entry) is not named.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
4 participants