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

Define circuit name at initialization #979

Merged
merged 2 commits into from
Nov 28, 2023
Merged

Conversation

rragona
Copy link

@rragona rragona commented Nov 26, 2023

I suggest to have the possibility to define the name of a circuit network during the circuit initialization, as argument of the constructor, e.g., cir = rf.Circuit(cnx, name = 'circuit').

To use a network inside a circuit connection list requires the network to have a name. Indeed in the __init__ of circuit.py:

# check if all networks have a name  
        for cnx in self.connections:  
            for (ntw, _) in cnx:  
                if not self._is_named(ntw):  
                    raise AttributeError('All Networks must have a name. Faulty network:', ntw)

Currently, one is forced to use a variable to store the circuit network, and then specify a name, e.g.:

cir = rf.Circuit(cnx)
ntw = cir.network
ntw.name = "circuit"

I find the suggested option more convenient, and readable, especially when nesting several circuits inside other circuits.

… is used for its network representation. Now, inserting a circuit network inside another circuit connection list does not require to create a network object and assign it a name before use.
@jhillairet jhillairet added Improvements Improvements of existing feature New Feature A new feature in progress labels Nov 26, 2023
Copy link
Member

@jhillairet jhillairet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Riccardo,

Thanks for the PR! I have only a minor modification suggested for the docstring.

skrf/circuit.py Outdated Show resolved Hide resolved
commit suggested changes
@jhillairet jhillairet merged commit 94a3fbc into scikit-rf:master Nov 28, 2023
12 checks passed
@jhillairet
Copy link
Member

Thank you @rragona and welcome as a new contributor :) !

@jhillairet jhillairet mentioned this pull request Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Circuit Improvements Improvements of existing feature New Feature A new feature in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants