Skip to content

Commit e3b3652

Browse files
authored
Use ruff for formatting and linting (#7)
* Remove catchall except * Fix ruff checks * Remove wildcard imports * Ruff format * Check format with ruff * Add ruff badge * pytest * pytest
1 parent 87b076c commit e3b3652

19 files changed

+129
-116
lines changed

.github/workflows/linting.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ jobs:
2323
pip install -r requirements.txt
2424
pip install -e .
2525
26-
- name: Check format with black
26+
- name: Check format with ruff
2727
run: |
28-
black --version
29-
black --diff pyDOE3
30-
black --check pyDOE3
28+
ruff --version
29+
ruff check

.github/workflows/tests.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ jobs:
3232
3333
- name: Test with pytest
3434
run: |
35-
pytest --doctest-modules
35+
pytest --doctest-modules pyDOE3
36+
pytest tests
37+
3638

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pyDOE3: An experimental design package for python
44
[![Tests](https://github.com/relf/pyDOE3/actions/workflows/tests.yml/badge.svg)](https://github.com/relf/pyDOE3/actions/workflows/tests.yml)
55
[![Documentation](https://readthedocs.org/projects/pydoe3/badge/?version=latest)](https://pydoe3.readthedocs.io/en/latest/?badge=latest)
66
[![DOI](https://zenodo.org/badge/709347557.svg)](https://zenodo.org/doi/10.5281/zenodo.10958492)
7+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
78

89
`pyDOE3` is a fork of the [`pyDOE2`](https://github.com/clicumu/pyDOE2) package
910
that is designed to help the scientist, engineer, statistician, etc., to
@@ -61,7 +62,7 @@ individuals for use with Scilab:
6162

6263
`pyDOE` was converted to Python by the following individual:
6364

64-
- Copyright (c) 2014, Abraham D. Lee & timsimst
65+
- Copyright (c) 2014, Abraham D. Lee
6566

6667
The following individuals forked and worked on `pyDOE2`:
6768

doc/conf.py

+48-47
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313

1414
from datetime import date
1515

16-
import sys, os
16+
import sys
17+
import os
1718

18-
sys.path.insert(0, os.path.abspath('..'))
19+
sys.path.insert(0, os.path.abspath(".."))
1920

2021
import pyDOE3
2122

2223
# If extensions (or modules to document with autodoc) are in another directory,
2324
# add these directories to sys.path here. If the directory is relative to the
2425
# documentation root, use os.path.abspath to make it absolute, like shown here.
25-
#sys.path.append(os.path.abspath('.'))
26+
# sys.path.append(os.path.abspath('.'))
2627

2728
# -- General configuration -----------------------------------------------------
2829

@@ -31,152 +32,152 @@
3132
extensions = []
3233

3334
# Add any paths that contain templates here, relative to this directory.
34-
templates_path = ['_templates']
35+
templates_path = ["_templates"]
3536

3637
# The suffix of source filenames.
37-
source_suffix = '.rst'
38+
source_suffix = ".rst"
3839

3940
# The encoding of source files.
40-
#source_encoding = 'utf-8'
41+
# source_encoding = 'utf-8'
4142

4243
# The master toctree document.
43-
master_doc = 'index_TOC'
44+
master_doc = "index_TOC"
4445

4546
# General information about the project.
46-
project = u'pyDOE3'
47-
if date.today().year!=2013:
48-
copyright = u'2013–%d, Abraham Lee' % date.today().year
47+
project = "pyDOE3"
48+
if date.today().year != 2013:
49+
copyright = "2013–%d, Abraham Lee" % date.today().year
4950
else:
50-
copyright = u'2013, Abraham Lee'
51+
copyright = "2013, Abraham Lee"
5152

5253
# The version info for the project you're documenting, acts as replacement for
5354
# |version| and |release|, also used in various other places throughout the
5455
# built documents.
5556
#
5657
# The short X.Y version.
57-
version = '1'
58+
version = "1"
5859
# The full version, including alpha/beta/rc tags.
5960
release = pyDOE3.__version__
6061

6162
# The language for content autogenerated by Sphinx. Refer to documentation
6263
# for a list of supported languages.
63-
#language = None
64+
# language = None
6465

6566
# There are two options for replacing |today|: either, you set today to some
6667
# non-false value, then it is used:
67-
#today = ''
68+
# today = ''
6869
# Else, today_fmt is used as the format for a strftime call.
69-
#today_fmt = '%B %d, %Y'
70+
# today_fmt = '%B %d, %Y'
7071

7172
# List of documents that shouldn't be included in the build.
72-
#unused_docs = []
73+
# unused_docs = []
7374

7475
# List of directories, relative to source directory, that shouldn't be searched
7576
# for source files.
76-
exclude_trees = ['_build']
77+
exclude_trees = ["_build"]
7778

7879
# The reST default role (used for this markup: `text`) to use for all documents.
79-
#default_role = None
80+
# default_role = None
8081

8182
# If true, '()' will be appended to :func: etc. cross-reference text.
82-
#add_function_parentheses = True
83+
# add_function_parentheses = True
8384

8485
# If true, the current module name will be prepended to all description
8586
# unit titles (such as .. function::).
86-
#add_module_names = True
87+
# add_module_names = True
8788

8889
# If true, sectionauthor and moduleauthor directives will be shown in the
8990
# output. They are ignored by default.
90-
#show_authors = False
91+
# show_authors = False
9192

9293
# The name of the Pygments (syntax highlighting) style to use.
93-
pygments_style = 'sphinx'
94+
pygments_style = "sphinx"
9495

9596
# A list of ignored prefixes for module index sorting.
96-
#modindex_common_prefix = []
97+
# modindex_common_prefix = []
9798

9899

99100
# -- Options for HTML output ---------------------------------------------------
100101

101102
# The theme to use for HTML and HTML Help pages. Major themes that come with
102103
# Sphinx are currently 'default' and 'sphinxdoc'.
103-
html_theme = 'sphinxdoc'
104+
html_theme = "sphinxdoc"
104105

105106
# Theme options are theme-specific and customize the look and feel of a theme
106107
# further. For a list of options available for each theme, see the
107108
# documentation.
108109
# html_theme_options = {}
109110

110111
# Add any paths that contain custom themes here, relative to this directory.
111-
#html_theme_path = []
112+
# html_theme_path = []
112113

113114
# The name for this set of Sphinx documents. If None, it defaults to
114115
# "<project> v<release> documentation".
115-
#html_title = None
116+
# html_title = None
116117

117118
# A shorter title for the navigation bar. Default is the same as html_title.
118-
#html_short_title = None
119+
# html_short_title = None
119120

120121
# The name of an image file (relative to this directory) to place at the top
121122
# of the sidebar.
122-
#html_logo = None
123+
# html_logo = None
123124

124125
# The name of an image file (within the static path) to use as favicon of the
125126
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
126127
# pixels large.
127-
html_favicon = 'favicon.ico'
128+
html_favicon = "favicon.ico"
128129

129130
# Add any paths that contain custom static files (such as style sheets) here,
130131
# relative to this directory. They are copied after the builtin static files,
131132
# so a file named "default.css" will overwrite the builtin "default.css".
132-
html_static_path = ['_static']
133+
html_static_path = ["_static"]
133134

134135
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
135136
# using the given strftime format.
136-
#html_last_updated_fmt = '%b %d, %Y'
137+
# html_last_updated_fmt = '%b %d, %Y'
137138

138139
# If true, SmartyPants will be used to convert quotes and dashes to
139140
# typographically correct entities.
140-
#html_use_smartypants = True
141+
# html_use_smartypants = True
141142

142143
# Custom sidebar templates, maps document names to template names.
143-
#html_sidebars = {}
144+
# html_sidebars = {}
144145

145146
# Additional templates that should be rendered to pages, maps page names to
146147
# template names.
147-
#html_additional_pages = {}
148+
# html_additional_pages = {}
148149

149150
# If false, no module index is generated.
150-
#html_use_modindex = True
151+
# html_use_modindex = True
151152

152153
# If false, no index is generated.
153-
#html_use_index = True
154+
# html_use_index = True
154155

155156
# If true, the index is split into individual pages for each letter.
156-
#html_split_index = False
157+
# html_split_index = False
157158

158159
# If true, links to the reST sources are added to the pages.
159160
html_show_sourcelink = False
160161

161162
# If true, an OpenSearch description file will be output, and all pages will
162163
# contain a <link> tag referring to it. The value of this option must be the
163164
# base URL from which the finished HTML is served.
164-
#html_use_opensearch = ''
165+
# html_use_opensearch = ''
165166

166167
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
167-
#html_file_suffix = ''
168+
# html_file_suffix = ''
168169

169170
# Output file base name for HTML help builder.
170-
htmlhelp_basename = 'pyDOEPythonPackagedoc'
171+
htmlhelp_basename = "pyDOEPythonPackagedoc"
171172

172173

173174
# -- Options for LaTeX output --------------------------------------------------
174175

175176
# The paper size ('letter' or 'a4').
176-
#latex_paper_size = 'letter'
177+
# latex_paper_size = 'letter'
177178

178179
# The font size ('10pt', '11pt' or '12pt').
179-
#latex_font_size = '10pt'
180+
# latex_font_size = '10pt'
180181

181182
# Grouping the document tree into LaTeX files. List of tuples
182183
# (source start file, target name, title, author, documentclass [howto/manual]).
@@ -187,17 +188,17 @@
187188

188189
# The name of an image file (relative to this directory) to place at the top of
189190
# the title page.
190-
#latex_logo = None
191+
# latex_logo = None
191192

192193
# For "manual" documents, if this is true, then toplevel headings are parts,
193194
# not chapters.
194-
#latex_use_parts = False
195+
# latex_use_parts = False
195196

196197
# Additional stuff for the LaTeX preamble.
197-
#latex_preamble = ''
198+
# latex_preamble = ''
198199

199200
# Documents to append as an appendix to all manuals.
200-
#latex_appendices = []
201+
# latex_appendices = []
201202

202203
# If false, no module index is generated.
203-
#latex_use_modindex = True
204+
# latex_use_modindex = True

pyDOE3/__init__.py

+32-10
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,38 @@
1717
The following individuals forked pyDOE and works on `pyDOE2`:
1818
1919
- Copyright (C) 2018 - Rickard Sjoegren and Daniel Svensson
20-
2120
"""
2221

23-
from ._version import __version__
24-
25-
from pyDOE3.doe_box_behnken import *
26-
from pyDOE3.doe_composite import *
27-
from pyDOE3.doe_factorial import *
28-
from pyDOE3.doe_lhs import *
29-
from pyDOE3.doe_fold import *
30-
from pyDOE3.doe_plackett_burman import *
31-
from pyDOE3.var_regression_matrix import *
22+
from pyDOE3.doe_box_behnken import bbdesign
23+
from pyDOE3.doe_composite import ccdesign
24+
from pyDOE3.doe_factorial import (
25+
fullfact,
26+
ff2n,
27+
fracfact,
28+
fracfact_by_res,
29+
fracfact_opt,
30+
fracfact_aliasing,
31+
alias_vector_indices,
32+
)
33+
from pyDOE3.doe_lhs import lhs
34+
from pyDOE3.doe_fold import fold
35+
from pyDOE3.doe_plackett_burman import pbdesign
36+
from pyDOE3.var_regression_matrix import var_regression_matrix
3237
from pyDOE3.doe_gsd import gsd
38+
39+
__all__ = [
40+
"bbdesign",
41+
"ccdesign",
42+
"fullfact",
43+
"ff2n",
44+
"fracfact",
45+
"fracfact_by_res",
46+
"fracfact_opt",
47+
"fracfact_aliasing",
48+
"alias_vector_indices",
49+
"lhs",
50+
"fold",
51+
"pbdesign",
52+
"var_regression_matrix",
53+
"gsd",
54+
]

pyDOE3/build_regression_matrix.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
Copyright (C) 2010 - 2011 - INRIA - Michael Baudin
77
Copyright (C) 2009 - Yann Collette
88
Copyright (C) 2009 - CEA - Jean-Marc Martinez
9-
9+
1010
website: forge.scilab.org/index.php/p/scidoe/sourcetree/master/macros
1111
12-
Much thanks goes to these individuals. It has been converted to Python by
12+
Much thanks goes to these individuals. It has been converted to Python by
1313
Abraham Lee.
1414
"""
1515

pyDOE3/doe_box_behnken.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
Copyright (C) 2010 - 2011 - INRIA - Michael Baudin
77
Copyright (C) 2009 - Yann Collette
88
Copyright (C) 2009 - CEA - Jean-Marc Martinez
9-
9+
1010
website: forge.scilab.org/index.php/p/scidoe/sourcetree/master/macros
1111
12-
Much thanks goes to these individuals. It has been converted to Python by
12+
Much thanks goes to these individuals. It has been converted to Python by
1313
Abraham Lee.
1414
"""
1515

@@ -77,12 +77,12 @@ def bbdesign(n, center=None):
7777
for i in range(n - 1):
7878
for j in range(i + 1, n):
7979
Index = Index + 1
80-
H[
81-
max([0, (Index - 1) * H_fact.shape[0]]) : Index * H_fact.shape[0], i
82-
] = H_fact[:, 0]
83-
H[
84-
max([0, (Index - 1) * H_fact.shape[0]]) : Index * H_fact.shape[0], j
85-
] = H_fact[:, 1]
80+
H[max([0, (Index - 1) * H_fact.shape[0]]) : Index * H_fact.shape[0], i] = (
81+
H_fact[:, 0]
82+
)
83+
H[max([0, (Index - 1) * H_fact.shape[0]]) : Index * H_fact.shape[0], j] = (
84+
H_fact[:, 1]
85+
)
8686

8787
if center is None:
8888
if n <= 16:

0 commit comments

Comments
 (0)