Forced-Alignment-and-Vowel-Extraction / alignedTextGrid

aligned-textgrid links textgrid sequences together
https://forced-alignment-and-vowel-extraction.github.io/alignedTextGrid/
GNU General Public License v3.0
6 stars 1 forks source link

[Bug]: Initializing an empty ATG results in RecursionError #169

Closed chrisbrickhouse closed 7 months ago

chrisbrickhouse commented 7 months ago

Contact Details

No response

What happened?

Reproduce with the following

import aligned_textgrid as atg
tg = atg.AlignedTextGrid()

Unclear what the expected output here is. On the one hand, I would like to be able to instantiate an empty textgrid. On the other hand, I can see why it might be more user friendly to keep people on rails and fail if there's nothing there. In the first case, we should initialize the expected attributes as empty. In the second case, we should give a more helpful error than RecursionError which doesn't give a sense of what the problem is.

What operating system are you using?

Ubuntu

Relevant log output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/cj/Linguistics/FAVE-org/textgrid-dataset/dev/lib/python3.11/site-packages/aligned_textgrid/aligned_textgrid.py", line 71, in __init__
    self.tier_groups = self._relate_tiers()
                       ^^^^^^^^^^^^^^^^^^^^
  File "/home/cj/Linguistics/FAVE-org/textgrid-dataset/dev/lib/python3.11/site-packages/aligned_textgrid/aligned_textgrid.py", line 251, in _relate_tiers
    for tier_group, classes in zip(self.tg_tiers, self.entry_classes):
                                   ^^^^^^^^^^^^^
  File "/home/cj/Linguistics/FAVE-org/textgrid-dataset/dev/lib/python3.11/site-packages/aligned_textgrid/aligned_textgrid.py", line 121, in __getattr__
    tier_group_names = [x.name for x in self.tier_groups]
                                        ^^^^^^^^^^^^^^^^
  File "/home/cj/Linguistics/FAVE-org/textgrid-dataset/dev/lib/python3.11/site-packages/aligned_textgrid/aligned_textgrid.py", line 121, in __getattr__
    tier_group_names = [x.name for x in self.tier_groups]
                                        ^^^^^^^^^^^^^^^^
  File "/home/cj/Linguistics/FAVE-org/textgrid-dataset/dev/lib/python3.11/site-packages/aligned_textgrid/aligned_textgrid.py", line 121, in __getattr__
    tier_group_names = [x.name for x in self.tier_groups]
                                        ^^^^^^^^^^^^^^^^
  [Previous line repeated 993 more times]
RecursionError: maximum recursion depth exceeded

Code of Conduct

JoFrhwld commented 7 months ago

This, #168 and #167 feel very broadly related to better programmatic creation of AlignedTextGrids within the package, rather than just processing and editing already existing textgrids. I think it's the right next step, so I've created a project for it, and added these issues to a v0.7 milestone.

Depending on the urgency with which you need these updates for your workflow, I'm happy to merge and publish patch updates to v0.6 as we go.

chrisbrickhouse commented 7 months ago

broadly related to better programmatic creation of AlignedTextGrids within the package

Yep, though technically the docs state all arguments to AlignedTextGrid.__init__ are optional, so according to the API it should work with no arguments, hence why this one is marked as a bug and the others are feature requests.

I'm happy to merge and publish patch updates to v0.6 as we go.

I don't need urgent updates to v0.6. For local development I just roll my own patches. Plus I'd rather preserve semantic versioning, so I'm generally against adding new features without at least a minor version bump.