Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
de843cf
deprecate PDFParser
cadenmyers13 Mar 17, 2026
567c8a1
build parse_file and deprecate getNumBank, selectBank, getFormat, get…
cadenmyers13 Mar 17, 2026
172fced
add ProfileParser to __init__ so it can be imported from fitbase
cadenmyers13 Mar 17, 2026
9680c77
add test files as conftest fixture
cadenmyers13 Mar 17, 2026
5568579
use ProfileParser in PDFContribution, replacing PDFParser
cadenmyers13 Mar 17, 2026
937e11f
Use ProfileParser instead of PDFParser for fitrecipe testing
cadenmyers13 Mar 17, 2026
97cfc58
getData --> get_data, and getMetaData --> get_metadata in Profile
cadenmyers13 Mar 17, 2026
9544243
add set_parsed_profile test with ProfileParser
cadenmyers13 Mar 17, 2026
a616dc2
update examples with new parser
cadenmyers13 Mar 17, 2026
515205c
update test_pdf to reflect new parser
cadenmyers13 Mar 17, 2026
7eaea4b
update old formatted test data to get parser to pass tests
cadenmyers13 Mar 17, 2026
dd32346
add test for ProfileParser
cadenmyers13 Mar 17, 2026
ecead8d
update sas module and test to reflect new changes
cadenmyers13 Mar 17, 2026
51d2a43
news
cadenmyers13 Mar 17, 2026
62b3af5
rm comment
cadenmyers13 Mar 17, 2026
653c98d
blank commit to fix pre-commit
cadenmyers13 Mar 17, 2026
63aa9e9
run pre-commit autoupdate and run pre-commit
cadenmyers13 Mar 17, 2026
985e474
set python version to 3.13 to pin pre-commit CI
cadenmyers13 Mar 17, 2026
17c9971
pin only docformatter to python3.13
cadenmyers13 Mar 17, 2026
ab44228
rm python3.13 pin on pre-commit-config for now
cadenmyers13 Mar 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ci:
submodules: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
Expand All @@ -21,45 +21,45 @@ repos:
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.4.2
rev: 26.3.1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
rev: 7.3.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 8.0.1
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
rev: 0.9.1
hooks:
- id: nbstripout
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: no-commit-to-branch
name: Prevent Commit to Main Branch
args: ["--branch", "main"]
stages: [pre-commit]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.2
hooks:
- id: codespell
additional_dependencies:
- tomli
# prettier - multi formatter for .json, .yml, and .md files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
rev: v4.0.0-alpha.8
hooks:
- id: prettier
additional_dependencies:
- "prettier@^3.2.4"
# docformatter - PEP 257 compliant docstring formatter
- repo: https://github.com/s-weigand/docformatter
rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.7
hooks:
- id: docformatter
additional_dependencies: [tomli]
Expand Down
5 changes: 3 additions & 2 deletions docs/examples/coreshellnp.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
FitRecipe,
FitResults,
Profile,
ProfileParser,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.pdf import PDFGenerator

# Example Code

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

# Load data and add it to the profile
parser = PDFParser()
parser = ProfileParser()
parser.parseFile(datname)
profile.load_parsed_data(parser)
profile.set_calculation_range(xmin=1.5, xmax=45, dx=0.1)
Expand Down
12 changes: 7 additions & 5 deletions docs/examples/crystalpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
FitRecipe,
FitResults,
Profile,
ProfileParser,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.pdf import PDFGenerator
from diffpy.structure import Structure

######
Expand All @@ -48,12 +49,12 @@ def makeRecipe(ciffile, datname):
profile = Profile()

# Load data and add it to the Profile. Unlike in other examples, we use a
# class (PDFParser) to help us load the data. This class will read the data
# and relevant metadata from a two- to four-column data file generated
# class (ProfileParser) to help us load the data. This class will read the
# data and relevant metadata from a two- to four-column data file generated
# with PDFGetX2 or PDFGetN. The metadata will be passed to the PDFGenerator
# when they are associated in the FitContribution, which saves some
# configuration steps.
parser = PDFParser()
parser = ProfileParser()
parser.parseFile(datname)
profile.load_parsed_data(parser)
profile.set_calculation_range(xmax=20)
Expand All @@ -62,7 +63,8 @@ def makeRecipe(ciffile, datname):
# The PDFGenerator is for configuring and calculating a PDF profile. Here,
# we want to refine a Structure object from diffpy.structure. We tell the
# PDFGenerator that with the 'setStructure' method. All other configuration
# options will be inferred from the metadata that is read by the PDFParser.
# options will be inferred from the metadata that is read by the
# ProfileParser.
# In particular, this will set the scattering type (x-ray or neutron), the
# Qmax value, as well as initial values for the non-structural Parameters.
generator = PDFGenerator("G")
Expand Down
5 changes: 3 additions & 2 deletions docs/examples/crystalpdfall.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
FitRecipe,
FitResults,
Profile,
ProfileParser,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.pdf import PDFGenerator

######
# Example Code
Expand All @@ -37,7 +38,7 @@
def makeProfile(datafile):
"""Make an place data within a Profile."""
profile = Profile()
parser = PDFParser()
parser = ProfileParser()
parser.parseFile(datafile)
profile.load_parsed_data(parser)
profile.set_calculation_range(xmax=20)
Expand Down
13 changes: 7 additions & 6 deletions docs/examples/crystalpdfobjcryst.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
FitRecipe,
FitResults,
Profile,
ProfileParser,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.pdf import PDFGenerator

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

# Load data and add it to the Profile. As before we use a PDFParser. The
# metadata is still passed to the PDFGenerator later on. The interaction
# between the PDFGenerator and the metadata does not depend on type of
# structure being refined.
parser = PDFParser()
# Load data and add it to the Profile. As before we use a ProfileParser.
# The metadata is still passed to the PDFGenerator later on.
# The interaction between the PDFGenerator and the metadata does not
# depend on type of structure being refined.
parser = ProfileParser()
parser.parseFile(datname)
profile.load_parsed_data(parser)
profile.set_calculation_range(xmax=20)
Expand Down
7 changes: 4 additions & 3 deletions docs/examples/crystalpdftwodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
FitRecipe,
FitResults,
Profile,
ProfileParser,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.pdf import PDFGenerator

######
# Example Code
Expand All @@ -46,12 +47,12 @@ def makeRecipe(ciffile, xdatname, ndatname):
nprofile = Profile()

# Load data and add it to the proper Profile.
parser = PDFParser()
parser = ProfileParser()
parser.parseFile(xdatname)
xprofile.load_parsed_data(parser)
xprofile.set_calculation_range(xmax=20)

parser = PDFParser()
parser = ProfileParser()
parser.parseFile(ndatname)
nprofile.load_parsed_data(parser)
nprofile.set_calculation_range(xmax=20)
Expand Down
5 changes: 3 additions & 2 deletions docs/examples/crystalpdftwophase.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
FitRecipe,
FitResults,
Profile,
ProfileParser,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.pdf import PDFGenerator

######
# Example Code
Expand All @@ -43,7 +44,7 @@ def makeRecipe(niciffile, siciffile, datname):
profile = Profile()

# Load data and add it to the profile
parser = PDFParser()
parser = ProfileParser()
parser.parseFile(datname)
profile.load_parsed_data(parser)
profile.set_calculation_range(xmax=20)
Expand Down
5 changes: 3 additions & 2 deletions docs/examples/nppdfcrystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
FitRecipe,
FitResults,
Profile,
ProfileParser,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.pdf import PDFGenerator


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

pdfparser = PDFParser()
pdfparser = ProfileParser()
pdfparser.parseFile(grdata)
pdfprofile.load_parsed_data(pdfparser)
pdfprofile.set_calculation_range(xmin=0.1, xmax=20)
Expand Down
5 changes: 3 additions & 2 deletions docs/examples/nppdfsas.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
FitRecipe,
FitResults,
Profile,
ProfileParser,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.pdf import PDFGenerator
from diffpy.srfit.pdf.characteristicfunctions import SASCF
from diffpy.srfit.sas import SASGenerator, SASParser

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

# Create a PDF contribution as before
pdfprofile = Profile()
pdfparser = PDFParser()
pdfparser = ProfileParser()
pdfparser.parseFile(grdata)
pdfprofile.load_parsed_data(pdfparser)
pdfprofile.set_calculation_range(xmin=0.1, xmax=20)
Expand Down
29 changes: 29 additions & 0 deletions news/profileparser_dep.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
**Added:**

* Add ``parse_file`` method to ``ProfileParser`` to parse a file directly with ``load_data`` from ``diffpy.utils``.
* Add ``get_num_bank`` method to ``ProfileParser`` to replace ``getNumBank``.
* Add ``select_bank`` method to ``ProfileParser`` to replace ``selectBank``.
* Add ``get_format`` method to ``ProfileParser`` to replace ``getFormat``.
* Add ``get_data`` method to ``ProfileParser`` to replace ``getData``.
* Add ``get_meta_data`` method to ``ProfileParser`` to replace ``getMetaData``.

**Changed:**

* <news item>

**Deprecated:**

* Deprecate ``PDFParser``. Use ``ProfileParser`` instead.
* Deprecate ``getNumBank``, ``selectBank``, ``getFormat``, ``getData``, and ``getMetaData`` in ``ProfileParser``.

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
1 change: 1 addition & 0 deletions src/diffpy/srfit/equation/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
> beq = c*f(a,b)
> eq = beq.makeEquation()
"""

import inspect
import numbers
import token
Expand Down
2 changes: 2 additions & 0 deletions src/diffpy/srfit/fitbase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"Profile",
"ProfileGenerator",
"SimpleRecipe",
"ProfileParser",
]

from diffpy.srfit.fitbase.calculator import Calculator
Expand All @@ -48,6 +49,7 @@
from diffpy.srfit.fitbase.fitresults import FitResults, initializeRecipe
from diffpy.srfit.fitbase.profile import Profile
from diffpy.srfit.fitbase.profilegenerator import ProfileGenerator
from diffpy.srfit.fitbase.profileparser import ProfileParser
from diffpy.srfit.fitbase.simplerecipe import SimpleRecipe

# End of file
4 changes: 2 additions & 2 deletions src/diffpy/srfit/fitbase/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def load_parsed_data(self, parser):

This sets the xobs, yobs, dyobs arrays as well as the metadata.
"""
x, y, junk, dy = parser.getData()
self.meta = dict(parser.getMetaData())
x, y, dx, dy = parser.get_data()
self.meta = dict(parser.get_metadata())
self.set_observed_profile(x, y, dy)
return

Expand Down
Loading
Loading