Skip to content

Commit

Permalink
Merge branch 'main' into __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
sbillinge authored May 29, 2024
2 parents d02cc9f + 668f6d7 commit 146f7f5
Show file tree
Hide file tree
Showing 29 changed files with 56 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
pre-commit:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository }}

runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""Tools for manipulating and comparing PDFs.
"""
# top-level import
from diffpy.pdfmorph.pdfmorph_api import morph_default_config, pdfmorph, plot_morph
from diffpy.pdfmorph.pdfmorph_api import morph_default_config, pdfmorph, plot_morph # noqa: F401

top_level = [
pdfmorph,
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/morph_helpers/transformpdftordf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""


from diffpy.pdfmorph.morphs.morph import *
from diffpy.pdfmorph.morphs.morph import LABEL_GR, LABEL_RA, LABEL_RR, Morph


class TransformXtalPDFtoRDF(Morph):
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/morph_helpers/transformrdftopdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import numpy

from diffpy.pdfmorph.morphs.morph import *
from diffpy.pdfmorph.morphs.morph import LABEL_GR, LABEL_RA, LABEL_RR, Morph


class TransformXtalRDFtoPDF(Morph):
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfmorph/morphs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"""


from diffpy.pdfmorph.morphs.morph import Morph
from diffpy.pdfmorph.morphs.morphchain import MorphChain
from diffpy.pdfmorph.morphs.morph import Morph # noqa: F401
from diffpy.pdfmorph.morphs.morphchain import MorphChain # noqa: F401
from diffpy.pdfmorph.morphs.morphishape import MorphISphere, MorphISpheroid
from diffpy.pdfmorph.morphs.morphresolution import MorphResolutionDamping
from diffpy.pdfmorph.morphs.morphrgrid import MorphRGrid
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/morphs/morphishape.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MorphISpheroid -- apply inverse spheroidal shape function

import numpy

from diffpy.pdfmorph.morphs.morph import *
from diffpy.pdfmorph.morphs.morph import LABEL_GR, LABEL_RA, Morph
from diffpy.pdfmorph.morphs.morphshape import _sphericalCF, _spheroidalCF


Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/morphs/morphresolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import numpy

from diffpy.pdfmorph.morphs.morph import *
from diffpy.pdfmorph.morphs.morph import LABEL_RA, LABEL_RR, Morph


class MorphResolutionDamping(Morph):
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/morphs/morphrgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import numpy

from diffpy.pdfmorph.morphs.morph import *
from diffpy.pdfmorph.morphs.morph import LABEL_GR, LABEL_RA, Morph

# roundoff tolerance for selecting bounds on arrays.
epsilon = 1e-8
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/morphs/morphscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""


from diffpy.pdfmorph.morphs.morph import *
from diffpy.pdfmorph.morphs.morph import LABEL_GR, LABEL_RA, Morph


class MorphScale(Morph):
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/morphs/morphshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MorphSpheroid -- apply a spheroidal shape function to the morph
from numpy import arctanh as atanh
from numpy import sqrt

from diffpy.pdfmorph.morphs.morph import *
from diffpy.pdfmorph.morphs.morph import LABEL_GR, LABEL_RA, Morph


class MorphSphere(Morph):
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/morphs/morphshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import numpy

from diffpy.pdfmorph.morphs.morph import *
from diffpy.pdfmorph.morphs.morph import LABEL_GR, LABEL_RA, Morph


class MorphShift(Morph):
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/morphs/morphsmear.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import numpy

from diffpy.pdfmorph.morphs.morph import *
from diffpy.pdfmorph.morphs.morph import LABEL_RA, LABEL_RR, Morph


class MorphSmear(Morph):
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfmorph/morphs/morphstretch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import numpy

from diffpy.pdfmorph.morphs.morph import *
from diffpy.pdfmorph.morphs.morph import LABEL_GR, LABEL_RA, Morph


class MorphStretch(Morph):
Expand Down
1 change: 0 additions & 1 deletion src/diffpy/pdfmorph/pdfmorph_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def pdfmorph(
print(morph_rv_dict['pcc'])
print(morph_rv_dict['rw'])
"""
operation_dict = {}
refpars = []
# input config
rv_cfg = dict(kwargs)
Expand Down
16 changes: 8 additions & 8 deletions src/diffpy/pdfmorph/pdfmorphapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,19 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
chain.append(morphs.MorphRGrid())
refpars = []

## Scale
# Scale
if opts.scale is not None:
scale_in = opts.scale
chain.append(morphs.MorphScale())
config["scale"] = opts.scale
refpars.append("scale")
## Stretch
# Stretch
if opts.stretch is not None:
stretch_in = opts.stretch
chain.append(morphs.MorphStretch())
config["stretch"] = opts.stretch
refpars.append("stretch")
## Smear
# Smear
if opts.smear is not None:
smear_in = opts.smear
chain.append(helpers.TransformXtalPDFtoRDF())
Expand All @@ -334,7 +334,7 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
if opts.baselineslope is None:
refpars.append("baselineslope")
config["baselineslope"] = -0.5
## Size
# Size
radii = [opts.radius, opts.pradius]
nrad = 2 - radii.count(None)
if nrad == 1:
Expand Down Expand Up @@ -362,7 +362,7 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
refpars.append("ipradius")
chain.append(morphs.MorphISpheroid())

## Resolution
# Resolution
if opts.qdamp is not None:
chain.append(morphs.MorphResolutionDamping())
refpars.append("qdamp")
Expand Down Expand Up @@ -426,7 +426,7 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
stdout_flag=stdout_flag,
)

except (FileNotFoundError, RuntimeError) as e:
except (FileNotFoundError, RuntimeError):
save_fail_message = "Unable to save to designated location."
parser.custom_error(save_fail_message)

Expand Down Expand Up @@ -518,7 +518,7 @@ def multiple_morphs(parser, opts, pargs, stdout_flag=True):
save_morphs_here = io.create_morphs_directory(save_directory)

# Could not create directory or find names to save morphs as
except (FileNotFoundError, RuntimeError) as e:
except (FileNotFoundError, RuntimeError):
save_fail_message = "\nUnable to create directory"
parser.custom_error(save_fail_message)

Expand Down Expand Up @@ -565,7 +565,7 @@ def multiple_morphs(parser, opts, pargs, stdout_flag=True):
verbose=opts.verbose,
stdout_flag=stdout_flag,
)
except (FileNotFoundError, RuntimeError) as e:
except (FileNotFoundError, RuntimeError):
save_fail_message = "Unable to save summary to directory."
parser.custom_error(save_fail_message)

Expand Down
2 changes: 0 additions & 2 deletions src/diffpy/pdfmorph/pdfplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import numpy
from bg_mpl_stylesheet.bg_mpl_stylesheet import bg_mpl_style

import diffpy.pdfmorph.tools as tools

plt.style.use(bg_mpl_style)


Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfmorph/tests/test_morph_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_morphfunc_verbose():
x_morph = x_target.copy()
y_morph = heaviside(x_target, lb * (1 + stretch), ub * (1 + stretch))
cfg = morph_default_config(stretch=0.1) # off init
morph_rv = pdfmorph(x_morph, y_morph, x_target, y_target, verbose=True, **cfg)
pdfmorph(x_morph, y_morph, x_target, y_target, verbose=True, **cfg)


def test_fixed_morph_with_morphfunc():
Expand All @@ -29,7 +29,7 @@ def test_fixed_morph_with_morphfunc():
y_morph = heaviside(x_target, lb * (1 + stretch), ub * (1 + stretch))
cfg = morph_default_config(stretch=0.1) # off init
cfg["scale"] = 30
morph_rv = pdfmorph(
pdfmorph(
x_morph,
y_morph,
x_target,
Expand Down
8 changes: 4 additions & 4 deletions src/diffpy/pdfmorph/tests/test_morphchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import numpy
import pytest

from diffpy.pdfmorph.morphs.morphchain import MorphChain
from diffpy.pdfmorph.morphs.morphrgrid import MorphRGrid
from diffpy.pdfmorph.morphs.morphscale import MorphScale

# useful variables
thisfile = locals().get("__file__", "file.py")
tests_dir = os.path.dirname(os.path.abspath(thisfile))
# testdata_dir = os.path.join(tests_dir, 'testdata')

from diffpy.pdfmorph.morphs.morphchain import MorphChain
from diffpy.pdfmorph.morphs.morphrgrid import MorphRGrid
from diffpy.pdfmorph.morphs.morphscale import MorphScale


class TestMorphChain:
@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfmorph/tests/test_morphpdftordf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import numpy
import pytest

from diffpy.pdfmorph.morph_helpers.transformpdftordf import TransformXtalPDFtoRDF

# useful variables
thisfile = locals().get("__file__", "file.py")
tests_dir = os.path.dirname(os.path.abspath(thisfile))
# testdata_dir = os.path.join(tests_dir, 'testdata')

from diffpy.pdfmorph.morph_helpers.transformpdftordf import TransformXtalPDFtoRDF


class TestTransformXtalPDFtoRDF:
@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfmorph/tests/test_morphrdftopdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import numpy
import pytest

from diffpy.pdfmorph.morph_helpers.transformrdftopdf import TransformXtalRDFtoPDF

# useful variables
thisfile = locals().get("__file__", "file.py")
tests_dir = os.path.dirname(os.path.abspath(thisfile))
# testdata_dir = os.path.join(tests_dir, 'testdata')

from diffpy.pdfmorph.morph_helpers.transformrdftopdf import TransformXtalRDFtoPDF


class TestTransformXtalRDFtoPDF:
@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfmorph/tests/test_morphresolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import numpy
import pytest

from diffpy.pdfmorph.morphs.morphresolution import MorphResolutionDamping

# useful variables
thisfile = locals().get("__file__", "file.py")
tests_dir = os.path.dirname(os.path.abspath(thisfile))
testdata_dir = os.path.join(tests_dir, "testdata")

from diffpy.pdfmorph.morphs.morphresolution import MorphResolutionDamping


class TestMorphScale:
@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfmorph/tests/test_morphrgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import numpy
import pytest

from diffpy.pdfmorph.morphs.morphrgrid import MorphRGrid

# useful variables
thisfile = locals().get("__file__", "file.py")
tests_dir = os.path.dirname(os.path.abspath(thisfile))
# testdata_dir = os.path.join(tests_dir, 'testdata')

from diffpy.pdfmorph.morphs.morphrgrid import MorphRGrid


##############################################################################
class TestMorphRGrid:
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfmorph/tests/test_morphscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import numpy
import pytest

from diffpy.pdfmorph.morphs.morphscale import MorphScale

# useful variables
thisfile = locals().get("__file__", "file.py")
tests_dir = os.path.dirname(os.path.abspath(thisfile))
# testdata_dir = os.path.join(tests_dir, 'testdata')

from diffpy.pdfmorph.morphs.morphscale import MorphScale


class TestMorphScale:
@pytest.fixture
Expand Down
8 changes: 5 additions & 3 deletions src/diffpy/pdfmorph/tests/test_morphshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
import numpy
import pytest

from diffpy.pdfmorph.morphs.morphishape import MorphISpheroid
from diffpy.pdfmorph.morphs.morphshape import MorphSphere, MorphSpheroid

# FIXME: add MorphISphere test

# useful variables
thisfile = locals().get("__file__", "file.py")
tests_dir = os.path.dirname(os.path.abspath(thisfile))
testdata_dir = os.path.join(tests_dir, "testdata")

from diffpy.pdfmorph.morphs.morphishape import MorphISphere, MorphISpheroid
from diffpy.pdfmorph.morphs.morphshape import MorphSphere, MorphSpheroid


class TestMorphSphere:
@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfmorph/tests/test_morphsmear.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import numpy
import pytest

from diffpy.pdfmorph.morphs.morphsmear import MorphSmear

# useful variables
thisfile = locals().get("__file__", "file.py")
tests_dir = os.path.dirname(os.path.abspath(thisfile))
# testdata_dir = os.path.join(tests_dir, 'testdata')

from diffpy.pdfmorph.morphs.morphsmear import MorphSmear


class TestMorphSmear:
@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfmorph/tests/test_morphstretch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import numpy
import pytest

from diffpy.pdfmorph.morphs.morphstretch import MorphStretch

# useful variables
thisfile = locals().get("__file__", "file.py")
tests_dir = os.path.dirname(os.path.abspath(thisfile))
# testdata_dir = os.path.join(tests_dir, 'testdata')

from diffpy.pdfmorph.morphs.morphstretch import MorphStretch


class TestMorphStretch:
@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfmorph/tests/test_pdfmorphio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import pytest

from diffpy.pdfmorph.pdfmorphapp import create_option_parser, multiple_morphs, single_morph

# Support Python 2
try:
from future_builtins import filter, zip
except ImportError:
pass

from diffpy.pdfmorph.pdfmorphapp import create_option_parser, multiple_morphs, single_morph

thisfile = locals().get("__file__", "file.py")
tests_dir = Path(thisfile).parent.resolve()
testdata_dir = tests_dir.joinpath("testdata")
Expand Down
Loading

0 comments on commit 146f7f5

Please sign in to comment.