Skip to content

fix(out_base): update 3D variant aspect matching logic#820

Merged
set-soft merged 1 commit into
INTI-CMNB:devfrom
mdeweerd:fix/818
May 19, 2025
Merged

fix(out_base): update 3D variant aspect matching logic#820
set-soft merged 1 commit into
INTI-CMNB:devfrom
mdeweerd:fix/818

Conversation

@mdeweerd
Copy link
Copy Markdown

  • Correct logic to select default 3D slot selection (added any_matched)
  • Renamed default to default_slots for clarity.
  • Add debug logging for variant matching
  • Apply default 3D models only if no variant matches

@mdeweerd
Copy link
Copy Markdown
Author

This is WIP. It already fixes some issues with the default selection.

However, I try to match when a Key is listed in the variant expression (abc,Key,def) to select a slot configuration.

For some reason "j8_clm" would match a variant not containing that key at all (matched = self.variant.matches_variant(var)).

logger.debug(f'XXX 3D: Test {var} vs {self.variant!r}: {matched!r}. Slots: {slots}')

produces:
                
DEBUG:XXX 3D: Test j8_clm vs '' (ph_cl_tbxy) [kibom]: True. Slots: ['3'] (kibot - out_base.py:761)

Digging a bit deeper.

@mdeweerd mdeweerd marked this pull request as ready for review May 17, 2025 15:42
@mdeweerd
Copy link
Copy Markdown
Author

I figured it out, I had to prefix the variant key in the footprint text fields $+key:3$ for instance.

@mdeweerd
Copy link
Copy Markdown
Author

@set-soft I did not find your review, I modified to have less changes.
I think technically there can be even less, but it's also important IMHO to differentiate the local match from the boolean indicating there was any successful match.

Comment thread kibot/out_base.py
break
if not matched and default is not None:
self.apply_list_of_3D_models(enable, slots, m, '_default_')
self.apply_list_of_3D_models(enable, default, m, '_default_')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't this enough?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I wrote "I think technically there can be even less" and explained why I prefer to keep the other changes as well.

Comment thread kibot/out_base.py Outdated
if matched:
matched_gi = var == variant_name
if matched_gi:
matched = True
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Once we have a match the loop ends, why we need two "match" variables?

@set-soft
Copy link
Copy Markdown
Member

@set-soft I did not find your review,

My fault, reviews must be approved, they doesn't become visible until I confirm them.

I modified to have less changes. I think technically there can be even less, but it's also important IMHO to differentiate the local match from the boolean indicating there was any successful match.

But when we have a match the loop ends. Both if matched has a break. There is no need to have 2 variables.

- Correct logic to select default 3D slot selection (added
  `any_matched`);
- Renamed `default` to `default_slots` for clarity.
@mdeweerd
Copy link
Copy Markdown
Author

But when we have a match the loop ends. Both if matched has a break. There is no need to have 2 variables.

It helps with readability, code analysis and future changes (for instance checking/using or warning about multiple matches).

Anyway, updated.

@set-soft set-soft merged commit af72057 into INTI-CMNB:dev May 19, 2025
21 checks passed
@set-soft
Copy link
Copy Markdown
Member

Thanks!

set-soft added a commit that referenced this pull request May 19, 2025
@set-soft
Copy link
Copy Markdown
Member

@mdeweerd : the above patch removes the need of a flag and addresses your concern.

@mdeweerd
Copy link
Copy Markdown
Author

@set-soft Thanks

In terms of code optimisation/DRY coding, we could have just one self.apply_list_of_3D_models(enable, slots, m, var) .

By setting it after the loop when slots is not None.

  • Initialise var to 'default', slots to None.
  • Set slots when 'default' is found, but continue the loop.
  • Set slots when a variant match is found, set var, and exit the loop.
  • After the loop, call apply_list_of_3D_models() when slots is not None.

set-soft added a commit that referenced this pull request May 20, 2025
@set-soft
Copy link
Copy Markdown
Member

In terms of code optimisation/DRY coding, we could have just one self.apply_list_of_3D_model

Sure, the above patch does it, also moves the search to a function

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