Skip to content

Commit b0008f2

Browse files
[pre-commit.ci] auto fixes from pre-commit hooks
1 parent 4f03fbd commit b0008f2

File tree

118 files changed

+3316
-2538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+3316
-2538
lines changed

.codecov.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ coverage:
1010
status:
1111
patch:
1212
default:
13-
target: '80'
13+
target: "80"
1414
if_no_uploads: error
1515
if_not_found: success
1616
if_ci_failed: failure
@@ -21,11 +21,11 @@ coverage:
2121
if_no_uploads: error
2222
if_not_found: success
2323
if_ci_failed: failure
24-
paths: '!*/tests/.*'
24+
paths: "!*/tests/.*"
2525

2626
tests:
2727
target: 97.9%
28-
paths: '*/tests/.*'
28+
paths: "*/tests/.*"
2929

3030
flags:
3131
tests:

.travis.yml

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ branches:
1919
except:
2020
- /^v[0-9]/
2121

22-
2322
before_install:
2423
- MYNAME=diffpy.srfit
2524
- MYCOMMIT="$(git rev-parse HEAD)"
@@ -28,25 +27,25 @@ before_install:
2827
- MYPYTHON=python; MYPIP=pip
2928
- NOSYS=true; NOAPT=true; NOBREW=true; NOMC=true
3029
- if ${MYUSEMC}; then
31-
NOMC=false;
30+
NOMC=false;
3231
elif [[ ${TRAVIS_OS_NAME} == linux ]]; then
33-
NOAPT=false; NOSYS=false;
34-
MYPIPFLAGS="--user";
32+
NOAPT=false; NOSYS=false;
33+
MYPIPFLAGS="--user";
3534
elif [[ ${TRAVIS_OS_NAME} == osx ]]; then
36-
NOBREW=false; NOSYS=false;
37-
MYPYTHON=python3;
38-
MYPIP=pip3;
39-
MYPIPFLAGS="--user";
35+
NOBREW=false; NOSYS=false;
36+
MYPYTHON=python3;
37+
MYPIP=pip3;
38+
MYPIPFLAGS="--user";
4039
fi
4140
- MYMCREPO=https://repo.anaconda.com/miniconda
4241
- case ${TRAVIS_OS_NAME} in
4342
linux)
44-
MYMCBUNDLE=Miniconda3-latest-Linux-x86_64.sh ;;
43+
MYMCBUNDLE=Miniconda3-latest-Linux-x86_64.sh ;;
4544
osx)
46-
MYMCBUNDLE=Miniconda3-latest-MacOSX-x86_64.sh ;;
45+
MYMCBUNDLE=Miniconda3-latest-MacOSX-x86_64.sh ;;
4746
*)
48-
echo "Unsupported operating system." >&2;
49-
exit 2 ;;
47+
echo "Unsupported operating system." >&2;
48+
exit 2 ;;
5049
esac
5150
- MYRUNDIR=${PWD}/build/rundir
5251

@@ -67,11 +66,11 @@ before_install:
6766
- $NOAPT || test "${TRAVIS_OS_NAME}" = "linux" || exit $?
6867
- $NOAPT || PATH="$(echo "$PATH" | sed 's,:/opt/pyenv/[^:]*,,g')"
6968
- $NOAPT || test "$(which python)" = "/usr/bin/python" || (
70-
which python; exit 1)
69+
which python; exit 1)
7170
- $NOAPT || sudo apt-get update -qq
7271
- $NOAPT || sudo apt-get install -y
73-
python-dev python-setuptools python-numpy
74-
build-essential
72+
python-dev python-setuptools python-numpy
73+
build-essential
7574

7675
- $NOBREW || test "${TRAVIS_OS_NAME}" = "osx" || exit $?
7776
- $NOBREW || brew update
@@ -81,18 +80,17 @@ before_install:
8180
- $NOSYS || devutils/makesdist
8281
- $NOSYS || MYTARBUNDLE="$(ls -t "${PWD}"/dist/*.tar.gz | head -1)"
8382

84-
8583
install:
8684
- $NOMC || conda build --python=${MYPYTHON_VERSION} conda-recipe
8785
- $NOMC || conda render --python=${MYPYTHON_VERSION} --output conda-recipe |
88-
sed 's,.*/,,; s/[.]tar[.]bz2$//; s/-/=/g' > /tmp/mypackage.txt
86+
sed 's,.*/,,; s/[.]tar[.]bz2$//; s/-/=/g' > /tmp/mypackage.txt
8987
- $NOMC || source activate testenv
9088
- $NOMC || conda install --yes --use-local --file=/tmp/mypackage.txt
9189
- $NOMC || conda install --yes
92-
diffpy.structure pyobjcryst "diffpy.srreal>=1.3.0"
90+
diffpy.structure pyobjcryst "diffpy.srreal>=1.3.0"
9391
# TODO - always install srfit-sasview when ready for Python 3.
9492
- if $MYUSEMC && [[ "$MYPYTHON_VERSION" == 2.7 ]]; then
95-
conda install --yes srfit-sasview;
93+
conda install --yes srfit-sasview;
9694
fi
9795

9896
- $NOSYS || $MYPIP install $MYPIPFLAGS coverage
@@ -103,20 +101,17 @@ install:
103101
- cd ${MYRUNDIR}
104102
- MYGIT_REV=$($MYPYTHON -c "import ${MYNAME}.version as v; print(v.__git_commit__)")
105103
- if [[ "${MYCOMMIT}" != "${MYGIT_REV}" ]]; then
106-
echo "Version mismatch ${MYCOMMIT} vs ${MYGIT_REV}.";
107-
exit 1;
104+
echo "Version mismatch ${MYCOMMIT} vs ${MYGIT_REV}.";
105+
exit 1;
108106
fi
109107

110-
111108
before_script:
112109
- $NOBREW || USER_BASE="$(python3 -c 'import site; print(site.USER_BASE)')"
113110
- $NOBREW || PATH="${USER_BASE}/bin:${PATH}"
114111

115-
116112
script:
117113
- coverage run --source ${MYNAME} -m ${MYNAME}.tests.run
118114

119-
120115
after_success:
121116
# do not post coverage reports when testing with system Python.
122117
- $NOMC || $MYPIP install $MYPIPFLAGS codecov

doc/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ clean:
3131
rm -rf diffpy.srfitapi
3232
rm -f srfit_examples.zip
3333
$(MAKE) -C devmanual $@
34-

doc/examples/README

Lines changed: 74 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1-
Purpose
2-
----------
1+
## Purpose
32

43
These example scripts are intended to help a developer get acquainted with the
54
SrFit programming interface. Although one can write scripts like these to drive
65
optimization, these scripts do not represent the SrFit user interface. That
76
interface will be made available in a future release.
87

9-
A secondary purpose of these tutorials is to generate interest in SrFit. By
8+
A secondary purpose of these tutorials is to generate interest in SrFit. By
109
reading through the examples we hope that you are inspired to think of exciting
1110
new ways to get the most out of your scientific data. If you think SrFit can
1211
help you with that, please feel free to contact us through the DiffPy website.
1312

1413
http://www.diffpy.org
1514

16-
17-
Overview
18-
----------
15+
## Overview
1916

2017
Three things are required for optimization: a function that generates a
2118
quantity to be minimized, variables that can be used to manipulate that
2219
function and an algorithm that can drive the function output to a smaller value
23-
by steering the variables. For scientific purposes, the quantity to be
20+
by steering the variables. For scientific purposes, the quantity to be
2421
minimized is the disagreement between a measured profile and a theoretical
2522
profile. The scientific understanding of the system under consideration partly
2623
determines the suitability of the theoretical profile generator and the
@@ -30,38 +27,36 @@ The purpose of SrFit is to give users the means to combine known information
3027
about a system of interest in order to extract scientifically relevant
3128
quantities, and thus understanding from it. Various experimental procedures and
3229
theoretical calculations may be needed to gain the desired understanding of the
33-
system. SrFit helps users combine these views of the system in a coherent and
30+
system. SrFit helps users combine these views of the system in a coherent and
3431
consistent manner.
3532

3633
To achieve this purpose, SrFit provides:
3734

38-
1) a function to be optimized (the residual) given one or more measured
35+
1. a function to be optimized (the residual) given one or more measured
3936
profiles, one or more profile generators and variables to be steered by an
4037
optimizer.
41-
2) constraints and restraints that encapsulate known information about the
38+
2. constraints and restraints that encapsulate known information about the
4239
system.
43-
3) a clearly defined programming interface that developers can use to add their
40+
3. a clearly defined programming interface that developers can use to add their
4441
own profile generators, thereby enabling the combination of more views of a
4542
system.
46-
4) an equation building interface that allows users to tweak profile generators
43+
4. an equation building interface that allows users to tweak profile generators
4744
when scientific understanding of a system is more advanced than the existing
4845
software.
4946

5047
The examples described below will go into detail about each of these points.
5148

49+
## Examples
5250

53-
Examples
54-
----------
55-
56-
The following examples are contained in the *doc/examples/* directory of the
57-
SrFit source distribution. They can be downloaded from
51+
The following examples are contained in the _doc/examples/_ directory of the
52+
SrFit source distribution. They can be downloaded from
5853
http://dev.danse.us/packages/srfit_examples-alpha9.zip
5954

6055
For each example, start by running the example by typing in the command line ::
6156

6257
python example.py
6358

64-
where *example.py* represents the example file. The output will show on screen
59+
where _example.py_ represents the example file. The output will show on screen
6560
and a plot window will display. Once you've studied the output and plot, close
6661
the plot window and open the example file. In the file there will be a
6762
description of what the script is doing and the purpose of the example. By
@@ -73,97 +68,94 @@ them in the order listed below.
7368

7469
Basic:
7570

76-
* gaussianrecipe.py_
77-
Introductory recipe building and configuration. This introduces the
78-
fundamental classes in SrFit.
71+
- gaussianrecipe.py\_
72+
Introductory recipe building and configuration. This introduces the
73+
fundamental classes in SrFit.
7974

80-
* debyemodel.py_
81-
Introductory recipe building and configuration. This shows how to use a
82-
function created by someone else in a refinement. This example also
83-
introduces restraints.
75+
- debyemodel.py\_
76+
Introductory recipe building and configuration. This shows how to use a
77+
function created by someone else in a refinement. This example also
78+
introduces restraints.
8479

85-
* debyemodelII.py_
86-
Refine two different values of a variable from two different regions of a
87-
profile. This example introduces constraints and working with multiple
88-
contributions to a fit.
80+
- debyemodelII.py\_
81+
Refine two different values of a variable from two different regions of a
82+
profile. This example introduces constraints and working with multiple
83+
contributions to a fit.
8984

9085
Advanced:
9186

92-
* gaussiangenerator.py_
93-
Create a custom ProfileGenerator and use it in a refinement. This is an
94-
instructive extension to gaussianrecipe.py_.
95-
96-
* npintensity.py_
97-
Use diffpy.structure to build a nanoparticle intensity generator, and use
98-
it to refine a structure to simulated data.
87+
- gaussiangenerator.py*
88+
Create a custom ProfileGenerator and use it in a refinement. This is an
89+
instructive extension to gaussianrecipe.py*.
9990

100-
* npintensityII.py_
101-
Use the calculator built in npintensity.py to simultaneously refine a
102-
structure to two data sets.
91+
- npintensity.py\_
92+
Use diffpy.structure to build a nanoparticle intensity generator, and use
93+
it to refine a structure to simulated data.
10394

95+
- npintensityII.py\_
96+
Use the calculator built in npintensity.py to simultaneously refine a
97+
structure to two data sets.
10498

105-
Use Cases
106-
-----------
99+
## Use Cases
107100

108101
There are several examples that demonstrate various SrFit use cases. These do
109102
not adopt the tutorial format of the previous examples. Regardless, developers
110103
should read through these use cases to gain an understanding of PDF and SAS
111104
refinement with SrFit.
112105

113-
* crystalpdf.py_
114-
Refine a diffpy.structure crystal to PDF data using automatic explicit
115-
space group constraints.
106+
- crystalpdf.py\_
107+
Refine a diffpy.structure crystal to PDF data using automatic explicit
108+
space group constraints.
116109

117-
* simplepdf.py_
118-
As crystalpdf.py_, but with a simplified interface.
110+
- simplepdf.py*
111+
As crystalpdf.py*, but with a simplified interface.
119112

120-
* crystalpdfobjcryst.py_
121-
Refine a pyobjcryst crystal to PDF data using automatic implicit space
122-
group constraints.
113+
- crystalpdfobjcryst.py\_
114+
Refine a pyobjcryst crystal to PDF data using automatic implicit space
115+
group constraints.
123116

124-
* crystalpdftwophase.py_
125-
Refine a two-phase structure to PDF data using two profile generators.
117+
- crystalpdftwophase.py\_
118+
Refine a two-phase structure to PDF data using two profile generators.
126119

127-
* simplepdftwophase.py_
128-
crystalpdftwophase.py_ using the simplified PDFContribution interface.
120+
- simplepdftwophase.py*
121+
crystalpdftwophase.py* using the simplified PDFContribution interface.
129122

130-
* crystalpdftwodata.py_
131-
Refine a single structure to x-ray and neutron data simultaneously.
123+
- crystalpdftwodata.py\_
124+
Refine a single structure to x-ray and neutron data simultaneously.
132125

133-
* crystalpdfall.py_
134-
Refine a two-phase structure using four data sets.
126+
- crystalpdfall.py\_
127+
Refine a two-phase structure using four data sets.
135128

136-
* nppdfobjcryst.py_
137-
Refine the C60 structure to real data.
129+
- nppdfobjcryst.py\_
130+
Refine the C60 structure to real data.
138131

139-
* nppdfcrystal.py_
140-
Fit a nanoparticle PDF as a crystal PDF attenuated by a nanoparticle form
141-
factor.
132+
- nppdfcrystal.py\_
133+
Fit a nanoparticle PDF as a crystal PDF attenuated by a nanoparticle form
134+
factor.
142135

143-
* coreshellnp.py_
144-
As above, but fit the PDF from core-shell nanoparticles.
136+
- coreshellnp.py\_
137+
As above, but fit the PDF from core-shell nanoparticles.
145138

146-
* ellipsoidsas.py_
147-
Refine an ellipsoid SAS model to ideal data.
139+
- ellipsoidsas.py\_
140+
Refine an ellipsoid SAS model to ideal data.
148141

149-
* nppdfsas.py_
150-
Refine PDF from nanoparticle of assumed shape using a crystal model and SAS
151-
data from the same system.
142+
- nppdfsas.py\_
143+
Refine PDF from nanoparticle of assumed shape using a crystal model and SAS
144+
data from the same system.
152145

153-
Miscellaneous
154-
--------------
146+
## Miscellaneous
155147

156148
These demonstrate other SrFit features. These are in flux and may not be in
157149
future versions.
158150

159-
* simplerecipe.py_
160-
This introduces the SimpleRecipe class that is a FitRecipe with an embedded
161-
Profile and FitContribution. SimpleRecipe exposes methods from the Profile
162-
and FitContribution, and adds other methods so it is easy to set up a
163-
simple fit.
164-
165-
* interface.py_
166-
This example introduces some interface enhancements that allow the SrFit
167-
recipes to be written with less code. This is not the same as a
168-
full-featured scripting interface, but rather somewhere in between a
169-
scripting interface and the API.
151+
- simplerecipe.py\_
152+
This introduces the SimpleRecipe class that is a FitRecipe with an embedded
153+
Profile and FitContribution. SimpleRecipe exposes methods from the Profile
154+
and FitContribution, and adds other methods so it is easy to set up a
155+
simple fit.
156+
157+
- interface.py\_
158+
This example introduces some interface enhancements that allow the SrFit
159+
recipes to be written with less code. This is not the same as a
160+
full-featured scripting interface, but rather somewhere in between a
161+
scripting interface and the API.

0 commit comments

Comments
 (0)