Skip to content

Commit 9ca3afe

Browse files
authored
Updates to support numpy2 and github actions (sandialabs#84)
* bump action versions * update to use np.nan (all lowercase) * replace freq string H and S with lower case string * index into the series using iloc * update trapz to trapezoid * use raw string when docs contain math * updated build action for docs * bump version number * updated build action * update to combine files in coverage report * update build action
1 parent 72571b1 commit 9ca3afe

21 files changed

+112
-115
lines changed

.github/workflows/build_docs.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ name: docs
55
on:
66
push:
77
branches: [main]
8+
pull_request:
9+
branches: [main]
810
workflow_dispatch:
11+
912
jobs:
1013
build:
1114
name: Build the documentation with Sphinx
@@ -29,13 +32,14 @@ jobs:
2932
- name: Build documentation
3033
run: sphinx-build documentation/ documentation/_build/html
3134
- name: Upload artifact
32-
uses: actions/upload-pages-artifact@v1
35+
uses: actions/upload-pages-artifact@v3
3336
with:
3437
path: 'documentation/_build/html'
3538

3639
deploy:
3740
name: Deploy documentation to GitHub Pages
3841
needs: build
42+
if: github.event_name == 'push'
3943
permissions:
4044
contents: read
4145
pages: write # to deploy to Pages
@@ -49,4 +53,4 @@ jobs:
4953
uses: actions/configure-pages@v3
5054
- name: Deploy to GitHub Pages
5155
id: deployment
52-
uses: actions/deploy-pages@v1
56+
uses: actions/deploy-pages@v4

.github/workflows/build_tests.yml

+37-62
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ on:
1313

1414
jobs:
1515

16-
build:
16+
build_wheels:
17+
name: Build wheels
1718
runs-on: ${{ matrix.os }}
1819
strategy:
1920
matrix:
2021
python-version: ['3.9', '3.10', '3.11', '3.12']
2122
os: [windows-latest, macOS-latest, ubuntu-latest]
23+
fail-fast: false
2224
steps:
23-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v4
2426
- name: Set up Python
25-
uses: actions/setup-python@v4
27+
uses: actions/setup-python@v5
2628
with:
2729
python-version: ${{ matrix.python-version }}
2830
- name: Install dependencies
@@ -35,47 +37,50 @@ jobs:
3537
run: |
3638
python setup.py bdist_wheel
3739
ls dist/*
38-
- name: Save wheel
39-
uses: actions/upload-artifact@v3
40+
- name: Upload wheels
41+
uses: actions/upload-artifact@v4
4042
with:
4143
name: pecos_${{ matrix.python-version }}_${{ matrix.os }}.whl
4244
path: dist/pecos*
4345

44-
install_import:
45-
needs: build
46+
test_wheels:
47+
name: Test wheels
48+
needs: build_wheels
4649
runs-on: ${{ matrix.os }}
4750
strategy:
4851
matrix:
4952
python-version: ['3.9', '3.10', '3.11', '3.12']
50-
os: [windows-latest, macOS-latest, ubuntu-latest]
53+
os: [windows-latest, macOS-latest, ubuntu-latest]
54+
fail-fast: false
5155
steps:
5256
- name: Set up Python
53-
uses: actions/setup-python@v4
57+
uses: actions/setup-python@v5
5458
with:
5559
python-version: ${{ matrix.python-version }}
5660
- name: Download wheel
57-
uses: actions/download-artifact@v3
61+
uses: actions/download-artifact@v4
5862
with:
5963
name: pecos_${{ matrix.python-version }}_${{ matrix.os }}.whl
6064
- name: Install pecos
6165
run: |
6266
python -m pip install --upgrade pip
6367
pip install wheel numpy pandas jinja2 matplotlib pytest
6468
pip install --no-index --pre --find-links=. pecos
65-
- name: Usage of pecos
69+
- name: Import pecos
6670
run: |
6771
python -c "import pecos"
6872
69-
pytest_coverage:
73+
run_coverage:
7074
runs-on: ${{ matrix.os }}
7175
strategy:
7276
matrix:
7377
python-version: ['3.9', '3.10', '3.11', '3.12']
7478
os: [windows-latest, macOS-latest, ubuntu-latest]
79+
fail-fast: false
7580
steps:
76-
- uses: actions/checkout@v2
81+
- uses: actions/checkout@v4
7782
- name: Set up Python ${{ matrix.python-version }}
78-
uses: actions/setup-python@v4
83+
uses: actions/setup-python@v5
7984
with:
8085
python-version: ${{ matrix.python-version }}
8186
- name: Install dependencies
@@ -85,37 +90,41 @@ jobs:
8590
pip install -r requirements.txt
8691
python -m pip install -e .
8792
- name: Run Tests
88-
run: |
93+
run: |
8994
coverage erase
9095
coverage run --context=${{ matrix.os }}.py${{ matrix.python-version }} --source=pecos --omit="*/tests/*" -m pytest --doctest-modules --doctest-glob="*.rst" pecos
9196
coverage run --context=${{ matrix.os }}.py${{ matrix.python-version }} --source=pecos --omit="*/tests/*" --append -m pytest --doctest-glob="*.rst" documentation
9297
env:
9398
COVERAGE_FILE: .coverage.${{ matrix.python-version }}.${{ matrix.os }}
9499
- name: Save coverage
95-
uses: actions/upload-artifact@v2
100+
uses: actions/upload-artifact@v4
96101
with:
97-
name: coverage
102+
name: .coverage.${{ matrix.python-version }}.${{ matrix.os }}
98103
path: .coverage.${{ matrix.python-version }}.${{ matrix.os }}
104+
include-hidden-files: true
99105

100106
combine_reports:
101-
needs: [ pytest_coverage ]
107+
needs: [ run_coverage ]
102108
runs-on: ubuntu-latest
103109
steps:
104110
- name: Set up Python
105-
uses: actions/setup-python@v4
111+
uses: actions/setup-python@v5
106112
with:
107113
python-version: 3.11
108-
- uses: actions/checkout@v2
114+
- uses: actions/checkout@v4
109115
- name: Install coverage
110116
run: |
111117
python -m pip install --upgrade pip
112118
pip install -r requirements.txt
113119
python -m pip install -e .
120+
pip install coveralls
114121
- name: Download coverage artifacts from test matrix
115-
uses: actions/download-artifact@v2
122+
uses: actions/download-artifact@v4
116123
with:
117-
name: coverage
124+
pattern: .coverage.*.ubuntu-latest # coverage from other OS cause problems
118125
- name: Setup coverage and combine reports
126+
run: coverage combine .coverage.*.ubuntu-latest
127+
- name: Create coverage report
119128
run: |
120129
echo "[paths]" > .coveragerc
121130
echo "source = " >> .coveragerc
@@ -124,55 +133,21 @@ jobs:
124133
echo " D:\\a\\pecos\\pecos\\pecos" >> .coveragerc
125134
echo " /home/runner/work/pecos/pecos/pecos" >> .coveragerc
126135
echo " /Users/runner/work/pecos/pecos/pecos" >> .coveragerc
127-
coverage combine
128-
- name: Create coverage report
129-
run: |
136+
echo " ${{ github.workspace }}/pecos" >> .coveragerc
130137
coverage report
131138
coverage json --pretty-print
132139
coverage html --show-contexts
133140
- name: Save coverage JSON
134-
uses: actions/upload-artifact@v2
141+
uses: actions/upload-artifact@v4
135142
with:
136-
name: coverage
143+
name: coverage-json
137144
path: coverage.json
138145
- name: Save coverage html
139-
uses: actions/upload-artifact@v2
146+
uses: actions/upload-artifact@v4
140147
with:
141-
name: coverage
148+
name: coverage-html
142149
path: htmlcov
143-
144-
coveralls:
145-
needs: [ pytest_coverage ]
146-
runs-on: ubuntu-latest
147-
continue-on-error: true
148-
steps:
149-
- name: Set up Python
150-
uses: actions/setup-python@v4
151-
with:
152-
python-version: 3.11
153-
- uses: actions/checkout@v2
154-
- name: Install coverage
155-
run: |
156-
python -m pip install --upgrade pip
157-
pip install coveralls
158-
pip install -r requirements.txt
159-
python -m pip install -e .
160-
- name: Download coverage artifacts from test matrix
161-
uses: actions/download-artifact@v2
162-
with:
163-
name: coverage
164-
- name: Setup coverage and combine reports
165-
run: |
166-
echo "[paths]" > .coveragerc
167-
echo "source = " >> .coveragerc
168-
echo " pecos/" >> .coveragerc
169-
echo " pecos\\" >> .coveragerc
170-
echo " D:\\a\\pecos\\pecos\\pecos" >> .coveragerc
171-
echo " /home/runner/work/pecos/pecos/pecos" >> .coveragerc
172-
echo " /Users/runner/work/pecos/pecos/pecos" >> .coveragerc
173-
coverage combine
174150
- name: Push to coveralls
175-
run: |
176-
coveralls --service=github
151+
run: coveralls --service=github --rcfile=.coveragerc
177152
env:
178153
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

documentation/composite_signal.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ the PerformanceMonitoring object.
3636
>>> import numpy as np
3737
>>> import pecos
3838
>>> pm = pecos.monitoring.PerformanceMonitoring()
39-
>>> index = pd.date_range('1/1/2017', periods=24, freq='H')
39+
>>> index = pd.date_range('1/1/2017', periods=24, freq='h')
4040
>>> data = {'A': np.arange(24)}
4141
>>> df = pd.DataFrame(data, index=index)
4242
>>> pm.add_dataframe(df)

documentation/metrics.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To compute QCI,
3131
>>> import numpy as np
3232
>>> import pecos
3333
>>> pm = pecos.monitoring.PerformanceMonitoring()
34-
>>> index = pd.date_range('1/1/2017', periods=24, freq='H')
34+
>>> index = pd.date_range('1/1/2017', periods=24, freq='h')
3535
>>> data = {'A': np.arange(24)}
3636
>>> df = pd.DataFrame(data, index=index)
3737
>>> pm.add_dataframe(df)

documentation/timefilter.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The following example defines a time filter between 3 AM and 9 PM,
1616
>>> import numpy as np
1717
>>> import pecos
1818
>>> pm = pecos.monitoring.PerformanceMonitoring()
19-
>>> index = pd.date_range('1/1/2017', periods=24, freq='H')
19+
>>> index = pd.date_range('1/1/2017', periods=24, freq='h')
2020
>>> data = {'A': np.arange(24)}
2121
>>> df = pd.DataFrame(data, index=index)
2222
>>> pm.add_dataframe(df)

documentation/whatsnew.rst

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Release Notes
22
================
33

4+
.. include:: whatsnew/v1.0.0.rst
5+
6+
.. include:: whatsnew/v0.3.1.rst
7+
48
.. include:: whatsnew/v0.3.0.rst
59

610
.. include:: whatsnew/v0.2.0.rst

documentation/whatsnew/v0.3.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.. _whatsnew_030:
22

3-
v0.3.0 (main)
3+
v0.3.0 (October 17, 2023)
44
--------------------------
55

66
* Bug fix in custom static and streaming quality control tests to use a specific column

documentation/whatsnew/v0.3.1.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. _whatsnew_031:
2+
3+
v0.3.1 (October 27, 2023)
4+
--------------------------
5+
6+
* Relaxed dtype check in tests
7+
* Fixed import fail due to pytest ModuleNotFoundError

documentation/whatsnew/v1.0.0.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. _whatsnew_100:
2+
3+
Version 1.0.0 (main)
4+
--------------------------
5+
6+
* Updates to support Numpy2
7+

examples/dashboard/dashboard_example_1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
# Populate the object with a dataframe and translation dictionary
4242
# In this example, fake data is generated using a sin wave function
43-
index = pd.date_range(analysis_date, periods=24, freq='H')
43+
index = pd.date_range(analysis_date, periods=24, freq='h')
4444
data=np.sin(np.random.rand(3,1)*np.arange(0,24,1))
4545
df = pd.DataFrame(data=data.transpose(), index=index, columns=['A', 'B', 'C'])
4646
pm.add_dataframe(df)

pecos/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pecos import utils
77
from pecos import pv
88

9-
__version__ = '0.3.1'
9+
__version__ = '1.0.0'
1010

1111
__copyright__ = """Copyright 2016 National Technology & Engineering
1212
Solutions of Sandia, LLC (NTESS). Under the terms of Contract

pecos/graphics.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def plot_timeseries(data, tfilter=None, test_results_group=None, xaxis_min=None,
157157
temp = np.append(temp[0],len(tfilter)-1)
158158
count = 0
159159
for i in range(len(temp)-1):
160-
if tfilter[temp[i]] == 0:
160+
if tfilter.iloc[temp[i]] == 0:
161161
if count == 0:
162162
ax.axvspan(data.index[temp[i]], data.index[temp[i+1]],
163163
facecolor='k', alpha=0.2, label='Time filter')
@@ -399,7 +399,7 @@ def plot_doy_heatmap(data, cmap='nipy_spectral', vmin=None, vmax=None,
399399
data.index.minute + \
400400
data.index.second/60 + \
401401
data.index.microsecond/(60*1000000.0)
402-
piv = pd.pivot_table(data,values=col_name,index=['Y'],columns=['X'],fill_value=np.NaN)
402+
piv = pd.pivot_table(data,values=col_name,index=['Y'],columns=['X'],fill_value=np.nan)
403403

404404
# Create the heatmap
405405
plt.figure(figsize = figsize)

pecos/metrics.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
logger = logging.getLogger(__name__)
1010

1111
def qci(mask, tfilter=None):
12-
"""
12+
r"""
1313
Compute the quality control index (QCI) for each column, defined as:
1414
1515
:math:`QCI=\dfrac{\sum_{t\in T}X_{dt}}{|T|}`
@@ -42,7 +42,7 @@ def qci(mask, tfilter=None):
4242
return qci
4343

4444
def rmse(data1, data2, tfilter=None):
45-
"""
45+
r"""
4646
Compute the root mean squared error (RMSE) for each column, defined as:
4747
4848
:math:`RMSE=\sqrt{\dfrac{\sum{(data_1-data_2)^2}}{n}}`
@@ -86,15 +86,15 @@ def rmse(data1, data2, tfilter=None):
8686
return rmse
8787

8888
def time_integral(data, tfilter=None):
89-
"""
89+
r"""
9090
Compute the time integral (F) for each column, defined as:
9191
9292
:math:`F=\int{fdt}`
9393
9494
where
9595
:math:`f` is a column of data
9696
:math:`dt` is the time step between observations.
97-
The integral is computed using the trapezoidal rule from numpy.trapz.
97+
The integral is computed using the trapezoidal rule from numpy.trapezoid.
9898
Results are given in [original data units]*seconds.
9999
NaN values are set to 0 for integration.
100100
@@ -124,14 +124,14 @@ def time_integral(data, tfilter=None):
124124

125125
F = {}
126126
for col in data.columns:
127-
F[col] = float(np.trapz(data.loc[:,col], tdelta))
127+
F[col] = float(np.trapezoid(data.loc[:,col], tdelta))
128128

129129
F = pd.Series(F)
130130

131131
return F
132132

133133
def time_derivative(data, tfilter=None):
134-
"""
134+
r"""
135135
Compute the derivative (f') of each column, defined as:
136136
137137
:math:`f'=\dfrac{df}{dt}`
@@ -170,7 +170,7 @@ def time_derivative(data, tfilter=None):
170170
return f
171171

172172
def probability_of_detection(observed, actual, tfilter=None):
173-
"""
173+
r"""
174174
Compute probability of detection (PD) for each column, defined as:
175175
176176
:math:`PD=\dfrac{TP}{TP+FN}`
@@ -228,7 +228,7 @@ def probability_of_detection(observed, actual, tfilter=None):
228228
return PD
229229

230230
def false_alarm_rate(observed, actual, tfilter=None):
231-
"""
231+
r"""
232232
Compute false alarm rate (FAR) for each column, defined as:
233233
234234
:math:`FAR=\dfrac{TN}{TN+FP}`

0 commit comments

Comments
 (0)