Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.4.0 #177 +/- ##
=======================================
Coverage 99.15% 99.15%
=======================================
Files 14 14
Lines 2359 2359
=======================================
Hits 2339 2339
Misses 20 20 🚀 New features to boost your workflow:
|
sbillinge
reviewed
Mar 6, 2026
| return stru | ||
|
|
||
| def toLines(self, stru): | ||
| """Convert `Structure` stru to a list of lines in PDFfit format. |
Contributor
There was a problem hiding this comment.
@stevenhua0320 this is a lot of lines being deleted. Normally, this would be the new function. Please can you check that everything is ok here and confirm before I merge this? Thanks.
Contributor
Author
There was a problem hiding this comment.
@sbillinge I have checked this. This is because in the previous PR I forgot to replace the old function with the new function call. Originally I have created the new function but forgot to replace it. This is the current code in this branch. I also run the pytest and everything is right.
def toLines(self, stru):
"""This function has been deprecated and will be removed in
version 4.0.0.
Please use diffpy.structure.P_pdffit.toLines instead.
"""
return self.to_lines(stru)
def to_lines(self, stru):
"""Convert `Structure` stru to a list of lines in PDFfit format.
Parameters
----------
stru : Structure
Structure to be converted.
Returns
-------
list of str
List of lines in PDFfit format.
"""
# build the stru_pdffit dictionary initialized from the defaults
# in PDFFitStructure
stru_pdffit = PDFFitStructure().pdffit
if stru.pdffit:
stru_pdffit.update(stru.pdffit)
lines = []
# default values of standard deviations
d_sigxyz = numpy.zeros(3, dtype=float)
d_sigo = 0.0
d_sigU = numpy.zeros((3, 3), dtype=float)
# here we can start
line = "title " + stru.title
lines.append(line.strip())
lines.append("format pdffit")
lines.append("scale %9.6f" % stru_pdffit["scale"])
lines.append(
"sharp %9.6f, %9.6f, %9.6f, %9.6f"
% (
stru_pdffit["delta2"],
stru_pdffit["delta1"],
stru_pdffit["sratio"],
stru_pdffit["rcut"],
)
)
lines.append("spcgr " + stru_pdffit["spcgr"])
if stru_pdffit.get("spdiameter", 0.0) > 0.0:
line = "shape sphere, %g" % stru_pdffit["spdiameter"]
lines.append(line)
if stru_pdffit.get("stepcut", 0.0) > 0.0:
line = "shape stepcut, %g" % stru_pdffit["stepcut"]
lines.append(line)
lat = stru.lattice
lines.append(
"cell %9.6f, %9.6f, %9.6f, %9.6f, %9.6f, %9.6f"
% (lat.a, lat.b, lat.c, lat.alpha, lat.beta, lat.gamma)
)
lines.append("dcell %9.6f, %9.6f, %9.6f, %9.6f, %9.6f, %9.6f" % tuple(stru_pdffit["dcell"]))
lines.append("ncell %9i, %9i, %9i, %9i" % (1, 1, 1, len(stru)))
lines.append("atoms")
for a in stru:
ad = a.__dict__
lines.append(
"%-4s %17.8f %17.8f %17.8f %12.4f"
% (
a.element.upper(),
a.xyz[0],
a.xyz[1],
a.xyz[2],
a.occupancy,
)
)
sigmas = numpy.concatenate((ad.get("sigxyz", d_sigxyz), [ad.get("sigo", d_sigo)]))
lines.append(" %18.8f %17.8f %17.8f %12.4f" % tuple(sigmas))
sigU = ad.get("sigU", d_sigU)
Uii = (a.U[0][0], a.U[1][1], a.U[2][2])
Uij = (a.U[0][1], a.U[0][2], a.U[1][2])
sigUii = (sigU[0][0], sigU[1][1], sigU[2][2])
sigUij = (sigU[0][1], sigU[0][2], sigU[1][2])
lines.append(" %18.8f %17.8f %17.8f" % Uii)
lines.append(" %18.8f %17.8f %17.8f" % sigUii)
lines.append(" %18.8f %17.8f %17.8f" % Uij)
lines.append(" %18.8f %17.8f %17.8f" % sigUij)
return lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@sbillinge ready to review. Note that I realized in the previous
getParserandtoLinesprocess I missed to replace the deprecation docstring for all of thegetParserand one of the function replacement toto_linescall. In this PR I also supplement that.