Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
23 changes: 23 additions & 0 deletions news/intro.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Option to skip printing of introductory information when initializing the `PdfFit` class.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
22 changes: 19 additions & 3 deletions src/diffpy/pdffit2/pdffit.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def _convertCallable(var):


class PdfFit(object):
"""Create PdfFit object."""

# constants and enumerators from pdffit.h:
# selection of all atoms
Expand Down Expand Up @@ -1252,13 +1251,30 @@ def rcut():

# End refinable variables.

def __init__(self):
def __init__(self, intro=True):
"""Initialize the Pdffit class, create a new PdfFit object.

Parameters
----------
intro : bool, optional
If True, display an introduction message. Default is True.

Attributes
----------
stru_files : list
A list to store structure files.
data_files : list
A list to store data files.
_handle : PyCapsule
A python capsules to retrieve the printer to PdfFit object.
"""

self.stru_files = []
self.data_files = []

self._handle = pdffit2.create()
self.intro()
if intro:
self.intro()
return

def __getRef(self, var_string):
Expand Down
111 changes: 62 additions & 49 deletions tests/test_pdffit.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,56 +702,69 @@ def test_occ(self):
self.assertEqual(1, pf.getvar(pf.occ(i)))
return

# def test_pscale(self):
# """check PdfFit.pscale()
# """
# return
#
# def test_pscale(self):
# """check PdfFit.pscale()
# """
# return
#
# def test_sratio(self):
# """check PdfFit.sratio()
# """
# return
#
# def test_delta1(self):
# """check PdfFit.delta1()
# """
# return
#
# def test_delta2(self):
# """check PdfFit.delta2()
# """
# return
#
# def test_dscale(self):
# """check PdfFit.dscale()
# """
# return
#
# def test_qdamp(self):
# """check PdfFit.qdamp()
# """
# return
#
# def test_qbroad(self):
# """check PdfFit.qbroad()
# """
# return
#
# def test_rcut(self):
# """check PdfFit.rcut()
# """
# return
#

def test___init__(self):
"""Check PdfFit.__init__()"""
P = PdfFit()
self.assertEqual([], P.stru_files)
self.assertEqual([], P.data_files)

output_true = self.capture_output(PdfFit, intro=True).strip()
output_false = self.capture_output(PdfFit, intro=False).strip()

import diffpy.pdffit2.pdffit as pdffit

self.assertEqual(len(output_true), len(pdffit.__intro_message__.strip()))
self.assertEqual(len(output_false), 0)

return


# def test_pscale(self):
# """check PdfFit.pscale()
# """
# return
#
# def test_pscale(self):
# """check PdfFit.pscale()
# """
# return
#
# def test_sratio(self):
# """check PdfFit.sratio()
# """
# return
#
# def test_delta1(self):
# """check PdfFit.delta1()
# """
# return
#
# def test_delta2(self):
# """check PdfFit.delta2()
# """
# return
#
# def test_dscale(self):
# """check PdfFit.dscale()
# """
# return
#
# def test_qdamp(self):
# """check PdfFit.qdamp()
# """
# return
#
# def test_qbroad(self):
# """check PdfFit.qbroad()
# """
# return
#
# def test_rcut(self):
# """check PdfFit.rcut()
# """
# return
#
# def test___init__(self):
# """check PdfFit.__init__()
# """
# return
#
# def test__PdfFit__getRef(self):
# """check PdfFit._PdfFit__getRef()
Expand Down
Loading