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
2 changes: 1 addition & 1 deletion .github/workflows/check-news-item.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Check for News
on:
pull_request_target:
branches:
- main # GitHub does not evaluate expressions in trigger filters; edit this value if your base branch is not main
- main # GitHub does not evaluate expressions in trigger filters; edit this value if your base branch is not main

jobs:
check-news-item:
Expand Down
34 changes: 34 additions & 0 deletions LICENSE_DANSE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
This program is part of the DiffPy and DANSE open-source projects at Columbia
University and is available subject to the conditions and terms laid out below.

Copyright (c) 2008-2011, The Trustees of Columbia University in
the City of New York. All rights reserved.

For more information please visit the diffpy web-page at
http://www.diffpy.org
or email Prof. Simon Billinge at sb2896@columbia.edu.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the names of COLUMBIA UNIVERSITY, MICHIGAN STATE UNIVERSITY nor the
names of their contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 changes: 23 additions & 0 deletions news/migrate-structure.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* No news added.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ maintainers = [
description = "diffpy.cmi package for doing refinements with structure objects"
keywords = ['diffraction', 'PDF', 'X-ray', 'neutron']
readme = "README.rst"
requires-python = ">=3.12, <3.15"
requires-python = ">=3.11, <3.14"
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
Expand All @@ -25,9 +25,9 @@ classifiers = [
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Scientific/Engineering :: Chemistry',
]
Expand All @@ -49,7 +49,7 @@ exclude = [] # exclude packages matching these glob patterns (empty by default)
namespaces = false # to disable scanning PEP 420 namespaces (true by default)

[project.scripts]
diffpy-cmistructure = "diffpy.cmistructure.app:main"
diffpy-cmistructure = "diffpy.cmistructure.cmistructure_app:main"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements/pip.txt"]}
Expand Down
3 changes: 3 additions & 0 deletions requirements/conda.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
numpy
diffpy.srreal
diffpy.srfit
diffpy.structure
3 changes: 3 additions & 0 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
numpy
diffpy.srreal
diffpy.srfit
diffpy.structure
1 change: 1 addition & 0 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ codecov
coverage
pytest-cov
pytest-env
pyobjcryst
3 changes: 3 additions & 0 deletions src/diffpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
# See LICENSE.rst for license information.
#
##############################################################################
from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)
56 changes: 55 additions & 1 deletion src/diffpy/cmistructure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,65 @@
# See LICENSE.rst for license information.
#
##############################################################################
"""diffpy.cmi package for doing refinements with structure objects"""
"""Modules and classes that adapt structure representations to the
ParameterSet interface and automatic structure constraint generation
from space group information."""

from diffpy.cmistructure.sgconstraints import constrain_as_space_group

# package version
from diffpy.cmistructure.version import __version__ # noqa

__all__ = ["constrain_as_space_group", "structure_to_parameter_set"]


def structure_to_parameter_set(name, structure):
"""Create a ParameterSet adapted to a structure object.

The adapter is chosen from the type of `structure`. Supported types are
diffpy.structure.Structure, pyobjcryst.crystal.Crystal,
pyobjcryst.molecule.Molecule and cctbx.crystal.special_position_settings.

Parameters
----------
name : str
The name to give the structure.
structure : object
The structure object to adapt.

Returns
-------
BaseStructureParSet
The ParameterSet adapting `structure`.

Raises
------
TypeError
If `structure` is not one of the supported structure types.
"""
from diffpy.cmistructure.diffpyparset import DiffpyStructureParSet

if DiffpyStructureParSet.can_adapt(structure):
return DiffpyStructureParSet(name, structure)

from diffpy.cmistructure.objcrystparset import ObjCrystCrystalParSet

if ObjCrystCrystalParSet.can_adapt(structure):
return ObjCrystCrystalParSet(name, structure)

from diffpy.cmistructure.objcrystparset import ObjCrystMoleculeParSet

if ObjCrystMoleculeParSet.can_adapt(structure):
return ObjCrystMoleculeParSet(name, structure)

from diffpy.cmistructure.cctbxparset import CCTBXCrystalParSet

if CCTBXCrystalParSet.can_adapt(structure):
return CCTBXCrystalParSet(name, structure)

raise TypeError("Unadaptable structure format")


# silence the pyflakes syntax checker
assert __version__ or True

Expand Down
101 changes: 101 additions & 0 deletions src/diffpy/cmistructure/basestructureparset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/env python
##############################################################################
#
# (c) 2009 The Trustees of Columbia University in the City of New York.
# (c) 2026 Contributors to diffpy.cmistructure.
# All rights reserved.
#
# File coded by: Chris Farrow and members of the diffpy community.
#
# Originally developed in diffpy.srfit by the DANSE Diffraction group and
# Simon J. L. Billinge.
#
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/diffpy/diffpy.cmistructure/graphs/contributors
#
# See LICENSE.rst and LICENSE_DANSE.rst for license information.
#
##############################################################################
"""Base class for adapting structures to a ParameterSet interface.

The BaseStructureParSet is a ParameterSet with functionality required by
all structure adapters.
"""

__all__ = ["BaseStructureParSet"]

from diffpy.srfit.fitbase.parameterset import ParameterSet


class BaseStructureParSet(ParameterSet):
"""Base class for structure adapters.

BaseStructureParSet derives from ParameterSet and provides methods that
help interface the ParameterSet with the space group constraint methods in
the sgconstraints module and to ProfileGenerators.

Attributes
----------
structure : object
The adapted structure object.
"""

@classmethod
def can_adapt(self, structure):
"""Return whether the structure can be adapted by this class.

Parameters
----------
structure : object
The structure object to check.

Returns
-------
bool
The flag indicating if `structure` can be adapted. The base class
always returns False.
"""
return False

def get_lattice(self):
"""Return the ParameterSet containing the lattice Parameters.

The returned ParameterSet may contain other Parameters than the
lattice Parameters. It is assumed that the lattice parameters
are named "a", "b", "c", "alpha", "beta", "gamma".

The lattice must also have the "angle_units" attribute, which is
either "deg" or "rad", to signify degrees or radians.

Returns
-------
ParameterSet
The ParameterSet holding the lattice Parameters.

Raises
------
NotImplementedError
If the subclass does not override this method.
"""
raise NotImplementedError("The must be overloaded")

def get_scatterers(self):
"""Return the list of ParameterSets that represent the
scatterers.

The site positions must be accessible from the list entries via
the names "x", "y", and "z". The ADPs must be accessible as
well, but the name and nature of the ADPs (U-factors, B-factors,
isotropic, anisotropic) depends on the adapted structure.

Returns
-------
list of ParameterSet
The ParameterSets of the scatterers in the structure.

Raises
------
NotImplementedError
If the subclass does not override this method.
"""
raise NotImplementedError("The must be overloaded")
Loading
Loading