From 5369f6ae66b3c2f37b964cb3ec0cf37a1423e5e9 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 24 Sep 2024 23:31:28 -0400 Subject: [PATCH 01/20] Move tests dir and use testutils --- requirements/run.txt | 2 +- src/diffpy/pdfgui/tests/__init__.py | 80 ------------------ src/diffpy/pdfgui/tests/conftest.py | 19 ----- src/diffpy/pdfgui/tests/debug.py | 36 -------- src/diffpy/pdfgui/tests/run.py | 38 --------- .../tests => tests}/showphasenotebookpanel.py | 0 .../tests => tests}/test_aboutdialog.py | 6 +- .../tests => tests}/test_calculation.py | 0 .../pdfgui/tests => tests}/test_constraint.py | 0 .../tests => tests}/test_datasetpanels.py | 2 +- .../tests => tests}/test_dopingseriespanel.py | 2 +- .../tests => tests}/test_extendedplotframe.py | 2 +- .../pdfgui/tests => tests}/test_fitdataset.py | 2 +- .../tests => tests}/test_fitstructure.py | 2 +- .../tests => tests}/test_insertrowsdialog.py | 2 +- .../tests => tests}/test_loadproject.py | 2 +- .../pdfgui/tests => tests}/test_mainframe.py | 2 +- .../pdfgui/tests => tests}/test_parameter.py | 2 +- .../tests => tests}/test_parameterspanel.py | 2 +- .../pdfgui/tests => tests}/test_pdfdataset.py | 2 +- .../tests => tests}/test_pdfguicontrol.py | 0 .../tests => tests}/test_pdfstructure.py | 2 +- .../test_phaseconfigurepanel.py | 2 +- .../tests => tests}/test_structureviewer.py | 2 +- .../test_temperatureseriespanel.py | 2 +- .../pdfgui/tests => tests}/testdata/300K.gr | 0 .../pdfgui/tests => tests}/testdata/550K.gr | 0 .../testdata/CdSe_bulk_wur.stru | 0 .../tests => tests}/testdata/LaMnO3.stru | 0 .../pdfgui/tests => tests}/testdata/Ni.dat | 0 .../pdfgui/tests => tests}/testdata/Ni.stru | 0 .../tests => tests}/testdata/Ni_2-8.chi.gr | 0 .../pdfgui/tests => tests}/testdata/lcmo.ddp | Bin .../tests => tests}/testdata/lcmo_00.gr | 0 .../tests => tests}/testdata/lcmo_20.gr | 0 .../tests => tests}/testdata/lcmo_full.ddp | Bin .../pdfgui/tests => tests}/testdata/ni.ddp | Bin .../pdfgui/tests => tests}/testutils.py | 2 - 38 files changed, 19 insertions(+), 194 deletions(-) delete mode 100644 src/diffpy/pdfgui/tests/__init__.py delete mode 100644 src/diffpy/pdfgui/tests/conftest.py delete mode 100644 src/diffpy/pdfgui/tests/debug.py delete mode 100644 src/diffpy/pdfgui/tests/run.py rename {src/diffpy/pdfgui/tests => tests}/showphasenotebookpanel.py (100%) rename {src/diffpy/pdfgui/tests => tests}/test_aboutdialog.py (96%) rename {src/diffpy/pdfgui/tests => tests}/test_calculation.py (100%) rename {src/diffpy/pdfgui/tests => tests}/test_constraint.py (100%) rename {src/diffpy/pdfgui/tests => tests}/test_datasetpanels.py (97%) rename {src/diffpy/pdfgui/tests => tests}/test_dopingseriespanel.py (95%) rename {src/diffpy/pdfgui/tests => tests}/test_extendedplotframe.py (96%) rename {src/diffpy/pdfgui/tests => tests}/test_fitdataset.py (99%) rename {src/diffpy/pdfgui/tests => tests}/test_fitstructure.py (99%) rename {src/diffpy/pdfgui/tests => tests}/test_insertrowsdialog.py (96%) rename {src/diffpy/pdfgui/tests => tests}/test_loadproject.py (98%) rename {src/diffpy/pdfgui/tests => tests}/test_mainframe.py (97%) rename {src/diffpy/pdfgui/tests => tests}/test_parameter.py (97%) rename {src/diffpy/pdfgui/tests => tests}/test_parameterspanel.py (98%) rename {src/diffpy/pdfgui/tests => tests}/test_pdfdataset.py (98%) rename {src/diffpy/pdfgui/tests => tests}/test_pdfguicontrol.py (100%) rename {src/diffpy/pdfgui/tests => tests}/test_pdfstructure.py (98%) rename {src/diffpy/pdfgui/tests => tests}/test_phaseconfigurepanel.py (96%) rename {src/diffpy/pdfgui/tests => tests}/test_structureviewer.py (98%) rename {src/diffpy/pdfgui/tests => tests}/test_temperatureseriespanel.py (95%) rename {src/diffpy/pdfgui/tests => tests}/testdata/300K.gr (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/550K.gr (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/CdSe_bulk_wur.stru (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/LaMnO3.stru (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/Ni.dat (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/Ni.stru (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/Ni_2-8.chi.gr (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/lcmo.ddp (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/lcmo_00.gr (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/lcmo_20.gr (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/lcmo_full.ddp (100%) rename {src/diffpy/pdfgui/tests => tests}/testdata/ni.ddp (100%) rename {src/diffpy/pdfgui/tests => tests}/testutils.py (99%) diff --git a/requirements/run.txt b/requirements/run.txt index a8d863e1..e9899e93 100644 --- a/requirements/run.txt +++ b/requirements/run.txt @@ -1,4 +1,4 @@ -numpy < 2.0.0 # Need to fix deprecations before 2.0.0 compat +numpy wxpython diffpy.pdffit2 diffpy.structure diff --git a/src/diffpy/pdfgui/tests/__init__.py b/src/diffpy/pdfgui/tests/__init__.py deleted file mode 100644 index beb24343..00000000 --- a/src/diffpy/pdfgui/tests/__init__.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# diffpy.pdfgui by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2012-2024 Trustees of the Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE.txt for license information. -# -############################################################################## - -"""Unit tests for diffpy.pdfgui. -""" - -import unittest - - -def testsuite(pattern=""): - """Create a unit tests suite for diffpy.pdfgui package. - - Parameters - ---------- - pattern : str, optional - Regular expression pattern for selecting test cases. - Select all tests when empty. Ignore the pattern when - any of unit test modules fails to import. - - Returns - ------- - suite : `unittest.TestSuite` - The TestSuite object containing the matching tests. - """ - import re - from importlib.resources import files - from itertools import chain - from os.path import dirname - - loader = unittest.defaultTestLoader - thisdir = str(files(__name__)) - depth = __name__.count(".") + 1 - topdir = thisdir - for i in range(depth): - topdir = dirname(topdir) - suite_all = loader.discover(thisdir, top_level_dir=topdir) - # always filter the suite by pattern to test-cover the selection code. - suite = unittest.TestSuite() - rx = re.compile(pattern) - tsuites = list(chain.from_iterable(suite_all)) - tsok = all(isinstance(ts, unittest.TestSuite) for ts in tsuites) - if not tsok: # pragma: no cover - return suite_all - tcases = chain.from_iterable(tsuites) - for tc in tcases: - tcwords = tc.id().split(".") - shortname = ".".join(tcwords[-3:]) - if rx.search(shortname): - suite.addTest(tc) - # verify all tests are found for an empty pattern. - assert pattern or suite_all.countTestCases() == suite.countTestCases() - return suite - - -def test(): - """Execute all unit tests for the diffpy.pdfgui package. - - Returns - ------- - result : `unittest.TestResult` - """ - suite = testsuite() - runner = unittest.TextTestRunner() - result = runner.run(suite) - return result - - -# End of file diff --git a/src/diffpy/pdfgui/tests/conftest.py b/src/diffpy/pdfgui/tests/conftest.py deleted file mode 100644 index e3b63139..00000000 --- a/src/diffpy/pdfgui/tests/conftest.py +++ /dev/null @@ -1,19 +0,0 @@ -import json -from pathlib import Path - -import pytest - - -@pytest.fixture -def user_filesystem(tmp_path): - base_dir = Path(tmp_path) - home_dir = base_dir / "home_dir" - home_dir.mkdir(parents=True, exist_ok=True) - cwd_dir = base_dir / "cwd_dir" - cwd_dir.mkdir(parents=True, exist_ok=True) - - home_config_data = {"username": "home_username", "email": "home@email.com"} - with open(home_dir / "diffpyconfig.json", "w") as f: - json.dump(home_config_data, f) - - yield tmp_path diff --git a/src/diffpy/pdfgui/tests/debug.py b/src/diffpy/pdfgui/tests/debug.py deleted file mode 100644 index c26a68d2..00000000 --- a/src/diffpy/pdfgui/tests/debug.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# (c) 2016 Brookhaven Science Associates, Brookhaven National Laboratory. -# (c) 2024 The Trustees of Columbia University in the City of New York. -# All rights reserved. -# -# File coded by: Billinge Group members and community contributors. -# -# See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.pdfgui/graphs/contributors -# -# See LICENSE.rst for license information. -# -############################################################################## - -""" -Convenience module for debugging the unit tests using - -python -m diffpy.pdfgui.tests.debug - -Exceptions raised by failed tests or other errors are not caught. -""" - - -if __name__ == "__main__": - import sys - - from diffpy.pdfgui.tests import testsuite - - pattern = sys.argv[1] if len(sys.argv) > 1 else "" - suite = testsuite(pattern) - suite.debug() - - -# End of file diff --git a/src/diffpy/pdfgui/tests/run.py b/src/diffpy/pdfgui/tests/run.py deleted file mode 100644 index 2184cda6..00000000 --- a/src/diffpy/pdfgui/tests/run.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# (c) 2012-2024 The Trustees of Columbia University in the City of New York. -# All rights reserved. -# -# File coded by: Billinge Group members and community contributors. -# -# See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.pdfgui/graphs/contributors -# -# See LICENSE.rst for license information. -# -############################################################################## - -"""Convenience module for executing all unit tests with - -python -m diffpy.pdfgui.tests.run -""" - - -if __name__ == "__main__": - import sys - - # show warnings by default - if not sys.warnoptions: - import os - import warnings - - warnings.simplefilter("default") - # also affect subprocesses - os.environ["PYTHONWARNINGS"] = "default" - from diffpy.pdfgui.tests import test - - # produce zero exit code for a successful test - sys.exit(not test().wasSuccessful()) - -# End of file diff --git a/src/diffpy/pdfgui/tests/showphasenotebookpanel.py b/tests/showphasenotebookpanel.py similarity index 100% rename from src/diffpy/pdfgui/tests/showphasenotebookpanel.py rename to tests/showphasenotebookpanel.py diff --git a/src/diffpy/pdfgui/tests/test_aboutdialog.py b/tests/test_aboutdialog.py similarity index 96% rename from src/diffpy/pdfgui/tests/test_aboutdialog.py rename to tests/test_aboutdialog.py index 44078276..d369090d 100644 --- a/src/diffpy/pdfgui/tests/test_aboutdialog.py +++ b/tests/test_aboutdialog.py @@ -20,12 +20,12 @@ import unittest import wx - +import pytest from diffpy.pdfgui.gui import aboutdialog -from diffpy.pdfgui.tests.testutils import GUITestCase, overridewebbrowser +from testutils import GUITestCase, overridewebbrowser -# ---------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- class TestDialogAbout(GUITestCase): def setUp(self): diff --git a/src/diffpy/pdfgui/tests/test_calculation.py b/tests/test_calculation.py similarity index 100% rename from src/diffpy/pdfgui/tests/test_calculation.py rename to tests/test_calculation.py diff --git a/src/diffpy/pdfgui/tests/test_constraint.py b/tests/test_constraint.py similarity index 100% rename from src/diffpy/pdfgui/tests/test_constraint.py rename to tests/test_constraint.py diff --git a/src/diffpy/pdfgui/tests/test_datasetpanels.py b/tests/test_datasetpanels.py similarity index 97% rename from src/diffpy/pdfgui/tests/test_datasetpanels.py rename to tests/test_datasetpanels.py index 8d01dd40..21534837 100644 --- a/src/diffpy/pdfgui/tests/test_datasetpanels.py +++ b/tests/test_datasetpanels.py @@ -22,7 +22,7 @@ import wx from diffpy.pdfgui.gui.mainframe import MainFrame -from diffpy.pdfgui.tests.testutils import GUITestCase, datafile, tooltiptext +from testutils import GUITestCase, datafile, tooltiptext # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_dopingseriespanel.py b/tests/test_dopingseriespanel.py similarity index 95% rename from src/diffpy/pdfgui/tests/test_dopingseriespanel.py rename to tests/test_dopingseriespanel.py index c678c177..dce5ecfa 100644 --- a/src/diffpy/pdfgui/tests/test_dopingseriespanel.py +++ b/tests/test_dopingseriespanel.py @@ -22,7 +22,7 @@ import wx from diffpy.pdfgui.gui.dopingseriespanel import DopingSeriesPanel -from diffpy.pdfgui.tests.testutils import GUITestCase, datafile, overridefiledialog +from testutils import GUITestCase, datafile, overridefiledialog # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_extendedplotframe.py b/tests/test_extendedplotframe.py similarity index 96% rename from src/diffpy/pdfgui/tests/test_extendedplotframe.py rename to tests/test_extendedplotframe.py index f97ad51a..3c086cf8 100644 --- a/src/diffpy/pdfgui/tests/test_extendedplotframe.py +++ b/tests/test_extendedplotframe.py @@ -25,7 +25,7 @@ from diffpy.pdfgui.control.plotter import Plotter from diffpy.pdfgui.gui import extendedplotframe as epf from diffpy.pdfgui.gui.extendedplotframe import ExtendedPlotFrame -from diffpy.pdfgui.tests.testutils import GUITestCase, overridefiledialog +from testutils import GUITestCase, overridefiledialog # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_fitdataset.py b/tests/test_fitdataset.py similarity index 99% rename from src/diffpy/pdfgui/tests/test_fitdataset.py rename to tests/test_fitdataset.py index d8d8aba6..dec1d5ef 100644 --- a/src/diffpy/pdfgui/tests/test_fitdataset.py +++ b/tests/test_fitdataset.py @@ -23,7 +23,7 @@ import diffpy.pdfgui.control.fitdataset as fds from diffpy.pdfgui.control.fitdataset import FitDataSet -from diffpy.pdfgui.tests.testutils import datafile +from testutils import datafile # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_fitstructure.py b/tests/test_fitstructure.py similarity index 99% rename from src/diffpy/pdfgui/tests/test_fitstructure.py rename to tests/test_fitstructure.py index f49caabb..f025f831 100644 --- a/src/diffpy/pdfgui/tests/test_fitstructure.py +++ b/tests/test_fitstructure.py @@ -10,7 +10,7 @@ from diffpy.pdfgui.control.controlerrors import ControlTypeError from diffpy.pdfgui.control.fitstructure import FitStructure from diffpy.pdfgui.control.pdfstructure import PDFStructure -from diffpy.pdfgui.tests.testutils import datafile +from testutils import datafile from diffpy.structure import Structure # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_insertrowsdialog.py b/tests/test_insertrowsdialog.py similarity index 96% rename from src/diffpy/pdfgui/tests/test_insertrowsdialog.py rename to tests/test_insertrowsdialog.py index 86baea93..329f00cc 100644 --- a/src/diffpy/pdfgui/tests/test_insertrowsdialog.py +++ b/tests/test_insertrowsdialog.py @@ -22,7 +22,7 @@ import wx from diffpy.pdfgui.gui.insertrowsdialog import InsertRowsDialog -from diffpy.pdfgui.tests.testutils import GUITestCase +from testutils import GUITestCase # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_loadproject.py b/tests/test_loadproject.py similarity index 98% rename from src/diffpy/pdfgui/tests/test_loadproject.py rename to tests/test_loadproject.py index 004d7e14..ebaa0afb 100644 --- a/src/diffpy/pdfgui/tests/test_loadproject.py +++ b/tests/test_loadproject.py @@ -20,7 +20,7 @@ import unittest from diffpy.pdfgui.control.controlerrors import ControlFileError -from diffpy.pdfgui.tests.testutils import GUITestCase, datafile +from testutils import GUITestCase, datafile from diffpy.pdfgui.tui import LoadProject # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_mainframe.py b/tests/test_mainframe.py similarity index 97% rename from src/diffpy/pdfgui/tests/test_mainframe.py rename to tests/test_mainframe.py index 32922c74..79310afa 100644 --- a/src/diffpy/pdfgui/tests/test_mainframe.py +++ b/tests/test_mainframe.py @@ -22,7 +22,7 @@ import wx from diffpy.pdfgui.gui.mainframe import MainFrame -from diffpy.pdfgui.tests.testutils import GUITestCase +from testutils import GUITestCase # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_parameter.py b/tests/test_parameter.py similarity index 97% rename from src/diffpy/pdfgui/tests/test_parameter.py rename to tests/test_parameter.py index 6559c42c..16f34e84 100644 --- a/src/diffpy/pdfgui/tests/test_parameter.py +++ b/tests/test_parameter.py @@ -24,7 +24,7 @@ from diffpy.pdfgui.control.controlerrors import ControlKeyError, ControlTypeError from diffpy.pdfgui.control.parameter import Parameter from diffpy.pdfgui.gui.mainframe import MainFrame -from diffpy.pdfgui.tests.testutils import GUITestCase, datafile +from testutils import GUITestCase, datafile # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_parameterspanel.py b/tests/test_parameterspanel.py similarity index 98% rename from src/diffpy/pdfgui/tests/test_parameterspanel.py rename to tests/test_parameterspanel.py index a05574f2..acb758d5 100644 --- a/src/diffpy/pdfgui/tests/test_parameterspanel.py +++ b/tests/test_parameterspanel.py @@ -23,7 +23,7 @@ from diffpy.pdfgui.control.parameter import Parameter from diffpy.pdfgui.gui.parameterspanel import ParametersPanel -from diffpy.pdfgui.tests.testutils import GUITestCase, clickcell +from testutils import GUITestCase, clickcell # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_pdfdataset.py b/tests/test_pdfdataset.py similarity index 98% rename from src/diffpy/pdfgui/tests/test_pdfdataset.py rename to tests/test_pdfdataset.py index d3172865..bb9f0c95 100644 --- a/src/diffpy/pdfgui/tests/test_pdfdataset.py +++ b/tests/test_pdfdataset.py @@ -20,7 +20,7 @@ import unittest from diffpy.pdfgui.control.pdfdataset import PDFDataSet -from diffpy.pdfgui.tests.testutils import datafile +from testutils import datafile ############################################################################## diff --git a/src/diffpy/pdfgui/tests/test_pdfguicontrol.py b/tests/test_pdfguicontrol.py similarity index 100% rename from src/diffpy/pdfgui/tests/test_pdfguicontrol.py rename to tests/test_pdfguicontrol.py diff --git a/src/diffpy/pdfgui/tests/test_pdfstructure.py b/tests/test_pdfstructure.py similarity index 98% rename from src/diffpy/pdfgui/tests/test_pdfstructure.py rename to tests/test_pdfstructure.py index f4506ac8..5b02ca1a 100644 --- a/src/diffpy/pdfgui/tests/test_pdfstructure.py +++ b/tests/test_pdfstructure.py @@ -8,7 +8,7 @@ from diffpy.pdfgui.control.controlerrors import ControlFileError, ControlKeyError from diffpy.pdfgui.control.pdfstructure import PDFStructure -from diffpy.pdfgui.tests.testutils import datafile +from testutils import datafile # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_phaseconfigurepanel.py b/tests/test_phaseconfigurepanel.py similarity index 96% rename from src/diffpy/pdfgui/tests/test_phaseconfigurepanel.py rename to tests/test_phaseconfigurepanel.py index acc01ec6..fa9face6 100644 --- a/src/diffpy/pdfgui/tests/test_phaseconfigurepanel.py +++ b/tests/test_phaseconfigurepanel.py @@ -23,7 +23,7 @@ from diffpy.pdfgui.gui.mainframe import MainFrame from diffpy.pdfgui.gui.phaseconfigurepanel import PhaseConfigurePanel -from diffpy.pdfgui.tests.testutils import GUITestCase, clickcell, datafile, overrideclipboard, tooltiptext +from testutils import GUITestCase, clickcell, datafile, overrideclipboard, tooltiptext # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_structureviewer.py b/tests/test_structureviewer.py similarity index 98% rename from src/diffpy/pdfgui/tests/test_structureviewer.py rename to tests/test_structureviewer.py index d9205b63..37f33a04 100644 --- a/src/diffpy/pdfgui/tests/test_structureviewer.py +++ b/tests/test_structureviewer.py @@ -9,7 +9,7 @@ from diffpy.pdfgui.control.controlerrors import ControlConfigError from diffpy.pdfgui.control.structureviewer import StructureViewer, getStructureViewer -from diffpy.pdfgui.tests.testutils import datafile +from testutils import datafile ############################################################################## diff --git a/src/diffpy/pdfgui/tests/test_temperatureseriespanel.py b/tests/test_temperatureseriespanel.py similarity index 95% rename from src/diffpy/pdfgui/tests/test_temperatureseriespanel.py rename to tests/test_temperatureseriespanel.py index 5835bff4..d103f120 100644 --- a/src/diffpy/pdfgui/tests/test_temperatureseriespanel.py +++ b/tests/test_temperatureseriespanel.py @@ -22,7 +22,7 @@ import wx from diffpy.pdfgui.gui.temperatureseriespanel import TemperatureSeriesPanel -from diffpy.pdfgui.tests.testutils import GUITestCase, datafile, overridefiledialog +from testutils import GUITestCase, datafile, overridefiledialog # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/testdata/300K.gr b/tests/testdata/300K.gr similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/300K.gr rename to tests/testdata/300K.gr diff --git a/src/diffpy/pdfgui/tests/testdata/550K.gr b/tests/testdata/550K.gr similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/550K.gr rename to tests/testdata/550K.gr diff --git a/src/diffpy/pdfgui/tests/testdata/CdSe_bulk_wur.stru b/tests/testdata/CdSe_bulk_wur.stru similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/CdSe_bulk_wur.stru rename to tests/testdata/CdSe_bulk_wur.stru diff --git a/src/diffpy/pdfgui/tests/testdata/LaMnO3.stru b/tests/testdata/LaMnO3.stru similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/LaMnO3.stru rename to tests/testdata/LaMnO3.stru diff --git a/src/diffpy/pdfgui/tests/testdata/Ni.dat b/tests/testdata/Ni.dat similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/Ni.dat rename to tests/testdata/Ni.dat diff --git a/src/diffpy/pdfgui/tests/testdata/Ni.stru b/tests/testdata/Ni.stru similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/Ni.stru rename to tests/testdata/Ni.stru diff --git a/src/diffpy/pdfgui/tests/testdata/Ni_2-8.chi.gr b/tests/testdata/Ni_2-8.chi.gr similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/Ni_2-8.chi.gr rename to tests/testdata/Ni_2-8.chi.gr diff --git a/src/diffpy/pdfgui/tests/testdata/lcmo.ddp b/tests/testdata/lcmo.ddp similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/lcmo.ddp rename to tests/testdata/lcmo.ddp diff --git a/src/diffpy/pdfgui/tests/testdata/lcmo_00.gr b/tests/testdata/lcmo_00.gr similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/lcmo_00.gr rename to tests/testdata/lcmo_00.gr diff --git a/src/diffpy/pdfgui/tests/testdata/lcmo_20.gr b/tests/testdata/lcmo_20.gr similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/lcmo_20.gr rename to tests/testdata/lcmo_20.gr diff --git a/src/diffpy/pdfgui/tests/testdata/lcmo_full.ddp b/tests/testdata/lcmo_full.ddp similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/lcmo_full.ddp rename to tests/testdata/lcmo_full.ddp diff --git a/src/diffpy/pdfgui/tests/testdata/ni.ddp b/tests/testdata/ni.ddp similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/ni.ddp rename to tests/testdata/ni.ddp diff --git a/src/diffpy/pdfgui/tests/testutils.py b/tests/testutils.py similarity index 99% rename from src/diffpy/pdfgui/tests/testutils.py rename to tests/testutils.py index bf0e832f..e09d565b 100644 --- a/src/diffpy/pdfgui/tests/testutils.py +++ b/tests/testutils.py @@ -19,7 +19,6 @@ import os from contextlib import contextmanager from unittest import TestCase - import wx from diffpy.pdfgui.control import pdfguicontrol @@ -34,7 +33,6 @@ def datafile(filename): rv = str(files(__name__).joinpath("testdata", filename)) return rv - @contextmanager def overridewebbrowser(fnc_open): "Temporarily replace `webbrowser.open` with given function." From e9157f2ed7226c2713a0c5db7a989706f15471b0 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 24 Sep 2024 23:32:31 -0400 Subject: [PATCH 02/20] Commit changes --- tests/test_aboutdialog.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_aboutdialog.py b/tests/test_aboutdialog.py index d369090d..fdb93713 100644 --- a/tests/test_aboutdialog.py +++ b/tests/test_aboutdialog.py @@ -20,7 +20,6 @@ import unittest import wx -import pytest from diffpy.pdfgui.gui import aboutdialog from testutils import GUITestCase, overridewebbrowser From 664de8ee70574b96b8da9fc8cc0e8e3aefa13162 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 24 Sep 2024 23:37:11 -0400 Subject: [PATCH 03/20] Add all GH actions yml --- .github/workflows/check-news-item.yml | 12 +++ .github/workflows/codecov.yml | 62 ---------------- .github/workflows/docs.yml | 48 ------------ .github/workflows/main.yml | 52 ------------- .../matrix-and-codecov-on-merge-to-main.yml | 21 ++++++ .github/workflows/matrix.yml | 73 ------------------- .github/workflows/publish-docs-on-release.yml | 14 ++++ .github/workflows/tests-on-pr.yml | 16 ++++ 8 files changed, 63 insertions(+), 235 deletions(-) create mode 100644 .github/workflows/check-news-item.yml delete mode 100644 .github/workflows/codecov.yml delete mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/matrix-and-codecov-on-merge-to-main.yml delete mode 100644 .github/workflows/matrix.yml create mode 100644 .github/workflows/publish-docs-on-release.yml create mode 100644 .github/workflows/tests-on-pr.yml diff --git a/.github/workflows/check-news-item.yml b/.github/workflows/check-news-item.yml new file mode 100644 index 00000000..3982a783 --- /dev/null +++ b/.github/workflows/check-news-item.yml @@ -0,0 +1,12 @@ +name: Check for News + +on: + pull_request_target: + branches: + - main + +jobs: + build: + uses: Billingegroup/release-scripts/.github/workflows/_check-news-item.yml@v0 + with: + project: diffpy.pdfgui diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml deleted file mode 100644 index 465d42c7..00000000 --- a/.github/workflows/codecov.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Gather coverage report and upload to codecov - -on: - push: - branches: - - main - release: - types: - - prereleased - - published - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - coverage: - runs-on: ubuntu-latest - steps: - - name: Check out diffpy.pdfgui - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - auto-update-conda: true - environment-file: environment.yml - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdfgui and requirements - run: | - conda install --file requirements/run.txt - conda install --file requirements/test.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: Install Xvfb - run: sudo apt-get install -y xvfb - - - name: Start Xvfb - run: | - export DISPLAY=:99 - Xvfb :99 -screen 0 1024x768x16 & - - - name: Validate diffpy.pdfgui - run: | - export DISPLAY=:99 - coverage run -m pytest -vv -s - coverage report -m - codecov - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 624a7a66..00000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build and Deploy Documentation - -on: - release: - types: - - published - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - docs: - runs-on: ubuntu-latest - steps: - - name: Check out diffpy.pdfgui - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: build - auto-update-conda: true - environment-file: environment.yml - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdfgui and build requirements - run: | - conda install --file requirements/build.txt - conda install --file requirements/run.txt - conda install --file requirements/docs.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: build documents - run: make -C doc html - - - name: Deploy - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./doc/build/html diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 1722ee0f..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Test - -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - validate: - runs-on: ubuntu-latest - steps: - - name: Check out diffpy.pdfgui - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - auto-update-conda: true - environment-file: environment.yml - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdfgui and requirements - run: | - conda install --file requirements/run.txt - conda install --file requirements/test.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: Install Xvfb - run: sudo apt-get install -y xvfb - - - name: Start Xvfb - run: | - export DISPLAY=:99 - Xvfb :99 -screen 0 1024x768x16 & - - - name: Validate diffpy.pdfgui - run: | - export DISPLAY=:99 - python -m pytest diff --git a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml new file mode 100644 index 00000000..23dd9d8f --- /dev/null +++ b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml @@ -0,0 +1,21 @@ +name: CI + +on: + push: + branches: + - main + release: + types: + - prereleased + - published + workflow_dispatch: + +jobs: + coverage: + uses: Billingegroup/release-scripts/.github/workflows/_matrix-and-codecov-on-merge-to-main.yml@v0 + with: + project: diffpy.pdfgui + c_extension: false + headless: true + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml deleted file mode 100644 index c2d3446c..00000000 --- a/.github/workflows/matrix.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Matrix test - -on: - push: - branches: - - main - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - test: - name: Python ${{ matrix.python-version }}, OS ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ['3.10', '3.11', '3.12'] - os: ["macos-latest", "ubuntu-latest", "windows-latest"] - steps: - - name: check out diffpy.pdfgui - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - auto-update-conda: true - environment-file: environment.yml - python-version: ${{ matrix.python-version }} - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdfgui and requirements - run: | - conda install --file requirements/run.txt - conda install --file requirements/test.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: Install latest diffpy.pdffit2 for Mac - if: runner.os == 'macos-latest' - run: | - conda uninstall diffpy.pdffit2 - brew install gsl - pip install diffpy.pdffit2==1.4.4rc1 - - - name: Install Xvfb - if: runner.os == 'Linux' - run: sudo apt-get install -y xvfb - - - name: Start Xvfb - if: runner.os == 'Linux' - run: | - export DISPLAY=:99 - Xvfb :99 -screen 0 1024x768x16 & - - - name: Validate diffpy.pdfgui - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - export DISPLAY=:99 - fi - python -m pytest - - - name: Display Python and Conda info - run: | - python --version - conda info diff --git a/.github/workflows/publish-docs-on-release.yml b/.github/workflows/publish-docs-on-release.yml new file mode 100644 index 00000000..51215241 --- /dev/null +++ b/.github/workflows/publish-docs-on-release.yml @@ -0,0 +1,14 @@ +name: Build and Deploy Docs + +on: + release: + types: + - published + workflow_dispatch: + +jobs: + docs: + uses: Billingegroup/release-scripts/.github/workflows/_publish-docs-on-release.yml@v0 + with: + project: diffpy.pdfgui + c_extension: false diff --git a/.github/workflows/tests-on-pr.yml b/.github/workflows/tests-on-pr.yml new file mode 100644 index 00000000..a5fb414f --- /dev/null +++ b/.github/workflows/tests-on-pr.yml @@ -0,0 +1,16 @@ +name: Tests on PR + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + validate: + uses: Billingegroup/release-scripts/.github/workflows/_tests-on-pr.yml@v0 + with: + project: diffpy.pdfgui + c_extension: false + headless: true From 0456b9c0077c8a08ca8af338430ebeaf04d9558f Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 24 Sep 2024 23:39:18 -0400 Subject: [PATCH 04/20] Add manifest --- .gitarchive.cfg | 5 ----- .gitattributes | 1 - .pre-commit-config.yaml | 5 ++++- MANIFEST.in | 29 ++++++++++------------------- 4 files changed, 14 insertions(+), 26 deletions(-) delete mode 100644 .gitarchive.cfg delete mode 100644 .gitattributes diff --git a/.gitarchive.cfg b/.gitarchive.cfg deleted file mode 100644 index 95e1448c..00000000 --- a/.gitarchive.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[DEFAULT] -commit = $Format:%H$ -date = $Format:%ci$ -timestamp = $Format:%ct$ -refnames = $Format:%D$ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 0caa8f9f..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -diffpy.pdfgui/_version.py export-subst diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c4588061..3070e199 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,10 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - exclude: '\.(rst|txt)$' + - id: check-case-conflict + - id: check-merge-conflict + - id: check-toml + - id: check-added-large-files - repo: https://github.com/psf/black rev: 24.4.2 hooks: diff --git a/MANIFEST.in b/MANIFEST.in index 3716e8cb..f1a78eec 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,21 +1,12 @@ -recursive-include src * -recursive-include doc * -recursive-exclude * __pycache__ -recursive-exclude * *.py[co] -exclude doc/manual/images/*.pdf -recursive-exclude doc/manual Makefile *.py *.texinfo -recursive-exclude doc/manual *.aux *.cp *.cps *.err *.log *.toc *.vr *.vrs -recursive-include icons *.png *.ico -recursive-exclude icons *.m *.xcf -global-exclude .gitattributes .gitignore .gitarchive.cfg -global-exclude .DS_Store +graft src +graft tests +graft requirements -include AUTHORS.rst -include LICENSE.rst -include README.rst -include requirements.txt +include AUTHORS.rst LICENSE*.rst README.rst -include diffpy.pdfgui/_version.py - -# If including data files in the package, add them like: -# include path/to/data_file +# Exclude all bytecode files and __pycache__ directories +global-exclude *.py[cod] # Exclude all .pyc, .pyo, and .pyd files. +global-exclude .DS_Store # Exclude Mac filesystem artifacts. +global-exclude __pycache__ # Exclude Python cache directories. +global-exclude .git* # Exclude git files and directories. +global-exclude .idea # Exclude PyCharm project settings. From a3bd7894374d4fc07476cec8667fb818bdafb60c Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 24 Sep 2024 23:39:45 -0400 Subject: [PATCH 05/20] Add pyproject.toml --- pyproject.toml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f1926b11..e6ff9605 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=62.0", "setuptools-git-versioning<2"] +requires = ["setuptools>=62.0", "setuptools-git-versioning>=2.0"] build-backend = "setuptools.build_meta" [project] name = "diffpy.pdfgui" -dynamic=['version'] +dynamic=['version', 'dependencies'] authors = [ { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, ] @@ -27,13 +27,11 @@ classifiers = [ 'Operating System :: Unix', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Scientific/Engineering :: Physics', 'Topic :: Scientific/Engineering :: Chemistry', ] -[project.scripts] -pdfgui = "diffpy.pdfgui.applications.pdfgui:main" - [project.urls] Homepage = "https://github.com/diffpy/diffpy.pdfgui/" Issues = "https://github.com/diffpy/diffpy.pdfgui/issues/" @@ -47,9 +45,12 @@ dirty_template = "{tag}" [tool.setuptools.packages.find] where = ["src"] # list of folders that contain the packages (["."] by default) include = ["*"] # package names should match these glob patterns (["*"] by default) -exclude = ["diffpy.pdfgui.tests*"] # exclude packages matching these glob patterns (empty by default) +exclude = [] # exclude packages matching these glob patterns (empty by default) namespaces = false # to disable scanning PEP 420 namespaces (true by default) +[tool.setuptools.dynamic] +dependencies = {file = ["requirements/run.txt"]} + [tool.black] line-length = 115 include = '\.pyi?$' From 5384f39e0e1be73c4ef0aac81172a4dd3c7ece50 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 24 Sep 2024 23:40:22 -0400 Subject: [PATCH 06/20] remove devutils --- devutils/makesdist | 60 ---------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100755 devutils/makesdist diff --git a/devutils/makesdist b/devutils/makesdist deleted file mode 100755 index dccfaa99..00000000 --- a/devutils/makesdist +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -"""Create source distribution tar.gz archive, where each file belongs -to a root user and modification time is set to the git commit time. -""" - -import glob -import gzip -import os -import subprocess -import sys -import tarfile - -from setup import FALLBACK_VERSION, versiondata - -BASEDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) -sys.path.insert(0, BASEDIR) - -timestamp = versiondata.getint("DEFAULT", "timestamp") - -vfb = versiondata.get("DEFAULT", "version").split(".post")[0] + ".post0" -emsg = "Invalid FALLBACK_VERSION. Expected %r got %r." -assert vfb == FALLBACK_VERSION, emsg % (vfb, FALLBACK_VERSION) - - -def inform(s): - sys.stdout.write(s) - sys.stdout.flush() - return - - -inform('Run "setup.py sdist --formats=tar" ') -cmd_sdist = [sys.executable] + "setup.py sdist --formats=tar".split() -ec = subprocess.call(cmd_sdist, cwd=BASEDIR, stdout=open(os.devnull, "w")) -if ec: - sys.exit(ec) -inform("[done]\n") - -tarname = max(glob.glob(BASEDIR + "/dist/*.tar"), key=os.path.getmtime) - -tfin = tarfile.open(tarname) -fpout = gzip.GzipFile(tarname + ".gz", "w", mtime=0) -tfout = tarfile.open(fileobj=fpout, mode="w") - - -def fixtarinfo(tinfo): - tinfo.uid = tinfo.gid = 0 - tinfo.uname = tinfo.gname = "root" - tinfo.mtime = timestamp - tinfo.mode &= ~0o022 - return tinfo - - -inform("Filter %s --> %s.gz " % (2 * (os.path.basename(tarname),))) -for ti in tfin: - tfout.addfile(fixtarinfo(ti), tfin.extractfile(ti)) - -tfin.close() -os.remove(tarname) -inform("[done]\n") From b0b84c62dd70a62c205f4b4dff2603d766dcffe7 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 24 Sep 2024 23:45:31 -0400 Subject: [PATCH 07/20] Remove setup.py --- setup.py | 37 +++++++++++++++++++++++++++++++++++ src/diffpy/pdfgui/__init__.py | 20 +++++++++---------- 2 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..33b3764e --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +# Extensions script for diffpy.pdfgui + +import os +import re +import sys +import glob +from setuptools import setup +from setuptools import Extension + +# Define extension arguments here +ext_kws = { + 'libraries' : [], + 'extra_compile_args' : [], + 'extra_link_args' : [], + 'include_dirs' : [], +} + +def create_extensions(): + "Initialize Extension objects for the setup function." + ext = Extension('diffpy.pdfgui.pdfgui', + glob.glob('src/extensions/*.cpp'), + **ext_kws) + return [ext] + + +# Extensions not included in pyproject.toml +setup_args = dict( + ext_modules = [], +) + + +if __name__ == '__main__': + setup_args['ext_modules'] = create_extensions() + setup(**setup_args) + diff --git a/src/diffpy/pdfgui/__init__.py b/src/diffpy/pdfgui/__init__.py index c12002ca..e4d1d6c0 100644 --- a/src/diffpy/pdfgui/__init__.py +++ b/src/diffpy/pdfgui/__init__.py @@ -1,23 +1,21 @@ #!/usr/bin/env python ############################################################################## # -# diffpy.pdfgui by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2006 trustees of the Michigan State University. -# All rights reserved. +# (c) 2024 The Trustees of Columbia University in the City of New York. +# All rights reserved. # -# File coded by: Pavol Juhas +# File coded by: Billinge Group members and community contributors. # -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE.txt for license information. +# See GitHub contributions for a more detailed list of contributors. +# https://github.com/diffpy/diffpy.pdfgui/graphs/contributors +# +# See LICENSE.rst for license information. # ############################################################################## -"""Constants: - __version__ -- full version of this PDFgui release -""" - +"""GUI for PDF simulation and structure refinement.""" +# package version from diffpy.pdfgui.version import __version__ # silence the pyflakes syntax checker From 913bf5a4bb45be2debe7384c7f922474d4616fde Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 24 Sep 2024 23:46:03 -0400 Subject: [PATCH 08/20] Add test version --- tests/conftest.py | 19 +++++++++++++++++++ tests/test_version.py | 10 ++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/conftest.py create mode 100644 tests/test_version.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..e3b63139 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,19 @@ +import json +from pathlib import Path + +import pytest + + +@pytest.fixture +def user_filesystem(tmp_path): + base_dir = Path(tmp_path) + home_dir = base_dir / "home_dir" + home_dir.mkdir(parents=True, exist_ok=True) + cwd_dir = base_dir / "cwd_dir" + cwd_dir.mkdir(parents=True, exist_ok=True) + + home_config_data = {"username": "home_username", "email": "home@email.com"} + with open(home_dir / "diffpyconfig.json", "w") as f: + json.dump(home_config_data, f) + + yield tmp_path diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 00000000..f7b12e23 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,10 @@ +"""Unit tests for __version__.py +""" + +import diffpy.pdfgui + + +def test_package_version(): + """Ensure the package version is defined and not set to the initial placeholder.""" + assert hasattr(diffpy.pdfgui, "__version__") + assert diffpy.pdfgui.__version__ != "0.0.0" From 7c54d6c04c9f859e014964098cb1a64eb9a61f73 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 24 Sep 2024 23:50:27 -0400 Subject: [PATCH 09/20] remove setup --- setup.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 setup.py diff --git a/setup.py b/setup.py deleted file mode 100644 index 33b3764e..00000000 --- a/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python - -# Extensions script for diffpy.pdfgui - -import os -import re -import sys -import glob -from setuptools import setup -from setuptools import Extension - -# Define extension arguments here -ext_kws = { - 'libraries' : [], - 'extra_compile_args' : [], - 'extra_link_args' : [], - 'include_dirs' : [], -} - -def create_extensions(): - "Initialize Extension objects for the setup function." - ext = Extension('diffpy.pdfgui.pdfgui', - glob.glob('src/extensions/*.cpp'), - **ext_kws) - return [ext] - - -# Extensions not included in pyproject.toml -setup_args = dict( - ext_modules = [], -) - - -if __name__ == '__main__': - setup_args['ext_modules'] = create_extensions() - setup(**setup_args) - From 0bb459d8b5737485c179ce83f8e24eb3075d47ee Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 24 Sep 2024 23:59:20 -0400 Subject: [PATCH 10/20] Access datafile not using import module --- pyproject.toml | 1 - tests/testutils.py | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e6ff9605..38fc401c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,6 @@ classifiers = [ 'Operating System :: Unix', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', 'Topic :: Scientific/Engineering :: Physics', 'Topic :: Scientific/Engineering :: Chemistry', ] diff --git a/tests/testutils.py b/tests/testutils.py index e09d565b..9d37cf6f 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -20,6 +20,7 @@ from contextlib import contextmanager from unittest import TestCase import wx +from pathlib import Path from diffpy.pdfgui.control import pdfguicontrol from diffpy.pdfgui.gui import mainframe, pdfguiglobals @@ -28,10 +29,8 @@ def datafile(filename): - from importlib.resources import files - - rv = str(files(__name__).joinpath("testdata", filename)) - return rv + return "tests/testdata/" + filename + @contextmanager def overridewebbrowser(fnc_open): From 5350fbe0d6139fc1ec5455e156fee756364b7063 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Sep 2024 00:01:50 -0400 Subject: [PATCH 11/20] Confirm requirement files --- requirements/build.txt | 2 -- requirements/run.txt | 12 ++++++------ requirements/test.txt | 3 ++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/requirements/build.txt b/requirements/build.txt index f72d870d..e69de29b 100644 --- a/requirements/build.txt +++ b/requirements/build.txt @@ -1,2 +0,0 @@ -python -setuptools diff --git a/requirements/run.txt b/requirements/run.txt index e9899e93..5b4d7ebd 100644 --- a/requirements/run.txt +++ b/requirements/run.txt @@ -1,6 +1,6 @@ -numpy -wxpython -diffpy.pdffit2 -diffpy.structure -diffpy.utils -matplotlib-base +numpy +wxpython +diffpy.pdffit2 +diffpy.structure +diffpy.utils +matplotlib-base diff --git a/requirements/test.txt b/requirements/test.txt index 977a5764..eca1f580 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,6 +1,7 @@ flake8 -freezegun pytest +freezegun codecov coverage +pytest-cov pytest-env From ad963199a7568d300efed2ccd074a72dc962602b Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Sep 2024 00:03:02 -0400 Subject: [PATCH 12/20] Confirm readme --- README.rst | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/README.rst b/README.rst index 3f1a9a10..371a04ba 100644 --- a/README.rst +++ b/README.rst @@ -15,8 +15,8 @@ .. |Black| image:: https://img.shields.io/badge/code_style-black-black :target: https://github.com/psf/black -.. |CI| image:: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/main.yml/badge.svg - :target: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/main.yml +.. |CI| image:: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/matrix-and-codecov-on-merge-to-main.yml/badge.svg + :target: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/matrix-and-codecov-on-merge-to-main.yml .. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.pdfgui/branch/main/graph/badge.svg :target: https://codecov.io/gh/diffpy/diffpy.pdfgui @@ -87,31 +87,22 @@ Then, to fully install ``diffpy.pdfgui`` in our active environment, run :: Another option is to use ``pip`` to download and install the latest release from `Python Package Index `_. -To install using ``pip`` into your ``diffpy.pdfgui_env`` environment, we will also have to -install dependencies :: - - pip install -r https://raw.githubusercontent.com/diffpy/diffpy.pdfgui/main/requirements/run.txt - -and then install the package :: +To install using ``pip`` into your ``diffpy.pdfgui_env`` environment, type :: pip install diffpy.pdfgui If you prefer to install from sources, after installing the dependencies, obtain the source archive from -`GitHub `_. Once installed, ``cd`` into your ``diffpy.pdfgui`` -directory and run the following :: +`GitHub `_. Once installed, ``cd`` into your ``diffpy.pdfgui`` directory +and run the following :: pip install . Support and Contribute ---------------------- -`Diffpy user group `_ is the discussion forum for general -questions and discussions about the use of diffpy.pdfgui. Please join the diffpy.pdfgui users community -by joining the Google group. The diffpy.pdfgui project welcomes your expertise and enthusiasm! +`Diffpy user group `_ is the discussion forum for general questions and discussions about the use of diffpy.pdfgui. Please join the diffpy.pdfgui users community by joining the Google group. The diffpy.pdfgui project welcomes your expertise and enthusiasm! -If you see a bug or want to request a feature, please `report it as an issue `_ -and/or `submit a fix as a PR `_. You can also post it to the -`Diffpy user group `_. +If you see a bug or want to request a feature, please `report it as an issue `_ and/or `submit a fix as a PR `_. You can also post it to the `Diffpy user group `_. Feel free to fork the project and contribute. To install diffpy.pdfgui in a development mode, with its sources being directly used by Python @@ -139,5 +130,4 @@ Before contribuing, please read our `Code of Conduct `_ or email Prof. Simon Billinge -at sb2896@columbia.edu. +For more information on diffpy.pdfgui please visit the project `web-page `_ or email Prof. Simon Billinge at sb2896@columbia.edu. From 2c89c35cba37877729d01374bcbb4f00081428cc Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Sep 2024 00:03:24 -0400 Subject: [PATCH 13/20] Remove nonused path module --- tests/testutils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testutils.py b/tests/testutils.py index 9d37cf6f..f1018929 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -20,7 +20,6 @@ from contextlib import contextmanager from unittest import TestCase import wx -from pathlib import Path from diffpy.pdfgui.control import pdfguicontrol from diffpy.pdfgui.gui import mainframe, pdfguiglobals From f06cb22672f771b5dba2e1b921d0e98baae10d41 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Sep 2024 00:05:43 -0400 Subject: [PATCH 14/20] Include doc files --- doc/make.bat | 72 +++++++++---------- doc/source/api/diffpy.pdfgui.applications.rst | 1 + doc/source/api/diffpy.pdfgui.control.rst | 1 + doc/source/api/diffpy.pdfgui.gui.design.rst | 1 + doc/source/api/diffpy.pdfgui.gui.rst | 1 + .../api/diffpy.pdfgui.gui.wxextensions.rst | 1 + doc/source/api/diffpy.pdfgui.icons.rst | 10 +++ doc/source/api/diffpy.pdfgui.rst | 2 + 8 files changed, 53 insertions(+), 36 deletions(-) create mode 100644 doc/source/api/diffpy.pdfgui.icons.rst diff --git a/doc/make.bat b/doc/make.bat index 2be83069..ac53d5bd 100644 --- a/doc/make.bat +++ b/doc/make.bat @@ -1,36 +1,36 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build -set SPHINXPROJ=PackagingScientificPython - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% - -:end -popd +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build +set SPHINXPROJ=PackagingScientificPython + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/doc/source/api/diffpy.pdfgui.applications.rst b/doc/source/api/diffpy.pdfgui.applications.rst index c9fc29a7..29d9683d 100644 --- a/doc/source/api/diffpy.pdfgui.applications.rst +++ b/doc/source/api/diffpy.pdfgui.applications.rst @@ -18,3 +18,4 @@ diffpy.pdfgui.applications.pdfgui module :members: :undoc-members: :show-inheritance: + diff --git a/doc/source/api/diffpy.pdfgui.control.rst b/doc/source/api/diffpy.pdfgui.control.rst index 01ed5579..89d31f0d 100644 --- a/doc/source/api/diffpy.pdfgui.control.rst +++ b/doc/source/api/diffpy.pdfgui.control.rst @@ -138,3 +138,4 @@ diffpy.pdfgui.control.organizer module :members: :undoc-members: :show-inheritance: + diff --git a/doc/source/api/diffpy.pdfgui.gui.design.rst b/doc/source/api/diffpy.pdfgui.gui.design.rst index 049857ee..6f768f65 100644 --- a/doc/source/api/diffpy.pdfgui.gui.design.rst +++ b/doc/source/api/diffpy.pdfgui.gui.design.rst @@ -7,3 +7,4 @@ diffpy.pdfgui.gui.design package :members: :undoc-members: :show-inheritance: + diff --git a/doc/source/api/diffpy.pdfgui.gui.rst b/doc/source/api/diffpy.pdfgui.gui.rst index 8e2c9750..67db606e 100644 --- a/doc/source/api/diffpy.pdfgui.gui.rst +++ b/doc/source/api/diffpy.pdfgui.gui.rst @@ -371,3 +371,4 @@ diffpy.pdfgui.gui.mainframe module :members: :undoc-members: :show-inheritance: + diff --git a/doc/source/api/diffpy.pdfgui.gui.wxextensions.rst b/doc/source/api/diffpy.pdfgui.gui.wxextensions.rst index eee1258e..eb6cc419 100644 --- a/doc/source/api/diffpy.pdfgui.gui.wxextensions.rst +++ b/doc/source/api/diffpy.pdfgui.gui.wxextensions.rst @@ -58,3 +58,4 @@ diffpy.pdfgui.gui.wxextensions.paneldialog module :members: :undoc-members: :show-inheritance: + diff --git a/doc/source/api/diffpy.pdfgui.icons.rst b/doc/source/api/diffpy.pdfgui.icons.rst new file mode 100644 index 00000000..ebee0ad7 --- /dev/null +++ b/doc/source/api/diffpy.pdfgui.icons.rst @@ -0,0 +1,10 @@ +:tocdepth: -1 + +diffpy.pdfgui.icons package +=========================== + +.. automodule:: diffpy.pdfgui.icons + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/api/diffpy.pdfgui.rst b/doc/source/api/diffpy.pdfgui.rst index eaf4bd3f..7679a4fb 100644 --- a/doc/source/api/diffpy.pdfgui.rst +++ b/doc/source/api/diffpy.pdfgui.rst @@ -14,6 +14,7 @@ Subpackages .. toctree:: :titlesonly: + diffpy.pdfgui.icons diffpy.pdfgui.gui diffpy.pdfgui.applications diffpy.pdfgui.control @@ -36,3 +37,4 @@ diffpy.pdfgui.tui module :members: :undoc-members: :show-inheritance: + From 5a44e70278c5313c46be343a01485d6e03dd959c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 04:11:23 +0000 Subject: [PATCH 15/20] [pre-commit.ci] auto fixes from pre-commit hooks --- AUTHORS.rst | 14 +++---- README.rst | 22 +++++------ doc/source/api/diffpy.pdfgui.applications.rst | 1 - doc/source/api/diffpy.pdfgui.control.rst | 1 - doc/source/api/diffpy.pdfgui.gui.design.rst | 1 - doc/source/api/diffpy.pdfgui.gui.rst | 1 - .../api/diffpy.pdfgui.gui.wxextensions.rst | 1 - doc/source/api/diffpy.pdfgui.icons.rst | 1 - doc/source/api/diffpy.pdfgui.rst | 1 - doc/source/index.rst | 38 +++++++++---------- tests/test_aboutdialog.py | 3 +- tests/test_datasetpanels.py | 2 +- tests/test_dopingseriespanel.py | 2 +- tests/test_extendedplotframe.py | 2 +- tests/test_fitdataset.py | 2 +- tests/test_fitstructure.py | 3 +- tests/test_insertrowsdialog.py | 2 +- tests/test_loadproject.py | 3 +- tests/test_mainframe.py | 2 +- tests/test_parameter.py | 2 +- tests/test_parameterspanel.py | 2 +- tests/test_pdfdataset.py | 3 +- tests/test_pdfstructure.py | 3 +- tests/test_phaseconfigurepanel.py | 2 +- tests/test_structureviewer.py | 3 +- tests/test_temperatureseriespanel.py | 2 +- tests/testutils.py | 3 +- 27 files changed, 61 insertions(+), 61 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 99b148ea..739f2f4b 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -15,17 +15,17 @@ This code was developed as part of the DiffPy project to create python modules for structure investigations from diffraction data. The main contributors to this package were - Chris Farrow, - Jiwu Liu, - Pavol Juhas, + Chris Farrow, + Jiwu Liu, + Pavol Juhas, Dmitriy Bryndin Other current and former contributors of the DiffPy project include - Simon Billinge, - Chris Farrow, - Emil Bozin, - Wenduo Zhou, + Simon Billinge, + Chris Farrow, + Emil Bozin, + Wenduo Zhou, Peng Tian The DiffPy team is part of the Billinge Group at Columbia University in New York, diff --git a/README.rst b/README.rst index 371a04ba..74ca65ab 100644 --- a/README.rst +++ b/README.rst @@ -38,11 +38,11 @@ Graphical user interface program for structure refinements to atomic pair distribution function. -For users who do not have the expertise or necessity for command -line analysis, PDFgui is a convenient and easy to use graphical front -end for the PDFfit2 refinement program. It is capable of full-profile -fitting of the atomic pair distribution function (PDF) derived from x-ray -or neutron diffraction data and comes with built in graphical and structure +For users who do not have the expertise or necessity for command +line analysis, PDFgui is a convenient and easy to use graphical front +end for the PDFfit2 refinement program. It is capable of full-profile +fitting of the atomic pair distribution function (PDF) derived from x-ray +or neutron diffraction data and comes with built in graphical and structure visualization capabilities. PDFgui is a friendly interface to the PDFfit2 refinement engine, with many @@ -50,18 +50,18 @@ powerful extensions. To get started, please open the manual from the help menu and follow the tutorial instructions. A detailed description is available in `this paper `_. -For more information about diffpy.pdfgui, please consult our +For more information about diffpy.pdfgui, please consult our `online documentation `_. Citation -------- -If you use diffpy.pdfgui in a scientific publication, we would like you to +If you use diffpy.pdfgui in a scientific publication, we would like you to cite this package as - C L Farrow, P Juhas, J W Liu, D Bryndin, E S Božin, - J Bloch, Th Proffen and S J L Billinge, PDFfit2 and PDFgui: - computer programs for studying nanostructure in crystals, J. Phys.: + C L Farrow, P Juhas, J W Liu, D Bryndin, E S Božin, + J Bloch, Th Proffen and S J L Billinge, PDFfit2 and PDFgui: + computer programs for studying nanostructure in crystals, J. Phys.: Condens. Matter 19 (2007) 335219. doi:10.1088/0953-8984/19/33/335219 Installation @@ -102,7 +102,7 @@ Support and Contribute `Diffpy user group `_ is the discussion forum for general questions and discussions about the use of diffpy.pdfgui. Please join the diffpy.pdfgui users community by joining the Google group. The diffpy.pdfgui project welcomes your expertise and enthusiasm! -If you see a bug or want to request a feature, please `report it as an issue `_ and/or `submit a fix as a PR `_. You can also post it to the `Diffpy user group `_. +If you see a bug or want to request a feature, please `report it as an issue `_ and/or `submit a fix as a PR `_. You can also post it to the `Diffpy user group `_. Feel free to fork the project and contribute. To install diffpy.pdfgui in a development mode, with its sources being directly used by Python diff --git a/doc/source/api/diffpy.pdfgui.applications.rst b/doc/source/api/diffpy.pdfgui.applications.rst index 29d9683d..c9fc29a7 100644 --- a/doc/source/api/diffpy.pdfgui.applications.rst +++ b/doc/source/api/diffpy.pdfgui.applications.rst @@ -18,4 +18,3 @@ diffpy.pdfgui.applications.pdfgui module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.pdfgui.control.rst b/doc/source/api/diffpy.pdfgui.control.rst index 89d31f0d..01ed5579 100644 --- a/doc/source/api/diffpy.pdfgui.control.rst +++ b/doc/source/api/diffpy.pdfgui.control.rst @@ -138,4 +138,3 @@ diffpy.pdfgui.control.organizer module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.pdfgui.gui.design.rst b/doc/source/api/diffpy.pdfgui.gui.design.rst index 6f768f65..049857ee 100644 --- a/doc/source/api/diffpy.pdfgui.gui.design.rst +++ b/doc/source/api/diffpy.pdfgui.gui.design.rst @@ -7,4 +7,3 @@ diffpy.pdfgui.gui.design package :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.pdfgui.gui.rst b/doc/source/api/diffpy.pdfgui.gui.rst index 67db606e..8e2c9750 100644 --- a/doc/source/api/diffpy.pdfgui.gui.rst +++ b/doc/source/api/diffpy.pdfgui.gui.rst @@ -371,4 +371,3 @@ diffpy.pdfgui.gui.mainframe module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.pdfgui.gui.wxextensions.rst b/doc/source/api/diffpy.pdfgui.gui.wxextensions.rst index eb6cc419..eee1258e 100644 --- a/doc/source/api/diffpy.pdfgui.gui.wxextensions.rst +++ b/doc/source/api/diffpy.pdfgui.gui.wxextensions.rst @@ -58,4 +58,3 @@ diffpy.pdfgui.gui.wxextensions.paneldialog module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.pdfgui.icons.rst b/doc/source/api/diffpy.pdfgui.icons.rst index ebee0ad7..c953a711 100644 --- a/doc/source/api/diffpy.pdfgui.icons.rst +++ b/doc/source/api/diffpy.pdfgui.icons.rst @@ -7,4 +7,3 @@ diffpy.pdfgui.icons package :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.pdfgui.rst b/doc/source/api/diffpy.pdfgui.rst index 7679a4fb..ab800cde 100644 --- a/doc/source/api/diffpy.pdfgui.rst +++ b/doc/source/api/diffpy.pdfgui.rst @@ -37,4 +37,3 @@ diffpy.pdfgui.tui module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/index.rst b/doc/source/index.rst index 08740bd2..6d042abe 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -9,11 +9,11 @@ diffpy.pdfgui - GUI for PDF simulation and structure refinement. | Software version |release| | Last updated |today| -For users who do not have the expertise or necessity for command -line analysis, PDFgui is a convenient and easy to use graphical front -end for the PDFfit2 refinement program. It is capable of full-profile -fitting of the atomic pair distribution function (PDF) derived from x-ray -or neutron diffraction data and comes with built in graphical and structure +For users who do not have the expertise or necessity for command +line analysis, PDFgui is a convenient and easy to use graphical front +end for the PDFfit2 refinement program. It is capable of full-profile +fitting of the atomic pair distribution function (PDF) derived from x-ray +or neutron diffraction data and comes with built in graphical and structure visualization capabilities. PDFgui is a friendly interface to the PDFfit2 refinement engine, with many @@ -32,17 +32,17 @@ and do not necessarily reflect the views of the NSF. The main contributors to this package were - Chris Farrow, - Jiwu Liu, - Pavol Juhas, + Chris Farrow, + Jiwu Liu, + Pavol Juhas, Dmitriy Bryndin Other current and former contributors of the DiffPy project include - Simon Billinge, - Chris Farrow, - Emil Bozin, - Wenduo Zhou, + Simon Billinge, + Chris Farrow, + Emil Bozin, + Wenduo Zhou, Peng Tian The DiffPy team is part of the Billinge Group at Columbia University in New York, @@ -55,13 +55,13 @@ https://github.com/diffpy/diffpy.pdfgui/graphs/contributors. Reference ========= -If you use this program for a scientific research that leads to publication, -we ask that you acknowledge use of the program by citing the following paper +If you use this program for a scientific research that leads to publication, +we ask that you acknowledge use of the program by citing the following paper in your publication: - C L Farrow, P Juhas, J W Liu, D Bryndin, E S Božin, - J Bloch, Th Proffen and S J L Billinge, `PDFfit2 and PDFgui: - computer programs for studying nanostructure in crystals `_, + C L Farrow, P Juhas, J W Liu, D Bryndin, E S Božin, + J Bloch, Th Proffen and S J L Billinge, `PDFfit2 and PDFgui: + computer programs for studying nanostructure in crystals `_, J. Phys.: Condens. Matter 19 (2007) 335219. ============ @@ -75,9 +75,9 @@ file included with the distribution. Tutorial ======== -The tutorial for the package can be found here: +The tutorial for the package can be found here: -.. toctree:: +.. toctree:: tutorial diff --git a/tests/test_aboutdialog.py b/tests/test_aboutdialog.py index fdb93713..532bd2e8 100644 --- a/tests/test_aboutdialog.py +++ b/tests/test_aboutdialog.py @@ -20,12 +20,13 @@ import unittest import wx -from diffpy.pdfgui.gui import aboutdialog from testutils import GUITestCase, overridewebbrowser +from diffpy.pdfgui.gui import aboutdialog # ---------------------------------------------------------------------------- + class TestDialogAbout(GUITestCase): def setUp(self): self.app = wx.App() diff --git a/tests/test_datasetpanels.py b/tests/test_datasetpanels.py index 21534837..ae83979b 100644 --- a/tests/test_datasetpanels.py +++ b/tests/test_datasetpanels.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase, datafile, tooltiptext from diffpy.pdfgui.gui.mainframe import MainFrame -from testutils import GUITestCase, datafile, tooltiptext # ---------------------------------------------------------------------------- diff --git a/tests/test_dopingseriespanel.py b/tests/test_dopingseriespanel.py index dce5ecfa..5dd06404 100644 --- a/tests/test_dopingseriespanel.py +++ b/tests/test_dopingseriespanel.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase, datafile, overridefiledialog from diffpy.pdfgui.gui.dopingseriespanel import DopingSeriesPanel -from testutils import GUITestCase, datafile, overridefiledialog # ---------------------------------------------------------------------------- diff --git a/tests/test_extendedplotframe.py b/tests/test_extendedplotframe.py index 3c086cf8..4c7830bc 100644 --- a/tests/test_extendedplotframe.py +++ b/tests/test_extendedplotframe.py @@ -21,11 +21,11 @@ import numpy import wx +from testutils import GUITestCase, overridefiledialog from diffpy.pdfgui.control.plotter import Plotter from diffpy.pdfgui.gui import extendedplotframe as epf from diffpy.pdfgui.gui.extendedplotframe import ExtendedPlotFrame -from testutils import GUITestCase, overridefiledialog # ---------------------------------------------------------------------------- diff --git a/tests/test_fitdataset.py b/tests/test_fitdataset.py index dec1d5ef..994402cc 100644 --- a/tests/test_fitdataset.py +++ b/tests/test_fitdataset.py @@ -20,10 +20,10 @@ import unittest import numpy +from testutils import datafile import diffpy.pdfgui.control.fitdataset as fds from diffpy.pdfgui.control.fitdataset import FitDataSet -from testutils import datafile # ---------------------------------------------------------------------------- diff --git a/tests/test_fitstructure.py b/tests/test_fitstructure.py index f025f831..090ed876 100644 --- a/tests/test_fitstructure.py +++ b/tests/test_fitstructure.py @@ -6,11 +6,12 @@ import unittest +from testutils import datafile + from diffpy.pdfgui.control.constraint import Constraint from diffpy.pdfgui.control.controlerrors import ControlTypeError from diffpy.pdfgui.control.fitstructure import FitStructure from diffpy.pdfgui.control.pdfstructure import PDFStructure -from testutils import datafile from diffpy.structure import Structure # ---------------------------------------------------------------------------- diff --git a/tests/test_insertrowsdialog.py b/tests/test_insertrowsdialog.py index 329f00cc..7879582c 100644 --- a/tests/test_insertrowsdialog.py +++ b/tests/test_insertrowsdialog.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase from diffpy.pdfgui.gui.insertrowsdialog import InsertRowsDialog -from testutils import GUITestCase # ---------------------------------------------------------------------------- diff --git a/tests/test_loadproject.py b/tests/test_loadproject.py index ebaa0afb..ac1f0443 100644 --- a/tests/test_loadproject.py +++ b/tests/test_loadproject.py @@ -19,8 +19,9 @@ import unittest -from diffpy.pdfgui.control.controlerrors import ControlFileError from testutils import GUITestCase, datafile + +from diffpy.pdfgui.control.controlerrors import ControlFileError from diffpy.pdfgui.tui import LoadProject # ---------------------------------------------------------------------------- diff --git a/tests/test_mainframe.py b/tests/test_mainframe.py index 79310afa..3a177a1f 100644 --- a/tests/test_mainframe.py +++ b/tests/test_mainframe.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase from diffpy.pdfgui.gui.mainframe import MainFrame -from testutils import GUITestCase # ---------------------------------------------------------------------------- diff --git a/tests/test_parameter.py b/tests/test_parameter.py index 16f34e84..b0161a9f 100644 --- a/tests/test_parameter.py +++ b/tests/test_parameter.py @@ -20,11 +20,11 @@ import unittest import wx +from testutils import GUITestCase, datafile from diffpy.pdfgui.control.controlerrors import ControlKeyError, ControlTypeError from diffpy.pdfgui.control.parameter import Parameter from diffpy.pdfgui.gui.mainframe import MainFrame -from testutils import GUITestCase, datafile # ---------------------------------------------------------------------------- diff --git a/tests/test_parameterspanel.py b/tests/test_parameterspanel.py index acb758d5..ddb9a81b 100644 --- a/tests/test_parameterspanel.py +++ b/tests/test_parameterspanel.py @@ -20,10 +20,10 @@ import unittest import wx.grid +from testutils import GUITestCase, clickcell from diffpy.pdfgui.control.parameter import Parameter from diffpy.pdfgui.gui.parameterspanel import ParametersPanel -from testutils import GUITestCase, clickcell # ---------------------------------------------------------------------------- diff --git a/tests/test_pdfdataset.py b/tests/test_pdfdataset.py index bb9f0c95..be5fe080 100644 --- a/tests/test_pdfdataset.py +++ b/tests/test_pdfdataset.py @@ -19,9 +19,10 @@ import unittest -from diffpy.pdfgui.control.pdfdataset import PDFDataSet from testutils import datafile +from diffpy.pdfgui.control.pdfdataset import PDFDataSet + ############################################################################## class TestPDFDataSet(unittest.TestCase): diff --git a/tests/test_pdfstructure.py b/tests/test_pdfstructure.py index 5b02ca1a..2753328d 100644 --- a/tests/test_pdfstructure.py +++ b/tests/test_pdfstructure.py @@ -6,9 +6,10 @@ import unittest +from testutils import datafile + from diffpy.pdfgui.control.controlerrors import ControlFileError, ControlKeyError from diffpy.pdfgui.control.pdfstructure import PDFStructure -from testutils import datafile # ---------------------------------------------------------------------------- diff --git a/tests/test_phaseconfigurepanel.py b/tests/test_phaseconfigurepanel.py index fa9face6..aae1a27d 100644 --- a/tests/test_phaseconfigurepanel.py +++ b/tests/test_phaseconfigurepanel.py @@ -20,10 +20,10 @@ import unittest import wx +from testutils import GUITestCase, clickcell, datafile, overrideclipboard, tooltiptext from diffpy.pdfgui.gui.mainframe import MainFrame from diffpy.pdfgui.gui.phaseconfigurepanel import PhaseConfigurePanel -from testutils import GUITestCase, clickcell, datafile, overrideclipboard, tooltiptext # ---------------------------------------------------------------------------- diff --git a/tests/test_structureviewer.py b/tests/test_structureviewer.py index 37f33a04..02602087 100644 --- a/tests/test_structureviewer.py +++ b/tests/test_structureviewer.py @@ -7,9 +7,10 @@ import os import unittest +from testutils import datafile + from diffpy.pdfgui.control.controlerrors import ControlConfigError from diffpy.pdfgui.control.structureviewer import StructureViewer, getStructureViewer -from testutils import datafile ############################################################################## diff --git a/tests/test_temperatureseriespanel.py b/tests/test_temperatureseriespanel.py index d103f120..02ae7897 100644 --- a/tests/test_temperatureseriespanel.py +++ b/tests/test_temperatureseriespanel.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase, datafile, overridefiledialog from diffpy.pdfgui.gui.temperatureseriespanel import TemperatureSeriesPanel -from testutils import GUITestCase, datafile, overridefiledialog # ---------------------------------------------------------------------------- diff --git a/tests/testutils.py b/tests/testutils.py index f1018929..6a887686 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -19,6 +19,7 @@ import os from contextlib import contextmanager from unittest import TestCase + import wx from diffpy.pdfgui.control import pdfguicontrol @@ -29,7 +30,7 @@ def datafile(filename): return "tests/testdata/" + filename - + @contextmanager def overridewebbrowser(fnc_open): From 07ca11d2e1b736d9c3dfa9330f973f8b360d4de7 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Sep 2024 00:22:21 -0400 Subject: [PATCH 16/20] Add entry main point back in pyproject --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 38fc401c..8f24911f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,9 @@ classifiers = [ 'Topic :: Scientific/Engineering :: Chemistry', ] +[project.scripts] +pdfgui = "diffpy.pdfgui.applications.pdfgui:main" + [project.urls] Homepage = "https://github.com/diffpy/diffpy.pdfgui/" Issues = "https://github.com/diffpy/diffpy.pdfgui/issues/" From 03d627a8139830aa8d2dc0ec93e8b895ec6c4985 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Sep 2024 07:46:20 -0400 Subject: [PATCH 17/20] Rename showphasenotebookpanel.py to test_showphasenotebookpanel.py --- .../{showphasenotebookpanel.py => test_showphasenotebookpanel.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{showphasenotebookpanel.py => test_showphasenotebookpanel.py} (100%) diff --git a/tests/showphasenotebookpanel.py b/tests/test_showphasenotebookpanel.py similarity index 100% rename from tests/showphasenotebookpanel.py rename to tests/test_showphasenotebookpanel.py From 2f81b9ba8199d8e1aac9f97578bb63161a1c09f4 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Sep 2024 14:15:45 -0400 Subject: [PATCH 18/20] Use testutils for datafile --- tests/test_showphasenotebookpanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_showphasenotebookpanel.py b/tests/test_showphasenotebookpanel.py index 71c3f0d3..0846dcf1 100644 --- a/tests/test_showphasenotebookpanel.py +++ b/tests/test_showphasenotebookpanel.py @@ -20,7 +20,7 @@ import wx from diffpy.pdfgui.gui.phasenotebookpanel import PhaseNotebookPanel -from diffpy.pdfgui.tests.testutils import datafile +from testutils import datafile from diffpy.pdfgui.tui import LoadProject From 1cea35acde6dcb299acb8c46c77c707f5904f932 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:15:58 +0000 Subject: [PATCH 19/20] [pre-commit.ci] auto fixes from pre-commit hooks --- tests/test_showphasenotebookpanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_showphasenotebookpanel.py b/tests/test_showphasenotebookpanel.py index 0846dcf1..5fec5d5e 100644 --- a/tests/test_showphasenotebookpanel.py +++ b/tests/test_showphasenotebookpanel.py @@ -18,9 +18,9 @@ import wx +from testutils import datafile from diffpy.pdfgui.gui.phasenotebookpanel import PhaseNotebookPanel -from testutils import datafile from diffpy.pdfgui.tui import LoadProject From 4efbad55530bd2fa8b3a10a65cc41d738cc8b7f1 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Wed, 25 Sep 2024 14:20:24 -0400 Subject: [PATCH 20/20] Add numpy pinning below 2 --- requirements/run.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/run.txt b/requirements/run.txt index 5b4d7ebd..949c77f6 100644 --- a/requirements/run.txt +++ b/requirements/run.txt @@ -1,4 +1,4 @@ -numpy +numpy < 2.0.0 wxpython diffpy.pdffit2 diffpy.structure