ManimCommunity / ManimCommunity/manim

Table.get_entries() should be split in two

Open
#2,051 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

Currently there is this method:

```
def get_entries(
self, pos: Optional[Sequence[int]] = None
) -> Union[VMobject, VGroup]:
"""Return the individual entries of the table (including labels) or one specific entry
if the parameter, ``pos``, is set.
```

It would be much better if this were two separate functions:

```
def get_entries(self) -> VGroup:
...

def get_entry(self, pos:Sequence[int]) -> VMobject:
...
```

More obvious what is happening, simpler, you don't have the weirdness of get_entr**ies** returning a single entry, and it makes the return type explicit.

The code even makes it obvious that this is really two methods merged into one:

```
if pos is not None:
# One method here.
if (
self.row_labels is not None
and self.col_labels is not None
and self.top_left_entry is None
):
index = len(self.mob_table[0]) * (pos[0] - 1) + pos[1] - 2
return self.elements[index]
else:
index = len(self.mob_table[0]) * (pos[0] - 1) + pos[1] - 1
return self.elements[index]
else:
# A completely different one here.
return self.elements
```

Same for `get_entries_without_labels`.

I assume since you're still at version 0.10 breaking changes are allowed?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the Table class for get_entries and get_entries_without_labels, then inspect their callers to identify the affected public API paths. Split the combined behavior into separate collection and single-entry methods, update callers for the new names and signatures, and verify that labeled and unlabeled tables retain their existing entry selection behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.