Skip to content

Conversation

@cadenmyers13
Copy link
Contributor

closes #142

@cadenmyers13
Copy link
Contributor Author

cadenmyers13 commented Jan 29, 2026

@sbillinge ready for review, new plot_recipe method for srfit. I tested this on the Ni refinement and one where there are two fit contributions and it worked as expected

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.36%. Comparing base (ff4d668) to head (65a4c85).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #143      +/-   ##
==========================================
+ Coverage   66.60%   69.36%   +2.76%     
==========================================
  Files          25       25              
  Lines        3171     3457     +286     
==========================================
+ Hits         2112     2398     +286     
  Misses       1059     1059              
Files with missing lines Coverage Δ
tests/conftest.py 91.48% <100.00%> (+4.82%) ⬆️
tests/test_fitrecipe.py 99.76% <100.00%> (+0.27%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cadenmyers13
Copy link
Contributor Author

An example plot

Screenshot 2026-01-29 at 6 52 15 PM

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

this looks great. Actually, more configurable than I kind of intended, but ok. A few questions:

  1. make sure that we are using the group style-sheet.
  2. Start all the docstring descriptions with The (so Label for y-axis becomes The label for the y-axis. Never don't do that (i.e. ALWAYS start descriptions with The, it always works.)
  3. I like the examples. Very nice.
  4. It would be quite a bit of typing, but do we want to hold the parameters as attributes of the class? That way the user could just update the attribute to customize their plot and it would stay persistent for all their plots until they reset it or reinstantiated?
  5. Tests look good. Very comprehensive.
  6. Do we want to move the "build_recipe" functions to conftest.py as fixtures? In that way simple test recipes will be available to all tests.

All in all, this is excellent.

from collections import OrderedDict

import matplotlib.pyplot as plt
import six
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we shouldn't need six, what is it being used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sbillinge for instance checks like isinstance(x, six.string_types). This can be replaced with just str

@sbillinge
Copy link
Contributor

in the plot there are no figure axis labels. Is there a ready way to guess these? I guess the challenge is to know what is being fit and what is on teh x-axis so it may be more trouble than it is worth.

@cadenmyers13
Copy link
Contributor Author

@sbillinge ready for review

make sure that we are using the group style-sheet.

Done

Start all the docstring descriptions with The

Done

It would be quite a bit of typing, but do we want to hold the parameters as attributes of the class? That way the user could just update the attribute to customize their plot and it would stay persistent for all their plots until they reset it or reinstantiated?

I added a plot_options attribute dictionary and a function that can be used to update it. Users can set global defaults and still modify individual plots if they want. I wrote a few more tests for this too.

Do we want to move the "build_recipe" functions to conftest.py as fixtures? In that way simple test recipes will be available to all tests.

Done

If the recipe has multiple contributions, a separate
plot is created for each contribution.

Parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this docstring needs to be moved somewhere, at least, deleted from here. But maybe method that sets these

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sbillinge I moved it to set_plot_defaults

@cadenmyers13
Copy link
Contributor Author

in the plot there are no figure axis labels. Is there a ready way to guess these? I guess the challenge is to know what is being fit and what is on teh x-axis so it may be more trouble than it is worth.

@sbillinge I added functionality to do this just for PDF files. The PDFParser loads metadata and one of the metadata is filename. so if gr is in the filename it defaults the labels to PDF labels. The user-defined labels will override that default though

@sbillinge sbillinge merged commit 47d6dc6 into diffpy:main Feb 1, 2026
7 checks passed
@sbillinge
Copy link
Contributor

I merged. Please can we update the docs with, more or less what is in the docstrings which are very good and informational.

the code was a bit verbose, I am guessing we could have structured it better, but let's leave that for the future......don't let perfect be the enemy of good.

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.

feat: add plot_recipe() method to FitRecipe

2 participants