Skip to content

Commit ee05250

Browse files
committed
add PdfFit class __init__ docstring and tests
1 parent 22f4f12 commit ee05250

File tree

2 files changed

+78
-50
lines changed

2 files changed

+78
-50
lines changed

src/diffpy/pdffit2/pdffit.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ def _convertCallable(var):
104104

105105

106106
class PdfFit(object):
107-
"""Create PdfFit object."""
108107

109108
# constants and enumerators from pdffit.h:
110109
# selection of all atoms
@@ -1253,6 +1252,22 @@ def rcut():
12531252
# End refinable variables.
12541253

12551254
def __init__(self, intro=True):
1255+
"""Initialize the Pdffit class, create a new PdfFit object.
1256+
1257+
Parameters
1258+
----------
1259+
intro : bool, optional
1260+
If True, display an introduction message. Default is True.
1261+
1262+
Attributes
1263+
----------
1264+
stru_files : list
1265+
A list to store structure files.
1266+
data_files : list
1267+
A list to store data files.
1268+
_handle : PyCapsule
1269+
A python capsules to retrieve the printer to PdfFit object.
1270+
"""
12561271

12571272
self.stru_files = []
12581273
self.data_files = []

tests/test_pdffit.py

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -702,56 +702,69 @@ def test_occ(self):
702702
self.assertEqual(1, pf.getvar(pf.occ(i)))
703703
return
704704

705+
# def test_pscale(self):
706+
# """check PdfFit.pscale()
707+
# """
708+
# return
709+
#
710+
# def test_pscale(self):
711+
# """check PdfFit.pscale()
712+
# """
713+
# return
714+
#
715+
# def test_sratio(self):
716+
# """check PdfFit.sratio()
717+
# """
718+
# return
719+
#
720+
# def test_delta1(self):
721+
# """check PdfFit.delta1()
722+
# """
723+
# return
724+
#
725+
# def test_delta2(self):
726+
# """check PdfFit.delta2()
727+
# """
728+
# return
729+
#
730+
# def test_dscale(self):
731+
# """check PdfFit.dscale()
732+
# """
733+
# return
734+
#
735+
# def test_qdamp(self):
736+
# """check PdfFit.qdamp()
737+
# """
738+
# return
739+
#
740+
# def test_qbroad(self):
741+
# """check PdfFit.qbroad()
742+
# """
743+
# return
744+
#
745+
# def test_rcut(self):
746+
# """check PdfFit.rcut()
747+
# """
748+
# return
749+
#
750+
751+
def test___init__(self):
752+
"""Check PdfFit.__init__()"""
753+
P = PdfFit()
754+
self.assertEqual([], P.stru_files)
755+
self.assertEqual([], P.data_files)
756+
757+
output_true = self.capture_output(PdfFit, intro=True).strip()
758+
output_false = self.capture_output(PdfFit, intro=False).strip()
759+
760+
import diffpy.pdffit2.pdffit as pdffit
761+
762+
self.assertEqual(len(output_true), len(pdffit.__intro_message__.strip()))
763+
self.assertEqual(len(output_false), 0)
764+
765+
return
766+
705767

706-
# def test_pscale(self):
707-
# """check PdfFit.pscale()
708-
# """
709-
# return
710-
#
711-
# def test_pscale(self):
712-
# """check PdfFit.pscale()
713-
# """
714-
# return
715-
#
716-
# def test_sratio(self):
717-
# """check PdfFit.sratio()
718-
# """
719-
# return
720-
#
721-
# def test_delta1(self):
722-
# """check PdfFit.delta1()
723-
# """
724-
# return
725-
#
726-
# def test_delta2(self):
727-
# """check PdfFit.delta2()
728-
# """
729-
# return
730-
#
731-
# def test_dscale(self):
732-
# """check PdfFit.dscale()
733-
# """
734-
# return
735-
#
736-
# def test_qdamp(self):
737-
# """check PdfFit.qdamp()
738-
# """
739-
# return
740-
#
741-
# def test_qbroad(self):
742-
# """check PdfFit.qbroad()
743-
# """
744-
# return
745-
#
746-
# def test_rcut(self):
747-
# """check PdfFit.rcut()
748-
# """
749-
# return
750-
#
751-
# def test___init__(self):
752-
# """check PdfFit.__init__()
753-
# """
754-
# return
755768
#
756769
# def test__PdfFit__getRef(self):
757770
# """check PdfFit._PdfFit__getRef()

0 commit comments

Comments
 (0)