Skip to content

skpkg: setup CI after migrating tests, src, requirements, and .github folder #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
18 changes: 0 additions & 18 deletions .github/workflows/tests-on-pr.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __pycache__/
.Python
env/
build/
_build/
develop-eggs/
dist/
downloads/
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ exclude-file = ".codespell/ignore_lines.txt"
ignore-words = ".codespell/ignore_words.txt"
skip = "*.cif,*.dat"

[tool.docformatter]
recursive = true
wrap-summaries = 72
wrap-descriptions = 72

[tool.black]
line-length = 79
include = '\.pyi?$'
Expand Down
Empty file removed requirements/build.txt
Empty file.
1 change: 1 addition & 0 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sphinx
sphinx_rtd_theme
sphinx-copybutton
doctr
m2r
10 changes: 1 addition & 9 deletions src/diffpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
##############################################################################
#
# (c) 2022-2025 The Trustees of Columbia University in the City of New York.
# (c) 2025 The Trustees of Columbia University in the City of New York.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would like to keep the full date range here, so 2022-2025

# All rights reserved.
#
# File coded by: Billinge Group members and community contributors.
Expand All @@ -12,11 +12,3 @@
# See LICENSE.rst for license information.
#
##############################################################################
"""Blank namespace package for module diffpy."""


from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)

# End of file
6 changes: 3 additions & 3 deletions src/diffpy/fourigui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python
##############################################################################
#
# (c) 2022-2025 The Trustees of Columbia University in the City of New York.
# (c) 2025 The Trustees of Columbia University in the City of New York.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

date range

# All rights reserved.
#
# File coded by: Billinge Group members and community contributors.
# File coded by: Billinge Group members.
#
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/diffpy/diffpy.fourigui/graphs/contributors
Expand All @@ -15,7 +15,7 @@
"""Tool for visualizing 3D diffraction and PDF images."""

# package version
from diffpy.fourigui.version import __version__
from diffpy.fourigui.version import __version__ # noqa

# silence the pyflakes syntax checker
assert __version__ or True
Expand Down
37 changes: 20 additions & 17 deletions src/diffpy/fourigui/fourigui.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ def initUI(self):
) # , height=HEIGHT//2, width=WIDTH//2)

def load_cube(self):
"""Loads 3D array in h5py file format from the filename input panel 3D
array is expected to be a reconstructed reciprocal scattering volume
when executed, one slide perpendicular to the selected axis will be
plotted in the plot panel."""
"""Loads 3D array in h5py file format from the filename input
panel 3D array is expected to be a reconstructed reciprocal
scattering volume when executed, one slide perpendicular to the
selected axis will be plotted in the plot panel."""

filename = self.filename_entry.get()
f = h5py.File(filename, "r")
Expand Down Expand Up @@ -397,8 +397,8 @@ def colorrange_upd(self):
self.plot_plane()

def intensity_upd_local(self):
"""Show local intensity minimum, maximum and sum of current plotted
plane."""
"""Show local intensity minimum, maximum and sum of current
plotted plane."""
if self.axis.get() == 0:
plane = self.cube[self.plane_num.get(), :, :]
elif self.axis.get() == 1:
Expand All @@ -418,7 +418,8 @@ def intensity_upd_local(self):
self.localnanratio["text"] = f"{round(nan_ratio, 2)}"

def intensity_upd_global(self):
"""Load global intensity minimum, maximum and sum of 3D array."""
"""Load global intensity minimum, maximum and sum of 3D
array."""
self.intensity_upd_local()
nan_ratio = np.count_nonzero(np.isnan(self.cube)) / self.cube.size
self.globalmax["text"] = (
Expand All @@ -433,8 +434,9 @@ def intensity_upd_global(self):
self.globalnanratio["text"] = "{}".format(round(nan_ratio, 2))

def fft(self):
"""Fourier transform 3D array from reciprocal to real space the origin
of reciprocal and real space is expected to be the central voxel."""
"""Fourier transform 3D array from reciprocal to real space the
origin of reciprocal and real space is expected to be the
central voxel."""

def perform_fft(fftholder):
fftholder = np.nan_to_num(fftholder)
Expand Down Expand Up @@ -487,9 +489,9 @@ def perform_fft(fftholder):
self.intensity_upd_global()

def ifft(self):
"""Inverse Fourier transform 3D array from real to reciprocal space the
origin of real and reciprocal space is expected to be the central
voxel."""
"""Inverse Fourier transform 3D array from real to reciprocal
space the origin of real and reciprocal space is expected to be
the central voxel."""
if not self.cutoff.get():
self.cube_real = self.cube
self.cube = self.cube_reci
Expand Down Expand Up @@ -562,8 +564,8 @@ def applycutoff(self):
self.intensity_upd_global()

def redocutuff(self):
"""Redo the cutoff operation depending on the current space (real or
reciprocal)."""
"""Redo the cutoff operation depending on the current space
(real or reciprocal)."""
if self.space.get(): # in real space
self.cube_realcut = self.cube
if not self.transformed:
Expand All @@ -588,8 +590,8 @@ def newcutoff(self):
self.applycutoff()

def plot_next_plane(self):
"""Plot the next plane in the dataset, looping back to the first if at
the end."""
"""Plot the next plane in the dataset, looping back to the first
if at the end."""
n = self.plane_num.get()
if n == len(self.cube[self.axis.get()]) - 1:
n = 0
Expand All @@ -616,7 +618,8 @@ def animation(self):
self.plot_next_plane()

def multiple_funcs(*funcs):
"""Executes multiple functions passed as arguments in sequence."""
"""Executes multiple functions passed as arguments in
sequence."""
for func in funcs:
func

Expand Down
31 changes: 31 additions & 0 deletions src/diffpy/fourigui/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import numpy as np


def dot_product(a, b):
"""Compute the dot product of two vectors of any size.

Ensure that the inputs, a and b, are of the same size.
The supported types are "array_like" objects, which can
be converted to a NumPy array. Examples include lists and tuples.

Parameters
----------
a : array_like
The first input vector.
b : array_like
The second input vector.

Returns
-------
float
The dot product of the two vectors.

Examples
--------
Compute the dot product of two lists:
>>> a = [1, 2, 3]
>>> b = [4, 5, 6]
>>> dot_product(a, b)
32.0
"""
return float(np.dot(a, b))
6 changes: 3 additions & 3 deletions src/diffpy/fourigui/version.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python
##############################################################################
#
# (c) 2022-2025 The Trustees of Columbia University in the City of New York.
# (c) 2025 The Trustees of Columbia University in the City of New York.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

date

# All rights reserved.
#
# File coded by: Billinge Group members and community contributors.
# File coded by: Billinge Group members.
#
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/diffpy/diffpy.fourigui/graphs/contributors
# https://github.com/diffpy/diffpy.fourigui/graphs/contributors # noqa: E501
#
# See LICENSE.rst for license information.
#
Expand Down
40 changes: 40 additions & 0 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import numpy as np
import pytest

from diffpy.fourigui import functions # noqa


def test_dot_product_2D_list():
a = [1, 2]
b = [3, 4]
expected = 11.0
actual = functions.dot_product(a, b)
assert actual == expected


def test_dot_product_3D_list():
a = [1, 2, 3]
b = [4, 5, 6]
expected = 32.0
actual = functions.dot_product(a, b)
assert actual == expected


@pytest.mark.parametrize(
"a, b, expected",
[
# Test whether the dot product function works with 2D and 3D vectors
# C1: lists, expect correct float output
([1, 2], [3, 4], 11.0),
([1, 2, 3], [4, 5, 6], 32.0),
# C2: tuples, expect correct float output
((1, 2), (3, 4), 11.0),
((1, 2, 3), (4, 5, 6), 32.0),
# C3: numpy arrays, expect correct float output
(np.array([1, 2]), np.array([3, 4]), 11.0),
(np.array([1, 2, 3]), np.array([4, 5, 6]), 32.0),
],
)
def test_dot_product(a, b, expected):
actual = functions.dot_product(a, b)
assert actual == expected
2 changes: 1 addition & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Unit tests for __version__.py."""

import diffpy.fourigui
import diffpy.fourigui # noqa


def test_package_version():
Expand Down