Skip to content

Commit

Permalink
Merge 6b57cdb into 454ed73
Browse files Browse the repository at this point in the history
  • Loading branch information
swryan committed Oct 25, 2023
2 parents 454ed73 + 6b57cdb commit 07b6f8a
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/openmdao_latest_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
echo "============================================================="
echo "Install latest versions of 'doe' dependencies"
echo "============================================================="
python -m pip install --upgrade --pre pyDOE2
python -m pip install --upgrade --pre pyDOE3
echo "============================================================="
echo "Install latest versions of 'notebooks' dependencies"
Expand Down
10 changes: 5 additions & 5 deletions openmdao/drivers/differential_evolution_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import numpy as np

try:
from pyDOE2 import lhs
from pyDOE3 import lhs
except ModuleNotFoundError:
lhs = None

Expand Down Expand Up @@ -65,10 +65,10 @@ def __init__(self, **kwargs):
Initialize the DifferentialEvolutionDriver driver.
"""
if lhs is None:
raise RuntimeError(f"{self.__class__.__name__} requires the 'pyDOE2' package, "
raise RuntimeError(f"{self.__class__.__name__} requires the 'pyDOE3' package, "
"which can be installed with one of the following commands:\n"
" pip install openmdao[doe]\n"
" pip install pyDOE2")
" pip install pyDOE3")

super().__init__(**kwargs)

Expand Down Expand Up @@ -536,10 +536,10 @@ def __init__(self, objfun, comm=None, model_mpi=None):
Initialize genetic algorithm object.
"""
if lhs is None:
raise RuntimeError(f"{self.__class__.__name__} requires the 'pyDOE2' package, "
raise RuntimeError(f"{self.__class__.__name__} requires the 'pyDOE3' package, "
"which can be installed with one of the following commands:\n"
" pip install openmdao[doe]\n"
" pip install pyDOE2")
" pip install pyDOE3")

self.objfun = objfun
self.comm = comm
Expand Down
24 changes: 12 additions & 12 deletions openmdao/drivers/doe_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import numpy as np

try:
import pyDOE2
import pyDOE3
except ImportError:
pyDOE2 = None
pyDOE3 = None

from openmdao.utils.name_maps import prom_name2abs_name

Expand Down Expand Up @@ -277,7 +277,7 @@ def __call__(self, design_vars, model=None):

class _pyDOE_Generator(DOEGenerator):
"""
Base class for DOE case generators implementing methods from pyDOE2.
Base class for DOE case generators implementing methods from pyDOE3.
Parameters
----------
Expand All @@ -299,11 +299,11 @@ def __init__(self, levels=_LEVELS):
"""
Initialize the _pyDOE_Generator.
"""
if pyDOE2 is None:
raise RuntimeError(f"{self.__class__.__name__} requires the 'pyDOE2' package, "
if pyDOE3 is None:
raise RuntimeError(f"{self.__class__.__name__} requires the 'pyDOE3' package, "
"which can be installed with one of the following commands:\n"
" pip install openmdao[doe]\n"
" pip install pyDOE2")
" pip install pyDOE3")

super().__init__()
self._levels = levels
Expand Down Expand Up @@ -452,7 +452,7 @@ def _generate_design(self, size):
ndarray
The design matrix as a size x levels array of indices.
"""
return pyDOE2.fullfact(self._get_all_levels())
return pyDOE3.fullfact(self._get_all_levels())


class GeneralizedSubsetGenerator(_pyDOE_Generator):
Expand Down Expand Up @@ -507,7 +507,7 @@ def _generate_design(self, size):
ndarray
The design matrix as a size x levels array of indices.
"""
return pyDOE2.gsd(levels=self._get_all_levels(), reduction=self._reduction, n=self._n)
return pyDOE3.gsd(levels=self._get_all_levels(), reduction=self._reduction, n=self._n)


class PlackettBurmanGenerator(_pyDOE_Generator):
Expand Down Expand Up @@ -535,7 +535,7 @@ def _generate_design(self, size):
ndarray
The design matrix as a size x levels array of indices.
"""
doe = pyDOE2.pbdesign(size)
doe = pyDOE3.pbdesign(size)

doe[doe < 0] = 0 # replace -1 with zero

Expand Down Expand Up @@ -583,14 +583,14 @@ def _generate_design(self, size):
"but must be at least 3 when using %s. " %
(size, self.__class__.__name__))

doe = pyDOE2.bbdesign(size, center=self._center)
doe = pyDOE3.bbdesign(size, center=self._center)

return doe + 1 # replace [-1, 0, 1] with [0, 1, 2]


class LatinHypercubeGenerator(DOEGenerator):
"""
DOE case generator implementing Latin hypercube method via pyDOE2.
DOE case generator implementing Latin hypercube method via pyDOE3.
Parameters
----------
Expand Down Expand Up @@ -673,7 +673,7 @@ def __call__(self, design_vars, model=None):
self._samples = size

# generate design
doe = pyDOE2.lhs(size, samples=self._samples,
doe = pyDOE3.lhs(size, samples=self._samples,
criterion=self._criterion,
iterations=self._iterations,
random_state=self._seed)
Expand Down
10 changes: 5 additions & 5 deletions openmdao/drivers/genetic_algorithm_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import numpy as np

try:
from pyDOE2 import lhs
from pyDOE3 import lhs
except ModuleNotFoundError:
lhs = None

Expand Down Expand Up @@ -70,10 +70,10 @@ def __init__(self, **kwargs):
Initialize the SimpleGADriver driver.
"""
if lhs is None:
raise RuntimeError(f"{self.__class__.__name__} requires the 'pyDOE2' package, "
raise RuntimeError(f"{self.__class__.__name__} requires the 'pyDOE3' package, "
"which can be installed with one of the following commands:\n"
" pip install openmdao[doe]\n"
" pip install pyDOE2")
" pip install pyDOE3")

super().__init__(**kwargs)

Expand Down Expand Up @@ -633,10 +633,10 @@ def __init__(self, objfun, comm=None, model_mpi=None):
Initialize genetic algorithm object.
"""
if lhs is None:
raise RuntimeError(f"{self.__class__.__name__} requires the 'pyDOE2' package, "
raise RuntimeError(f"{self.__class__.__name__} requires the 'pyDOE3' package, "
"which can be installed with one of the following commands:\n"
" pip install openmdao[doe]\n"
" pip install pyDOE2")
" pip install pyDOE3")

self.objfun = objfun
self.comm = comm
Expand Down
30 changes: 15 additions & 15 deletions openmdao/drivers/tests/test_differential_evolution_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
PETScVector = None

try:
import pyDOE2
import pyDOE3
except ImportError:
pyDOE2 = None
pyDOE3 = None

extra_prints = False # enable printing results

Expand All @@ -52,28 +52,28 @@ def _test_func_name(func, num, param):

class TestErrors(unittest.TestCase):

@unittest.skipIf(pyDOE2, "only runs if 'pyDOE2' is not installed")
def test_no_pyDOE2(self):
@unittest.skipIf(pyDOE3, "only runs if 'pyDOE3' is not installed")
def test_no_pyDOE3(self):
with self.assertRaises(RuntimeError) as err:
DifferentialEvolution(lambda: 0)

self.assertEqual(str(err.exception),
"DifferentialEvolution requires the 'pyDOE2' package, "
"DifferentialEvolution requires the 'pyDOE3' package, "
"which can be installed with one of the following commands:\n"
" pip install openmdao[doe]\n"
" pip install pyDOE2")
" pip install pyDOE3")

with self.assertRaises(RuntimeError) as err:
om.DifferentialEvolutionDriver()

self.assertEqual(str(err.exception),
"DifferentialEvolutionDriver requires the 'pyDOE2' package, "
"DifferentialEvolutionDriver requires the 'pyDOE3' package, "
"which can be installed with one of the following commands:\n"
" pip install openmdao[doe]\n"
" pip install pyDOE2")
" pip install pyDOE3")


@unittest.skipUnless(pyDOE2, "requires 'pyDOE2', install openmdao[doe]")
@unittest.skipUnless(pyDOE3, "requires 'pyDOE3', install openmdao[doe]")
class TestDifferentialEvolution(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -433,7 +433,7 @@ def test_vectorized_constraints(self):
self.assertLessEqual(1.0 - 1e-6, prob["x"][i])


@unittest.skipUnless(pyDOE2, "requires 'pyDOE2', install openmdao[doe]")
@unittest.skipUnless(pyDOE3, "requires 'pyDOE3', install openmdao[doe]")
class TestDriverOptionsDifferentialEvolution(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -466,7 +466,7 @@ def test_driver_options(self):
self.assertEqual(prob.driver.options['Pc'], 0.0123)


@unittest.skipUnless(pyDOE2, "requires 'pyDOE2', install openmdao[doe]")
@unittest.skipUnless(pyDOE3, "requires 'pyDOE3', install openmdao[doe]")
class TestMultiObjectiveDifferentialEvolution(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -579,7 +579,7 @@ def compute(self, inputs, outputs):
self.assertGreater(h2, h1) # top area does not depend on height


@unittest.skipUnless(pyDOE2, "requires 'pyDOE2', install openmdao[doe]")
@unittest.skipUnless(pyDOE3, "requires 'pyDOE3', install openmdao[doe]")
class TestConstrainedDifferentialEvolution(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -864,7 +864,7 @@ def test_inf_constraints(self, equals, lower, upper):


@unittest.skipUnless(MPI and PETScVector, "MPI and PETSc are required.")
@unittest.skipUnless(pyDOE2, "requires 'pyDOE2', install openmdao[doe]")
@unittest.skipUnless(pyDOE3, "requires 'pyDOE3', install openmdao[doe]")
class MPITestDifferentialEvolution(unittest.TestCase):
N_PROCS = 2

Expand Down Expand Up @@ -914,7 +914,7 @@ def test_random_state_bug(self):


@unittest.skipUnless(MPI and PETScVector, "MPI and PETSc are required.")
@unittest.skipUnless(pyDOE2, "requires 'pyDOE2', install openmdao[doe]")
@unittest.skipUnless(pyDOE3, "requires 'pyDOE3', install openmdao[doe]")
class MPITestDifferentialEvolutionNoSetSeed(unittest.TestCase):
N_PROCS = 2

Expand Down Expand Up @@ -1001,7 +1001,7 @@ def compute(self, inputs, outputs):


@unittest.skipUnless(MPI and PETScVector, "MPI and PETSc are required.")
@unittest.skipUnless(pyDOE2, "requires 'pyDOE2', install openmdao[doe]")
@unittest.skipUnless(pyDOE3, "requires 'pyDOE3', install openmdao[doe]")
@use_tempdirs
class MPITestDifferentialEvolution4Procs(unittest.TestCase):
N_PROCS = 4
Expand Down

0 comments on commit 07b6f8a

Please sign in to comment.