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

Documentation minor fixes #197

Merged
merged 2 commits into from
Nov 3, 2024
Merged

Conversation

githubalexliu
Copy link
Contributor

Summary

Changes:

Checklist

  • Google format doc strings added.
  • Code linted with ruff. (For guidance in fixing rule violates, see rule list)
  • Type annotations included. Check with mypy.
  • Tests added for new features/fixes.
  • I have run the tests locally and they passed.

Tip: Install pre-commit hooks to auto-check types and linting before every commit:

pip install -U pre-commit
pre-commit install

@rkingsbury rkingsbury added the docs documentation label Oct 29, 2024
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.79%. Comparing base (98e7824) to head (f68c297).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #197   +/-   ##
=======================================
  Coverage   81.79%   81.79%           
=======================================
  Files           9        9           
  Lines        1494     1494           
  Branches      256      256           
=======================================
  Hits         1222     1222           
  Misses        226      226           
  Partials       46       46           

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

@rkingsbury
Copy link
Member

@githubalexliu this is great, thank you!

I'm not an expert in sphinx - do you know if there is a way to get these private methods to show up as public attributes in the docs? Because, when one uses Solution, you actually call them as attributes, e.g. Solution.get_molar_conductivity, but internally the actual calculation is done by the private method; this is to make caching possible. But the public attributes also exist (see Solution.get_diffusion_coefficient, for example)

@githubalexliu
Copy link
Contributor Author

Not sure if can change those methods to become something similar to the pressure property in the same file.
image

Something like

def get_property(self, solute: str, name: str) -> Any | None:
  ''' add the docstring here'''
  return lru_cache()(self._get_property)

@rkingsbury
Copy link
Member

Interesting idea @githubalexliu ; I don't know whether or not that would work (but it might). I was hoping there might be a way to accomplish this just in the docs settings (without changing the underlying methods) but there may not be.

The reference I used when implementing the cached class properties was https://rednafi.com/python/lru_cache_on_methods/ but it doesn't speak to using a decorated property. If you're interested in trying it, I would just want to see some timings (using %%timeit in Jupyter or similar) to verify that the caching still works as intended. One way to check would be to call get_conductivity in a for loop a bunch of times, because that method requires iterating over all the solute's diffusion coefficients. This should be much slower without caching than it is with caching enabled.

I also understand if this is more than you wanted to take on in this PR. I'm happy to merge this and save the further improvement for something separate; just let me know.

@githubalexliu
Copy link
Contributor Author

Thanks for the insights and the reference! For now, I think it might be best to go ahead and merge this PR as-is. We can explore the caching and documentation improvements in a separate issue.

@rkingsbury rkingsbury merged commit 2c970b0 into KingsburyLab:main Nov 3, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation: minor fixes
2 participants