summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2009-10-08 13:53:36 +0000
committerDavid Cournapeau <cournape@gmail.com>2009-10-08 13:53:36 +0000
commit77966f7aa170f0a6eb603f5dae7111429f015262 (patch)
tree8cf4cf89824bd84a49283c48e0838a4fb1bffa3d
parent7630f51a972641b79a88507e814800237ef85699 (diff)
downloadnumpy-77966f7aa170f0a6eb603f5dae7111429f015262.tar.gz
ENH: check lack of hole in check_api_dict
-rw-r--r--numpy/core/code_generators/genapi2.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/core/code_generators/genapi2.py b/numpy/core/code_generators/genapi2.py
index 1376f5517..9937ec5a5 100644
--- a/numpy/core/code_generators/genapi2.py
+++ b/numpy/core/code_generators/genapi2.py
@@ -1,3 +1,8 @@
+import sys
+
+if sys.version_info[:2] < (2, 6):
+ from sets import Set as set
+
from genapi import API_FILES, find_functions
def order_dict(d):
@@ -35,6 +40,15 @@ Same index has been used twice in api definition: %s
if len(names) != 1]
raise ValueError(msg)
+ # No 'hole' in the indexes may be allowed, and it must starts at 0
+ indexes = set(d.values())
+ expected = set(range(len(indexes)))
+ if not indexes == expected:
+ diff = expected.symmetric_difference(indexes)
+ msg = "There are some holes in the API indexing: " \
+ "(symmetric diff is %s)" % diff
+ raise ValueError(msg)
+
def get_api_functions(tagname, api_dict):
"""Parse source files to get functions tagged by the given tag."""
functions = []