Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add node attributes #110

Merged
merged 2 commits into from
Aug 19, 2024
Merged

add node attributes #110

merged 2 commits into from
Aug 19, 2024

Conversation

toruseo
Copy link
Owner

@toruseo toruseo commented Aug 19, 2024

No description provided.

@toruseo toruseo merged commit e13331a into main Aug 19, 2024
12 checks passed
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files Coverage Δ
uxsim/uxsim.py 86.07% <100.00%> (ø)

... and 1 file with indirect coverage changes

@EwoutH
Copy link
Contributor

EwoutH commented Aug 19, 2024

You could even go a bit further here, by adding **kwargs to the init functions, and then assigning all kwargs directly as attributes. Then you can add any attributes you would like.

class Node:
    def __init__(s, W, ..., **kwargs):
        ...
        # Assign all kwargs directly as attributes
        for key, value in kwargs.items():
            setattr(s, key, value)

I don't know if there are significant disadvantages to this approach, that should be checked.

@toruseo
Copy link
Owner Author

toruseo commented Aug 19, 2024

it will be troublesome for users if future official update adds arguments with the same name.

Note that attribute parameter can be anything. You can define dict or any other objects

@EwoutH
Copy link
Contributor

EwoutH commented Aug 19, 2024

it will be troublesome for users if future official update adds arguments with the same name.

Yeah that's very true. And you can now always pass a dict and do Node.attribute["key"] to get your desired value.

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.

3 participants