doc: Update docstrings across fitbase/ and pdf/ to group standards - #198
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.3.0 #198 +/- ##
==========================================
+ Coverage 79.08% 82.08% +2.99%
==========================================
Files 25 25
Lines 3821 3969 +148
==========================================
+ Hits 3022 3258 +236
+ Misses 799 711 -88
🚀 New features to boost your workflow:
|
|
I changed docs to use the |
sbillinge
left a comment
There was a problem hiding this comment.
please see my comment. Some of the "plot_results" cases seem to be a bit more complicated, but let's think if we can handle them with our new API and avoid the plot_results wrapper. If it is too much work for some edge cases, we can define a simple plot_results wrapper just for those cases?
|
|
||
|
|
||
| def plotResults(recipe): | ||
| def plot_results(recipe): |
There was a problem hiding this comment.
this seems to be such a shallow wrap, do we need it? Isn't plot_recipe kind of doing what plot_results is intended to do?
I would maybe argue a better "exemplar" would be that we define a style dictionary, something like
plot_styles = {
data_color:"b",
fit_color:"r",
diff_color:"g",
data_label:"G(r) Data",
fit_label:"G(r) Fit",
diff_label:"G(r) diff",
xlabel:r"$r (\AA)$",
ylabel:r"$G (\AA^{-2})$"
}
then just use
recipe.plot_recipe(**plot_styles)
or something along those lines? Then we don't need the plot_results() function at all.
There was a problem hiding this comment.
@sbillinge yeah good rec. I'll implement it
|
@sbillinge Ready for review. Upon testing I realized that if a fit has multiple contributions the plots generated from |
| _, axes = recipe.plot_recipe(show=False, return_fig=True) | ||
| actual_titles = [ax.get_title() for ax in axes] | ||
| expected_titles = ["c1", "c2"] | ||
| assert actual_titles == expected_titles |
There was a problem hiding this comment.
The above two tests cannot be merged using parameterize because of the different fixtures it uses
|
@sbillinge CI is back. Ready for review |
* deprecate addProfileGenerator * update api docs * mock utils and pyobjcryst for doc rendering * news * restore api docs * revert conf.py commit * deprecate addContribution and replace with add_contribution * news * deprecate setEquation and replace with set_equation * more set_equation replacements * news * reorder dep message to prevent merge conflicts * one final setEquation switch in tests * pushFitHook deprecation * popFitHook deprecation * popFitHook dep message * getFitHooks and clearFitHooks deprecation * setWeight deprecation * news * news pt2 * addParameterSet deprecation * news * docstring typo * deprecate getEquation in fitcontribution.py * deprecate getEquation from builder.BaseBuilder * news * news typo * deprecate SimpleRecipe.loadParsedData * deprecate Profile.loadParsedData * deprecate Profile.setObservedProfile and SimpleRecipe.setObservedProfile * news * setCalculationRange * setCalculationPoints * change rebinArray to rebin_array * make _rebin_array private * missed deprecation tag in SimpleRecipe * setResidualEquation deprecation * getResidualEquation deprecation * news * news again * add test for remove and add param_set * removeParameterSet deprecation * scalarResidual deprecation * addVar deprecation * delVar deprecation * newVar deprecation * news * news 2 * isFree deprecation * getValues deprecation * fix typo in base name * getNames deprecation * getBounds deprecation * getBounds2 deprecation * add test for boundsToRestraints * boundsToRestraints deprecation * make bounds to restraints docstring better * news * news 2 * make new test cleaner * remove minus sign typo causing tests to fail * formatResults deprecation * printResults deprecation * add tests for printResults and formatResults * write test for saveResults * test for the addition of a header to results * saveResults deprecation * news * set fixtures to scope=function * add constraints and restraints for more strict testing * add initialization test and method * news * remove accidental commit * add test for ValueError * AUTHORS.rst * CODE-OF-CONDUCT.rst * cookiecutter.json * LICENSE.rst * LICENSE.rst pt2 * MANIFEST.in * pyproject.toml * README.rst * release_checklist.md * build-and-publish-docs-on-dispatch.yml * build-wheel-release-upload.yml * matrix-and-codecov.yml * README.rst pt2 * conf.py * index.rst * license.rst * diffpy.srfit.rst * __init__.py * __init__.py * __init__.py * srfit_app.py * version.py * news * [pre-commit.ci] auto fixes from pre-commit hooks * resultsDictionary deprecation, added to FitResults * news * test for resultsDictionary * improve test * add comments describing tests * rm merge-to-main duplicate workflow * add __init__ header to README * pull PR to list branch to fix docformatter failure * [pre-commit.ci] auto fixes from pre-commit hooks * fix conftest fixture so it creates new recipe object on each call * update fixture initial values to be more different * update expected to accound for the slight difference now * feat: initialize FitRecipe from a results file or object * test: tests for the new feature * add utils objects to get dict from results object or file * news * fix accident in test_fitresults * use get_results_dictionary method to get params_dict * initializeRecipe deprecation * add better docstrings to fitrecipe and fitresults * add 'The' to docstrings * do linspace with odd number of points * revert recipe fixture back, explicitly set scope to 'function', and add a new helper function that builds recipe for init testing * add assert recipes arent equal * add fixture that returns two identical recipes * add second recipe to fixture build_recipe_one_contribution * change fixture name to be plural (build_recipes_one_contribution) * rm deprecated six and other deprecated python2 objects * setValue deprecation * news * skip test_speed.py * ignore test_speed.py in codecov * iterPars deprecation * registerCalculator deprecation * registerFunction deprecation in EquationFactory and RecipeOrganizer * registerStringFunction deprecation * evaluateEquation deprecation * isConstrained deprecation * replace par with parameter * getConstrainedPars deprecation, and write a test for it :) * small fix * clearConstraints deprecation, and write small test * clean up and fix variable names in restrain and constrain methods * minor docstring typos * news * constrain and unconstrain deprecation * change name to register_restraint * restrain deprecation * unrestrain deprecation * clearRestraints deprecation * equationFromString deprecation * news * constrain_parameter --> add_constraint * unconstrain_parameter --> remove_constraint * add_restraint --> add_penalty * remove_restraint --> remove_penalty * register_restraint --> register_penalty * clear_all_restraints --> clear_all_penalties * change lb to lower_bound everywhere * change ub to upper_bound everywhere * add_penalty --> add_soft_bounds * remove_penalty --> remove_soft_bounds * register_penalty --> register_soft_bounds * clear_all_penalties --> clear_all_soft_bounds * add more to add_soft_bounds docstring * more to docstring * processMetaData --> _process_metadata * isConst --> is_constant * change Attributes --> Parameters in all docstrings * boundRange --> bound_range * boundWindow --> bound_window * write tests for bound_window and bound_range * news * minor docstring fix * deprecate PDFParser * build parse_file and deprecate getNumBank, selectBank, getFormat, getData, and getMetaData * add ProfileParser to __init__ so it can be imported from fitbase * add test files as conftest fixture * use ProfileParser in PDFContribution, replacing PDFParser * Use ProfileParser instead of PDFParser for fitrecipe testing * getData --> get_data, and getMetaData --> get_metadata in Profile * add set_parsed_profile test with ProfileParser * update examples with new parser * update test_pdf to reflect new parser * update old formatted test data to get parser to pass tests * add test for ProfileParser * update sas module and test to reflect new changes * news * rm comment * blank commit to fix pre-commit * run pre-commit autoupdate and run pre-commit * set python version to 3.13 to pin pre-commit CI * pin only docformatter to python3.13 * rm python3.13 pin on pre-commit-config for now * pip pre-commit docformatter to 3.13 * fix: fix iterpars behavior * [pre-commit.ci] auto fixes from pre-commit hooks * chore: rename par to parameter * chore: change docstring, refind test description and structure * [pre-commit.ci] auto fixes from pre-commit hooks * chore: change to if else statement in the logic * chore: refactor pytest fixtures and sync `pyproject.toml` and pre-commit file with main (#188) * sync pre-commit file and pyproject.toml with main * refactor pytest fixtures to remove use of triple quotes * chore: news * [pre-commit.ci] auto fixes from pre-commit hooks * fix docformatter and black conflicts * chore: news v2 * clean up ugly docstring formating * empty commit --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * chore: merge remaining `main` edits into `v3.3.0` (#189) * fix: fix Qmax update after load new parsed data * chore: add news item * chore: rename the private method * build: add diffpy.structure back to requirement * chore: rebuild the documentation with proper metadata handling * chore: update pre-commit (#184) * chore: update pre-commit * [pre-commit.ci] auto fixes from pre-commit hooks * chore: fix docformatter and black conflict * chore: run pre-commit for file I missed * [pre-commit.ci] auto fixes from pre-commit hooks * chore: add #FIXME workaround * chore: add #FIXME workaround * [pre-commit.ci] auto fixes from pre-commit hooks * chore: add another #FIXME workaround * chore: add another #FIXME workaround * [pre-commit.ci] auto fixes from pre-commit hooks * chore: moved import statement to the top of import modules * [pre-commit.ci] auto fixes from pre-commit hooks * chore: added try except workaround --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * release: add support for python 3.14 and remove for 3.11 (#187) * chore: news * chore: remove duplicate FIXME line * chore: fix improperly merged method in ProfileGenerator --------- Co-authored-by: stevenhua0320 <r.hua@mail.utoronto.ca> Co-authored-by: Simon Billinge <sbillinge@users.noreply.github.com> Co-authored-by: Daniel Sirakov <danielsirakov73@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * skpkg: update project to latest scikit-package template (#190) * skpkg: update project to latest scikit-package template * Reorganize update message in changelog Moved the update of the project template from 'Changed' to 'Fixed' section. --------- Co-authored-by: Simon Billinge <sbillinge@users.noreply.github.com> * change: Handle uncertainties as `None` rather than `1`s (#193) * fix: return None instead of 0 for unavailable dx/dy uncertainties * test: update and add tests for None uncertainty behavior * chore: add news entry for uncertainty None fix * test: add tests to ensure new handling of uncertainties doesn't break refinements * change: update profile.set_observed_profile() to not convert dy to ones if dy is None * chore: update news file * Update tests to make it easier to not use a testdata file for interpretability * add as_list as a fixture * add comment about how the fixture is used in test * add three_column case * use as_list as a fixture * Fix: Restore extensibility of `ProfileParser` and use `load_data` from `diffpy.utils` (#196) * Update examples to use the correct parser and add description of how to create your own parser in docs * update old metadata format to new xPDFsuite and pdfgetx headers. One testdata file for each * add test for new parser behavior * change how ProfileParsers work by allowing user to create their own parsers for metadata and the data itself * update the pre-existing news file with these changes * Make PDFParser identical to ProfileParser now that ProfileParser defaults to load_data * update old data metadata formats in testdata files to mirror xPDFsuite (neutron data) and pdfgetx (xray data) * updated expected metadata in test * fix docs description of ProfileParser * update news * minor docstring fix * tests for adding metadata upon parsing a file with ProfileParser * feat: allow user to append metadata when parsing a file with profileparser * doc: Update docstrings across `fitbase/` and `pdf/` to group standards (#198) * Update docstrings in fitbase to numpy/group standards * update docstrings in pdf to np/group standards * update docstrings in interface and structure to group standards * news * use recipe.plot_recipe() to plot fits in examples * remove plot_results in favor of recipe.plot_recipe() method * Change plot_recipe to display the contribution name as the title * add tests for the new plot_recipe behavior * rm accidentally commited output file * tidy a test up * empty commit for CI * dep: Deprecate characteristic functions containing camel case (#197) * Deprecate characteristic function camel case names * Change cf names in example scripts * add tests for characteristic functions * news * deprecate constrainAsSpaceGroup * update news * change: emit a warning if a characteristic function goes to a negative value during refinement. The output goes to zero * Add tests for new CF behavior for non-physical input parameters * cf news * empty commit for CI * change: update how the deprecated characteristic functions handle the signature changes (#199) * revert parameters in old function signatures to prevent errors when the name is specified in the signature * Change how the deprecated characteristic functions handle the signature change * Add test cases for the deprecated functions signature changes * news --------- Co-authored-by: Simon Billinge <sbillinge@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: stevenhua0320 <r.hua@mail.utoronto.ca> Co-authored-by: Daniel Sirakov <danielsirakov73@gmail.com>
There were also some updates in
structureandinterface.This is awesome. Claude just parsed through all of it and did a great job.