René's URL Explorer Experiment


Title: Update model.py by ren-oz · Pull Request #13 · CarletonCognitiveModelingLab/python_actr · GitHub

Open Graph Title: Update model.py by ren-oz · Pull Request #13 · CarletonCognitiveModelingLab/python_actr

X Title: Update model.py by ren-oz · Pull Request #13 · CarletonCognitiveModelingLab/python_actr

Description: Cleaned up (deleted) old comments, made code PEP-8 compliant. Updated Python 2 string formatting to Python 3 f-strings. Fixed bug related to initializing children -- does not work as expected. The issue can be recreated with the following code: from python_actr import ACTR, Model env = Model() env.a1 = ACTR() print(env.get_children()) # List is empty print(env._children) # Raises AttributeError: "'Model' object has no attribute '_children'." env.a2 = ACTR() print(env.get_children()) # List has only one value print(env._children) # No exception raised, but only a2 is in children! This is resolved by moving self.__dict__[key] = value to the end of the __setattr__ method in class Model. The problem occurs because (if I am correct) whenever a class attribute of type Model is set for the first time in a parent Model instance (e.g., an environment), the parent class instance is forced into a conversion method (self._ensure_converted). During this conversion process, all Model instances in the parent namespace are also converted via: for k, v in list(self.__dict__.items()): if k[0] != '_' and k != 'parent' and isinstance(v, Model): if not v.__converted: v.__convert(parent=self) This leads to the child instance having its parent attribute set, and thus the parent _children attribute does not get set due to if getattr(value, 'parent', None) is not None: pass Interestingly, commenting out the for k, v in list(self.__dict__.items()): [...] block doesn't seem to break anything (hasn't been extensively tested though) and also resolves the issue as the children conversion happens later on in __setaatr__ along with an explicit setting of the parent _children attribute. But this is a larger block of code and must have been put in for some reason, so I'm hesitant to commit its deletion in this pull request. Future changes to consider: Ultimately, the methods in this file have low cohesion and are responsible for a lot of unrelated work. Refactoring model.py to delegate single responsibilities to other methods is something to strongly consider as it would help make maintenance easier in the event of future bugs. It should also help in developing new subclasses with less pain and ideally favour extensibility. That said, this must be done with care as much is built on top of this module so the changes could snowball. I am happy to assist in this process with pull requests if the team deems it worthwhile.

Open Graph Description: Cleaned up (deleted) old comments, made code PEP-8 compliant. Updated Python 2 string formatting to Python 3 f-strings. Fixed bug related to initializing children -- does not work as expected. The ...

X Description: Cleaned up (deleted) old comments, made code PEP-8 compliant. Updated Python 2 string formatting to Python 3 f-strings. Fixed bug related to initializing children -- does not work as expected. The ...

Opengraph URL: https://github.com/CarletonCognitiveModelingLab/python_actr/pull/13

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:dceeef91-e608-c1d0-2ba4-90ceccd64db6
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id87E6:18F774:01D6:02AF:69826E4A
html-safe-nonce5955c17247cd9ac5aabb5939aa4c01525117b685e9e2379e10fdbdff13ce8e76
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0U2OjE4Rjc3NDowMUQ2OjAyQUY6Njk4MjZFNEEiLCJ2aXNpdG9yX2lkIjoiODMyNzc5MDU2MDQ4NDE1OTA1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8092c148569d0e073eb6a225b7660df5733380a3667f8f3d06a67d175a627376
hovercard-subject-tagpull_request:879410111
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/CarletonCognitiveModelingLab/python_actr/pull/13/files
twitter:imagehttps://avatars.githubusercontent.com/u/35468537?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/35468537?s=400&v=4
og:image:altCleaned up (deleted) old comments, made code PEP-8 compliant. Updated Python 2 string formatting to Python 3 f-strings. Fixed bug related to initializing children -- does not work as expected. The ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noned8cbbf00e6212b4e561a1d6db613194a319d58a2967494f7cc81cf6da3fbb985
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/CarletonCognitiveModelingLab/python_actr git https://github.com/CarletonCognitiveModelingLab/python_actr.git
octolytics-dimension-user_id6578142
octolytics-dimension-user_loginCarletonCognitiveModelingLab
octolytics-dimension-repository_id432934233
octolytics-dimension-repository_nwoCarletonCognitiveModelingLab/python_actr
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id432934233
octolytics-dimension-repository_network_root_nwoCarletonCognitiveModelingLab/python_actr
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
release15d777483e72943a892af4ab5c0bbdb20215e6f3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FCarletonCognitiveModelingLab%2Fpython_actr%2Fpull%2F13%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FCarletonCognitiveModelingLab%2Fpython_actr%2Fpull%2F13%2Ffiles
Sign up https://patch-diff.githubusercontent.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=CarletonCognitiveModelingLab%2Fpython_actr
Reloadhttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files
Reloadhttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files
Reloadhttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files
CarletonCognitiveModelingLab https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab
python_actrhttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2FCarletonCognitiveModelingLab%2Fpython_actr
Fork 20 https://patch-diff.githubusercontent.com/login?return_to=%2FCarletonCognitiveModelingLab%2Fpython_actr
Star 36 https://patch-diff.githubusercontent.com/login?return_to=%2FCarletonCognitiveModelingLab%2Fpython_actr
Code https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr
Issues 8 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/issues
Pull requests 11 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pulls
Actions https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/actions
Projects 0 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/projects
Wiki https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/wiki
Security 0 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/security
Insights https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pulse
Code https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr
Issues https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/issues
Pull requests https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pulls
Actions https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/actions
Projects https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/projects
Wiki https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/wiki
Security https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/security
Insights https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2FCarletonCognitiveModelingLab%2Fpython_actr%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2FCarletonCognitiveModelingLab%2Fpython_actr%2Fissues%2Fnew%2Fchoose
ren-ozhttps://patch-diff.githubusercontent.com/ren-oz
CarletonCognitiveModelingLab:mainhttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/tree/main
ren-oz:mainhttps://patch-diff.githubusercontent.com/ren-oz/python_actr/tree/main
Conversation 0 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13
Commits 5 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/commits
Checks 0 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/checks
Files changed https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files
Please reload this pagehttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files
Update model.py https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files#top
Show all changes 5 commits https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files
f466945 Update model.py ren-oz Mar 14, 2022 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/commits/f466945caebe9c50e5026a2caa63e54b91ab3e47
b5e93c9 Update scheduler.py. Moved exceptions to own module ren-oz Mar 14, 2022 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/commits/b5e93c9457031348e7b2ba3c346e1afdc69bdf25
a2be098 Update folder structure ren-oz Mar 14, 2022 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/commits/a2be0989330d6012e4720279ff046511d9edf6fb
2ad90d8 Revert "Update folder structure" ren-oz Mar 15, 2022 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/commits/2ad90d8b36018061caf81fba152f6e34b91f848a
38153cd Update setup.py ren-oz Mar 15, 2022 https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/commits/38153cd460dbee2c7dd7c4754f041c8bcdb40591
Clear filters https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files
Please reload this pagehttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files
Please reload this pagehttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files
__init__.py https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files#diff-bd020383acf03338e81491f567017b575671d745b3592b02c04ffece461ce651
errors.py https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files#diff-3d82e88101551014a0f3383b5395588d0a5502559a9335d56dca1b708973ec22
model.py https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files#diff-62b1ba9150bcc54aba5806d043392ac5384958bcf89e355778053c128d144ea2
scheduler.py https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files#diff-cf62a2a7bdd3c47327ba1bd85bea25d376f26930327d9abfb57b78b138bc629f
setup.py https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files#diff-60f61ab7a8d1910d86d9fda2261620314edcae5894d5aaa236b821c7256badd7
python_actr/errors/__init__.pyhttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files#diff-bd020383acf03338e81491f567017b575671d745b3592b02c04ffece461ce651
View file https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/blob/38153cd460dbee2c7dd7c4754f041c8bcdb40591/python_actr/errors/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/{{ revealButtonHref }}
python_actr/errors/errors.pyhttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/files#diff-3d82e88101551014a0f3383b5395588d0a5502559a9335d56dca1b708973ec22
View file https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/blob/38153cd460dbee2c7dd7c4754f041c8bcdb40591/python_actr/errors/errors.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/{{ revealButtonHref }}
Please reload this pagehttps://patch-diff.githubusercontent.com/CarletonCognitiveModelingLab/python_actr/pull/13/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.