Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an "Align.NONE" enum member. #734

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Conversation

smurfix
Copy link

@smurfix smurfix commented Oct 13, 2024

This option means "leave me alone".
It is necessary for placing text on its baseline.

This option means "leave me alone".
It is necessary for placing text on its baseline.
Copy link

codecov bot commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 9.09091% with 10 lines in your changes missing coverage. Please review.

Project coverage is 95.88%. Comparing base (dacb347) to head (f54698d).
Report is 7 commits behind head on dev.

Files with missing lines Patch % Lines
src/build123d/build_common.py 0.00% 4 Missing ⚠️
src/build123d/geometry.py 0.00% 2 Missing ⚠️
src/build123d/objects_part.py 0.00% 2 Missing ⚠️
src/build123d/objects_sketch.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #734      +/-   ##
==========================================
- Coverage   96.00%   95.88%   -0.12%     
==========================================
  Files          25       25              
  Lines        8351     8362      +11     
==========================================
+ Hits         8017     8018       +1     
- Misses        334      344      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gumyr
Copy link
Owner

gumyr commented Oct 13, 2024

A few lines of unittests are required - patch coverage should be 100%.

@gumyr
Copy link
Owner

gumyr commented Oct 13, 2024

Oh, how about changing elif self.align[i] == Align.NONE: to elif self.align[i] == Align.NONE or self.align[i] is None:?

@smurfix
Copy link
Author

smurfix commented Oct 13, 2024

I can do that. However … having the same set of tests in no less than five different locations is a red flag. Time to refactor that instead of adding more repetitive code (and tests for it).

Ideas for a good function name? I tend towards align_offset(min: Tuple[float], max: Tuple[float], align: Tuple[Align]|Align|None) -> VectorLike.

@gumyr
Copy link
Owner

gumyr commented Oct 14, 2024

What are you proposing to change?

@smurfix
Copy link
Author

smurfix commented Oct 14, 2024

What are you proposing to change?

This code

            align_offset=[]
            for i in however_many_axes:
                if align[i] == Align.MIN:
                    align_offset.append(min_coord()[i])
                elif align[i] == Align.CENTER:
                    align_offset.append((min_coord()[i]+max_coord()[i])/2)
                elif align[i] == Align.MAX:
                    align_offset.append(max_coord()[i])
                elif align[i] == Align.NONE:
                    align_offset.append(0)
                # note no check for any other value

appears five times in build123d's codebase. That's four times too many. Also I'd like to calculate the coordinates once each instead of up to three times, plus I don't like to rely on typechecking to prevent results like the one you get if you align=(None,Align.MAX).

@gumyr
Copy link
Owner

gumyr commented Oct 15, 2024

Sure, that code could be improved. There is an related issue #457 - are you planning on fixing this too?

@smurfix
Copy link
Author

smurfix commented Oct 15, 2024

Thanks for the pointer. Yes.

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