Skip to content

Level 5 #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# As of now, flake8 does not natively support configuration via pyproject.toml
# https://github.com/microsoft/vscode-flake8/issues/135
[flake8]
exclude =
.git,
Expand Down
1 change: 1 addition & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[settings]
# Keep import statement below line_length character limit
line_length = 115
multi_line_output = 3
include_trailing_comma = True
22 changes: 16 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ build-backend = "setuptools.build_meta"
name = "diffpy.structure"
dynamic=['version', 'dependencies']
authors = [
{ name="Simon J.L. Billinge group", email="[email protected]" },
{ name="Simon Billinge", email="[email protected]" },
]
maintainers = [
{ name="Simon J.L. Billinge group", email="[email protected]" },
{ name="Simon Billinge", email="[email protected]" },
]
description = "Crystal structure container and parsers for structure formats."
keywords = ['diffpy', 'crystal structure data storage CIF PDB']
keywords = ['diffpy', 'crystal structure data storage', 'CIF', 'PDB']
readme = "README.rst"
requires-python = ">=3.11, <3.14"
classifiers = [
Expand All @@ -32,13 +32,13 @@ classifiers = [
'Topic :: Scientific/Engineering :: Chemistry',
]

[project.scripts]
transtru = "diffpy.structure.apps.transtru:main"

[project.urls]
Homepage = "https://github.com/diffpy/diffpy.structure/"
Issues = "https://github.com/diffpy/diffpy.structure/issues/"

[project.scripts]
transtru = "diffpy.structure.apps.transtru:main"

[tool.setuptools-git-versioning]
enabled = true
template = "{tag}"
Expand All @@ -54,6 +54,16 @@ namespaces = false # to disable scanning PEP 420 namespaces (true by default)
[tool.setuptools.dynamic]
dependencies = {file = ["requirements/pip.txt"]}

[tool.codespell]
exclude-file = ".codespell/ignore_lines.txt"
ignore-words = ".codespell/ignore_words.txt"
skip = "*.cif,*.dat"

[tool.docformatter]
recursive = true
wrap-summaries = 72
wrap-descriptions = 72

[tool.black]
line-length = 115
include = '\.pyi?$'
Expand Down
11 changes: 1 addition & 10 deletions src/diffpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
##############################################################################
#
# (c) 2024 The Trustees of Columbia University in the City of New York.
# (c) 2024-2025 The Trustees of Columbia University in the City of New York.
# All rights reserved.
#
# File coded by: Billinge Group members and community contributors.
Expand All @@ -12,12 +12,3 @@
# See LICENSE.rst for license information.
#
##############################################################################

"""Blank namespace package for module diffpy."""


from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)

# End of file
8 changes: 3 additions & 5 deletions src/diffpy/structure/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#!/usr/bin/env python
##############################################################################
#
# (c) 2024 The Trustees of Columbia University in the City of New York.
# (c) 2024-2025 The Trustees of Columbia University in the City of New York.
# All rights reserved.
#
# File coded by: Billinge Group members and community contributors.
# File coded by: Chris Farrow, Pavol Juhas, Simon Billinge, Billinge Group members.
#
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/diffpy/diffpy.structure/graphs/contributors
#
# See LICENSE.rst for license information.
#
##############################################################################

"""
Crystal structure container and parsers for structure formats.
"""Crystal structure container and parsers for structure formats.

Classes related to the structure of materials:
* Atom
Expand Down
6 changes: 3 additions & 3 deletions src/diffpy/structure/_legacy_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
# See LICENSE.txt for license information.
#
##############################################################################

"""
Support import of old camel-case module names with DeprecationWarning.
"""Support import of old camel-case module names with
DeprecationWarning.

The imported camel-case modules are aliases for the current module
instances. Their `__name__` attributes are thus all in lower-case.
Expand Down Expand Up @@ -61,6 +60,7 @@ def find_spec(self, fullname, path=None, target=None):

class MapRenamedStructureModule(importlib.abc.Loader):
"""Loader for old camel-case module names.

Import the current module and alias it under the old name.
"""

Expand Down
1 change: 0 additions & 1 deletion src/diffpy/structure/apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""Script applications that use the `diffpy.structure` package."""
9 changes: 4 additions & 5 deletions src/diffpy/structure/apps/anyeye.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""
Anyeye view structure file in atomeye.
"""Anyeye view structure file in atomeye.

Usage: ``anyeye [options] strufile``

Expand Down Expand Up @@ -65,7 +63,8 @@


def usage(style=None):
"""Show usage info, for ``style=="brief"`` show only first 2 lines."""
"""Show usage info, for ``style=="brief"`` show only first 2
lines."""
import os.path

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


def parseFormula(formula):
"""Parse chemical formula and return a list of elements"""
"""Parse chemical formula and return a list of elements."""
# remove all blanks
formula = re.sub(r"\s", "", formula)
if not re.match("^[A-Z]", formula):
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/structure/apps/transtru.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""Translate structure file to different format.

Usage: ``transtru INFMT..OUTFMT strufile``
Expand Down Expand Up @@ -44,7 +43,8 @@


def usage(style=None):
"""Show usage info, for ``style=="brief"`` show only first 2 lines."""
"""Show usage info, for ``style=="brief"`` show only first 2
lines."""
import os.path

myname = os.path.basename(sys.argv[0])
Expand Down
18 changes: 10 additions & 8 deletions src/diffpy/structure/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""
Provide class Atom for managing properties of an atom in structure model.
"""
"""Provide class Atom for managing properties of an atom in structure
model."""

import numpy

Expand Down Expand Up @@ -176,7 +174,8 @@ def msdLat(self, vl):
return msd

def msdCart(self, vc):
"""Calculate mean square displacement along the Cartesian vector.
"""Calculate mean square displacement along the Cartesian
vector.

Parameters
----------
Expand Down Expand Up @@ -252,7 +251,8 @@ def __copy__(self, target=None):

@property
def xyz_cartn(self):
"""numpy.ndarray: Atom position in absolute Cartesian coordinates.
"""numpy.ndarray: Atom position in absolute Cartesian
coordinates.

This is computed from fractional coordinates `xyz` and the
current `lattice` setup. Assignment to *xyz_cartn* or
Expand Down Expand Up @@ -301,7 +301,8 @@ def anisotropy(self, value):

@property
def U(self):
"""numpy.ndarray : The 3x3 matrix of anisotropic atomic displacements.
"""numpy.ndarray : The 3x3 matrix of anisotropic atomic
displacements.

For isotropic displacements (when `anisotropy` is ``False``)
assignment to *U* uses only the first ``Unew[0, 0]`` element
Expand Down Expand Up @@ -537,7 +538,8 @@ def __setitem__(self, idx, value):
return

def __array_wrap__(self, out_arr, context=None, return_scalar=None):
"""Ensure math operations on this type yield standard numpy array."""
"""Ensure math operations on this type yield standard numpy
array."""
return out_arr.view(numpy.ndarray)


Expand Down
1 change: 0 additions & 1 deletion src/diffpy/structure/expansion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""Methods and classes for manipulating `Structure` instances.

Package content:
Expand Down
4 changes: 1 addition & 3 deletions src/diffpy/structure/expansion/makeellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""Make a spheroid nanoparticle from a template structure."""

from math import ceil
Expand Down Expand Up @@ -42,8 +41,7 @@ def makeSphere(S, radius):


def makeEllipsoid(S, a, b=None, c=None):
"""
Cut a `Structure` out of another one.
"""Cut a `Structure` out of another one.

Parameters
----------
Expand Down
1 change: 0 additions & 1 deletion src/diffpy/structure/expansion/shapeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""Utilities for making shapes."""


Expand Down
7 changes: 3 additions & 4 deletions src/diffpy/structure/expansion/supercell_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""This module contains functions for simple `Structure` manipulation."""
"""This module contains functions for simple `Structure`
manipulation."""

import numpy

from diffpy.structure import Atom, Structure


def supercell(S, mno):
"""
Perform supercell expansion for a `Structure`.
"""Perform supercell expansion for a `Structure`.

New `lattice` parameters are multiplied and fractional coordinates
divided by corresponding multiplier. New `Atoms` are grouped with
Expand Down
7 changes: 4 additions & 3 deletions src/diffpy/structure/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""Class Lattice stores properties and provides simple operations in lattice
coordinate system.
"""Class Lattice stores properties and provides simple operations in
lattice coordinate system.

Attributes
----------
Expand Down Expand Up @@ -442,6 +441,7 @@ def setLatBase(self, base):

def abcABG(self):
"""Return the cell parameters in the standard setting.

Returns
-------
tuple :
Expand All @@ -452,6 +452,7 @@ def abcABG(self):

def reciprocal(self):
"""Return the reciprocal lattice of the current lattice.

Returns
-------
Lattice
Expand Down
1 change: 0 additions & 1 deletion src/diffpy/structure/parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""Conversion plugins for various structure formats.

The recognized structure formats are defined by subclassing `StructureParser`,
Expand Down
14 changes: 8 additions & 6 deletions src/diffpy/structure/parsers/p_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################

"""Parser for automatic file format detection.

This Parser does not provide the the `toLines()` method.
Expand Down Expand Up @@ -54,6 +53,7 @@ def __init__(self, **kw):
# parseLines helpers
def _getOrderedFormats(self):
"""Build a list of relevance ordered structure formats.

This only works when `self.filename` has a known extension.
"""
from diffpy.structure.parsers import inputFormats
Expand All @@ -77,7 +77,8 @@ def _getOrderedFormats(self):
return ofmts

def parseLines(self, lines):
"""Detect format and create `Structure` instance from a list of lines.
"""Detect format and create `Structure` instance from a list of
lines.

Set format attribute to the detected file format.

Expand Down Expand Up @@ -119,7 +120,8 @@ def parse(self, s):
return self._wrapParseMethod("parse", s)

def parseFile(self, filename):
"""Detect format and create Structure instance from an existing file.
"""Detect format and create Structure instance from an existing
file.

Set format attribute to the detected file format.

Expand All @@ -144,9 +146,9 @@ def parseFile(self, filename):
return self._wrapParseMethod("parseFile", filename)

def _wrapParseMethod(self, method, *args, **kwargs):
"""A helper evaluator method that try the specified parse method with
each registered structure parser and return the first successful
resul.
"""A helper evaluator method that try the specified parse method
with each registered structure parser and return the first
successful resul.

Structure parsers that match structure file extension are
tried first.
Expand Down
Loading