diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..2909d67f --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,43 @@ +name: Build Documentation + +on: + push: + branches: + - main + release: + +jobs: + test: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: build + auto-update-conda: true + + - name: install requirements + run: >- + conda install -n build -c conda-forge + --file requirements/build.txt + --file requirements/run.txt + --file requirements/docs.txt + --quiet --yes + + - name: install the package + run: 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 new file mode 100644 index 00000000..e3ade008 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,53 @@ +name: CI + +on: + push: + branches: + - main + - CI + pull_request: + workflow_dispatch: + +jobs: + miniconda: + name: Miniconda ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["ubuntu-latest"] + steps: + - name: check out diffpy.pdfgui + uses: actions/checkout@v3 + with: + repository: diffpy/diffpy.pdfgui + path: . + fetch-depth: 0 # avoid shallow clone with no tags + + - name: Install Mamba + run: | + wget "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh" -O mambaforge.sh + bash mambaforge.sh -b -p $HOME/mambaforge + echo "$HOME/mambaforge/bin" >> $GITHUB_PATH + source $HOME/mambaforge/etc/profile.d/conda.sh + conda init bash + + - name: Create conda environment + run: | + source $HOME/mambaforge/etc/profile.d/conda.sh + conda create -n test_env python=3.12 xonsh regolith -c conda-forge -y + conda activate test_env + pip install case_insensitive_dict + + - name: Install dependencies + run: | + source $HOME/mambaforge/etc/profile.d/conda.sh + conda activate test_env + mamba install --file requirements/run.txt + mamba install --file requirements/test.txt + pip install -e . + + - name: Use Xvfb Action + uses: GabrielBB/xvfb-action@v1 + with: + run: | + bash -c "source $HOME/mambaforge/etc/profile.d/conda.sh && conda activate test_env && python -m run_tests.py" diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..f2ff7e42 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,19 @@ +name: pre-commit + +on: + pull_request: + push: + workflow_dispatch: + +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 + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - uses: pre-commit/action@v3.0.0 + with: + extra_args: --all-files diff --git a/conda-recipe/run_test.py b/conda-recipe/dont_run.py similarity index 100% rename from conda-recipe/run_test.py rename to conda-recipe/dont_run.py diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.suppress_yaml similarity index 96% rename from conda-recipe/meta.yaml rename to conda-recipe/meta.suppress_yaml index 2eeff68a..568d0c7d 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.suppress_yaml @@ -54,7 +54,7 @@ test: # entry points work. - # You can also put a file called run_test.py in the recipe that will be run + # You can also put a file called dont_run.py in the recipe that will be run # at test time. # requires: diff --git a/environment.yml b/environment.yml new file mode 100644 index 00000000..a3904941 --- /dev/null +++ b/environment.yml @@ -0,0 +1,6 @@ +name: diffpy.pdfgui +channels: + - conda-forge +dependencies: + - python=3 + - pip diff --git a/requirements/run.txt b/requirements/run.txt index 10e45f83..40bce3f0 100644 --- a/requirements/run.txt +++ b/requirements/run.txt @@ -1,4 +1,4 @@ -numpy +numpy==1.26 wxpython diffpy.pdffit2 diffpy.utils diff --git a/requirements/test.txt b/requirements/test.txt index 7167f602..628a048a 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,2 +1,4 @@ pytest freezegun +coverage +codecov diff --git a/run_tests.py b/run_tests.py new file mode 100644 index 00000000..a2a69494 --- /dev/null +++ b/run_tests.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python + +import diffpy.pdfgui.tests + +assert diffpy.pdfgui.tests.testdeps().wasSuccessful() diff --git a/src/diffpy/pdfgui/applications/__init__.py b/src/diffpy/pdfgui/applications/__init__.py index d698044f..8bdc5f5a 100644 --- a/src/diffpy/pdfgui/applications/__init__.py +++ b/src/diffpy/pdfgui/applications/__init__.py @@ -3,7 +3,7 @@ # # diffpy.pdfgui by DANSE Diffraction group # Simon J. L. Billinge -# (c) 2009 Trustees of the Columbia University +# (c) 2009-2024 Trustees of the Columbia University # in the City of New York. All rights reserved. # # File coded by: Pavol Juhas diff --git a/src/diffpy/pdfgui/control/structureviewer.py b/src/diffpy/pdfgui/control/structureviewer.py index d58def97..85308d10 100644 --- a/src/diffpy/pdfgui/control/structureviewer.py +++ b/src/diffpy/pdfgui/control/structureviewer.py @@ -3,7 +3,7 @@ # # diffpy.pdfgui by DANSE Diffraction group # Simon J. L. Billinge -# (c) 2009 Trustees of the Columbia University +# (c) 2009-2024 Trustees of the Columbia University # in the City of New York. All rights reserved. # # File coded by: Pavol Juhas diff --git a/src/diffpy/pdfgui/gui/aboutdialog.py b/src/diffpy/pdfgui/gui/aboutdialog.py index 37bd30c7..c71c45b3 100644 --- a/src/diffpy/pdfgui/gui/aboutdialog.py +++ b/src/diffpy/pdfgui/gui/aboutdialog.py @@ -4,6 +4,8 @@ # PDFgui by DANSE Diffraction group # Simon J. L. Billinge # (c) 2006 trustees of the Michigan State University. +# (c) 2024 trustees of the Columbia University in the City +# of New York # All rights reserved. # # File coded by: Dmitriy Bryndin @@ -233,7 +235,7 @@ def onColumbiaLogo(self, event): # wxGlade: DialogAbout. # end of class DialogAbout -##### testing code ########################################################### +# #### testing code ########################################################### if __name__ == "__main__": app = wx.App() diff --git a/src/diffpy/pdfgui/gui/adddatapanel.py b/src/diffpy/pdfgui/gui/adddatapanel.py index 7f5f1407..15cb48ca 100644 --- a/src/diffpy/pdfgui/gui/adddatapanel.py +++ b/src/diffpy/pdfgui/gui/adddatapanel.py @@ -5,6 +5,7 @@ # PDFgui by DANSE Diffraction group # Simon J. L. Billinge # (c) 2006 trustees of the Michigan State University. +# (c) 2024 trustees of the Columbia University in the City # All rights reserved. # # File coded by: Chris Farrow diff --git a/src/diffpy/pdfgui/gui/errorwrapper.py b/src/diffpy/pdfgui/gui/errorwrapper.py index a45a55fc..de99d93b 100644 --- a/src/diffpy/pdfgui/gui/errorwrapper.py +++ b/src/diffpy/pdfgui/gui/errorwrapper.py @@ -75,7 +75,7 @@ def _f(*args, **kwargs): return rvpass # Everything else - except: + except Exception: if pdfguiglobals.dbopts.pythondebugger: import pdb diff --git a/src/diffpy/pdfgui/gui/fittree.py b/src/diffpy/pdfgui/gui/fittree.py index 886a6e61..d82970c2 100644 --- a/src/diffpy/pdfgui/gui/fittree.py +++ b/src/diffpy/pdfgui/gui/fittree.py @@ -356,9 +356,9 @@ def AddFit(self, fitname="Fit 1", cdata=None, paste=False): cdata = self.control.paste(cdata, None, fitname, pos) self.SetControlData(newfit, cdata) return newfit - except: + except Exception: self.Delete(newfit) - raise + raise Exception return def AddPhase(self, node, label, insertafter=None, filename=None, makedata=True, cdata=None): @@ -427,9 +427,9 @@ def AddPhase(self, node, label, insertafter=None, filename=None, makedata=True, elif cdata is not None: self.control.paste(cdata, pdata, label, pos) return newphase - except: + except Exception: self.Delete(newphase) - raise + raise Exception return def AddDataSet(self, node, label, insertafter=None, filename=None, makedata=True, cdata=None): @@ -492,9 +492,9 @@ def AddDataSet(self, node, label, insertafter=None, filename=None, makedata=True elif cdata is not None: self.control.paste(cdata, pdata, label, pos) return newset - except: + except Exception: self.Delete(newset) - raise + raise Exception return def AddCalc(self, node, label, insertafter=None, makedata=True, cdata=None): @@ -553,9 +553,9 @@ def AddCalc(self, node, label, insertafter=None, makedata=True, cdata=None): elif cdata is not None: self.control.paste(cdata, pdata, label, pos) return newcalc - except: + except Exception: self.Delete(newcalc) - raise + raise Exception return def CopyBranch(self, startnode): @@ -611,7 +611,7 @@ def GetClipboard(self): if cdatabytes[:16] == "pdfgui_cliboard=".encode(): cdatabytes = cdatabytes[16:] cdata = pickle_loads(cdatabytes) - except: + except Exception: pass return cdata diff --git a/src/diffpy/pdfgui/gui/phasepanelutils.py b/src/diffpy/pdfgui/gui/phasepanelutils.py index 6b4d03af..8459294e 100644 --- a/src/diffpy/pdfgui/gui/phasepanelutils.py +++ b/src/diffpy/pdfgui/gui/phasepanelutils.py @@ -234,7 +234,7 @@ def canPasteIntoCells(panel): # Strip any trailing tabs rowlist = [r.rstrip("\t") for r in rowlist] celllist = [r.split("\t") for r in rowlist] - except: + except wx.PyDeadObjectError: return False if len(celllist) == 0: diff --git a/src/diffpy/pdfgui/gui/plotpanel.py b/src/diffpy/pdfgui/gui/plotpanel.py index 241f4b48..eab29b06 100644 --- a/src/diffpy/pdfgui/gui/plotpanel.py +++ b/src/diffpy/pdfgui/gui/plotpanel.py @@ -16,8 +16,6 @@ # generated by wxGlade 0.9.3 on Fri Jul 19 16:05:24 2019 -import sys - import wx from diffpy.pdfgui.control.controlerrors import ControlConfigError @@ -167,7 +165,7 @@ def _represent(mixedNames): xvals = _represent(xdata) try: xvals.remove("rw") - except: + except ValueError: pass numericStringSort(xvals) diff --git a/src/diffpy/pdfgui/gui/wxextensions/wx12.py b/src/diffpy/pdfgui/gui/wxextensions/wx12.py index 17a3f938..ddbc7641 100644 --- a/src/diffpy/pdfgui/gui/wxextensions/wx12.py +++ b/src/diffpy/pdfgui/gui/wxextensions/wx12.py @@ -46,7 +46,9 @@ def Append(self, *args, **kwargs): if WX4: - Menu = wx.Menu + RealMenu = wx.Menu +else: + RealMenu = Menu # ---------------------------------------------------------------------------- @@ -58,7 +60,9 @@ class ListCtrl(wx.ListCtrl): if WX4: - ListCtrl = wx.ListCtrl + RealListCtrl = wx.ListCtrl +else: + RealListCtrl = ListCtrl # ---------------------------------------------------------------------------- @@ -70,7 +74,9 @@ class TreeCtrl(wx.TreeCtrl): if WX4: - TreeCtrl = wx.TreeCtrl + RealTreeCtrl = wx.TreeCtrl +else: + RealTreeCtrl = TreeCtrl # wx.ToolBar ----------------------------------------------------------------- @@ -92,6 +98,6 @@ def patchToolBarMethods(toolbar): # Final checks --------------------------------------------------------------- -assert WX3 ^ (Menu is wx.Menu) -assert WX3 ^ (TreeCtrl is wx.TreeCtrl) -assert WX3 ^ (ListCtrl is wx.ListCtrl) +assert WX3 ^ (RealMenu is wx.Menu) +assert WX3 ^ (RealTreeCtrl is wx.TreeCtrl) +assert WX3 ^ (RealListCtrl is wx.ListCtrl) diff --git a/src/diffpy/pdfgui/tests/__init__.py b/src/diffpy/pdfgui/tests/__init__.py index accc2e33..863e9949 100644 --- a/src/diffpy/pdfgui/tests/__init__.py +++ b/src/diffpy/pdfgui/tests/__init__.py @@ -3,7 +3,7 @@ # # diffpy.pdfgui by DANSE Diffraction group # Simon J. L. Billinge -# (c) 2012 Trustees of the Columbia University +# (c) 2012-2024 Trustees of the Columbia University # in the City of New York. All rights reserved. # # File coded by: Pavol Juhas diff --git a/src/diffpy/pdfgui/tests/run.py b/src/diffpy/pdfgui/tests/run.py index f1bf407e..461d7c01 100644 --- a/src/diffpy/pdfgui/tests/run.py +++ b/src/diffpy/pdfgui/tests/run.py @@ -3,7 +3,7 @@ # # diffpy.pdfgui by DANSE Diffraction group # Simon J. L. Billinge -# (c) 2012 Trustees of the Columbia University +# (c) 2012-2024 Trustees of the Columbia University # in the City of New York. All rights reserved. # # File coded by: Pavol Juhas diff --git a/src/diffpy/pdfgui/tests/rundeps.py b/src/diffpy/pdfgui/tests/rundeps.py index 0181a83f..9818fc86 100644 --- a/src/diffpy/pdfgui/tests/rundeps.py +++ b/src/diffpy/pdfgui/tests/rundeps.py @@ -3,7 +3,7 @@ # # diffpy.pdfgui by DANSE Diffraction group # Simon J. L. Billinge -# (c) 2012 Trustees of the Columbia University +# (c) 2012-2024 Trustees of the Columbia University # in the City of New York. All rights reserved. # # File coded by: Pavol Juhas diff --git a/src/diffpy/pdfgui/tests/showphasenotebookpanel.py b/src/diffpy/pdfgui/tests/showphasenotebookpanel.py index 4dfb8cde..71c3f0d3 100644 --- a/src/diffpy/pdfgui/tests/showphasenotebookpanel.py +++ b/src/diffpy/pdfgui/tests/showphasenotebookpanel.py @@ -3,7 +3,7 @@ # # diffpy.pdfgui by DANSE Diffraction group # Simon J. L. Billinge -# (c) 2016 Trustees of the Columbia University +# (c) 2016-2024 Trustees of the Columbia University # in the City of New York. All rights reserved. # # File coded by: Pavol Juhas diff --git a/src/diffpy/pdfgui/tests/testutils.py b/src/diffpy/pdfgui/tests/testutils.py index eb981e2b..70147319 100644 --- a/src/diffpy/pdfgui/tests/testutils.py +++ b/src/diffpy/pdfgui/tests/testutils.py @@ -3,7 +3,7 @@ # # diffpy.pdfgui by DANSE Diffraction group # Simon J. L. Billinge -# (c) 2016 Trustees of the Columbia University +# (c) 2016-2024 Trustees of the Columbia University # in the City of New York. All rights reserved. # # File coded by: Pavol Juhas