timmahrt / praatIO

A python library for working with praat, textgrids, time aligned audio transcripts, and audio files. It is primarily used for extracting features from and making manipulations on audio files given hierarchical time-aligned transcriptions (utterance > word > syllable > phone, etc).
MIT License
299 stars 32 forks source link

fix: check other's type before accessing other's properties #36

Closed timmahrt closed 2 years ago

timmahrt commented 2 years ago

An unhandled exception occurs if the user attempts to do something like:

tg1 = Textgrid()
tg2 = 5

if tg1 == tg2:
...

This is because in the custom equality check methods, I assume both things have the same properties--if one is not, then accessing one of the properties causes an exception.

Now, in all __eq__ methods, I now first verify that the two things are of the same type.

coveralls commented 2 years ago

Coverage Status

Coverage increased (+0.1%) to 68.282% when pulling 1fef26018ddeab7c2309990d688cb9aa77ea6236 on bugfix_testing_equivalence_of_unrelated_things_causes_exceptions into a8522fec9359623f68a5e26fad763fda9faa7768 on main.