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

Refactor Resolver serialization + ball ball friction sub models #171

Merged
merged 41 commits into from
Jan 8, 2025

Conversation

ekiefl
Copy link
Owner

@ekiefl ekiefl commented Jan 2, 2025

Instead of serializing a dumbed down version of Resolver via ResolverConfig, Resolver is itself serialized (as ~/.config/pooltool/physics/resolver.yaml).

Summary of changes:

  • get_X_model functions are removed. It was an obfuscating abstraction.
  • All physics models are expected to be attrs classes, so they can be serialized.
  • Model attributes can be any type, so long as they are round-trip serializable. That means sub-models can exist as attributes of models.
  • Each model has a model attribute. This is used as a cattrs structuring directive.
  • Ball ball friction models were condensed to a single file.
  • I still need to update docs/resources/custom_physics.md.

The default resolver.yaml now looks like this:

ball_ball:
  friction:
    a: 0.009951
    b: 0.108
    c: 1.088
    model: alciatore
  num_iterations: 1000
  model: frictional_mathavan
ball_linear_cushion:
  model: han_2005
ball_circular_cushion:
  model: han_2005
ball_pocket:
  model: canonical
stick_ball:
  english_throttle: 1.0
  squirt_throttle: 1.0
  model: instantaneous_point
transition:
  model: canonical
version: 6

@ekiefl ekiefl requested a review from derek-mcblane January 2, 2025 06:26
Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 73.97260% with 57 lines in your changes missing coverage. Please review.

Project coverage is 44.74%. Comparing base (0e89b7f) to head (1e23f82).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
pooltool/physics/resolve/__init__.py 11.42% 31 Missing ⚠️
pooltool/physics/resolve/resolver.py 53.48% 20 Missing ⚠️
pooltool/serialize/convert.py 50.00% 4 Missing ⚠️
pooltool/physics/resolve/ball_ball/friction.py 93.54% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #171      +/-   ##
==========================================
+ Coverage   44.22%   44.74%   +0.52%     
==========================================
  Files         127      129       +2     
  Lines        8554     8684     +130     
==========================================
+ Hits         3783     3886     +103     
- Misses       4771     4798      +27     
Flag Coverage Δ
service 44.74% <73.97%> (+0.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@derek-mcblane
Copy link
Collaborator

Looks good!

And I think the inclusion of the Alciatore friction model will give better results for Mathavan.

derek-mcblane
derek-mcblane previously approved these changes Jan 6, 2025
@ekiefl
Copy link
Owner Author

ekiefl commented Jan 8, 2025

Got around to adding new instructions for adding custom physics. Merging this now. Hopefully all goes well!

@ekiefl ekiefl merged commit f5bd153 into main Jan 8, 2025
10 checks passed
@ekiefl ekiefl deleted the ek/recursive-modelargs branch January 8, 2025 08:13
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