Skip to content

Commit

Permalink
AdditiveConfiguratorChain: Drop None entries
Browse files Browse the repository at this point in the history
This allows `AdditiveConfiguratorChain(foo if bar else None)`.
  • Loading branch information
moi90 committed May 30, 2024
1 parent c39fd0b commit c3e5aa3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions experitur/core/configurators.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,12 @@ class AdditiveConfiguratorChain(BaseConfigurator):
shuffle (bool, optional): Shuffle child configurations.
"""

def __init__(self, *configurators: BaseConfigurator, shuffle=False) -> None:
self.configurators = configurators
def __init__(
self, *configurators: Optional[BaseConfigurator], shuffle=False
) -> None:
# Drop None entries
# (This allows `AdditiveConfiguratorChain(foo if bar else None)`.)
self.configurators = [c for c in configurators if c is not None]
self.shuffle = shuffle

def build_sampler(
Expand Down

0 comments on commit c3e5aa3

Please # to comment.