Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

REF Check whether shape and label match.

  • Loading branch information...
commit b1285e8e7fb77263e1be68593c0fe465e727d8af 1 parent 9e84c4c
Steven Troxler authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 la/flarry.py
View
14 la/flarry.py
@@ -1847,7 +1847,12 @@ def lrange(shape=None, label=None, start=0, step=1, dtype=None):
if isinstance(shape, int):
shape = (shape,)
if label is not None:
- shape = [len(lab) for lab in label]
+ if shape is not None:
+ _shape = [len(lab) for lab in label]
+ if _shape != shape:
+ raise ValueError("Shape and label cannot disagree")
+ else:
+ shape = [len(lab) for lab in label]
else:
if shape is None:
raise ValueError("Either `label` or `shape` must be supplied.")
@@ -1935,7 +1940,12 @@ def empty(shape=None, label=None, dtype=None, order='C'):
if isinstance(shape, int):
shape = (shape,)
if label is not None:
- shape = [len(lab) for lab in label]
+ if shape is not None:
+ _shape = [len(lab) for lab in label]
+ if _shape != shape:
+ raise ValueError("Shape and label cannot disagree")
+ else:
+ shape = [len(lab) for lab in label]
else:
if shape is None:
raise ValueError("Either `label` or `shape` must be supplied.")
Please sign in to comment.
Something went wrong with that request. Please try again.