77import numpy as np
88
99# Local modules
10- from .pyOpt_error import Error, pyOptSparseWarning
10+ from .pyOpt_error import pyOptSparseWarning
1111from .pyOpt_types import Dict1DType
1212from .pyOpt_utils import INFINITY, _broadcast_to_array, convertToCOO
1313
@@ -204,7 +204,7 @@ def finalize(self, variables: OrderedDict, dvOffset, index: int):
204204 try:
205205 self.wrt = list(self.wrt)
206206 except Exception:
207- raise Error (f"The 'wrt' argument to constraint '{self.name}' must be an iterable list")
207+ raise TypeError (f"The 'wrt' argument to constraint '{self.name}' must be an iterable list")
208208
209209 # We allow 'None' to be in the list...they are null so
210210 # just pop them out:
@@ -214,7 +214,7 @@ def finalize(self, variables: OrderedDict, dvOffset, index: int):
214214 # *actually* are variables
215215 for dvGroup in self.wrt:
216216 if dvGroup not in variables:
217- raise Error (
217+ raise KeyError (
218218 f"The supplied dvGroup '{dvGroup}' in 'wrt' for the {self.name} constraint, does not exist. "
219219 + "It must be added with a call to addVar() or addVarGroup()."
220220 )
@@ -254,7 +254,7 @@ def finalize(self, variables: OrderedDict, dvOffset, index: int):
254254 # sparse constraints.
255255
256256 if self.linear:
257- raise Error (
257+ raise ValueError (
258258 "The 'jac' keyword to argument to addConGroup() must be supplied for a linear constraint. "
259259 + f"The constraint in error is {self.name}."
260260 )
@@ -274,7 +274,7 @@ def finalize(self, variables: OrderedDict, dvOffset, index: int):
274274 else:
275275 # First sanitize input:
276276 if not isinstance(self.jac, dict):
277- raise Error (
277+ raise TypeError (
278278 "The 'jac' keyword argument to addConGroup() must be a dictionary. "
279279 + f"The constraint in error is {self.name}."
280280 )
@@ -301,7 +301,7 @@ def finalize(self, variables: OrderedDict, dvOffset, index: int):
301301
302302 # Generically check the shape:
303303 if self.jac[dvGroup]["shape"][0] != self.ncon or self.jac[dvGroup]["shape"][1] != ndvs:
304- raise Error (
304+ raise ValueError (
305305 f"The supplied Jacobian for dvGroup {dvGroup}' in constraint {self.name}, was the incorrect size. "
306306 + f"Expecting a Jacobian of size ({self.ncon}, {ndvs}) but received a Jacobian of size "
307307 + f"({self.jac[dvGroup]['shape'][0]}, {self.jac[dvGroup]['shape'][1]})."
0 commit comments