diff --git a/.github/workflows/format-and-lint.yaml b/.github/workflows/format-and-lint.yaml new file mode 100644 index 0000000..5607a79 --- /dev/null +++ b/.github/workflows/format-and-lint.yaml @@ -0,0 +1,12 @@ +name: Format and Lint + +on: + push: + branches: [main] + tags: + - v*.*.* + pull_request: + +jobs: + pre-commit: + uses: mdolab/.github/.github/workflows/format-and-lint.yaml@ruffConfig diff --git a/.gitignore b/.gitignore index f5956b1..62ae286 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,8 @@ doc/_build # VS code configurations -*.vscode \ No newline at end of file +*.vscode + +# pre-commit/ruff configuration +.pre-commit-config.yaml +ruff.toml diff --git a/LICENSE.md b/LICENSE.md index 526dee3..33cebf4 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -10,13 +10,10 @@ All rights reserved. ______________________________________________________________________________ baseClasses is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at:\ -http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 ______________________________________________________________________________ University of Michigan's Multidisciplinary Design Optimization Laboratory (MDO Lab)\ College of Engineering, Aerospace Engineering Department\ http://mdolab.engin.umich.edu/ ______________________________________________________________________________ - - - diff --git a/baseclasses/problems/pyAero_problem.py b/baseclasses/problems/pyAero_problem.py index 83658b2..00ec8b3 100644 --- a/baseclasses/problems/pyAero_problem.py +++ b/baseclasses/problems/pyAero_problem.py @@ -585,7 +585,7 @@ def addDV( Examples -------- >>> # Add alpha variable with typical bounds - >>> ap.addDV('alpha', value=2.5, lower=0.0, upper=10.0, scale=0.1) + >>> ap.addDV("alpha", value=2.5, lower=0.0, upper=10.0, scale=0.1) """ if (key not in self.allVarFuncs) and (key not in self.possibleBCDVs): diff --git a/baseclasses/problems/pyFieldPerformance_problem.py b/baseclasses/problems/pyFieldPerformance_problem.py index 13d607d..374e660 100644 --- a/baseclasses/problems/pyFieldPerformance_problem.py +++ b/baseclasses/problems/pyFieldPerformance_problem.py @@ -275,7 +275,7 @@ def addDV(self, key, value=None, lower=None, upper=None, scale=1.0, name=None, d Examples -------- >>> # Add alpha variable with typical bounds - >>> fpp.addDV('TOW', value=250000, lower=0.0, upper=300000.0, scale=0.1) + >>> fpp.addDV("TOW", value=250000, lower=0.0, upper=300000.0, scale=0.1) """ # First check if we are allowed to add the DV: diff --git a/baseclasses/problems/pyMission_problem.py b/baseclasses/problems/pyMission_problem.py index 007a62a..3a2624a 100644 --- a/baseclasses/problems/pyMission_problem.py +++ b/baseclasses/problems/pyMission_problem.py @@ -1113,7 +1113,7 @@ def addDV(self, paramKey, lower=-1e20, upper=1e20, scale=1.0, name=None): Examples -------- >>> # Add initMach variable with typical bounds - >>> seg.addDV('initMach', value=0.75, lower=0.0, upper=1.0, scale=1.0) + >>> seg.addDV("initMach", value=0.75, lower=0.0, upper=1.0, scale=1.0) """ # First check if we are allowed to add the DV: diff --git a/baseclasses/problems/pyStruct_problem.py b/baseclasses/problems/pyStruct_problem.py index cbda796..c183d9e 100644 --- a/baseclasses/problems/pyStruct_problem.py +++ b/baseclasses/problems/pyStruct_problem.py @@ -26,7 +26,7 @@ class StructProblem: Examples -------- - >>> sp = StructProblem('lc0', loadFile='loads.txt') + >>> sp = StructProblem("lc0", loadFile="loads.txt") """ def __init__(self, name, loadFile=None, loadFactor=None, evalFuncs=None): diff --git a/baseclasses/problems/pyWeight_problem.py b/baseclasses/problems/pyWeight_problem.py index c0cf85b..5ea8a1a 100644 --- a/baseclasses/problems/pyWeight_problem.py +++ b/baseclasses/problems/pyWeight_problem.py @@ -128,7 +128,7 @@ def setSurface(self, surf): >>> surf = CFDsolver.getTriangulatedMeshSurface() >>> wp.setSurface(surf) >>> # Or using a pyGeo surface object: - >>> surf = pyGeo('iges',fileName='wing.igs') + >>> surf = pyGeo("iges", fileName="wing.igs") >>> wp.setSurface(surf) """ @@ -643,8 +643,8 @@ def addDV( Examples -------- >>> # Add W variable with typical bounds - >>> fuelCase.addDV('fuelFraction', value=0.5, lower=0.0, upper=1.0, scale=0.1) - >>> fuelCase.addDV('reserveFraction', value=0.1, lower=0.0, upper=1.0, scale=0.1) + >>> fuelCase.addDV("fuelFraction", value=0.5, lower=0.0, upper=1.0, scale=0.1) + >>> fuelCase.addDV("reserveFraction", value=0.1, lower=0.0, upper=1.0, scale=0.1) """ # First check if we are allowed to add the DV: diff --git a/baseclasses/solvers/BaseSolver.py b/baseclasses/solvers/BaseSolver.py index 6ca0575..e44bdfb 100644 --- a/baseclasses/solvers/BaseSolver.py +++ b/baseclasses/solvers/BaseSolver.py @@ -23,7 +23,7 @@ def __init__( name, category, defaultOptions={}, - options={}, + options=None, immutableOptions=set(), deprecatedOptions={}, comm=None, @@ -87,8 +87,9 @@ def __init__( else: self.setOption(key, optionValue) - for key in options: - self.setOption(key, options[key]) + if options is not None: + for key in options: + self.setOption(key, options[key]) self.solverCreated = True diff --git a/baseclasses/solvers/pyAero_solver.py b/baseclasses/solvers/pyAero_solver.py index c31c912..f64456c 100644 --- a/baseclasses/solvers/pyAero_solver.py +++ b/baseclasses/solvers/pyAero_solver.py @@ -388,7 +388,7 @@ def setSurfaceCoordinates(self, coordinates, groupName=None): self._updateGeomInfo = True if self.mesh is None: - raise Error("Cannot set new surface coordinate locations without a mesh" "warping object present.") + raise Error("Cannot set new surface coordinate locations without a meshwarping object present.") # First get the surface coordinates of the meshFamily in case # the groupName is a subset, those values will remain unchanged. diff --git a/doc/regression_example.rst b/doc/regression_example.rst index 61afec4..6c3ce78 100644 --- a/doc/regression_example.rst +++ b/doc/regression_example.rst @@ -38,5 +38,5 @@ Then, when running ``testflo`` we can specify to run all of the training functio Normally, when ``testflo`` is run, it looks for all functions that begin with ``test_``. The ``-m`` flag allows us to specify a different prefix. -In this case, by using the ``train_`` prefix on all of the training functions we can run them all at once with the above command. +In this case, by using the ``train_`` prefix on all of the training functions we can run them all at once with the above command. Once the reference files are created, just calling ``testflo`` will run all the regression tests.