Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bqpd committed Dec 1, 2020
1 parent f318ccd commit c3074b5
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions gpkit/keydict.py
Expand Up @@ -186,19 +186,17 @@ def __getitem__(self, key):

def __setitem__(self, key, value):
"Overloads __setitem__ and []= to work with all keys"
# pylint: disable=too-many-boolean-expressions
# pylint: disable=too-many-boolean-expressions,too-many-branches
try:
key, idx = self.parse_and_index(key)
except KeyError as e: # may be indexed VectorVariable
# NOTE: this check takes ~4% of the time in this loop
# and arguably the functionality isn't worth it
if hasattr(key, "shape"):
if not hasattr(value, "shape"):
value = np.full(key.shape, value)
for subkey, subval in zip(key.flat, value.flat):
if not hasattr(subkey, "key"):
raise e
self[subkey] = subval
# NOTE: this try/except takes ~4% of the time in this loop
if not hasattr(key, "shape"):
raise e
if not hasattr(value, "shape"):
value = np.full(key.shape, value)
for subkey, subval in zip(key.flat, value.flat):
self[subkey] = subval
return
value = clean_value(key, value)
if key not in self.keymap:
Expand Down

0 comments on commit c3074b5

Please sign in to comment.