Skip to content
Merged
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
11 changes: 11 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[flake8]
exclude =
.git,
__pycache__,
build,
dist,
doc/source/conf.py
max-line-length = 115
# Ignore some style 'errors' produced while formatting by 'black'
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
extend-ignore = E203
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ lib64
tags
errors.err

# IDE configs
.idea
.vscode

# Installer logs
pip-log.txt
MANIFEST
Expand Down
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions conda-recipe/run_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python

import diffpy.pdffit2.tests

assert diffpy.pdffit2.tests.test().wasSuccessful()
1 change: 1 addition & 0 deletions diffpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)


Expand Down
22 changes: 13 additions & 9 deletions diffpy/pdffit2/ipy_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@

def load_ipython_extension(ipython):
from diffpy.pdffit2 import PdfFit

pf = PdfFit()
pdf = EasyPDFPlotting(pf)
print(' Type help(pdffit) or help(topic) for information.\n')
print(" Type help(pdffit) or help(topic) for information.\n")
ns = dict(pdffit=PdfFit, pdf=pdf)
pf._exportAll(ns)
ipython.user_ns.update(ns)
return


class EasyPDFPlotting(object):
"""Convenience functions for accessing and plotting PDFfit2 data.
"""
"""Convenience functions for accessing and plotting PDFfit2 data."""

def __init__(self, pdffit_instance):
self._pdffit = pdffit_instance
Expand Down Expand Up @@ -55,36 +55,40 @@ def showfit(self, offset=None):
"""
from matplotlib.pyplot import gca
from math import floor

cr = self.r
cGobs = self.Gobs
cGcalc = self.Gcalc
cGdiff = self.Gdiff
if offset is None:
offset = floor(min([min(cGobs), min(cGcalc)]) - max(cGdiff))
ax = gca()
ax.plot(cr, cGobs, 'r.', cr, cGcalc, 'b-', cr, cGdiff + offset, 'g-')
ax.plot(cr, cGobs, "r.", cr, cGcalc, "b-", cr, cGdiff + offset, "g-")
xl = ax.xaxis.get_label().get_text()
yl = ax.yaxis.get_label().get_text()
if xl == "":
ax.set_xlabel('r (A)')
ax.set_xlabel("r (A)")
if yl == "":
ax.set_ylabel('G (A**-2)')
ax.set_ylabel("G (A**-2)")
return

def showRw(self):
"Plot cumulative Rw."
from matplotlib.pyplot import gca

cRw = self._asarray(self._pdffit.getcrw())
ax = gca()
ax.plot(self.r, cRw)
ax.set_title('Cumulative Rw = %.4f' % cRw[-1])
ax.set_xlabel('r')
ax.set_ylabel('Rw')
ax.set_title("Cumulative Rw = %.4f" % cRw[-1])
ax.set_xlabel("r")
ax.set_ylabel("Rw")
return

@staticmethod
def _asarray(x, dtype=None):
import numpy

return numpy.asarray(x, dtype=dtype)


# End of class EasyPDFPlotting
3 changes: 3 additions & 0 deletions diffpy/pdffit2/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# create module variable stdout

from sys import stdout as stdout

# silence pyflakes checker
assert stdout

Expand All @@ -30,9 +31,11 @@ def redirect_stdout(dst):
The dst value is stored in module variable stdout.
"""
from diffpy.pdffit2.pdffit2 import redirect_stdout

redirect_stdout(dst)
global stdout
stdout = dst
return


# End of file
Loading