Skip to content

Commit abc25b1

Browse files
authored
Merge pull request #138 from TingwenZhang/level-5
Level 5
2 parents e5a2e4c + 1acf3f4 commit abc25b1

Some content is hidden

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

47 files changed

+287
-280
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# As of now, flake8 does not natively support configuration via pyproject.toml
2+
# https://github.com/microsoft/vscode-flake8/issues/135
13
[flake8]
24
exclude =
35
.git,

.isort.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[settings]
2+
# Keep import statement below line_length character limit
23
line_length = 115
34
multi_line_output = 3
45
include_trailing_comma = True

pyproject.toml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ build-backend = "setuptools.build_meta"
66
name = "diffpy.structure"
77
dynamic=['version', 'dependencies']
88
authors = [
9-
{ name="Simon J.L. Billinge group", email="[email protected]" },
9+
{ name="Simon Billinge", email="[email protected]" },
1010
]
1111
maintainers = [
12-
{ name="Simon J.L. Billinge group", email="[email protected]" },
12+
{ name="Simon Billinge", email="[email protected]" },
1313
]
1414
description = "Crystal structure container and parsers for structure formats."
15-
keywords = ['diffpy', 'crystal structure data storage CIF PDB']
15+
keywords = ['diffpy', 'crystal structure data storage', 'CIF', 'PDB']
1616
readme = "README.rst"
1717
requires-python = ">=3.11, <3.14"
1818
classifiers = [
@@ -32,13 +32,13 @@ classifiers = [
3232
'Topic :: Scientific/Engineering :: Chemistry',
3333
]
3434

35+
[project.scripts]
36+
transtru = "diffpy.structure.apps.transtru:main"
37+
3538
[project.urls]
3639
Homepage = "https://github.com/diffpy/diffpy.structure/"
3740
Issues = "https://github.com/diffpy/diffpy.structure/issues/"
3841

39-
[project.scripts]
40-
transtru = "diffpy.structure.apps.transtru:main"
41-
4242
[tool.setuptools-git-versioning]
4343
enabled = true
4444
template = "{tag}"
@@ -54,6 +54,16 @@ namespaces = false # to disable scanning PEP 420 namespaces (true by default)
5454
[tool.setuptools.dynamic]
5555
dependencies = {file = ["requirements/pip.txt"]}
5656

57+
[tool.codespell]
58+
exclude-file = ".codespell/ignore_lines.txt"
59+
ignore-words = ".codespell/ignore_words.txt"
60+
skip = "*.cif,*.dat"
61+
62+
[tool.docformatter]
63+
recursive = true
64+
wrap-summaries = 72
65+
wrap-descriptions = 72
66+
5767
[tool.black]
5868
line-length = 115
5969
include = '\.pyi?$'

src/diffpy/__init__.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
##############################################################################
33
#
4-
# (c) 2024 The Trustees of Columbia University in the City of New York.
4+
# (c) 2024-2025 The Trustees of Columbia University in the City of New York.
55
# All rights reserved.
66
#
77
# File coded by: Billinge Group members and community contributors.
@@ -12,12 +12,3 @@
1212
# See LICENSE.rst for license information.
1313
#
1414
##############################################################################
15-
16-
"""Blank namespace package for module diffpy."""
17-
18-
19-
from pkgutil import extend_path
20-
21-
__path__ = extend_path(__path__, __name__)
22-
23-
# End of file

src/diffpy/structure/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
#!/usr/bin/env python
22
##############################################################################
33
#
4-
# (c) 2024 The Trustees of Columbia University in the City of New York.
4+
# (c) 2024-2025 The Trustees of Columbia University in the City of New York.
55
# All rights reserved.
66
#
7-
# File coded by: Billinge Group members and community contributors.
7+
# File coded by: Chris Farrow, Pavol Juhas, Simon Billinge, Billinge Group members.
88
#
99
# See GitHub contributions for a more detailed list of contributors.
1010
# https://github.com/diffpy/diffpy.structure/graphs/contributors
1111
#
1212
# See LICENSE.rst for license information.
1313
#
1414
##############################################################################
15-
16-
"""
17-
Crystal structure container and parsers for structure formats.
15+
"""Crystal structure container and parsers for structure formats.
1816
1917
Classes related to the structure of materials:
2018
* Atom

src/diffpy/structure/_legacy_importer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
# See LICENSE.txt for license information.
1313
#
1414
##############################################################################
15-
16-
"""
17-
Support import of old camel-case module names with DeprecationWarning.
15+
"""Support import of old camel-case module names with
16+
DeprecationWarning.
1817
1918
The imported camel-case modules are aliases for the current module
2019
instances. Their `__name__` attributes are thus all in lower-case.
@@ -61,6 +60,7 @@ def find_spec(self, fullname, path=None, target=None):
6160

6261
class MapRenamedStructureModule(importlib.abc.Loader):
6362
"""Loader for old camel-case module names.
63+
6464
Import the current module and alias it under the old name.
6565
"""
6666

src/diffpy/structure/apps/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
1615
"""Script applications that use the `diffpy.structure` package."""

src/diffpy/structure/apps/anyeye.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
16-
"""
17-
Anyeye view structure file in atomeye.
15+
"""Anyeye view structure file in atomeye.
1816
1917
Usage: ``anyeye [options] strufile``
2018
@@ -65,7 +63,8 @@
6563

6664

6765
def usage(style=None):
68-
"""Show usage info, for ``style=="brief"`` show only first 2 lines."""
66+
"""Show usage info, for ``style=="brief"`` show only first 2
67+
lines."""
6968
import os.path
7069

7170
myname = os.path.basename(sys.argv[0])
@@ -175,7 +174,7 @@ def cleanUp(pd):
175174

176175

177176
def parseFormula(formula):
178-
"""Parse chemical formula and return a list of elements"""
177+
"""Parse chemical formula and return a list of elements."""
179178
# remove all blanks
180179
formula = re.sub(r"\s", "", formula)
181180
if not re.match("^[A-Z]", formula):

src/diffpy/structure/apps/transtru.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
1615
"""Translate structure file to different format.
1716
1817
Usage: ``transtru INFMT..OUTFMT strufile``
@@ -44,7 +43,8 @@
4443

4544

4645
def usage(style=None):
47-
"""Show usage info, for ``style=="brief"`` show only first 2 lines."""
46+
"""Show usage info, for ``style=="brief"`` show only first 2
47+
lines."""
4848
import os.path
4949

5050
myname = os.path.basename(sys.argv[0])

src/diffpy/structure/atom.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
16-
"""
17-
Provide class Atom for managing properties of an atom in structure model.
18-
"""
15+
"""Provide class Atom for managing properties of an atom in structure
16+
model."""
1917

2018
import numpy
2119

@@ -176,7 +174,8 @@ def msdLat(self, vl):
176174
return msd
177175

178176
def msdCart(self, vc):
179-
"""Calculate mean square displacement along the Cartesian vector.
177+
"""Calculate mean square displacement along the Cartesian
178+
vector.
180179
181180
Parameters
182181
----------
@@ -252,7 +251,8 @@ def __copy__(self, target=None):
252251

253252
@property
254253
def xyz_cartn(self):
255-
"""numpy.ndarray: Atom position in absolute Cartesian coordinates.
254+
"""numpy.ndarray: Atom position in absolute Cartesian
255+
coordinates.
256256
257257
This is computed from fractional coordinates `xyz` and the
258258
current `lattice` setup. Assignment to *xyz_cartn* or
@@ -301,7 +301,8 @@ def anisotropy(self, value):
301301

302302
@property
303303
def U(self):
304-
"""numpy.ndarray : The 3x3 matrix of anisotropic atomic displacements.
304+
"""numpy.ndarray : The 3x3 matrix of anisotropic atomic
305+
displacements.
305306
306307
For isotropic displacements (when `anisotropy` is ``False``)
307308
assignment to *U* uses only the first ``Unew[0, 0]`` element
@@ -537,7 +538,8 @@ def __setitem__(self, idx, value):
537538
return
538539

539540
def __array_wrap__(self, out_arr, context=None, return_scalar=None):
540-
"""Ensure math operations on this type yield standard numpy array."""
541+
"""Ensure math operations on this type yield standard numpy
542+
array."""
541543
return out_arr.view(numpy.ndarray)
542544

543545

src/diffpy/structure/expansion/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
1615
"""Methods and classes for manipulating `Structure` instances.
1716
1817
Package content:

src/diffpy/structure/expansion/makeellipsoid.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
1615
"""Make a spheroid nanoparticle from a template structure."""
1716

1817
from math import ceil
@@ -42,8 +41,7 @@ def makeSphere(S, radius):
4241

4342

4443
def makeEllipsoid(S, a, b=None, c=None):
45-
"""
46-
Cut a `Structure` out of another one.
44+
"""Cut a `Structure` out of another one.
4745
4846
Parameters
4947
----------

src/diffpy/structure/expansion/shapeutils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
1615
"""Utilities for making shapes."""
1716

1817

src/diffpy/structure/expansion/supercell_mod.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
16-
"""This module contains functions for simple `Structure` manipulation."""
15+
"""This module contains functions for simple `Structure`
16+
manipulation."""
1717

1818
import numpy
1919

2020
from diffpy.structure import Atom, Structure
2121

2222

2323
def supercell(S, mno):
24-
"""
25-
Perform supercell expansion for a `Structure`.
24+
"""Perform supercell expansion for a `Structure`.
2625
2726
New `lattice` parameters are multiplied and fractional coordinates
2827
divided by corresponding multiplier. New `Atoms` are grouped with

src/diffpy/structure/lattice.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
16-
"""Class Lattice stores properties and provides simple operations in lattice
17-
coordinate system.
15+
"""Class Lattice stores properties and provides simple operations in
16+
lattice coordinate system.
1817
1918
Attributes
2019
----------
@@ -442,6 +441,7 @@ def setLatBase(self, base):
442441

443442
def abcABG(self):
444443
"""Return the cell parameters in the standard setting.
444+
445445
Returns
446446
-------
447447
tuple :
@@ -452,6 +452,7 @@ def abcABG(self):
452452

453453
def reciprocal(self):
454454
"""Return the reciprocal lattice of the current lattice.
455+
455456
Returns
456457
-------
457458
Lattice

src/diffpy/structure/parsers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
1615
"""Conversion plugins for various structure formats.
1716
1817
The recognized structure formats are defined by subclassing `StructureParser`,

src/diffpy/structure/parsers/p_auto.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
1615
"""Parser for automatic file format detection.
1716
1817
This Parser does not provide the the `toLines()` method.
@@ -54,6 +53,7 @@ def __init__(self, **kw):
5453
# parseLines helpers
5554
def _getOrderedFormats(self):
5655
"""Build a list of relevance ordered structure formats.
56+
5757
This only works when `self.filename` has a known extension.
5858
"""
5959
from diffpy.structure.parsers import inputFormats
@@ -77,7 +77,8 @@ def _getOrderedFormats(self):
7777
return ofmts
7878

7979
def parseLines(self, lines):
80-
"""Detect format and create `Structure` instance from a list of lines.
80+
"""Detect format and create `Structure` instance from a list of
81+
lines.
8182
8283
Set format attribute to the detected file format.
8384
@@ -119,7 +120,8 @@ def parse(self, s):
119120
return self._wrapParseMethod("parse", s)
120121

121122
def parseFile(self, filename):
122-
"""Detect format and create Structure instance from an existing file.
123+
"""Detect format and create Structure instance from an existing
124+
file.
123125
124126
Set format attribute to the detected file format.
125127
@@ -144,9 +146,9 @@ def parseFile(self, filename):
144146
return self._wrapParseMethod("parseFile", filename)
145147

146148
def _wrapParseMethod(self, method, *args, **kwargs):
147-
"""A helper evaluator method that try the specified parse method with
148-
each registered structure parser and return the first successful
149-
resul.
149+
"""A helper evaluator method that try the specified parse method
150+
with each registered structure parser and return the first
151+
successful resul.
150152
151153
Structure parsers that match structure file extension are
152154
tried first.

0 commit comments

Comments
 (0)