Fix bugs in chapters 11 and 12#4
Open
techfort wants to merge 1 commit into
Open
Conversation
- animals_ann.py: pass integers to randint() instead of floats - landmark_utils/utils.py: return early in log_csv() guard (was pass, so CSV was always written); fix double assignment typo - train.py: preserve -1 sentinel from waitKey before subtracting 48, so the "no key pressed" branch works correctly - detect_gesture.py: pass BGR color tuple to putText() instead of bare int - test_handler.py: update test to match active lambda_handler (returns coords, not message); mock requests.get and cv2.imread; fix fixture to supply url query param Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
animals_ann.py:randint(3.0, 5.0)→randint(3, 5)—random.randintrequires integer arguments; floats raiseTypeErroron Python 3.10+landmark_utils/utils.py:pass→returninlog_csv()guard — the early-exit condition was a no-op, so the CSV was always written regardless of the key pressed; also fixed double assignment typo (csv_path = csv_path = ...)train.py: Fixed key-to-number translation —cv2.waitKeyreturns-1when no key is pressed, sonumber = receivedKey - 48produced-49instead of-1, meaning the "Press key for gesture number" prompt never displayeddetect_gesture.py: Color argument tocv2.putTextchanged from bare255to(255, 255, 255)— BGR images require a 3-tupletest_handler.py: Updated test to match the activelambda_handler(returns{"coords": ...}, not{"message": "hello world"}); added mocks forrequests.getandcv2.imread; fixed fixture to supply the requiredurlquery parameterTest plan
python chapter11/animals_ann.pyand confirm condor samples generate withoutTypeErrorpython chapter11/hand-gesture-recognition/train.pyand confirm "Press key for gesture number" appears on screen when no key is helddetect_gesture.pyoutput windowpytest chapter12/tests/and confirmtest_lambda_handlerpasses🤖 Generated with Claude Code