Skip to content

Commit

Permalink
Merge pull request #609 from tupui/drop_old_python
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
ConnectedSystems committed Mar 4, 2024
2 parents 1bcbf23 + 1be03b0 commit ee5e2cf
Show file tree
Hide file tree
Showing 30 changed files with 66 additions and 87 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ on:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: pre-commit/[email protected].0
python-version: "3.12"
- uses: pre-commit/[email protected].1
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.10']
python-version: ['3.9', '3.12']
defaults:
run:
shell: bash -l {0}
Expand Down Expand Up @@ -50,7 +50,8 @@ jobs:
id: envcache

- name: Update Conda Environment
run: mamba env update -n SALib -f environment.yml
run: |
mamba env update -n SALib -f environment.yml
if: steps.envcache.outputs.cache-hit != 'true'

- name: Install package
Expand All @@ -59,13 +60,13 @@ jobs:
pip install .[test]
- name: Test
if: matrix.python-version != '3.10'
if: matrix.python-version != '3.12'
run: |
conda activate SALib
pytest
- name: Test with coverage and uploads
if: matrix.python-version == '3.10'
if: matrix.python-version == '3.12'
run: |
conda activate SALib
python -m pip install coveralls
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ __pycache__
.*.swp
*/.ipynb_checkpoints/*

.DS_Store

# Project files
.ropeproject
.project
Expand Down
24 changes: 10 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: check-ast
- id: check-byte-order-marker
- id: fix-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: detect-private-key
- id: end-of-file-fixer

- repo: https://github.com/psf/black
rev: 22.6.0
rev: 24.2.0
hooks:
- id: black
exclude: "src/SALib/sample/directions.py"

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
exclude: "src/SALib/sample/directions.py"
args:
- "--max-line-length=88"
# whitespace before ':'
# line too long
# module level import not at top of file
- "--extend-ignore=E203,E402"
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.0
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
9 changes: 4 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
# serve to show the default.

from datetime import date
import os
import sys
import importlib.metadata
import inspect
import os
import shutil
import sys

# -- Path setup --------------------------------------------------------------

Expand Down Expand Up @@ -106,9 +107,7 @@
project = "SALib"
copyright = f"{date.today().year}, Jon Herman, Will Usher and others"

import SALib

version = SALib.__version__
version = importlib.metadata.version("SALib")
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down
11 changes: 5 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ channels:
dependencies:
# required
- numpy>=1.20.3
- python>=3.8
- pandas>=1.1.2
- matplotlib>=3.2.2
- scipy>=1.7.3
- pathos>=0.2.5
- pandas>=2.0
- matplotlib>=3.5
- scipy>=1.9.3
- pathos>=0.3.2
# tests
- pytest
- pytest-cov
Expand All @@ -18,7 +17,7 @@ dependencies:
# doc
- sphinx
- numpydoc
- pydata-sphinx-theme>=0.10
- pydata-sphinx-theme>=0.15.2
- pip
- pip:
- myst_parser
1 change: 0 additions & 1 deletion examples/Problem/problem_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


if __name__ == "__main__":

# Create the SALib Problem specification
sp = ProblemSpec(
{
Expand Down
19 changes: 10 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[build-system]
requires = ["hatchling>=1.8.1"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "SALib"
dynamic = ["version"]
description = "Tools for global sensitivity analysis. Contains Sobol', Morris, FAST, DGSM, PAWN, HDMR, Moment Independent and fractional factorial methods"
readme = "README.rst"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = "MIT"
authors = [
{ name = "Jon Herman", email = "[email protected]" },
Expand All @@ -20,9 +20,10 @@ maintainers = [
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: MIT License",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Developers",
Expand All @@ -32,15 +33,15 @@ classifiers = [

dependencies = [
"numpy>=1.20.3",
"scipy>=1.7.3",
"matplotlib>=3.2.2",
"pandas>=1.2",
"scipy>=1.9.3",
"matplotlib>=3.5",
"pandas>=2.0",
"multiprocess",
]

[project.optional-dependencies]
distributed = [
"pathos>=0.2.5",
"pathos>=0.3.2",
]

test = [
Expand All @@ -53,7 +54,7 @@ doc = [
"sphinx",
"myst_parser",
"numpydoc",
"pydata-sphinx-theme>=0.10"
"pydata-sphinx-theme>=0.15.2"
]

dev = [
Expand All @@ -72,7 +73,7 @@ Documentation = "https://salib.readthedocs.io"
"Source code" = "https://github.com/SALib/SALib"

[tool.hatch]
version.path = "src/SALib/__init__.py"
version.source = "vcs"
build.targets.sdist.exclude = [
".github",
"docs",
Expand Down
2 changes: 0 additions & 2 deletions src/SALib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from SALib.util import ProblemSpec

__version__ = "1.4.7"

__all__ = ["ProblemSpec"]
8 changes: 5 additions & 3 deletions src/SALib/analyze/enhanced_hdmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,11 @@ def _core_params(
"S_sum_conf",
)
Si = ResultDict(
(k, np.zeros((hdmr.nc_t, bootstrap)))
if k in ("S", "Sa", "Sb", "Signf")
else (k, np.zeros(hdmr.nc_t))
(
(k, np.zeros((hdmr.nc_t, bootstrap)))
if k in ("S", "Sa", "Sb", "Signf")
else (k, np.zeros(hdmr.nc_t))
)
for k in keys
)
Si["Term"] = problem["names"]
Expand Down
1 change: 0 additions & 1 deletion src/SALib/analyze/morris.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ def _compute_elementary_effects(
difference = _calc_results_difference(result_increased, result_decreased)

if scaling:

# calculate the scaled value of delta (step size)
dx_trajectory = _calculate_step_size_x(input_matrix)

Expand Down
1 change: 1 addition & 0 deletions src/SALib/plotting/hdmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
This submodule produces two different figures: (1) emulator vs simulator,
(2) regression lines of first order component functions
"""

import matplotlib.pyplot as plt
import numpy as np

Expand Down
5 changes: 3 additions & 2 deletions src/SALib/plotting/morris.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
p = SALib.plotting.morris.horizontal_bar_plot(ax, Si, {'marker':'x'})
p.show()
"""

import numpy as np


Expand Down Expand Up @@ -53,7 +54,7 @@ def horizontal_bar_plot(ax, Si, opts=None, sortby="mu_star", unit=""):
xerr=mu_star_conf_sorted,
align="center",
ecolor="black",
**opts
**opts,
)

ax.set_yticks(y_pos)
Expand Down Expand Up @@ -135,7 +136,7 @@ def sample_histograms(fig, input_sample, problem, opts=None):
bins=num_levels,
density=False,
label=None,
**opts
**opts,
)
)

Expand Down
1 change: 0 additions & 1 deletion src/SALib/sample/latin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def sample(problem, N, seed=None):
)

for group in range(num_groups):

np.random.shuffle(temp[:, group])

for sample in range(num_samples):
Expand Down
10 changes: 4 additions & 6 deletions src/SALib/sample/morris/brute.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
"""
""" """

from SALib.sample.morris.strategy import Strategy
from scipy.special import comb as nchoosek # type: ignore
from itertools import combinations, islice
Expand Down Expand Up @@ -136,9 +136,7 @@ def mappable(combos, pairwise, distance_matrix):
# Create a list of all pairwise combination for each combo in combos
combo_list = combos[
:,
pairwise[
:,
],
pairwise[:,],
]

addresses = (combo_list[:, :, 1], combo_list[:, :, 0])
Expand Down Expand Up @@ -181,7 +179,7 @@ def nth(iterable, n, default=None):
The default value to return
"""

if type(n) != int:
if not isinstance(n, int):
raise TypeError("n is not an integer")

return next(islice(iterable, n, None), default)
4 changes: 2 additions & 2 deletions src/SALib/sample/morris/local.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
"""
""" """

from itertools import combinations
import numpy as np # type: ignore
from typing import List, Tuple, Union
Expand Down
1 change: 1 addition & 0 deletions src/SALib/sample/morris/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
>>> context = SampleMorris(localoptimisation)
>>> context.sample(input_sample, num_samples, num_params, k_choices, groups)
"""

import abc

import numpy as np # type: ignore
Expand Down
1 change: 0 additions & 1 deletion src/SALib/sample/saltelli.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def sample(
index = 0

for i in range(skip_values, N + skip_values):

# Copy matrix "A"
for j in range(D):
saltelli_sequence[index, j] = base_sequence[i, j]
Expand Down
1 change: 1 addition & 0 deletions src/SALib/scripts/salib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command-line utility for SALib"""

import importlib
import argparse
from SALib import analyze, sample
Expand Down
1 change: 0 additions & 1 deletion src/SALib/test_functions/oakley2004.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def evaluate(X: np.ndarray, A: np.ndarray, M: np.ndarray) -> np.ndarray:


if __name__ == "__main__":

# Raw values taken from: http:https://www.jeremy-oakley.staff.shef.ac.uk/psa_example.txt
M = np.array(
[
Expand Down
3 changes: 1 addition & 2 deletions src/SALib/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""A set of utility functions
"""A set of utility functions"""

"""
from collections import OrderedDict
from typing import Dict, Tuple
import warnings
Expand Down
Loading

0 comments on commit ee5e2cf

Please sign in to comment.