FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: deprecate abcABG and readStr method by stevenhua0320 · Pull Request #164 · diffpy/diffpy.structure · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (6) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
25 changes: 25 additions & 0 deletions news/deprecate-lattice-readstr-method.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**Added:**

* Added ``read_structure`` method into ``PDFFitStructure`` class
* Added ``cell_parms`` method into ``Lattice`` class

**Changed:**

* <news item>

**Deprecated:**

* Deprecated ``readStr`` method in ``PDFFitStructure`` class for removal in version 4.0.0
* Deprecated ``abcABG`` method in ``Lattice`` class for removal in version 4.0.0

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
15 changes: 15 additions & 0 deletions src/diffpy/structure/lattice.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
"set_new_latt_base_vec",
removal_version,
)
abcABG_deprecation_msg = build_deprecation_message(
base,
"abcABG",
"cell_parms",
removal_version,
)

# Helper Functions -----------------------------------------------------------

Expand Down Expand Up @@ -559,7 +565,16 @@ def set_new_latt_base_vec(self, base):
)
return

@deprecated(abcABG_deprecation_msg)
def abcABG(self):
"""'diffpy.structure.Lattice.abcABG' is deprecated and will be
removed in version 4.0.0.

Please use 'diffpy.structure.Lattice.cell_parms' instead.
"""
return self.cell_parms()

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

Returns
Expand Down
9 changes: 9 additions & 0 deletions src/diffpy/structure/pdffitstructure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ def read(self, filename, format="auto"):
return p

def readStr(self, s, format="auto"):
"""'diffpy.structure.PDFFitStructure.readStr' is deprecated and
will be removed in version 4.0.0.

Please use 'diffpy.structure.PDFFitStructure.read_structure'
instead.
"""
return self.read_structure(s, format)

def read_structure(self, s, format="auto"):
"""Same as `Structure.readStr`, but update `spcgr` value in
`self.pdffit` when parser can get spacegroup.

Expand Down
6 changes: 3 additions & 3 deletions tests/test_lattice.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test___init__(self):
L2 = Lattice(base=L0.base)
self.assertTrue(numpy.array_equal(L0.base, L2.base))
self.assertTrue(numpy.array_equal(L0.isotropicunit, L2.isotropicunit))
L3 = Lattice(*L0.abcABG(), baserot=L0.baserot)
L3 = Lattice(*L0.cell_parms(), baserot=L0.baserot)
self.assertTrue(numpy.allclose(L0.base, L3.base))
self.assertTrue(numpy.allclose(L0.isotropicunit, L3.isotropicunit))
return
Expand Down Expand Up @@ -229,10 +229,10 @@ def test_set_lat_base(self):
def test_reciprocal(self):
"""Check calculation of reciprocal lattice."""
r1 = self.lattice.reciprocal()
self.assertEqual((1, 1, 1, 90, 90, 90), r1.abcABG())
self.assertEqual((1, 1, 1, 90, 90, 90), r1.cell_parms())
L2 = Lattice(2, 4, 8, 90, 90, 90)
r2 = L2.reciprocal()
self.assertEqual((0.5, 0.25, 0.125, 90, 90, 90), r2.abcABG())
self.assertEqual((0.5, 0.25, 0.125, 90, 90, 90), r2.cell_parms())
rr2 = r2.reciprocal()
self.assertTrue(numpy.array_equal(L2.base, rr2.base))
return
Expand Down
2 changes: 1 addition & 1 deletion tests/test_p_discus.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_read_discus_Ni(self):
self.assertEqual("Fm-3m", stru.pdffit["spcgr"])
# cell record
abcABG = (3.52, 3.52, 3.52, 90.0, 90.0, 90.0)
self.assertEqual(abcABG, stru.lattice.abcABG())
self.assertEqual(abcABG, stru.lattice.cell_parms())
# ncell
self.assertEqual([1, 1, 1, 4], stru.pdffit["ncell"])
self.assertEqual(4, len(stru))
Expand Down
11 changes: 10 additions & 1 deletion tests/test_structure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def test___imul__(self):
self.assertEqual(0, len(self.stru))
return

def test__get_lattice(self):
def test__get_lattice_dep(self):
"""Check Structure._get_lattice()"""
lat = Lattice()
stru = Structure()
Expand All @@ -429,6 +429,15 @@ def test__get_lattice(self):
self.assertTrue(lat is stru2.lattice)
return

def test__get_lattice(self):
"""Check Structure._get_lattice()"""
lat = Lattice()
stru = Structure()
self.assertEqual((1, 1, 1, 90, 90, 90), stru.lattice.cell_parms())
stru2 = Structure(lattice=lat)
self.assertTrue(lat is stru2.lattice)
return

def test__set_lattice(self):
"""Check Structure._set_lattice()"""
lat = Lattice()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_supercell.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def test_ni_supercell(self):
"""Check supercell expansion for Ni."""
ni_123 = supercell(self.stru_ni, (1, 2, 3))
self.assertEqual(6 * len(self.stru_ni), len(ni_123))
a, b, c = self.stru_ni.lattice.abcABG()[:3]
a1, b2, c3 = ni_123.lattice.abcABG()[:3]
a, b, c = self.stru_ni.lattice.cell_parms()[:3]
a1, b2, c3 = ni_123.lattice.cell_parms()[:3]
self.assertAlmostEqual(a, a1, 8)
self.assertAlmostEqual(b * 2, b2, 8)
self.assertAlmostEqual(c * 3, c3, 8)
Expand Down
Loading

Back | FazBrowse Home | New Git URL