René's URL Explorer Experiment


Title: R23-T058: Refactor resistor_color_code.py to share colour lookup and validation helpers by code-paul-creator · Pull Request #68 · S-AI-Projects/TheAlgorithms-Python · GitHub

Open Graph Title: R23-T058: Refactor resistor_color_code.py to share colour lookup and validation helpers by code-paul-creator · Pull Request #68 · S-AI-Projects/TheAlgorithms-Python

X Title: R23-T058: Refactor resistor_color_code.py to share colour lookup and validation helpers by code-paul-creator · Pull Request #68 · S-AI-Projects/TheAlgorithms-Python

Description: Description Refactors electronics/resistor_color_code.py without changing behaviour: the repeated "look the colour up in this band's table or raise ValueError" code in four functions is replaced by one shared helper, and the nested validation / resistance code is flattened. An equivalence test compares the original and refactored code to prove nothing changed. Related Issue Fixes: #58 Type of Change Bug Fix New Feature UI/UX Improvement Performance Improvement Tests Documentation Refactoring / Maintenance CI/CD Changes Made Added get_color_value(color, color_values, band_name) (with 2 doctests) and used it in get_significant_digits, get_multiplier, get_tolerance, get_temperature_coeffecient. Error messages are unchanged. check_validity: guard clauses instead of nested if/else (nesting depth 4 -> 2). calculate_resistance: guard clause, removed None placeholders, fixed local typo resisitance. Original 24 doctests unchanged (26 total); all 10 raise statements kept. Added work/R23-T058/REFACTOR.md, equivalence_test.py, and before/after complexity and coverage output. Screenshots / Recordings Not applicable (no UI changes). Testing python -m pytest --doctest-modules electronics/resistor_color_code.py -> 26 passed python -m pytest work/R23-T058/equivalence_test.py -> 60 passed (original vs refactored: same results and same exception type and message on thousands of inputs and every raise path) ruff check electronics/resistor_color_code.py -> all checks passed McCabe complexity per function: calculate_resistance 5 -> 3, get_significant_digits 3 -> 1, get_multiplier/get_tolerance/get_temperature_coeffecient 2 -> 1, check_validity 5 -> 5 (flatter), total 22 -> 17 Checklist I have tested my changes locally. I have added or updated tests, if needed. I have updated documentation, if needed. I have followed the project's coding guidelines. I have run the relevant tests and checks. I have addressed previous review feedback, if applicable. Additional Notes check_validity stays at complexity 5 (its three error conditions and the colour loop are inherent), so the worst score is unchanged; calculate_resistance, the longest function, drops from 5 to 3. The raise ValueError("Input is invalid") at the end of calculate_resistance is unreachable (check_validity raises first); it was kept so the 10 raise paths stay identical. Details in work/R23-T058/REFACTOR.md.

Open Graph Description: Description Refactors electronics/resistor_color_code.py without changing behaviour: the repeated "look the colour up in this band's table or raise ValueError" code in four functions ...

X Description: Description Refactors electronics/resistor_color_code.py without changing behaviour: the repeated "look the colour up in this band's table or raise ValueError" code in fou...

Opengraph URL: https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:c13d28a6-3fa7-ab2d-1270-d97348d5d9b5
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBC52:1EECAE:19C436:22D339:6AFE491A
html-safe-nonce61c6f997f6aecc171a285eaeaf76033b6ffbd7e48b61825980fb6263edf4d957
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzUyOjFFRUNBRToxOUM0MzY6MjJEMzM5OjZBRkU0OTFBIiwidmlzaXRvcl9pZCI6Ijg1MTczMTkwNDkxNDU2MzMwNTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac6289596115391e608d2255e3e07e7cf60f78f6f89824ca6282f366cfc017ca37
hovercard-subject-tagpull_request:5257974016
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
twitter:imagehttps://avatars.githubusercontent.com/u/260575160?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/260575160?s=400&v=4
og:image:altDescription Refactors electronics/resistor_color_code.py without changing behaviour: the repeated "look the colour up in this band's table or raise ValueError" code in four functions ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonef1a5901e2377b0af2a0b303f9528678f1475d04b9219dca1e993344196eaa07c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/S-AI-Projects/TheAlgorithms-Python git https://github.com/S-AI-Projects/TheAlgorithms-Python.git
octolytics-dimension-user_id351892385
octolytics-dimension-user_loginS-AI-Projects
octolytics-dimension-repository_id1444141022
octolytics-dimension-repository_nwoS-AI-Projects/TheAlgorithms-Python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forktrue
octolytics-dimension-repository_parent_id63476337
octolytics-dimension-repository_parent_nwoTheAlgorithms/Python
octolytics-dimension-repository_network_root_id63476337
octolytics-dimension-repository_network_root_nwoTheAlgorithms/Python
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasece393ea11ad276623b946bc9663d3e7d6f564275
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FS-AI-Projects%2FTheAlgorithms-Python%2Fpull%2F68%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FS-AI-Projects%2FTheAlgorithms-Python%2Fpull%2F68%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=S-AI-Projects%2FTheAlgorithms-Python
Reloadhttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
Reloadhttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
Reloadhttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
S-AI-Projectshttps://github.com/S-AI-Projects
TheAlgorithms-Pythonhttps://github.com/S-AI-Projects/TheAlgorithms-Python
Codehttps://github.com/S-AI-Projects/TheAlgorithms-Python
Issues60 (60)https://github.com/S-AI-Projects/TheAlgorithms-Python/issues
Pull requests39 (39)https://github.com/S-AI-Projects/TheAlgorithms-Python/pulls
Actionshttps://github.com/S-AI-Projects/TheAlgorithms-Python/actions
Projectshttps://github.com/S-AI-Projects/TheAlgorithms-Python/projects
Security and qualityhttps://github.com/S-AI-Projects/TheAlgorithms-Python/security
Insightshttps://github.com/S-AI-Projects/TheAlgorithms-Python/insights
Sign up for GitHub https://github.com/signup?return_to=%2FS-AI-Projects%2FTheAlgorithms-Python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FS-AI-Projects%2FTheAlgorithms-Python%2Fissues%2Fnew%2Fchoose
code-paul-creatorhttps://github.com/code-paul-creator
S-AI-Projects:masterhttps://github.com/S-AI-Projects/TheAlgorithms-Python/tree/master
code-paul-creator:R23-T058https://github.com/code-paul-creator/TheAlgorithms-Python/tree/R23-T058
Conversation 0 https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68
Commits 1 https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/commits
Checks 0 https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/checks
Files changed https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
Please reload this pagehttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
R23-T058: Refactor resistor_color_code.py to share colour lookup and validation helpers https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#top
Show all changes 1 commit https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
19663b0 R23-T058: share colour lookup and validation helpers in resistor_colo… code-paul-creator Nov 11, 2026 https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/commits/19663b036bae575d3a6e71d703a3f737dd235203
Clear filters https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
Please reload this pagehttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
Please reload this pagehttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
resistor_color_code.py https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
REFACTOR.md https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-882778930aefde88a9565dad4563e0a2c3a1b47a3fb755337a16f2e9c48e53c2
complexity_after.txt https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-0d7e2bb66e6d9df3a2e965b4c5cb8e72eb892cc00a36e4d93d3efc464518eeb1
complexity_before.txt https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-c016b75c6e0065a86bd43ff64b407281a83871fcaf68310f2cc59324345368b4
coverage_after.txt https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-95866931f4d62b186ae22e68539517735808086578a5256f54bf02d6129ae853
coverage_before.txt https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-0d187b5608ea2b95ec9fd525e6f877ee5a4858e1bd1ccc5d9ce086c837077b71
equivalence_test.py https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-0e2ab4ab605f31f322aafefa9e4c24eab1f8d9bdaecc6ebd6d7f865ce5b796f0
original_resistor_color_code.py https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-d66d28b719d7c0149aa05c0a57788a222c52ae20945a56f95d85d78f262868c6
electronics/resistor_color_code.pyhttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
View file https://github.com/S-AI-Projects/TheAlgorithms-Python/blob/19663b036bae575d3a6e71d703a3f737dd235203/electronics/resistor_color_code.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/{{ revealButtonHref }}
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-f099c5185abb8702c38047c14fdb31c57440dde9b94c9b8376ac3e71a589358f
work/R23-T058/REFACTOR.mdhttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-882778930aefde88a9565dad4563e0a2c3a1b47a3fb755337a16f2e9c48e53c2
View file https://github.com/S-AI-Projects/TheAlgorithms-Python/blob/19663b036bae575d3a6e71d703a3f737dd235203/work/R23-T058/REFACTOR.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/{{ revealButtonHref }}
work/R23-T058/complexity_after.txthttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-0d7e2bb66e6d9df3a2e965b4c5cb8e72eb892cc00a36e4d93d3efc464518eeb1
View file https://github.com/S-AI-Projects/TheAlgorithms-Python/blob/19663b036bae575d3a6e71d703a3f737dd235203/work/R23-T058/complexity_after.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/{{ revealButtonHref }}
work/R23-T058/complexity_before.txthttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-c016b75c6e0065a86bd43ff64b407281a83871fcaf68310f2cc59324345368b4
View file https://github.com/S-AI-Projects/TheAlgorithms-Python/blob/19663b036bae575d3a6e71d703a3f737dd235203/work/R23-T058/complexity_before.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/{{ revealButtonHref }}
work/R23-T058/coverage_after.txthttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-95866931f4d62b186ae22e68539517735808086578a5256f54bf02d6129ae853
View file https://github.com/S-AI-Projects/TheAlgorithms-Python/blob/19663b036bae575d3a6e71d703a3f737dd235203/work/R23-T058/coverage_after.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/{{ revealButtonHref }}
work/R23-T058/coverage_before.txthttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files#diff-0d187b5608ea2b95ec9fd525e6f877ee5a4858e1bd1ccc5d9ce086c837077b71
View file https://github.com/S-AI-Projects/TheAlgorithms-Python/blob/19663b036bae575d3a6e71d703a3f737dd235203/work/R23-T058/coverage_before.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/{{ revealButtonHref }}
Please reload this pagehttps://github.com/S-AI-Projects/TheAlgorithms-Python/pull/68/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.