Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector substitution unit test error #1576

Open
whoburg opened this issue Sep 24, 2023 · 1 comment
Open

Vector substitution unit test error #1576

whoburg opened this issue Sep 24, 2023 · 1 comment

Comments

@whoburg
Copy link
Collaborator

whoburg commented Sep 24, 2023

Found two failing tests on a fresh install. One of is already captured in #1573; the other one in test_vector_sweep seems new.

Per the instructions printed after running import gpkit.tests, here is the output:

Found no installed solvers, beginning a build.
# Building GPkit version 1.1
# Moving to the directory from which GPkit was imported.

Attempting to find and build solvers:

# Looking for `mosek_cli`
#   (A "success" is if mskexpopt complains that
#    we haven't specified a file for it to open.)
#     Calling 'mskexpopt'
##
### CALL BEGINS
/bin/sh: mskexpopt: command not found
### CALL ENDS
##
# Looks like `mskexpopt` was not found in the default PATH,
#  so let's try locating that binary ourselves.
# expected MOSEK directory not found: /Users/serenity/mosek
# Did not find
# mosek_cli

# Looking for `mosek_conif`
#   Trying to import mosek...
# Did not find
# mosek_conif

# Looking for `cvxopt`
#   Trying to import cvxopt...

Found cvxopt in the default PYTHONPATH

Found the following solvers: cvxopt
#     Replacing directory env
..........................E...............................................................................................................................................E......................................
======================================================================
ERROR: test_vector_sweep (gpkit.tests.t_sub.TestModelSubs)
Test sweep involving VectorVariables
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/serenity/code/gpkit/gpkit/tests/t_sub.py", line 205, in test_vector_sweep
    sol = m.solve(verbosity=0)
  File "/Users/serenity/code/gpkit/gpkit/constraints/prog_factories.py", line 123, in solvefn
    constants, sweep, linked = parse_subs(self.varkeys, self.substitutions)
  File "/Users/serenity/code/gpkit/gpkit/nomials/substitution.py", line 25, in parse_subs
    append_sub(sub, keys, constants, sweep, linkedsweep)
  File "/Users/serenity/code/gpkit/gpkit/nomials/substitution.py", line 47, in append_sub
    sub = np.array(sub) if not hasattr(sub, "shape") else sub
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

======================================================================
ERROR: test_breakdowns_cvxopt (gpkit.tests.t_examples.TestExamples)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/serenity/code/gpkit/gpkit/tests/helpers.py", line 55, in test
    testfn(name, import_dict, path)(self)
  File "/Users/serenity/code/gpkit/gpkit/tests/helpers.py", line 90, in test
    imported[name] = importlib.import_module(name)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/serenity/code/gpkit/docs/source/examples/breakdowns.py", line 11, in <module>
    sol = pickle.load(open(dirpath+"solar_13.p", "rb"))
ModuleNotFoundError: No module named 'pint.quantity'

----------------------------------------------------------------------
Ran 209 tests in 20.246s

FAILED (errors=2)

GPkit is now installed with solver(s) ['cvxopt']
To incorporate new solvers at a later date, run `gpkit.build()`.

If any tests didn't pass, please post the output above
(starting from "Found no installed solvers, beginning a build.")
to [email protected] or https://github.com/convexengineering/gpkit/issues/new
so we can prevent others from having these errors.
@whoburg whoburg changed the title Two failing tests on fresh install Vector substitution unit test error Sep 26, 2023
@whoburg
Copy link
Collaborator Author

whoburg commented Sep 26, 2023

Updated title to be about the vector substitution failure only -- #1573 captures the other failure.

I can work on fixing this but I'm unclear on the intent of how it should work. The model is

x = Variable("x")
x_min = Variable("x_min", 1)
y = VectorVariable(2, "y")
m = Model(x, [x >= y.prod()])

There are several different substitutions in test_vector_sweep; the first few are:

{y: ('sweep', [[2, 3], [5, 7], [9, 11]])}

(three different values for the vector of length 2, produces costs [6, 15, 27, 14, 35, 63, 22, 55, 99])

{y: ('sweep', [[2, 3], [5, 7, 11]])}

(the one that's failing with ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part. -- intended to produce costs [10, 15, 14, 21, 22, 33]),

{y: ('sweep', [[2, 3, 9], [5, 7, 11]])}

(wrong shape, intended to throw a ValueError) ... and a few more.

I'd support a solution that's more restrictive on shapes of substitutions that are supported - seems surprising to allow the inhomogeneous shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant