Skip to content

Support Python 3.12 with CI, move tests to top level #89

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

Merged
merged 6 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/tests-on-pr.yml
Original file line number Diff line number Diff line change
@@ -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.srfit
c_extension: false
headless: false
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: diffpy.srfit
channels:
- conda-forge
dependencies:
- python=3
- pip
50 changes: 44 additions & 6 deletions pyproject.toml
Copy link
Author

Choose a reason for hiding this comment

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

Providing just a basic setup to build from the sources.

Original file line number Diff line number Diff line change
@@ -1,20 +1,58 @@
[build-system]
requires = ["setuptools>=62.0", "setuptools-git-versioning>=2.0"]
build-backend = "setuptools.build_meta"

[project]
name = "diffpy.srfit"
dynamic=['version', 'dependencies']
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Scientific/Engineering :: Chemistry',
]


[tool.setuptools-git-versioning]
enabled = true
template = "{tag}"
dev_template = "{tag}"
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 = [] # 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?$'
exclude = '''
/(
\.git\
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build/
| \.rst
| \.txt
| _build
| buck-out
| build
| dist
# The following are specific to Black, you probably don't want those.
| blib2to3
| tests/data/
| hooks/post_gen_project.py$
| .*\.py$
| .*\.toml$
| tests/data
)/
'''
Empty file added requirements/pip.txt
Empty file.
3 changes: 3 additions & 0 deletions requirements/run.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scipy
numpy
matplotlib
Copy link
Author

@bobleesj bobleesj Sep 26, 2024

Choose a reason for hiding this comment

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

we could add diffpy.structure while/after we address the issue #90

Copy link
Contributor

Choose a reason for hiding this comment

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

yes. I think it is ok to add those other dependencies. For this particular package we could, if we want, have it split out into run-core.txt and ren-ext.txt? Strictly, srfit could be used as a general fitting program in a more or less stand-alone way, (core) but practically, it is always used with srreal and structure. What do you think?

Copy link
Author

@bobleesj bobleesj Sep 27, 2024

Choose a reason for hiding this comment

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

@sbillinge

Can we have the core packages underrun.txt and just create run_ext.txt for the extra?

Since our centralized GH CI workflow files need to be updated:

from:

      - name: Install ${{ inputs.project }} and requirements
        run: |
          conda install --file requirements/run.txt

to:

      - name: Install ${{ inputs.project }} and requirements
        run: |
          conda install --file requirements/run.txt
          conda install --file requirements/run-ext.txt

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, good idea

6 changes: 6 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
flake8
pytest
codecov
coverage
pytest-cov
pytest-env
File renamed without changes.
Binary file added src/diffpy/srfit/.DS_Store
Binary file not shown.
87 changes: 0 additions & 87 deletions src/diffpy/srfit/tests/__init__.py

This file was deleted.

35 changes: 0 additions & 35 deletions src/diffpy/srfit/tests/debug.py

This file was deleted.

38 changes: 0 additions & 38 deletions src/diffpy/srfit/tests/run.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -18,10 +18,10 @@
import unittest

import numpy
from utils import _makeArgs, noObserversInGlobalBuilders

import diffpy.srfit.equation.builder as builder
import diffpy.srfit.equation.literals as literals
from diffpy.srfit.tests.utils import _makeArgs, noObserversInGlobalBuilders


class TestBuilder(unittest.TestCase):
Original file line number Diff line number Diff line change
@@ -18,9 +18,9 @@
import unittest

import numpy
from utils import _msg_nosas, has_sas

from diffpy.srfit.sas.sasimport import sasimport
from diffpy.srfit.tests.utils import _msg_nosas, has_sas

# Global variables to be assigned in setUp
cf = None
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -18,13 +18,13 @@
import unittest

from numpy import arange, array_equal, dot, sin
from utils import noObserversInGlobalBuilders

from diffpy.srfit.exceptions import SrFitError
from diffpy.srfit.fitbase.fitcontribution import FitContribution
from diffpy.srfit.fitbase.parameter import Parameter
from diffpy.srfit.fitbase.profile import Profile
from diffpy.srfit.fitbase.profilegenerator import ProfileGenerator
from diffpy.srfit.tests.utils import noObserversInGlobalBuilders


class TestContribution(unittest.TestCase):
Original file line number Diff line number Diff line change
@@ -19,8 +19,7 @@
import unittest

import numpy

from diffpy.srfit.tests.utils import _msg_nostructure, has_structure
from utils import _msg_nostructure, has_structure

# Global variables to be assigned in setUp
Atom = Lattice = Structure = DiffpyStructureParSet = None
Original file line number Diff line number Diff line change
@@ -17,9 +17,10 @@

import unittest

from utils import _makeArgs, noObserversInGlobalBuilders

import diffpy.srfit.equation.literals as literals
from diffpy.srfit.equation import Equation
from diffpy.srfit.tests.utils import _makeArgs, noObserversInGlobalBuilders


class TestEquation(unittest.TestCase):
Original file line number Diff line number Diff line change
@@ -18,12 +18,12 @@
import unittest

from numpy import array_equal, dot, linspace, pi, sin
from utils import capturestdout

from diffpy.srfit.fitbase.fitcontribution import FitContribution
from diffpy.srfit.fitbase.fitrecipe import FitRecipe
from diffpy.srfit.fitbase.parameter import Parameter
from diffpy.srfit.fitbase.profile import Profile
from diffpy.srfit.tests.utils import capturestdout


class TestFitRecipe(unittest.TestCase):
Original file line number Diff line number Diff line change
@@ -17,9 +17,10 @@

import unittest

from utils import datafile

from diffpy.srfit.fitbase.fitrecipe import FitRecipe
from diffpy.srfit.fitbase.fitresults import initializeRecipe
from diffpy.srfit.tests.utils import datafile


class TestInitializeRecipe(unittest.TestCase):
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -18,8 +18,7 @@
import unittest

import numpy

from diffpy.srfit.tests.utils import _msg_nopyobjcryst, has_pyobjcryst
from utils import _msg_nopyobjcryst, has_pyobjcryst

# Global variables to be assigned in setUp
ObjCrystCrystalParSet = spacegroups = None
File renamed without changes.
File renamed without changes.
8 changes: 1 addition & 7 deletions src/diffpy/srfit/tests/testpdf.py → tests/test_pdf.py
Original file line number Diff line number Diff line change
@@ -20,16 +20,10 @@
import unittest

import numpy
from utils import _msg_nosrreal, _msg_nostructure, datafile, has_srreal, has_structure

from diffpy.srfit.exceptions import SrFitError
from diffpy.srfit.pdf import PDFContribution, PDFGenerator, PDFParser
from diffpy.srfit.tests.utils import (
_msg_nosrreal,
_msg_nostructure,
datafile,
has_srreal,
has_structure,
)

# ----------------------------------------------------------------------------

Original file line number Diff line number Diff line change
@@ -20,10 +20,10 @@
import unittest

from numpy import allclose, arange, array, array_equal, ones_like
from utils import datafile

from diffpy.srfit.exceptions import SrFitError
from diffpy.srfit.fitbase.profile import Profile
from diffpy.srfit.tests.utils import datafile


class TestProfile(unittest.TestCase):
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
import unittest

import numpy
from utils import capturestdout

from diffpy.srfit.equation.builder import EquationFactory
from diffpy.srfit.fitbase.calculator import Calculator
@@ -27,7 +28,6 @@
RecipeOrganizer,
equationFromString,
)
from diffpy.srfit.tests.utils import capturestdout

# ----------------------------------------------------------------------------

File renamed without changes.
2 changes: 1 addition & 1 deletion src/diffpy/srfit/tests/testsas.py → tests/test_sas.py
Original file line number Diff line number Diff line change
@@ -18,10 +18,10 @@
import unittest

import numpy
from utils import _msg_nosas, datafile, has_sas

from diffpy.srfit.sas import SASGenerator, SASParser, SASProfile
from diffpy.srfit.sas.sasimport import sasimport
from diffpy.srfit.tests.utils import _msg_nosas, datafile, has_sas

# ----------------------------------------------------------------------------

Original file line number Diff line number Diff line change
@@ -18,8 +18,7 @@
import unittest

import numpy

from diffpy.srfit.tests.utils import (
from utils import (
_msg_nopyobjcryst,
_msg_nostructure,
datafile,
Original file line number Diff line number Diff line change
@@ -20,10 +20,10 @@
import random

import numpy
from utils import _makeArgs

import diffpy.srfit.equation.literals as literals
import diffpy.srfit.equation.visitors as visitors
from diffpy.srfit.tests.utils import _makeArgs

x = numpy.arange(0, 20, 0.05)

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -17,9 +17,10 @@

import unittest

from utils import _makeArgs

import diffpy.srfit.equation.literals as literals
import diffpy.srfit.equation.visitors as visitors
from diffpy.srfit.tests.utils import _makeArgs


class TestValidator(unittest.TestCase):
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/diffpy/srfit/tests/utils.py → tests/utils.py
Original file line number Diff line number Diff line change
@@ -15,13 +15,13 @@

"""Helper routines for testing."""

import logging as logger
import sys

import six

import diffpy.srfit.equation.literals as literals
from diffpy.srfit.sas.sasimport import sasimport
from diffpy.srfit.tests import logger

# Resolve availability of optional third-party packages.