Skip to content
Open
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
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
20 changes: 11 additions & 9 deletions src/diffpy/structure/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ class Atom(object):

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code seems just to be setting defaults, so the default values just have to be moved up to the attribute description in the docstring above and deleted from here, something like that.


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

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

_anisotropy = False
lattice = None
Expand Down Expand Up @@ -294,8 +294,8 @@ def xyz_cartn(self):
coordinates.

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 +315,7 @@ def xyz_cartn(self, value):

@property
def anisotropy(self):
"""bool : Flag for allowing anisotropic displacement parameters.
"""Bool : Flag for allowing anisotropic displacement parameters.

When ``False`` the tensor of thermal displacement parameters `U`
must be isotropic and only its diagonal elements are taken into
Expand Down Expand Up @@ -439,7 +439,8 @@ def _set_uij(self, i, j, value):

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

Setting a new value rescales tensor `U` so it yields equivalent
direction-averaged displacements.
Expand Down Expand Up @@ -533,7 +534,8 @@ def Uisoequiv(self, value):

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

This equals ``8 * pi**2 * Uisoequiv``. Setting a new value
rescales `U` tensor to yield equivalent direction-average of
Expand Down Expand Up @@ -575,7 +577,7 @@ def __init__(self, atom):

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

def __setitem__(self, idx, value):
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 @@ -24,7 +24,6 @@
)
"""Utilities for making shapes."""


@deprecated(findCenter_deprecation_msg)
def findCenter(S):
"""This function has been deprecated and will be removed in version
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/structure/parsers/p_cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class P_cif(StructureParser):
del k

BtoU = 1.0 / (8 * numpy.pi**2)
"""float: Conversion factor from B values to U values."""
"""Float: Conversion factor from B values to U values."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielsirakov @stevenhua0320 we don't want string literals floating around in the code, so whenever we find things like this we want to clean them up. The correct fix in general is to move them to the docstring at the top of the function and put them into a standard format. Here, this may just be a constant and this should be changed from a string to a comment and placed above line 154.


def _tr_ignore(a, value):
return
Expand Down
5 changes: 3 additions & 2 deletions src/diffpy/structure/parsers/p_discus.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@


class P_discus(StructureParser):
"""Parser for DISCUS structure format. The parser chokes on molecule
and generator records.
"""Parser for DISCUS structure format.

The parser chokes on molecule and generator records.

Attributes
----------
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/structure/parsers/p_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ class P_pdb(StructureParser):
"MASTER",
"END",
]
"""list: Ordered list of PDB record labels."""
"""List: Ordered list of PDB record labels."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another floating string literal. It is documenting the static data list. Gemini suggested that even though it is not declared as self. it is still considered as a class attribute and so should be documented in the class docstring, something like:

class P_pdb(StructureParser):
    """Simple parser for PDB format.

    The parser understands following PDB records: `TITLE, CRYST1, SCALE1,
    SCALE2, SCALE3, ATOM, SIGATM, ANISOU, SIGUIJ, TER, HETATM, END`.

    Attributes
    ----------
    format : str
        Format name, default "pdb".
    orderOfRecords : list
        The ordered list of PDB record labels.
    validRecords : dict
        The set of valid PDB record labels.
    """

We can discuss this more, but in general I think taking this advice and using it also in other places in the PR is the right approach


validRecords = dict.fromkeys(orderOfRecords)
"""dict: Dictionary of PDB record labels."""
"""Dict: Dictionary of PDB record labels."""

def __init__(self):
StructureParser.__init__(self)
Expand Down
8 changes: 5 additions & 3 deletions src/diffpy/structure/parsers/p_vesta.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ class P_vesta(StructureParser):
"""

cluster_boundary = 2
"""int: Width of boundary around corners of non-periodic cluster.
Retained from the original AtomEye/XCFG parser for API compatibility.
VESTA handles periodicity natively so this value has no effect on output.
"""Int: Width of boundary around corners of non-periodic cluster.

Retained from the original AtomEye/XCFG parser for API
compatibility. VESTA handles periodicity natively so this value has
no effect on output.
"""

def __init__(self):
Expand Down
5 changes: 2 additions & 3 deletions src/diffpy/structure/parsers/p_xcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,8 @@ class P_xcfg(StructureParser):
"""

cluster_boundary = 2
"""int: Width of boundary around corners of non-periodic
cluster to avoid PBC effects in atomeye.
"""
"""Int: Width of boundary around corners of non-periodic cluster to
avoid PBC effects in atomeye."""

def __init__(self):
StructureParser.__init__(self)
Expand Down
1 change: 0 additions & 1 deletion src/diffpy/structure/pdffitstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
##############################################################################
"""Definition of PDFFitStructure class derived from Structure."""


from diffpy.structure.structure import Structure
from diffpy.utils._deprecator import build_deprecation_message, deprecated

Expand Down
1 change: 0 additions & 1 deletion src/diffpy/structure/sgtbxspacegroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
List of space group instances defined in this module.
"""


from diffpy.structure.spacegroupmod import (
Rot_mX_mY_mZ,
Rot_mX_mY_Z,
Expand Down
1 change: 0 additions & 1 deletion src/diffpy/structure/spacegroupmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ def check_group_name(self, name):
names of this space group or if it equals its `number`.
Return ``False`` otherwise.
"""

if name == self.short_name:
return True
if name == self.pdb_name:
Expand Down
1 change: 0 additions & 1 deletion src/diffpy/structure/spacegroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,6 @@ def find_space_group(symops, shuffle=False):
ValueError
When `symops` do not match any known SpaceGroup.
"""

tb = _get_sg_hash_lookup_table()
hh = _hash_symop_list(symops)
if hh not in tb:
Expand Down
Loading
Loading