Component iteration in pipelines - #1583
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1583 +/- ##
=========================================
+ Coverage 100.0% 100.0% +0.1%
=========================================
Files 242 242
Lines 19075 19143 +68
=========================================
+ Hits 19067 19135 +68
Misses 8 8
Continue to review full report at Codecov.
|
9289ca2 to
a742008
Compare
a742008 to
2d4f2ce
Compare
jeremyliweishih
left a comment
There was a problem hiding this comment.
really cool! looks good to me.
angela97lin
left a comment
There was a problem hiding this comment.
Looks great! Tests are solid, just curious what happens if index is not valid :P
| def test_linear_getitem(logistic_regression_binary_pipeline_class): | ||
| pipeline = logistic_regression_binary_pipeline_class({'One Hot Encoder': {'top_n': 4}}) | ||
|
|
||
| assert pipeline[0] == Imputer() |
There was a problem hiding this comment.
Amazing! Just to confirm, giving an invalid index throws... an IndexError? Or ValueError? Just curious since get_component throws a ValueError :p
bchen1116
left a comment
There was a problem hiding this comment.
This is super cool! LGTM!

Closes #1571
Obviously I'm not going to get this in before I leave today, but I had the time so I did what I couldContext since this is an old branch:
This PR addresses a breaking change made in #1543. Prior to #1543, the documented way to iterate through component instances was
[c for c in pipeline.component_graph]. However, #1543 made it so that thecomponent_graphattribute only lists the classes, not the instances. Rather than having users iterate through the private_component_graphattribute, we add a "public" accessor by making the pipelines iterable.This PR accomplishes that by:
__iter__and__next__method to pipelines (as opposed to relying on__getitem__)