Skip to content

Commit ba3869b

Browse files
Copilotmballance
andcommitted
Enhance documentation and test coverage for options handling
Co-authored-by: mballance <1340805+mballance@users.noreply.github.com>
1 parent ee8be3c commit ba3869b

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/vsc/coverage.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,17 @@ def __init__(self,
907907
ignore_bins=None):
908908
# Recursively flatten nested crosses by extracting their coverpoints
909909
def flatten_targets(targets):
910-
"""Recursively flatten a list of coverpoints and crosses."""
910+
"""Recursively flatten a list of coverpoints and crosses.
911+
912+
Args:
913+
targets: List of coverpoint and/or cross objects
914+
915+
Returns:
916+
List of coverpoint objects (flat list with all crosses expanded)
917+
918+
Raises:
919+
Exception: If any target is neither a coverpoint nor a cross
920+
"""
911921
flattened = []
912922
for t in targets:
913923
if isinstance(t, cross):

ve/unit/test_coverage_cross.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,33 @@ def __init__(self):
183183
self.cross_ab = vsc.cross([self.cp_a, self.cp_b])
184184

185185
# Nested cross with options
186-
self.cross_abc = vsc.cross(
186+
self.cross_abc_nested = vsc.cross(
187187
[self.cross_ab, self.cp_c],
188188
options=dict(at_least=2)
189189
)
190+
191+
# Non-nested cross with same options for comparison
192+
self.cross_abc_flat = vsc.cross(
193+
[self.cp_a, self.cp_b, self.cp_c],
194+
options=dict(at_least=2)
195+
)
190196

191197
cg = nested_cross_options_cg()
192198
cg.sample(10, 20, 30)
193199

194-
# Verify structure
195-
self.assertEqual(len(cg.cross_abc.target_l), 3)
196-
# Verify options were set correctly
197-
self.assertIsNotNone(cg.cross_abc.options)
198-
self.assertEqual(cg.cross_abc.options.at_least, 2)
200+
# Verify structure of nested cross
201+
self.assertEqual(len(cg.cross_abc_nested.target_l), 3)
202+
# Verify options were set correctly on nested cross
203+
self.assertIsNotNone(cg.cross_abc_nested.options)
204+
self.assertEqual(cg.cross_abc_nested.options.at_least, 2)
205+
206+
# Verify structure of flat cross
207+
self.assertEqual(len(cg.cross_abc_flat.target_l), 3)
208+
# Verify options were set correctly on flat cross
209+
self.assertIsNotNone(cg.cross_abc_flat.options)
210+
self.assertEqual(cg.cross_abc_flat.options.at_least, 2)
211+
212+
# Verify both crosses have same structure (proving flattening works correctly)
213+
for i in range(3):
214+
self.assertEqual(cg.cross_abc_nested.target_l[i], cg.cross_abc_flat.target_l[i])
199215

0 commit comments

Comments
 (0)