Skip to content

GroupModel: allow creating a group with no models - #322

Open
IbrarYunus wants to merge 1 commit into
Autostronomy:mainfrom
IbrarYunus:group-models-none
Open

IbrarYunus wants to merge 1 commit into
Autostronomy:mainfrom
IbrarYunus:group-models-none

Conversation

@IbrarYunus

Copy link
Copy Markdown

GroupModel.__init__ defaults models=None but then iterates over it, so creating an empty group to fill later fails:

ap.Model(model_type="group model", target=target)
# TypeError: 'NoneType' object is not iterable

None is now treated as an empty list. The group model tests pass.

@ConnorStoneAstro

Copy link
Copy Markdown
Member

Hi @IbrarYunus thanks for making this PR! Your update makes a ton of sense. There is a small modification I would add, just to make sure that things behave correctly wrt caskade.

In the imports change it to:

from caskade import forward, NodeList

And your modification would become:

if models is None:
    models = NodeList([])

That way when you add models later they will be properly integrated into the parameter graph.

This branch has not been deployed

No deployments
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.

2 participants