Skip to content

Commit 1167f96

Browse files
committed
wip
1 parent f36e1cd commit 1167f96

File tree

16 files changed

+39
-13
lines changed

16 files changed

+39
-13
lines changed

.github/workflows/build.yml

+13
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,16 @@ jobs:
3434
- run: pip install --upgrade pip pylint
3535
- run: pip install -r requirements.txt
3636
- run: cd src; pylint mistat
37+
38+
ruff:
39+
runs-on: ubuntu-latest
40+
name: Ruff
41+
steps:
42+
- uses: actions/checkout@v2
43+
- name: Set up Python
44+
uses: actions/setup-python@v2
45+
with:
46+
python-version: '3.12'
47+
- run: pip install --upgrade pip ruff
48+
- run: pip install -r requirements.txt
49+
- run: cd src; ruff check mistat

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@ mypy:
4242
pylint:
4343
docker run -it --rm -v $(PWD)/src:/src $(DEV_IMAGE) pylint mistat
4444

45+
ruff:
46+
docker run -it --rm -v $(PWD)/src:/src $(DEV_IMAGE) ruff check mistat
47+
4548
bash-dev:
4649
docker run -it --rm -v $(PWD)/src:/src $(DEV_IMAGE) bash

docker/Dockerfile.devtools

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM mistat_test_1
2-
RUN pip install mypy isort data-science-types types-setuptools pylint
2+
RUN pip install mypy isort data-science-types types-setuptools pylint ruff
33

44
WORKDIR /src
55

src/mistat/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Modern Statistics: A Computer Based Approach with Python
55
- Industrial Statistics: A Computer Based Approach with Python
66
"""
7+
# ruff: noqa:F401
78
from .data import describe_data, load_data
89
from .design import (FDS_Plot, addTreatments, calculateInteractions, calculateMainEffects, doe, getModelMatrix,
910
interactionPlot, mainEffectsPlot, marginalInteractionPlot, subgroupOfDefining)

src/mistat/acceptanceSampling/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa:F401
12
from .bandit import optimalOAB, simulateOAB
23
from .dodge.dodge_chain import ChainPlanBinomial, ChainPlanPoisson
34
from .dodge.dodge_curtailed import curtailedBinomial

src/mistat/design/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa:F401
12
from . import doe
23
from .doeUtilities import addTreatments, aliasesInSubgroup, subgroupOfDefining
34
from .graphs import (FDS_Plot, calculateInteractions, calculateMainEffects,

src/mistat/design/doepy/pydoe_corrected.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def fracfact_corrected(gen):
194194
C = [len(item) for item in A]
195195

196196
# Indices of single letters (main factors)
197-
I = [i for i, item in enumerate(C) if item == 1]
197+
I_idx = [i for i, item in enumerate(C) if item == 1]
198198

199199
# Indices of letter combinations (we need them to fill out H2 properly).
200200
J = [i for i, item in enumerate(C) if item != 1]
@@ -208,9 +208,9 @@ def fracfact_corrected(gen):
208208
R2 = _grep(U, "-")
209209

210210
# Fill in design with two level factorial design
211-
H1 = ff2n(len(I))
211+
H1 = ff2n(len(I_idx))
212212
H = np.zeros((H1.shape[0], len(C)))
213-
H[:, I] = H1
213+
H[:, I_idx] = H1
214214

215215
# Recognize combinations and fill in the rest of matrix H2 with the proper
216216
# products

src/mistat/design/graphs.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ def _calculateInteractions(df, response, factors=None):
137137
ax.plot([i] * len(values), values, color='grey')
138138
common = {'horizontalalignment': 'center', 'verticalalignment': 'center'}
139139
offset = -abs(offset) if values[0] > values[-1] else abs(offset)
140-
for n, (l, value) in enumerate(zip(me['level'], values)):
141-
s = f'${l:.5g}$'
140+
for n, (level, value) in enumerate(zip(me['level'], values)):
141+
s = f'${level:.5g}$'
142142
if levels:
143143
s = f'{s}: {levels[factor][n]:.5g}'
144144
if n == 0:
@@ -160,10 +160,10 @@ def _calculateInteractions(df, response, factors=None):
160160
level2 = sorted(subdf['l2'].unique())
161161

162162
shift_1 = {l1: i + s for l1, s in zip(level1, np.linspace(-0.25, 0.25, len(level1)))}
163-
markercol_1 = {f'{l:.4f}': 'grey' for l in level1}
163+
markercol_1 = {f'{level:.4f}': 'grey' for level in level1}
164164
markercol_1[f'{level1[0]:.4f}'] = 'red'
165165
markercol_1[f'{level1[-1]:.4f}'] = 'black'
166-
markercol_2 = {f'{l:.4f}': 'grey' for l in level2}
166+
markercol_2 = {f'{level:.4f}': 'grey' for level in level2}
167167
markercol_2[f'{level2[0]:.4f}'] = 'red'
168168
markercol_2[f'{level2[-1]:.4f}'] = 'black'
169169
mat = np.zeros([len(level1), len(level2)])

src/mistat/ml/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# ruff: noqa:F401
12
from .clustering import plot_dendrogram

src/mistat/mqcc/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# ruff: noqa:F401
12
from .mahalanobisT2 import MahalanobisT2
23
from .multivariateQualityControlChart import MultivariateQualityControlChart

src/mistat/qcc/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa:F401
12
from .cusum import Cusum, cusumArl, cusumPfaCed
23
from .ewmaChart import EWMA
34
from .paretoChart import ParetoChart

src/mistat/qcc/qualityControlChart.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ def plot(self, title=None, ax=None):
101101
lcl = [[], []]
102102
ucl = [[], []]
103103
last = None
104-
for xleft, xright, l, u in zip(df.x.values - delta[:-1], df.x.values + delta[1:],
104+
for xleft, xright, lower, upper in zip(df.x.values - delta[:-1], df.x.values + delta[1:],
105105
self.limits.LCL, self.limits.UCL):
106106
if last:
107107
lcl[0].extend([xleft, xleft])
108-
lcl[1].extend([last, l])
108+
lcl[1].extend([last, lower])
109109
ucl[0].extend([xleft, xleft])
110-
ucl[1].extend([last, u])
110+
ucl[1].extend([last, upper])
111111
lcl[0].extend([xleft, xright])
112-
lcl[1].extend([l, l])
112+
lcl[1].extend([lower, lower])
113113
ucl[0].extend([xleft, xright])
114-
ucl[1].extend([u, u])
114+
ucl[1].extend([upper, upper])
115115
ax.plot(*lcl, color='black', linestyle='--')
116116
ax.plot(*ucl, color='black', linestyle='--')
117117

src/mistat/regression/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# ruff: noqa:F401
12
from .stepwiseRegression import stepwise_regression

src/mistat/rsm/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# ruff: noqa:F401
12
from .responseSurfaceMethod import ResponseSurfaceMethod

src/mistat/simulation/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa:F401
12
from .mistatSimulation import SimulationResult, simulationGroup
23
from .pistonSimulation import PistonSimulator, pistonConfigurations
34
from .powerCircuitSimulation import PowerCircuitSimulation

src/mistat/timeseries/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa:F401
12
from .predictors import (dlmLinearGrowth, masPredictor, normRandomWalk,
23
optimalLinearPredictor, predictARMA,
34
quadraticPredictor, simulateARMA)

0 commit comments

Comments
 (0)