Skip to content

Fix range usage in Touches1D class to prevent TypeError#1

Merged
Heerkog merged 1 commit into
Heerkog:masterfrom
efranken:fix-Touches1D-TypeError
May 24, 2024
Merged

Fix range usage in Touches1D class to prevent TypeError#1
Heerkog merged 1 commit into
Heerkog:masterfrom
efranken:fix-Touches1D-TypeError

Conversation

@efranken

Copy link
Copy Markdown
Contributor

Description:
When calling Touches1d, error TypeError: 'type' object isn't subscriptable would be returned.

Changes Made:

  • Changed range[0:len(verticalLocations)] to range(0, len(verticalLocations)) in the Touches1D class to correctly use the range function.

Testing:

  • Verified that the Touches1D class now works without raising a TypeError.

Steps to reproduce:

from trill import Bar
from touch import Touches1D 
#initialize i2c connection to bar
while True:
    try:
        data = bar.read()
        touches = Touches1D(data)

        for index, touch in enumerate(touches.get_touches()):
            print(index, touch)

will result in TypeError: 'type' object isn't subscriptable, whereas the same code works when importing and using Touches2D.

@Heerkog Heerkog merged commit d0f5554 into Heerkog:master May 24, 2024
@Heerkog

Heerkog commented May 24, 2024

Copy link
Copy Markdown
Owner

Much appreciated!

@efranken

efranken commented May 24, 2024 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants