Skip to content

Commit edb4388

Browse files
authored
Merge pull request #171 from cadenmyers13/profileparser_dep
deprecate: Deprecate function in `ProfileParser` and deprecate `PDFParser`
2 parents 6012bb2 + ce39171 commit edb4388

31 files changed

+683
-108
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ci:
1111
submodules: false
1212
repos:
1313
- repo: https://github.com/pre-commit/pre-commit-hooks
14-
rev: v4.6.0
14+
rev: v6.0.0
1515
hooks:
1616
- id: check-yaml
1717
- id: end-of-file-fixer
@@ -21,46 +21,47 @@ repos:
2121
- id: check-toml
2222
- id: check-added-large-files
2323
- repo: https://github.com/psf/black
24-
rev: 24.4.2
24+
rev: 26.3.1
2525
hooks:
2626
- id: black
2727
- repo: https://github.com/pycqa/flake8
28-
rev: 7.0.0
28+
rev: 7.3.0
2929
hooks:
3030
- id: flake8
3131
- repo: https://github.com/pycqa/isort
32-
rev: 5.13.2
32+
rev: 8.0.1
3333
hooks:
3434
- id: isort
3535
args: ["--profile", "black"]
3636
- repo: https://github.com/kynan/nbstripout
37-
rev: 0.7.1
37+
rev: 0.9.1
3838
hooks:
3939
- id: nbstripout
4040
- repo: https://github.com/pre-commit/pre-commit-hooks
41-
rev: v4.4.0
41+
rev: v6.0.0
4242
hooks:
4343
- id: no-commit-to-branch
4444
name: Prevent Commit to Main Branch
4545
args: ["--branch", "main"]
4646
stages: [pre-commit]
4747
- repo: https://github.com/codespell-project/codespell
48-
rev: v2.3.0
48+
rev: v2.4.2
4949
hooks:
5050
- id: codespell
5151
additional_dependencies:
5252
- tomli
5353
# prettier - multi formatter for .json, .yml, and .md files
5454
- repo: https://github.com/pre-commit/mirrors-prettier
55-
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
55+
rev: v4.0.0-alpha.8
5656
hooks:
5757
- id: prettier
5858
additional_dependencies:
5959
- "prettier@^3.2.4"
6060
# docformatter - PEP 257 compliant docstring formatter
61-
- repo: https://github.com/s-weigand/docformatter
62-
rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c
61+
- repo: https://github.com/PyCQA/docformatter
62+
rev: v1.7.7
6363
hooks:
6464
- id: docformatter
65+
language_version: python3.13
6566
additional_dependencies: [tomli]
6667
args: [--in-place, --config, ./pyproject.toml]

docs/examples/coreshellnp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
FitRecipe,
3030
FitResults,
3131
Profile,
32+
ProfileParser,
3233
)
33-
from diffpy.srfit.pdf import PDFGenerator, PDFParser
34+
from diffpy.srfit.pdf import PDFGenerator
3435

3536
# Example Code
3637

@@ -42,7 +43,7 @@ def makeRecipe(stru1, stru2, datname):
4243
profile = Profile()
4344

4445
# Load data and add it to the profile
45-
parser = PDFParser()
46+
parser = ProfileParser()
4647
parser.parseFile(datname)
4748
profile.load_parsed_data(parser)
4849
profile.set_calculation_range(xmin=1.5, xmax=45, dx=0.1)

docs/examples/crystalpdf.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
FitRecipe,
3333
FitResults,
3434
Profile,
35+
ProfileParser,
3536
)
36-
from diffpy.srfit.pdf import PDFGenerator, PDFParser
37+
from diffpy.srfit.pdf import PDFGenerator
3738
from diffpy.structure import Structure
3839

3940
######
@@ -48,12 +49,12 @@ def makeRecipe(ciffile, datname):
4849
profile = Profile()
4950

5051
# Load data and add it to the Profile. Unlike in other examples, we use a
51-
# class (PDFParser) to help us load the data. This class will read the data
52-
# and relevant metadata from a two- to four-column data file generated
52+
# class (ProfileParser) to help us load the data. This class will read the
53+
# data and relevant metadata from a two- to four-column data file generated
5354
# with PDFGetX2 or PDFGetN. The metadata will be passed to the PDFGenerator
5455
# when they are associated in the FitContribution, which saves some
5556
# configuration steps.
56-
parser = PDFParser()
57+
parser = ProfileParser()
5758
parser.parseFile(datname)
5859
profile.load_parsed_data(parser)
5960
profile.set_calculation_range(xmax=20)
@@ -62,7 +63,8 @@ def makeRecipe(ciffile, datname):
6263
# The PDFGenerator is for configuring and calculating a PDF profile. Here,
6364
# we want to refine a Structure object from diffpy.structure. We tell the
6465
# PDFGenerator that with the 'setStructure' method. All other configuration
65-
# options will be inferred from the metadata that is read by the PDFParser.
66+
# options will be inferred from the metadata that is read by the
67+
# ProfileParser.
6668
# In particular, this will set the scattering type (x-ray or neutron), the
6769
# Qmax value, as well as initial values for the non-structural Parameters.
6870
generator = PDFGenerator("G")

docs/examples/crystalpdfall.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
FitRecipe,
2828
FitResults,
2929
Profile,
30+
ProfileParser,
3031
)
31-
from diffpy.srfit.pdf import PDFGenerator, PDFParser
32+
from diffpy.srfit.pdf import PDFGenerator
3233

3334
######
3435
# Example Code
@@ -37,7 +38,7 @@
3738
def makeProfile(datafile):
3839
"""Make an place data within a Profile."""
3940
profile = Profile()
40-
parser = PDFParser()
41+
parser = ProfileParser()
4142
parser.parseFile(datafile)
4243
profile.load_parsed_data(parser)
4344
profile.set_calculation_range(xmax=20)

docs/examples/crystalpdfobjcryst.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
FitRecipe,
2929
FitResults,
3030
Profile,
31+
ProfileParser,
3132
)
32-
from diffpy.srfit.pdf import PDFGenerator, PDFParser
33+
from diffpy.srfit.pdf import PDFGenerator
3334

3435
######
3536
# Example Code
@@ -42,11 +43,11 @@ def makeRecipe(ciffile, datname):
4243
# This will be used to store the observed and calculated PDF profile.
4344
profile = Profile()
4445

45-
# Load data and add it to the Profile. As before we use a PDFParser. The
46-
# metadata is still passed to the PDFGenerator later on. The interaction
47-
# between the PDFGenerator and the metadata does not depend on type of
48-
# structure being refined.
49-
parser = PDFParser()
46+
# Load data and add it to the Profile. As before we use a ProfileParser.
47+
# The metadata is still passed to the PDFGenerator later on.
48+
# The interaction between the PDFGenerator and the metadata does not
49+
# depend on type of structure being refined.
50+
parser = ProfileParser()
5051
parser.parseFile(datname)
5152
profile.load_parsed_data(parser)
5253
profile.set_calculation_range(xmax=20)

docs/examples/crystalpdftwodata.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
FitRecipe,
3030
FitResults,
3131
Profile,
32+
ProfileParser,
3233
)
33-
from diffpy.srfit.pdf import PDFGenerator, PDFParser
34+
from diffpy.srfit.pdf import PDFGenerator
3435

3536
######
3637
# Example Code
@@ -46,12 +47,12 @@ def makeRecipe(ciffile, xdatname, ndatname):
4647
nprofile = Profile()
4748

4849
# Load data and add it to the proper Profile.
49-
parser = PDFParser()
50+
parser = ProfileParser()
5051
parser.parseFile(xdatname)
5152
xprofile.load_parsed_data(parser)
5253
xprofile.set_calculation_range(xmax=20)
5354

54-
parser = PDFParser()
55+
parser = ProfileParser()
5556
parser.parseFile(ndatname)
5657
nprofile.load_parsed_data(parser)
5758
nprofile.set_calculation_range(xmax=20)

docs/examples/crystalpdftwophase.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
FitRecipe,
3030
FitResults,
3131
Profile,
32+
ProfileParser,
3233
)
33-
from diffpy.srfit.pdf import PDFGenerator, PDFParser
34+
from diffpy.srfit.pdf import PDFGenerator
3435

3536
######
3637
# Example Code
@@ -43,7 +44,7 @@ def makeRecipe(niciffile, siciffile, datname):
4344
profile = Profile()
4445

4546
# Load data and add it to the profile
46-
parser = PDFParser()
47+
parser = ProfileParser()
4748
parser.parseFile(datname)
4849
profile.load_parsed_data(parser)
4950
profile.set_calculation_range(xmax=20)

docs/examples/nppdfcrystal.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
FitRecipe,
3333
FitResults,
3434
Profile,
35+
ProfileParser,
3536
)
36-
from diffpy.srfit.pdf import PDFGenerator, PDFParser
37+
from diffpy.srfit.pdf import PDFGenerator
3738

3839

3940
def makeRecipe(ciffile, grdata):
@@ -42,7 +43,7 @@ def makeRecipe(ciffile, grdata):
4243
# Set up a PDF fit as has been done in other examples.
4344
pdfprofile = Profile()
4445

45-
pdfparser = PDFParser()
46+
pdfparser = ProfileParser()
4647
pdfparser.parseFile(grdata)
4748
pdfprofile.load_parsed_data(pdfparser)
4849
pdfprofile.set_calculation_range(xmin=0.1, xmax=20)

docs/examples/nppdfsas.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
FitRecipe,
3232
FitResults,
3333
Profile,
34+
ProfileParser,
3435
)
35-
from diffpy.srfit.pdf import PDFGenerator, PDFParser
36+
from diffpy.srfit.pdf import PDFGenerator
3637
from diffpy.srfit.pdf.characteristicfunctions import SASCF
3738
from diffpy.srfit.sas import SASGenerator, SASParser
3839

@@ -47,7 +48,7 @@ def makeRecipe(ciffile, grdata, iqdata):
4748

4849
# Create a PDF contribution as before
4950
pdfprofile = Profile()
50-
pdfparser = PDFParser()
51+
pdfparser = ProfileParser()
5152
pdfparser.parseFile(grdata)
5253
pdfprofile.load_parsed_data(pdfparser)
5354
pdfprofile.set_calculation_range(xmin=0.1, xmax=20)

news/profileparser_dep.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
**Added:**
2+
3+
* Add ``parse_file`` method to ``ProfileParser`` to parse a file directly with ``load_data`` from ``diffpy.utils``.
4+
* Add ``get_num_bank`` method to ``ProfileParser`` to replace ``getNumBank``.
5+
* Add ``select_bank`` method to ``ProfileParser`` to replace ``selectBank``.
6+
* Add ``get_format`` method to ``ProfileParser`` to replace ``getFormat``.
7+
* Add ``get_data`` method to ``ProfileParser`` to replace ``getData``.
8+
* Add ``get_meta_data`` method to ``ProfileParser`` to replace ``getMetaData``.
9+
10+
**Changed:**
11+
12+
* <news item>
13+
14+
**Deprecated:**
15+
16+
* Deprecate ``PDFParser``. Use ``ProfileParser`` instead.
17+
* Deprecate ``getNumBank``, ``selectBank``, ``getFormat``, ``getData``, and ``getMetaData`` in ``ProfileParser``.
18+
19+
**Removed:**
20+
21+
* <news item>
22+
23+
**Fixed:**
24+
25+
* <news item>
26+
27+
**Security:**
28+
29+
* <news item>

0 commit comments

Comments
 (0)