-
Notifications
You must be signed in to change notification settings - Fork 2
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
Use multiple gradients on a single ingredient #270
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to run and see the combined gradient results, very cool! Just one minor suggestion, everything else look good
cellpack/autopack/Analysis.py
Outdated
if not isinstance(ingr.gradient, list): | ||
self.center = center = self.env.gradients[ | ||
ingr.gradient | ||
].mode_settings.get("center", center) | ||
else: | ||
self.center = center |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe simply reverse if
and else
statements for readability?
if not isinstance(ingr.gradient, list): | |
self.center = center = self.env.gradients[ | |
ingr.gradient | |
].mode_settings.get("center", center) | |
else: | |
self.center = center | |
if isinstance(ingr.gradient, list): | |
self.center = center | |
else: | |
self.center = self.env.gradients[ | |
ingr.gradient | |
].mode_settings.get("center", center) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Ruge! This reminded me of another edge case of a single gradient in a list so I added that in as well here.
cellpack/autopack/Environment.py
Outdated
for gradient_name, gradient in self.gradients.items() | ||
if gradient_name in ingr.gradient | ||
] | ||
combined_weight = Gradient.get_combined_gradient_weight( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you push the logic above into a generic Gradient.pick_point_from_weight that figures out wether it needs to combine weights and returns the ptInd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! I added a static method Gradient.pick_point_for_ingredient
here
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #270 +/- ##
==========================================
- Coverage 98.75% 98.73% -0.03%
==========================================
Files 19 18 -1
Lines 563 553 -10
==========================================
- Hits 556 546 -10
Misses 7 7 ☔ View full report in Codecov by Sentry. |
Problem
Closes #262
Solution
Added support to allow multiple gradients on a single ingredient at the ingredient level.
Type of change
Change summary:
gradient
attribute of an ingredient to be aList
instance with multiple gradients.combined_weight
that specifies the probabilities of the grid point to be picked to place the ingredient.Gradient
class to be static methods.Steps to Verify:
Pack a recipe with an X and Y gradient combined:
Screenshots:
Weight map:
Simularium screenshot