Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# -- General configuration ---------------------------------------------------

# mock import for autodoc
autodoc_mock_imports = ["baseclasses", "scipy", "numpy", "sqlitedict"]
autodoc_mock_imports = ["baseclasses", "scipy", "sqlitedict"]

# logo
html_logo = "_static/pyOptSparse_logo.svg"
Expand Down
2 changes: 1 addition & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Requirements
~~~~~~~~~~~~
pyOptSparse has the following dependencies:

* Python 3
* Python 3.10+
* C and Fortran compilers.
We recommend ``gcc`` and ``gfortran`` which can be installed via the package manager for your operating system.

Expand Down
3 changes: 1 addition & 2 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sphinx_mdolab_theme>=1.2
sphinx-codeautolink
# temporary pin from https://github.com/executablebooks/sphinx-tabs/issues/212
docutils==0.21.2
numpy
18 changes: 9 additions & 9 deletions pyoptsparse/pyOpt_constraint.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Standard Python modules
from collections import OrderedDict
from collections.abc import Iterable
import copy
from typing import Dict, Iterable, List, Optional, Union

# External modules
import numpy as np
Expand All @@ -18,7 +18,7 @@ def __init__(
name: str,
nCon: int,
linear: bool,
wrt: Union[None, str, Iterable[str]],
wrt: str | Iterable[str] | None,
jac: Dict1DType,
lower,
upper,
Expand All @@ -36,10 +36,10 @@ def __init__(
self.linear = linear
self.wrt = wrt
self.jac = jac
self.partialReturnOk: Optional[bool] = None
self.partialReturnOk: bool | None = None
self.scale = scale
self.rs: Optional[int] = None
self.re: Optional[int] = None
self.rs: int | None = None
self.re: int | None = None
# Before we can do the processing below we need to have lower
# and upper arguments expanded:

Expand Down Expand Up @@ -67,12 +67,12 @@ def __init__(
# automatically.

# This keeps track of the equality constraints:
equalityConstraints: Dict[str, List] = {"value": [], "ind": [], "fact": []}
equalityConstraints: dict[str, list] = {"value": [], "ind": [], "fact": []}

# All (inequality) constraints get added to
# "twoSidedConstraints". This will be used in optimizers that
# can do two-sided constraints properly
twoSidedConstraints: Dict[str, List] = {"lower": [], "upper": [], "ind": [], "fact": []}
twoSidedConstraints: dict[str, list] = {"lower": [], "upper": [], "ind": [], "fact": []}

# All (inequality) constraints are also added to
# "oneSidedConstraints". These are processed such that the
Expand All @@ -82,7 +82,7 @@ def __init__(
# defined which is precisely 1.0 or -1.0. The -1.0 appears
# when a greater-than-constraint is turned into a
# less-than-constraint.
oneSidedConstraints: Dict[str, List] = {"lower": [], "upper": [], "ind": [], "fact": []}
oneSidedConstraints: dict[str, list] = {"lower": [], "upper": [], "ind": [], "fact": []}

for icon in range(self.ncon):
# Check for equality constraint:
Expand Down Expand Up @@ -167,7 +167,7 @@ def __init__(
self.oneSidedConstraints = oneSidedConstraints
self.twoSidedConstraints = twoSidedConstraints

def finalize(self, variables: OrderedDict, dvOffset, index: int):
def finalize(self, variables: OrderedDict, dvOffset, index: int) -> None:
"""
After the design variables have been finalized and the order
is known we can check the constraint for consistency.
Expand Down
9 changes: 3 additions & 6 deletions pyoptsparse/pyOpt_gradient.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Standard Python modules
from typing import Tuple, Union

# External modules
import numpy as np
from numpy import ndarray
Expand Down Expand Up @@ -37,7 +34,7 @@ def __init__(self, optProb: Optimization, sensType: str, sensStep: float = None,
"""
self.optProb = optProb
self.sensType = sensType
self.sensStep: Union[float, complex]
self.sensStep: float | complex
if sensStep is None:
if self.sensType in ["fd", "fdr"]:
self.sensStep = 1e-6
Expand All @@ -58,7 +55,7 @@ def __init__(self, optProb: Optimization, sensType: str, sensStep: float = None,
else:
self.mydvs = list(range(ndvs))

def _eval_func(self, x: ndarray) -> Tuple[ndarray, ndarray, bool]:
def _eval_func(self, x: ndarray) -> tuple[ndarray, ndarray, bool]:
"""Internal method to call function and extract obj, con"""

xCall = self.optProb.processXtoDict(x)
Expand All @@ -76,7 +73,7 @@ def _eval_func(self, x: ndarray) -> Tuple[ndarray, ndarray, bool]:

return fobj, fcon, fail

def __call__(self, x: Dict1DType, funcs: Dict1DType) -> Tuple[Dict2DType, bool]:
def __call__(self, x: Dict1DType, funcs: Dict1DType) -> tuple[Dict2DType, bool]:
"""
We need to make this object "look" the same as a user supplied
function handle. That way, the optimizers need not care how
Expand Down
14 changes: 7 additions & 7 deletions pyoptsparse/pyOpt_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, fileName, optProb=None, temp=False, flag="r"):
self.temp = temp
self.fileName = fileName

def close(self):
def close(self) -> None:
"""
Close the underlying database.
This should only be used in write mode. In read mode, we close the db
Expand All @@ -68,7 +68,7 @@ def close(self):
if self.temp:
os.remove(self.fileName)

def write(self, callCounter, data):
def write(self, callCounter, data) -> None:
"""
This is the main to write data. Basically, we just pass in
the callCounter, the integer forming the key, and a dictionary
Expand All @@ -95,7 +95,7 @@ def write(self, callCounter, data):
self.db.sync()
self.keys = list(self.db.keys())

def writeData(self, key, data):
def writeData(self, key, data) -> None:
"""
Write arbitrary `key:data` value to db.

Expand All @@ -111,7 +111,7 @@ def writeData(self, key, data):
self.db.commit()
self.keys = list(self.db.keys())

def pointExists(self, callCounter):
def pointExists(self, callCounter) -> bool:
"""
Determine if callCounter is in the database

Expand Down Expand Up @@ -152,7 +152,7 @@ def read(self, key):
except KeyError:
return None

def _searchCallCounter(self, x, last=None):
def _searchCallCounter(self, x, last=None) -> int | None:
"""
Searches through existing callCounters, and finds the one corresponding
to an evaluation at the design vector `x`.
Expand Down Expand Up @@ -186,7 +186,7 @@ def _searchCallCounter(self, x, last=None):
break
return callCounter

def _processDB(self):
def _processDB(self) -> None:
"""
Pre-processes the DB file and store various values into class attributes.
These will be used later when calling self.getXX functions.
Expand Down Expand Up @@ -735,7 +735,7 @@ def _readValidCallCounter(self, i, user_specified_callCounter, allowSens, major)
# end if - ("funcs" in val.keys()
# end if - pointExists

def __del__(self):
def __del__(self) -> None:
try:
self.db.close()
if self.temp:
Expand Down
2 changes: 1 addition & 1 deletion pyoptsparse/pyOpt_objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, name, scale=1.0):
self.value = 0.0
self.scale = scale

def __str__(self):
def __str__(self) -> str:
"""
Structured Print of Objective
"""
Expand Down
Loading
Loading