Skip to content
Open
18 changes: 9 additions & 9 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,31 +21,31 @@ repos:
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.4.2
rev: 26.5.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: 9.0.0a3
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:
Expand All @@ -58,8 +58,8 @@ repos:
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.8
hooks:
- id: docformatter
additional_dependencies: [tomli]
Expand Down
1 change: 0 additions & 1 deletion devutils/sgtbx_extra_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Not to be included with code distributions.
"""


import math
import re

Expand Down
1 change: 1 addition & 0 deletions news/CI-badge-fix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* No News Added: fix CI badge and target in README.rst


**Changed:**

* <news item>
Expand Down
23 changes: 23 additions & 0 deletions news/pre-commit_edits.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* No news needed: updating docformatter not user facing

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
1 change: 0 additions & 1 deletion src/diffpy/structure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* SymmetryError
"""


import os
import sys

Expand Down
1 change: 0 additions & 1 deletion src/diffpy/structure/_legacy_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
This module is deprecated and will be removed in the future.
"""


import importlib.abc
import sys
from warnings import warn
Expand Down
11 changes: 6 additions & 5 deletions src/diffpy/structure/apps/vesta_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@


def usage(style=None):
"""Show usage info. for ``style=="brief"`` show only first 2 lines.
"""Show usage info.
Parameters
----------
style : str, optional
The usage display style.
for ``style=="brief"`` show only first 2 lines.
Parameters
----------
style : str, optional
The usage display style.
"""
myname = Path(sys.argv[0]).name
msg = __doc__.replace("vestaview", myname)
Expand Down
70 changes: 35 additions & 35 deletions src/diffpy/structure/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@


class Atom(object):
"""Storage of structure information relevant for a single atom.
"""The storage of structure information relevant for a single atom.

This class manages atom information such as element symbol, position
in fractional and Cartesian coordinates, atomic displacement parameters
Expand All @@ -55,10 +55,10 @@ class Atom(object):
By default an empty string. When of the `Atom` type, create
a copy of `atype` and adjust it per other arguments.
xyz : numpy.ndarray, Optional
Fractional coordinates within the associated `lattice`.
The fractional coordinates within the associated `lattice`.
By default ``[0, 0, 0]``.
label : str, Optional
A unique string `label` for referring to this `Atom`.
The unique string `label` for referring to this `Atom`.
By default an empty string.
occupancy : float, Optional
The initial `occupancy` of this atom, by default ``1``.
Expand All @@ -76,25 +76,25 @@ class Atom(object):
*Uisoequiv* arguments may be provided at the same time. Assume
zero atomic displacements when *U* and *Uisoequiv* are unset.
lattice : Lattice, Optional
Coordinate system for the fractional coordinates `xyz`.
The coordinate system for the fractional coordinates `xyz`.
Use the absolute Cartesian system when ``None``.

Attributes
----------
element : str
The string type of the atom. An element or ion symbol.
The string type of the atom. An element or ion symbol, default "".
xyz : numpy.ndarray
The fractional coordinates in the associated `lattice`.
label : str
A unique string label referring to this atom, for example, "C_1".
The unique string label referring to this atom, for example, "C_1".
The *label* can be used to reference this atom when contained in
a `Structure` object.
a `Structure` object, default "".
occupancy : float
The fractional occupancy of this atom.
The fractional occupancy of this atom, default 1.0.
lattice : Lattice
Coordinate system for the fractional coordinates `xyz` and
The coordinate system for the fractional coordinates `xyz` and
the tensor of atomic displacement parameters `U`.
Use the absolute Cartesian coordinates when ``None``.
Use the absolute Cartesian coordinates when ``None`` as the default.

Note
----
Expand All @@ -104,21 +104,17 @@ class Atom(object):
# Private attributes
#
# _U : 3-by-3 ndarray
# Internal storage of the displacement parameters.
# The internal storage of the displacement parameters.

# instance attributes that have immutable default values
element = ""
"""str: Default values of `element`."""

label = ""
"""str: Default values of `label`."""

occupancy = 1.0
"""float: Default values of `occupancy`."""

_anisotropy = False
lattice = None
"""None: Default values of `lattice`."""

def __init__(
self,
Expand Down Expand Up @@ -232,7 +228,7 @@ def msd_cart(self, vc):
return msd

def __repr__(self):
"""String representation of this Atom."""
"""The string representation of this Atom."""
xyz = self.xyz
s = "%-4s %8.6f %8.6f %8.6f %6.4f" % (
self.element,
Expand Down Expand Up @@ -273,29 +269,29 @@ def __copy__(self, target=None):
x = property(
lambda self: self.xyz[0],
lambda self, val: self.xyz.__setitem__(0, val),
doc="float : fractional coordinate *x*, same as ``xyz[0]``.",
doc="The fractional coordinate *x*, same as ``xyz[0]``, as a float",
)
y = property(
lambda self: self.xyz[1],
lambda self, val: self.xyz.__setitem__(1, val),
doc="float : fractional coordinate *y*, same as ``xyz[1]``.",
doc="The fractional coordinate *y*, same as ``xyz[1]``, as a float",
)
z = property(
lambda self: self.xyz[2],
lambda self, val: self.xyz.__setitem__(2, val),
doc="float : fractional coordinate *z*, same as ``xyz[2]``.",
doc="The fractional coordinate *z*, same as ``xyz[2]``, as a float",
)

# xyz_cartn

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

This is computed from fractional coordinates `xyz` and the
current `lattice` setup. Assignment to *xyz_cartn* or
its components is applied on fractional coordinates `xyz`.
current `lattice` setup. Assignment to *xyz_cartn* or its
components is applied on fractional coordinates `xyz`.
"""
if not self.lattice:
rv = self.xyz
Expand All @@ -315,7 +311,8 @@ def xyz_cartn(self, value):

@property
def anisotropy(self):
"""bool : Flag for allowing anisotropic displacement parameters.
"""The flag for allowing anisotropic displacement parameters, as
a bool.

When ``False`` the tensor of thermal displacement parameters `U`
must be isotropic and only its diagonal elements are taken into
Expand All @@ -340,8 +337,8 @@ def anisotropy(self, value):

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

For isotropic displacements (when `anisotropy` is ``False``)
assignment to *U* uses only the first ``Unew[0, 0]`` element
Expand Down Expand Up @@ -387,7 +384,7 @@ def _set_uij(self, i, j, value):
# _doc_uii, _doc_uij are temporary local variables.

_doc_uii = """
float : The ``U[{0}, {0}]`` component of the displacement tensor `U`.
The ``U[{0}, {0}]`` component of the displacement tensor `U`, as a float

When `anisotropy` is ``False`` setting a new value updates entire
tensor *U*.
Expand All @@ -410,7 +407,7 @@ def _set_uij(self, i, j, value):
)

_doc_uij = """
float : The ``U[{0}, {1}]`` element of the displacement tensor `U`.
The ``U[{0}, {1}]`` element of the displacement tensor `U`, as a float

Sets ``U[{1}, {0}]`` together with ``U[{0}, {1}]``. Assignment
has no effect when `anisotropy` is ``False``.
Expand Down Expand Up @@ -439,7 +436,8 @@ def _set_uij(self, i, j, value):

@property
def Uisoequiv(self):
"""float : The isotropic displacement parameter or an equivalent value.
"""The isotropic displacement parameter or an equivalent value,
as a float.

Setting a new value rescales tensor `U` so it yields equivalent
direction-averaged displacements.
Expand Down Expand Up @@ -481,14 +479,14 @@ def Uisoequiv(self, value):
# _doc_bii, _doc_bij are local variables.

_doc_bii = """
float : The ``B{0}{0}`` element of the Debye-Waller matrix.
The ``B{0}{0}`` element of the Debye-Waller matrix, as a float

This is equivalent to ``8 * pi**2 * U{0}{0}``. When `anisotropy`
is ``False`` setting a new value updates entire tensor `U`.
"""

_doc_bij = """
float : The ``B{0}{1}`` element of the Debye-Waller matrix.
The ``B{0}{1}`` element of the Debye-Waller matrix, as a float

This is equivalent to ``8 * pi**2 * U{0}{1}``. Setting a new
value updates `U` in a symmetric way. Assignment has no effect
Expand Down Expand Up @@ -533,7 +531,8 @@ def Uisoequiv(self, value):

@property
def Bisoequiv(self):
"""float : The Debye-Waller isotropic displacement or an equivalent value.
"""The Debye-Waller isotropic displacement or an equivalent
value, as a float.

This equals ``8 * pi**2 * Uisoequiv``. Setting a new value
rescales `U` tensor to yield equivalent direction-average of
Expand All @@ -553,15 +552,16 @@ def Bisoequiv(self, value):


class _AtomCartesianCoordinates(numpy.ndarray):
"""Specialized `numpy.ndarray` for accessing Cartesian coordinates.
"""The specialized `numpy.ndarray` for accessing Cartesian
coordinates.

Inplace assignments to this array are applied on the *xyz* position
position of owner `Atom` as per the associated `Atom.lattice`.

Parameters
----------
atom : Atom
`Atom` instance to be linked to these coordinate array.
The `Atom` instance to be linked to these coordinate array.
"""

def __new__(self, atom):
Expand All @@ -575,7 +575,7 @@ def __init__(self, atom):

@property
def asarray(self):
"""ndarray : This array viewed as standard numpy array."""
"""This array viewed as standard numpy array."""
return self.view(numpy.ndarray)

def __setitem__(self, idx, value):
Expand Down
2 changes: 2 additions & 0 deletions src/diffpy/structure/expansion/shapeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
)
"""Utilities for making shapes."""

# FIXME: remove this line when `docformatter` fixes the blank line bug


@deprecated(findCenter_deprecation_msg)
def findCenter(S):
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/structure/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Attributes
----------
cartesian : Lattice
Constant instance of Lattice, default Cartesian system.
The default Cartesian lattice with a=b=c=1 and alpha=beta=gamma=90 degrees.
"""

import math
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/structure/parsers/p_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class P_auto(StructureParser):
Attributes
----------
format : str
Detected structure format. Initially set to "auto" and updated
The detected structure format. Initially set to "auto" and updated
after successful detection of the structure format.
pkw : dict
Keyword arguments passed to the parser.
The keyword arguments passed to the parser.
"""

def __init__(self, **kw):
Expand Down
Loading
Loading