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
4 changes: 4 additions & 0 deletions docs/source/api/diffpy.srfit.structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
diffpy.srfit.structure package
==============================

.. deprecated:: 3.5.0
``diffpy.srfit.structure`` has moved to ``diffpy.cmistructure`` and will
be removed in version 4.0.0. Please use ``diffpy.cmistructure`` instead.

.. automodule:: diffpy.srfit.structure
:members:
:undoc-members:
Expand Down
26 changes: 26 additions & 0 deletions news/structure-names-dep.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**Added:**

* The snake_case names of the structure adapter methods, which they have in ``diffpy.cmistructure``: ``can_adapt``, ``get_lattice``, ``get_scatterers``, ``get_space_group``, ``use_symmetry``, ``using_symmetry``, ``is_dummy``, ``has_scatterers``, ``wrap_restraints``, ``wrap_stretch_mode_parameters``, ``restrain_bond_length``, ``restrain_bond_angle``, ``restrain_dihedral_angle`` and their ``*_parameter`` forms, ``add_bond_length_parameter``, ``add_bond_angle_parameter``, ``add_dihedral_angle_parameter``, ``StretchModeParameter.add_atoms`` and ``BaseSpaceGroupParameters.add_parameter``.
* The attributes ``.angle_units``, ``.scatterer``, ``.restraint``, ``.mutated_atoms``, ``.space_group``, ``.structure_parameter_set`` and ``.index``, which they are called in ``diffpy.cmistructure``.

**Changed:**

* <news item>

**Deprecated:**

* The camelCase methods of the ``diffpy.srfit.structure`` adapters (``canAdapt``, ``getLattice``, ``getScatterers``, ``getSpaceGroup``, ``useSymmetry``, ``usingSymmetry``, ``isDummy``, ``hasScatterers``, ``wrapRestraints``, ``wrapStretchModeParameters``, the ``restrainBond*`` and ``restrainDihedral*`` methods, the ``add*Parameter`` methods of ``ObjCrystMoleculeParSet``, ``StretchModeParameter.addAtoms`` and ``BaseSpaceGroupParameters.addParameter``). Please use their snake_case names in ``diffpy.cmistructure`` instead.
* The attributes ``.angunits``, ``.scat``, ``.res``, ``.matoms``, ``.sg``, ``.strups`` and ``.idx``. Please use ``.angle_units``, ``.scatterer``, ``.restraint``, ``.mutated_atoms``, ``.space_group``, ``.structure_parameter_set`` and ``.index`` in ``diffpy.cmistructure`` instead.

**Removed:**

* <news item>

**Fixed:**

* ``ObjCrystMoleculeParSet.get_lattice`` no longer raises ``AttributeError``. It called ``newPar``, which ``ParameterSet`` doesn't have.
* ``ObjCrystMoleculeParSet.wrap_stretch_mode_parameters`` no longer raises ``AttributeError`` for a molecule with stretch modes. It called ``AddAtoms``, which ``StretchModeParameter`` doesn't have.

**Security:**

* <news item>
2 changes: 1 addition & 1 deletion src/diffpy/srfit/pdf/basepdfgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def set_structure_from_parset(self, parset, periodic=True):
self.add_parameter_set(parset)

# Set periodicity
self._phase.useSymmetry(periodic)
self._phase.use_symmetry(periodic)
return

@deprecated(setPhase_dep_msg)
Expand Down
8 changes: 4 additions & 4 deletions src/diffpy/srfit/structure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,22 @@ def structure_to_parameter_set(name, structure):
"""
from diffpy.srfit.structure.diffpyparset import DiffpyStructureParSet

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

from diffpy.srfit.structure.objcrystparset import ObjCrystCrystalParSet

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

from diffpy.srfit.structure.objcrystparset import ObjCrystMoleculeParSet

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

from diffpy.srfit.structure.cctbxparset import CCTBXCrystalParSet

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

raise TypeError("Unadaptable structure format")
Expand Down
72 changes: 67 additions & 5 deletions src/diffpy/srfit/structure/basestructureparset.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,34 @@
)


parset_base = "diffpy.srfit.structure.basestructureparset.BaseStructureParSet"
parset_new_base = "diffpy.cmistructure.basestructureparset.BaseStructureParSet"

parset_canAdapt_dep_msg = build_deprecation_message(
parset_base,
"canAdapt",
"can_adapt",
removal_version,
new_base=parset_new_base,
)

parset_getLattice_dep_msg = build_deprecation_message(
parset_base,
"getLattice",
"get_lattice",
removal_version,
new_base=parset_new_base,
)

parset_getScatterers_dep_msg = build_deprecation_message(
parset_base,
"getScatterers",
"get_scatterers",
removal_version,
new_base=parset_new_base,
)


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

Expand Down Expand Up @@ -65,23 +93,46 @@ def stru(self, value):
self.structure = value

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

def getLattice(self):
@classmethod
@deprecated(parset_canAdapt_dep_msg)
def canAdapt(self, stru):
"""This function has been deprecated and will be removed in version
4.0.0.

Please use
diffpy.cmistructure.basestructureparset.BaseStructureParSet.can_adapt
instead.
"""
return self.can_adapt(stru)

def get_lattice(self):
"""Get a 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".

Lattice must also have the "angunits" attribute, which is either
"deg" or "rad", to signify degrees or radians.
Lattice must also have the "angle_units" attribute, which is
either "deg" or "rad", to signify degrees or radians.
"""
raise NotImplementedError("The must be overloaded")

def getScatterers(self):
@deprecated(parset_getLattice_dep_msg)
def getLattice(self):
"""This function has been deprecated and will be removed in version
4.0.0.

Please use
diffpy.cmistructure.basestructureparset.BaseStructureParSet.get_lattice
instead.
"""
return self.get_lattice()

def get_scatterers(self):
"""Get a list of ParameterSets that represents the scatterers.

The site positions must be accessible from the list entries via
Expand All @@ -90,3 +141,14 @@ def getScatterers(self):
isotropic, anisotropic) depends on the adapted structure.
"""
raise NotImplementedError("The must be overloaded")

@deprecated(parset_getScatterers_dep_msg)
def getScatterers(self):
"""This function has been deprecated and will be removed in version
4.0.0.

Please use
diffpy.cmistructure.basestructureparset.BaseStructureParSet.get_scatterers
instead.
"""
return self.get_scatterers()
Loading
Loading