Repository: OpenMDAO/OpenMDAO

Issue:
If list_driver_vars is called twice with driver_scaling=False, the upper and lower bounds are changed.
### Description

If list_driver_vars is called twice with driver_scaling=False, the upper and lower bounds are changed.

### Example

I have a simple working example.

### OpenMDAO Version

3.36.1-dev

### Relevant environment information

_No response_

Hints from issue comments:

Solution patch:
diff --git a/openmdao/core/problem.py b/openmdao/core/problem.py
index 67eb07195..ef93e82c0 100644
--- a/openmdao/core/problem.py
+++ b/openmdao/core/problem.py
@@ -6,6 +6,7 @@ import shutil
 import sys
 import pprint
 import os
+from copy import deepcopy
 import weakref
 import pathlib
 import textwrap
@@ -1791,7 +1792,7 @@ class Problem(object, metaclass=ProblemMetaclass):
         desvars = self.driver._designvars
         vals = self.driver.get_design_var_values(get_remote=True, driver_scaling=driver_scaling)
         if not driver_scaling:
-            desvars = desvars.copy()
+            desvars = deepcopy(desvars)
             for meta in desvars.values():
                 scaler = meta['scaler'] if meta.get('scaler') is not None else 1.
                 adder = meta['adder'] if meta.get('adder') is not None else 0.
@@ -1819,7 +1820,7 @@ class Problem(object, metaclass=ProblemMetaclass):
         cons = self.driver._cons
         vals = self.driver.get_constraint_values(driver_scaling=driver_scaling)
         if not driver_scaling:
-            cons = cons.copy()
+            cons = deepcopy(cons)
             for meta in cons.values():
                 scaler = meta['scaler'] if meta.get('scaler') is not None else 1.
                 adder = meta['adder'] if meta.get('adder') is not None else 0.


Test patch:
diff --git a/openmdao/core/tests/test_problem.py b/openmdao/core/tests/test_problem.py
index 8e2b39d8d..1d55fc76a 100644
--- a/openmdao/core/tests/test_problem.py
+++ b/openmdao/core/tests/test_problem.py
@@ -1878,6 +1878,49 @@ class TestProblem(unittest.TestCase):
         # make sure the deprecated function still returns tha data
         self.assertEqual(set(prob_vars.keys()), {'constraints', 'design_vars', 'objectives'})
 
+    def test_list_driver_vars_bounds_bug(self):
+
+        model = SellarDerivatives()
+        model.nonlinear_solver = om.NonlinearBlockGS()
+
+        prob = om.Problem(model)
+        prob.driver = om.ScipyOptimizeDriver()
+        prob.driver.options['optimizer'] = 'SLSQP'
+        prob.driver.options['tol'] = 1e-9
+
+        model.add_design_var('z', lower=np.array([-10.0, 0.0]), upper=np.array([10.0, 10.0]), scaler=2.0)
+        model.add_objective('obj', scaler=0.1)
+        model.add_constraint('con1', upper=1.0, scaler=7.0)
+
+        prob.setup()
+        prob.run_driver()
+
+        info =  prob.list_driver_vars(
+            driver_scaling=False,
+            desvar_opts=['lower', 'upper', 'scaler', 'adder'],
+            cons_opts=['lower', 'upper', 'scaler', 'adder'],
+            objs_opts=['scaler', 'adder'],
+        )
+
+        upper = info['design_vars'][0][1]['upper']
+        assert_near_equal(upper, np.array([10., 10.]))
+
+        upper = info['constraints'][0][1]['upper']
+        assert_near_equal(upper, 1.0)
+
+        info =  prob.list_driver_vars(
+            driver_scaling=False,
+            desvar_opts=['lower', 'upper', 'scaler', 'adder'],
+            cons_opts=['lower', 'upper', 'scaler', 'adder'],
+            objs_opts=['scaler', 'adder'],
+        )
+
+        upper = info['design_vars'][0][1]['upper']
+        assert_near_equal(upper, np.array([10., 10.]))
+
+        upper = info['constraints'][0][1]['upper']
+        assert_near_equal(upper, 1.0)
+
     def test_list_driver_vars_before_final_setup(self):
         prob = om.Problem()
         prob.model.add_subsystem('parab', Paraboloid(), promotes_inputs=['x', 'y'])