[ { "hash": "c3ba22da35f011595b2643e894db1f797e7f2fec", "msg": "added speed test for list access and casting operations.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-29T08:18:10+00:00", "author_timezone": 0, "committer_date": "2002-09-29T08:18:10+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "e42148d6aadf52a9949f4aeaa6343ed0281ff5a3" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 0, "insertions": 53, "lines": 53, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/tests/test_scxx.py", "new_path": "weave/tests/test_scxx.py", "filename": "test_scxx.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -320,7 +320,60 @@ def check_access_set_speed(self):\n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == a \n+\n+ def _check_string_add_speed(self):\n+ N = 1000000\n+ print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n+ a = [\"blah\"] * N\n+ desired = [1] * N\n+ t1 = time.time()\n+ for i in xrange(N):\n+ desired[i] = a[i] + 'blah'\n+ t2 = time.time()\n+ print 'python:', t2 - t1\n \n+ a = [\"blah\"] * N\n+ b = [1] * N \n+ code = \"\"\"\n+ const int N = a.length();\n+ std::string blah = std::string(\"blah\");\n+ for(int i=0; i < N; i++)\n+ b[i] = (std::string)a[i] + blah; \n+ \"\"\"\n+ # compile not included in timing\n+ inline_tools.inline(code,['a','b']) \n+ t1 = time.time()\n+ inline_tools.inline(code,['a','b']) \n+ t2 = time.time()\n+ print 'weave:', t2 - t1\n+ assert b == desired \n+\n+ def check_int_add_speed(self):\n+ N = 1000000\n+ print 'int add -- b[i] = a[i] + 1 for N =', N \n+ a = [0] * N\n+ desired = [1] * N\n+ t1 = time.time()\n+ for i in xrange(N):\n+ desired[i] = a[i] + 1\n+ t2 = time.time()\n+ print 'python:', t2 - t1\n+ \n+ a = [0] * N\n+ b = [0] * N \n+ code = \"\"\"\n+ const int N = a.length();\n+ for(int i=0; i < N; i++)\n+ b[i] = (int)a[i] + 1; \n+ \"\"\"\n+ # compile not included in timing\n+ inline_tools.inline(code,['a','b']) \n+ t1 = time.time()\n+ inline_tools.inline(code,['a','b']) \n+ t2 = time.time()\n+ print 'weave:', t2 - t1\n+ assert b == desired \n+ \n class test_object_cast(unittest.TestCase):\n def check_int_cast(self):\n code = \"\"\"\n", "added_lines": 53, "deleted_lines": 0, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n \n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\n def check_access_speed(self):\n N = 1000000\n print 'list access -- val = a[i] for N =', N\n a = [0] * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self):\n N = 1000000\n print 'list access/set -- b[i] = a[i] for N =', N \n a = [0] * N\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == a \n\n def _check_string_add_speed(self):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 'blah'\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [\"blah\"] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n std::string blah = std::string(\"blah\");\n for(int i=0; i < N; i++)\n b[i] = (std::string)a[i] + blah; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\n def check_int_add_speed(self):\n N = 1000000\n print 'int add -- b[i] = a[i] + 1 for N =', N \n a = [0] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 1\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [0] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = (int)a[i] + 1; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n \nclass test_object_cast(unittest.TestCase):\n def check_int_cast(self):\n code = \"\"\"\n py::object val = py::number(1);\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self):\n code = \"\"\"\n py::object val = py::number(1.0);\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self):\n code = \"\"\"\n py::object val = py::number(1.0);\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self):\n code = \"\"\"\n py::object val = py::str(\"hello\");\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self):\n self.generic_attr('return_val = a.attr(\"b\").disown();')\n\n def check_string(self):\n self.generic_attr('return_val = a.attr(std::string(\"b\")).disown();')\n\n def check_obj(self):\n code = \"\"\"\n py::str name = py::str(\"b\");\n return_val = a.attr(name).disown();\n \"\"\" \n self.generic_attr(code,['a'])\n \nclass test_attr_call(unittest.TestCase):\n\n def check_call(self):\n a = foo() \n res = inline_tools.inline('return_val = a.attr(\"bar\").call().disown();',['a'])\n assert res == \"bar results\"\n\n \n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n suites.append( makeSuite(test_object_cast,'check_'))\n suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_attr_call,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n \n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\n def check_access_speed(self):\n N = 1000000\n print 'list access -- val = a[i] for N =', N\n a = [0] * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self):\n N = 1000000\n print 'list access/set -- b[i] = a[i] for N =', N \n a = [0] * N\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == a \n \nclass test_object_cast(unittest.TestCase):\n def check_int_cast(self):\n code = \"\"\"\n py::object val = py::number(1);\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self):\n code = \"\"\"\n py::object val = py::number(1.0);\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self):\n code = \"\"\"\n py::object val = py::number(1.0);\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self):\n code = \"\"\"\n py::object val = py::str(\"hello\");\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self):\n self.generic_attr('return_val = a.attr(\"b\").disown();')\n\n def check_string(self):\n self.generic_attr('return_val = a.attr(std::string(\"b\")).disown();')\n\n def check_obj(self):\n code = \"\"\"\n py::str name = py::str(\"b\");\n return_val = a.attr(name).disown();\n \"\"\" \n self.generic_attr(code,['a'])\n \nclass test_attr_call(unittest.TestCase):\n\n def check_call(self):\n a = foo() \n res = inline_tools.inline('return_val = a.attr(\"bar\").call().disown();',['a'])\n assert res == \"bar results\"\n\n \n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n suites.append( makeSuite(test_object_cast,'check_'))\n suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_attr_call,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx.py", "nloc": 26, "complexity": 3, "token_count": 127, "parameters": [ "self" ], "start_line": 269, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 128, "parameters": [ "self" ], "start_line": 298, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "_check_string_add_speed", "long_name": "_check_string_add_speed( self )", "filename": "test_scxx.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 324, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 351, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 378, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 384, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 390, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 396, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 405, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 414, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 425, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 428, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 431, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_call", "long_name": "check_call( self )", "filename": "test_scxx.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 440, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 10, "complexity": 2, "token_count": 74, "parameters": [ "level" ], "start_line": 447, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 458, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx.py", "nloc": 26, "complexity": 3, "token_count": 127, "parameters": [ "self" ], "start_line": 269, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 128, "parameters": [ "self" ], "start_line": 298, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 325, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 337, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 343, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 352, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 356, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 361, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 372, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 375, "end_line": 376, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 378, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_call", "long_name": "check_call( self )", "filename": "test_scxx.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 387, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 10, "complexity": 2, "token_count": 74, "parameters": [ "level" ], "start_line": 394, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 405, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_check_string_add_speed", "long_name": "_check_string_add_speed( self )", "filename": "test_scxx.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 324, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 351, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 } ], "nloc": 337, "complexity": 31, "token_count": 2110, "diff_parsed": { "added": [ "", " def _check_string_add_speed(self):", " N = 1000000", " print 'string add -- b[i] = a[i] + \"blah\" for N =', N", " a = [\"blah\"] * N", " desired = [1] * N", " t1 = time.time()", " for i in xrange(N):", " desired[i] = a[i] + 'blah'", " t2 = time.time()", " print 'python:', t2 - t1", " a = [\"blah\"] * N", " b = [1] * N", " code = \"\"\"", " const int N = a.length();", " std::string blah = std::string(\"blah\");", " for(int i=0; i < N; i++)", " b[i] = (std::string)a[i] + blah;", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a','b'])", " t1 = time.time()", " inline_tools.inline(code,['a','b'])", " t2 = time.time()", " print 'weave:', t2 - t1", " assert b == desired", "", " def check_int_add_speed(self):", " N = 1000000", " print 'int add -- b[i] = a[i] + 1 for N =', N", " a = [0] * N", " desired = [1] * N", " t1 = time.time()", " for i in xrange(N):", " desired[i] = a[i] + 1", " t2 = time.time()", " print 'python:', t2 - t1", "", " a = [0] * N", " b = [0] * N", " code = \"\"\"", " const int N = a.length();", " for(int i=0; i < N; i++)", " b[i] = (int)a[i] + 1;", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a','b'])", " t1 = time.time()", " inline_tools.inline(code,['a','b'])", " t2 = time.time()", " print 'weave:', t2 - t1", " assert b == desired", "" ], "deleted": [] } } ] }, { "hash": "920b35a1c9a88595384d4ff0f4a90ddf594ffedd", "msg": "This checkin has quite a few changes. Most are augmentations to the\npy::object class' capabilities and unit tests to check them and\nchanges to test cases/examples to use the new features.\n\nThere is also one other BIG change. return_val has been changed\nfrom a PyObject* to a py::object. This removes the need to handle\nreference counting almost completely from inline() code. I am very\nhappy about this. :-)\n\nAll tests pass on win32, but the examples still need some work.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-09-30T08:31:56+00:00", "author_timezone": 0, "committer_date": "2002-09-30T08:31:56+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c3ba22da35f011595b2643e894db1f797e7f2fec" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 81, "insertions": 526, "lines": 607, "files": 16, "dmm_unit_size": 0.7815384615384615, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.9815384615384616, "modified_files": [ { "old_path": "weave/c_spec.py", "new_path": "weave/c_spec.py", "filename": "c_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -18,7 +18,7 @@\n class %(type_name)s_handler\n {\n public: \n- %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n+ %(return_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n@@ -28,7 +28,7 @@ class %(type_name)s_handler\n return %(to_c_return)s;\n }\n \n- %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n+ %(return_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n@@ -81,6 +81,7 @@ def init_info(self):\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n+ self.return_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n@@ -128,6 +129,7 @@ def template_vars(self,inline=0):\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n+ d['return_type'] = self.return_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n@@ -193,6 +195,7 @@ def init_info(self):\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n+ self.return_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n@@ -218,6 +221,7 @@ def init_info(self):\n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n+ self.return_type = self.c_type\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n@@ -230,6 +234,7 @@ def init_info(self):\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n+ self.return_type = self.c_type\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n@@ -295,6 +300,7 @@ def init_info(self):\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n+ self.return_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n \n@@ -305,6 +311,7 @@ def init_info(self):\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n+ self.return_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n \n@@ -315,6 +322,7 @@ def init_info(self):\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n+ self.return_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n \n@@ -324,6 +332,7 @@ def init_info(self):\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n+ self.return_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n@@ -353,6 +362,7 @@ def init_info(self):\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n+ self.return_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n@@ -364,6 +374,7 @@ def init_info(self):\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n+ self.return_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n@@ -375,6 +386,7 @@ def init_info(self):\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n+ self.return_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n@@ -389,6 +401,7 @@ def init_info(self):\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n+ self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n@@ -405,6 +418,7 @@ def init_info(self):\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n+ self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n", "added_lines": 16, "deleted_lines": 2, "source_code": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(return_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(return_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.return_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['return_type'] = self.return_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.return_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.return_type = self.c_type\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.return_type = self.c_type\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['i'] = 'int'\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.return_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.return_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.return_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.return_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n '']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.return_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.return_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.return_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#\n# catch all now handles callable objects\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()\n", "source_code_before": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['i'] = 'int'\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n '']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#\n# catch all now handles callable objects\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 16, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 70, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 23, "complexity": 10, "token_count": 151, "parameters": [ "self" ], "start_line": 90, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 114, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 117, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 120, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 17, "complexity": 2, "token_count": 114, "parameters": [ "self", "inline" ], "start_line": 127, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 145, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 157, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 165, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 168, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 182, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 193, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 202, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 216, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 232, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 242, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 291, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 298, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 308, "end_line": 316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 319, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 330, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 351, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 360, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 372, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 384, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 399, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 416, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 425, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 428, "end_line": 430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 432, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 15, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 23, "complexity": 10, "token_count": 151, "parameters": [ "self" ], "start_line": 89, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 116, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 119, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 16, "complexity": 2, "token_count": 106, "parameters": [ "self", "inline" ], "start_line": 126, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 166, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 191, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 199, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 213, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 228, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 237, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 286, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 293, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 302, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 312, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 322, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 342, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 351, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 362, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 373, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 387, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 403, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 411, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 414, "end_line": 416, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 418, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 16, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 70, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 17, "complexity": 2, "token_count": 114, "parameters": [ "self", "inline" ], "start_line": 127, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "nloc": 329, "complexity": 47, "token_count": 1674, "diff_parsed": { "added": [ " %(return_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)", " %(return_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)", " self.return_type = 'PyObject*'", " d['return_type'] = self.return_type", " self.return_type = 'std::string'", " self.return_type = self.c_type", " self.return_type = self.c_type", " self.return_type = 'int'", " self.return_type = 'int'", " self.return_type = 'double'", " self.return_type = 'std::complex'", " self.return_type = 'py::list'", " self.return_type = 'py::tuple'", " self.return_type = 'py::dict'", " self.return_type = 'py::object'", " self.return_type = 'py::object'" ], "deleted": [ " %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)", " %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)" ] } }, { "old_path": "weave/examples/dict_sort.py", "new_path": "weave/examples/dict_sort.py", "filename": "dict_sort.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -21,20 +21,21 @@ def c_sort(adict):\n assert(type(adict) == type({}))\n code = \"\"\"\n #line 21 \"dict_sort.py\" \n- PWOList keys = adict.keys();\n+ py::list keys = adict.keys();\n PyObject* py_keys = (PyObject*)keys;\n- PWOList items(keys.len());\n+ py::list items(keys.len());\n PyObject* py_items = (PyObject*)items;\n keys.sort(); // surely this isn't any slower than raw API calls\n PyObject* item = NULL;\n- for(int i = 0; i < keys.len();i++)\n+ int N = keys.len();\n+ for(int i = 0; i < N;i++)\n {\n item = PyList_GET_ITEM(py_keys,i);\n item = PyDict_GetItem(py_adict,item);\n Py_XINCREF(item);\n PyList_SetItem(py_items,i,item); \n } \n- return_val = items.disOwn();\n+ return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n \n@@ -46,9 +47,10 @@ def c_sort2(adict):\n PWOList items(keys.len());\n keys.sort(); // surely this isn't any slower than raw API calls\n PyObject* item = NULL;\n- for(int i = 0; i < keys.len();i++)\n+ int N = keys.length();\n+ for(int i = 0; i < N;i++)\n items[i] = adict[keys[i]];\n- return_val = items.disOwn();\n+ return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n \n", "added_lines": 8, "deleted_lines": 6, "source_code": "# Borrowed from Alex Martelli's sort from Python cookbook using inlines\n# 2x over fastest Python version -- again, maybe not worth the effort...\n# Then again, 2x is 2x...\n#\n# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python dict_sort.py\n# Dict sort of 1000 items for 300 iterations:\n# speed in python: 0.250999927521\n# [0, 1, 2, 3, 4]\n# speed in c: 0.110000014305\n# speed up: 2.28\n# [0, 1, 2, 3, 4]\n# speed in c (scxx): 0.200000047684\n# speed up: 1.25\n# [0, 1, 2, 3, 4] \n\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\n\ndef c_sort(adict):\n assert(type(adict) == type({}))\n code = \"\"\"\n #line 21 \"dict_sort.py\" \n py::list keys = adict.keys();\n PyObject* py_keys = (PyObject*)keys;\n py::list items(keys.len());\n PyObject* py_items = (PyObject*)items;\n keys.sort(); // surely this isn't any slower than raw API calls\n PyObject* item = NULL;\n int N = keys.len();\n for(int i = 0; i < N;i++)\n {\n item = PyList_GET_ITEM(py_keys,i);\n item = PyDict_GetItem(py_adict,item);\n Py_XINCREF(item);\n PyList_SetItem(py_items,i,item); \n } \n return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n\ndef c_sort2(adict):\n assert(type(adict) == type({}))\n code = \"\"\"\n #line 21 \"dict_sort.py\" \n PWOList keys = adict.keys();\n PWOList items(keys.len());\n keys.sort(); // surely this isn't any slower than raw API calls\n PyObject* item = NULL;\n int N = keys.length();\n for(int i = 0; i < N;i++)\n items[i] = adict[keys[i]];\n return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n\n# (IMHO) the simplest approach:\ndef sortedDictValues1(adict):\n items = adict.items()\n items.sort()\n return [value for key, value in items]\n\n# an alternative implementation, which\n# happens to run a bit faster for large\n# dictionaries on my machine:\ndef sortedDictValues2(adict):\n keys = adict.keys()\n keys.sort()\n return [adict[key] for key in keys]\n\n# a further slight speed-up on my box\n# is to map a bound-method:\ndef sortedDictValues3(adict):\n keys = adict.keys()\n keys.sort()\n return map(adict.get, keys)\n\nimport time\n\ndef sort_compare(a,n):\n print 'Dict sort of %d items for %d iterations:'%(len(a),n)\n t1 = time.time()\n for i in range(n):\n b=sortedDictValues3(a)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)\n print b[:5]\n \n b=c_sort(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort(a)\n t2 = time.time()\n print ' speed in c:',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\n b=c_sort2(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort2(a)\n t2 = time.time()\n print ' speed in c (scxx):',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\ndef setup_dict(m):\n \" does insertion order matter?\"\n import whrandom\n a = range(m)\n d = {}\n for i in range(m):\n key = whrandom.choice(a)\n a.remove(key)\n d[key]=key\n return d \nif __name__ == \"__main__\":\n m = 1000\n a = setup_dict(m)\n n = 300\n sort_compare(a,n) \n", "source_code_before": "# Borrowed from Alex Martelli's sort from Python cookbook using inlines\n# 2x over fastest Python version -- again, maybe not worth the effort...\n# Then again, 2x is 2x...\n#\n# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python dict_sort.py\n# Dict sort of 1000 items for 300 iterations:\n# speed in python: 0.250999927521\n# [0, 1, 2, 3, 4]\n# speed in c: 0.110000014305\n# speed up: 2.28\n# [0, 1, 2, 3, 4]\n# speed in c (scxx): 0.200000047684\n# speed up: 1.25\n# [0, 1, 2, 3, 4] \n\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\n\ndef c_sort(adict):\n assert(type(adict) == type({}))\n code = \"\"\"\n #line 21 \"dict_sort.py\" \n PWOList keys = adict.keys();\n PyObject* py_keys = (PyObject*)keys;\n PWOList items(keys.len());\n PyObject* py_items = (PyObject*)items;\n keys.sort(); // surely this isn't any slower than raw API calls\n PyObject* item = NULL;\n for(int i = 0; i < keys.len();i++)\n {\n item = PyList_GET_ITEM(py_keys,i);\n item = PyDict_GetItem(py_adict,item);\n Py_XINCREF(item);\n PyList_SetItem(py_items,i,item); \n } \n return_val = items.disOwn();\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n\ndef c_sort2(adict):\n assert(type(adict) == type({}))\n code = \"\"\"\n #line 21 \"dict_sort.py\" \n PWOList keys = adict.keys();\n PWOList items(keys.len());\n keys.sort(); // surely this isn't any slower than raw API calls\n PyObject* item = NULL;\n for(int i = 0; i < keys.len();i++)\n items[i] = adict[keys[i]];\n return_val = items.disOwn();\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n\n# (IMHO) the simplest approach:\ndef sortedDictValues1(adict):\n items = adict.items()\n items.sort()\n return [value for key, value in items]\n\n# an alternative implementation, which\n# happens to run a bit faster for large\n# dictionaries on my machine:\ndef sortedDictValues2(adict):\n keys = adict.keys()\n keys.sort()\n return [adict[key] for key in keys]\n\n# a further slight speed-up on my box\n# is to map a bound-method:\ndef sortedDictValues3(adict):\n keys = adict.keys()\n keys.sort()\n return map(adict.get, keys)\n\nimport time\n\ndef sort_compare(a,n):\n print 'Dict sort of %d items for %d iterations:'%(len(a),n)\n t1 = time.time()\n for i in range(n):\n b=sortedDictValues3(a)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)\n print b[:5]\n \n b=c_sort(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort(a)\n t2 = time.time()\n print ' speed in c:',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\n b=c_sort2(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort2(a)\n t2 = time.time()\n print ' speed in c (scxx):',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\ndef setup_dict(m):\n \" does insertion order matter?\"\n import whrandom\n a = range(m)\n d = {}\n for i in range(m):\n key = whrandom.choice(a)\n a.remove(key)\n d[key]=key\n return d \nif __name__ == \"__main__\":\n m = 1000\n a = setup_dict(m)\n n = 300\n sort_compare(a,n) \n", "methods": [ { "name": "c_sort", "long_name": "c_sort( adict )", "filename": "dict_sort.py", "nloc": 21, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 20, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "c_sort2", "long_name": "c_sort2( adict )", "filename": "dict_sort.py", "nloc": 14, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 42, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "sortedDictValues1", "long_name": "sortedDictValues1( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 27, "parameters": [ "adict" ], "start_line": 58, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues2", "long_name": "sortedDictValues2( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "adict" ], "start_line": 66, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues3", "long_name": "sortedDictValues3( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "adict" ], "start_line": 73, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sort_compare", "long_name": "sort_compare( a , n )", "filename": "dict_sort.py", "nloc": 25, "complexity": 4, "token_count": 187, "parameters": [ "a", "n" ], "start_line": 80, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "setup_dict", "long_name": "setup_dict( m )", "filename": "dict_sort.py", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "m" ], "start_line": 108, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "methods_before": [ { "name": "c_sort", "long_name": "c_sort( adict )", "filename": "dict_sort.py", "nloc": 20, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 20, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "c_sort2", "long_name": "c_sort2( adict )", "filename": "dict_sort.py", "nloc": 13, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 41, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "sortedDictValues1", "long_name": "sortedDictValues1( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 27, "parameters": [ "adict" ], "start_line": 56, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues2", "long_name": "sortedDictValues2( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "adict" ], "start_line": 64, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues3", "long_name": "sortedDictValues3( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "adict" ], "start_line": 71, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sort_compare", "long_name": "sort_compare( a , n )", "filename": "dict_sort.py", "nloc": 25, "complexity": 4, "token_count": 187, "parameters": [ "a", "n" ], "start_line": 78, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "setup_dict", "long_name": "setup_dict( m )", "filename": "dict_sort.py", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "m" ], "start_line": 106, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "c_sort", "long_name": "c_sort( adict )", "filename": "dict_sort.py", "nloc": 21, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 20, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "c_sort2", "long_name": "c_sort2( adict )", "filename": "dict_sort.py", "nloc": 14, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 42, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 } ], "nloc": 91, "complexity": 13, "token_count": 434, "diff_parsed": { "added": [ " py::list keys = adict.keys();", " py::list items(keys.len());", " int N = keys.len();", " for(int i = 0; i < N;i++)", " return_val = items;", " int N = keys.length();", " for(int i = 0; i < N;i++)", " return_val = items;" ], "deleted": [ " PWOList keys = adict.keys();", " PWOList items(keys.len());", " for(int i = 0; i < keys.len();i++)", " return_val = items.disOwn();", " for(int i = 0; i < keys.len();i++)", " return_val = items.disOwn();" ] } }, { "old_path": "weave/examples/functional.py", "new_path": "weave/examples/functional.py", "filename": "functional.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -19,14 +19,15 @@ def c_list_map(func,seq):\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n #line 12 \"functional.py\"\n- PWOTuple args(1); \n- PWOList result(seq.len());\n- for(int i = 0; i < seq.len();i++)\n+ py::tuple = args(1);\n+ int N = seq.len(); \n+ py::list result(N);\n+ for(int i = 0; i < N;i++)\n {\n- args.setItem(0,seq[i]);\n+ args[0] = seq[i];\n result[i] = func.call(args);\n } \n- return_val = result.disOwn();\n+ return_val = result;\n \"\"\" \n return inline_tools.inline(code,['func','seq'])\n \n@@ -37,13 +38,14 @@ def c_list_map2(func,seq):\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n #line 32 \"functional.py\"\n- PWOTuple args(1); \n+ py::tuple args(1); \n PyObject* py_args = (PyObject*)args;\n- PWOList result(seq.len());\n+ py::list result(seq.len());\n PyObject* py_result = (PyObject*)result;\n PyObject* item = NULL;\n PyObject* this_result = NULL;\n- for(int i = 0; i < seq.len();i++)\n+ int N = seq.len();\n+ for(int i = 0; i < N;i++)\n {\n item = PyList_GET_ITEM(py_seq,i);\n Py_INCREF(item);\n@@ -51,7 +53,7 @@ def c_list_map2(func,seq):\n this_result = PyEval_CallObject(py_func,py_args);\n PyList_SetItem(py_result,i,this_result); \n } \n- return_val = result.disOwn();\n+ return_val = result;\n \"\"\" \n return inline_tools.inline(code,['func','seq'])\n \n", "added_lines": 11, "deleted_lines": 9, "source_code": "# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python functional.py\n# desired: [2, 3, 4]\n# actual: [2, 3, 4]\n# actual2: [2, 3, 4]\n# python speed: 0.039999961853\n# SCXX speed: 0.0599999427795\n# speed up: 0.666666666667\n# c speed: 0.0200001001358\n# speed up: 1.99998807913\n\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\nfrom types import *\ndef c_list_map(func,seq):\n \"\"\" Uses CXX C code to implement a simple map-like function.\n It does not provide any error checking.\n \"\"\"\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n #line 12 \"functional.py\"\n py::tuple = args(1);\n int N = seq.len(); \n py::list result(N);\n for(int i = 0; i < N;i++)\n {\n args[0] = seq[i];\n result[i] = func.call(args);\n } \n return_val = result;\n \"\"\" \n return inline_tools.inline(code,['func','seq'])\n\ndef c_list_map2(func,seq):\n \"\"\" Uses Python API more than CXX to implement a simple map-like function.\n It does not provide any error checking.\n \"\"\"\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n #line 32 \"functional.py\"\n py::tuple args(1); \n PyObject* py_args = (PyObject*)args;\n py::list result(seq.len());\n PyObject* py_result = (PyObject*)result;\n PyObject* item = NULL;\n PyObject* this_result = NULL;\n int N = seq.len();\n for(int i = 0; i < N;i++)\n {\n item = PyList_GET_ITEM(py_seq,i);\n Py_INCREF(item);\n PyTuple_SetItem(py_args,0,item);\n this_result = PyEval_CallObject(py_func,py_args);\n PyList_SetItem(py_result,i,this_result); \n } \n return_val = result;\n \"\"\" \n return inline_tools.inline(code,['func','seq'])\n \ndef main():\n seq = ['aa','bbb','cccc']\n print 'desired:', map(len,seq)\n print 'actual:', c_list_map(len,seq)\n print 'actual2:', c_list_map2(len,seq)\n\ndef time_it(m,n):\n import time\n seq = ['aadasdf'] * n\n t1 = time.time()\n for i in range(m):\n result = map(len,seq)\n t2 = time.time()\n py = t2 - t1\n print 'python speed:', py\n \n #load cache\n result = c_list_map(len,seq)\n t1 = time.time()\n for i in range(m):\n result = c_list_map(len,seq)\n t2 = time.time()\n c = t2-t1\n print 'SCXX speed:', c\n print 'speed up:', py / c\n\n #load cache\n result = c_list_map2(len,seq)\n t1 = time.time()\n for i in range(m):\n result = c_list_map2(len,seq)\n t2 = time.time()\n c = t2-t1\n print 'c speed:', c\n print 'speed up:', py / c\n\nif __name__ == \"__main__\":\n main()\n time_it(100,1000)", "source_code_before": "# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python functional.py\n# desired: [2, 3, 4]\n# actual: [2, 3, 4]\n# actual2: [2, 3, 4]\n# python speed: 0.039999961853\n# SCXX speed: 0.0599999427795\n# speed up: 0.666666666667\n# c speed: 0.0200001001358\n# speed up: 1.99998807913\n\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\nfrom types import *\ndef c_list_map(func,seq):\n \"\"\" Uses CXX C code to implement a simple map-like function.\n It does not provide any error checking.\n \"\"\"\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n #line 12 \"functional.py\"\n PWOTuple args(1); \n PWOList result(seq.len());\n for(int i = 0; i < seq.len();i++)\n {\n args.setItem(0,seq[i]);\n result[i] = func.call(args);\n } \n return_val = result.disOwn();\n \"\"\" \n return inline_tools.inline(code,['func','seq'])\n\ndef c_list_map2(func,seq):\n \"\"\" Uses Python API more than CXX to implement a simple map-like function.\n It does not provide any error checking.\n \"\"\"\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n #line 32 \"functional.py\"\n PWOTuple args(1); \n PyObject* py_args = (PyObject*)args;\n PWOList result(seq.len());\n PyObject* py_result = (PyObject*)result;\n PyObject* item = NULL;\n PyObject* this_result = NULL;\n for(int i = 0; i < seq.len();i++)\n {\n item = PyList_GET_ITEM(py_seq,i);\n Py_INCREF(item);\n PyTuple_SetItem(py_args,0,item);\n this_result = PyEval_CallObject(py_func,py_args);\n PyList_SetItem(py_result,i,this_result); \n } \n return_val = result.disOwn();\n \"\"\" \n return inline_tools.inline(code,['func','seq'])\n \ndef main():\n seq = ['aa','bbb','cccc']\n print 'desired:', map(len,seq)\n print 'actual:', c_list_map(len,seq)\n print 'actual2:', c_list_map2(len,seq)\n\ndef time_it(m,n):\n import time\n seq = ['aadasdf'] * n\n t1 = time.time()\n for i in range(m):\n result = map(len,seq)\n t2 = time.time()\n py = t2 - t1\n print 'python speed:', py\n \n #load cache\n result = c_list_map(len,seq)\n t1 = time.time()\n for i in range(m):\n result = c_list_map(len,seq)\n t2 = time.time()\n c = t2-t1\n print 'SCXX speed:', c\n print 'speed up:', py / c\n\n #load cache\n result = c_list_map2(len,seq)\n t1 = time.time()\n for i in range(m):\n result = c_list_map2(len,seq)\n t2 = time.time()\n c = t2-t1\n print 'c speed:', c\n print 'speed up:', py / c\n\nif __name__ == \"__main__\":\n main()\n time_it(100,1000)", "methods": [ { "name": "c_list_map", "long_name": "c_list_map( func , seq )", "filename": "functional.py", "nloc": 15, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 15, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "c_list_map2", "long_name": "c_list_map2( func , seq )", "filename": "functional.py", "nloc": 22, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 34, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "main", "long_name": "main( )", "filename": "functional.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [], "start_line": 60, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "time_it", "long_name": "time_it( m , n )", "filename": "functional.py", "nloc": 25, "complexity": 4, "token_count": 161, "parameters": [ "m", "n" ], "start_line": 66, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 } ], "methods_before": [ { "name": "c_list_map", "long_name": "c_list_map( func , seq )", "filename": "functional.py", "nloc": 14, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 15, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "c_list_map2", "long_name": "c_list_map2( func , seq )", "filename": "functional.py", "nloc": 21, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 33, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "main", "long_name": "main( )", "filename": "functional.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [], "start_line": 58, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "time_it", "long_name": "time_it( m , n )", "filename": "functional.py", "nloc": 25, "complexity": 4, "token_count": 161, "parameters": [ "m", "n" ], "start_line": 64, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "c_list_map", "long_name": "c_list_map( func , seq )", "filename": "functional.py", "nloc": 15, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 15, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "c_list_map2", "long_name": "c_list_map2( func , seq )", "filename": "functional.py", "nloc": 22, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 34, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "nloc": 74, "complexity": 7, "token_count": 321, "diff_parsed": { "added": [ " py::tuple = args(1);", " int N = seq.len();", " py::list result(N);", " for(int i = 0; i < N;i++)", " args[0] = seq[i];", " return_val = result;", " py::tuple args(1);", " py::list result(seq.len());", " int N = seq.len();", " for(int i = 0; i < N;i++)", " return_val = result;" ], "deleted": [ " PWOTuple args(1);", " PWOList result(seq.len());", " for(int i = 0; i < seq.len();i++)", " args.setItem(0,seq[i]);", " return_val = result.disOwn();", " PWOTuple args(1);", " PWOList result(seq.len());", " for(int i = 0; i < seq.len();i++)", " return_val = result.disOwn();" ] } }, { "old_path": "weave/examples/ramp.py", "new_path": "weave/examples/ramp.py", "filename": "ramp.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -52,7 +52,7 @@ def Ramp_list1(result, start, end):\n const int size = result.len();\n const double step = (end-start)/(size-1);\n for (int i = 0; i < size; i++) \n- result[i] = PWONumber(start + step*i);\n+ result[i] = start + step*i;\n \"\"\"\n weave.inline(code, [\"result\",\"start\", \"end\"], verbose=2)\n \n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Comparison of several different ways of calculating a \"ramp\"\n function.\n \n C:\\home\\ej\\wrk\\junk\\scipy\\weave\\examples>python ramp.py \n python (seconds*ratio): 128.149998188\n arr[500]: 0.0500050005001\n compiled numeric1 (seconds, speed up): 1.42199993134 90.1195530071\n arr[500]: 0.0500050005001\n compiled numeric2 (seconds, speed up): 0.950999975204 134.752893301\n arr[500]: 0.0500050005001\n compiled list1 (seconds, speed up): 53.100001812 2.41337088164\n arr[500]: 0.0500050005001\n compiled list4 (seconds, speed up): 30.5500030518 4.19476220578\n arr[500]: 0.0500050005001 \n\n\"\"\"\n\nimport time\nimport weave\nfrom Numeric import *\n\ndef Ramp(result, size, start, end):\n step = (end-start)/(size-1)\n for i in xrange(size):\n result[i] = start + step*i\n\ndef Ramp_numeric1(result,start,end):\n code = \"\"\"\n const int size = Nresult[0];\n const double step = (end-start)/(size-1);\n double val = start;\n for (int i = 0; i < size; i++)\n *result++ = start + step*i;\n \"\"\"\n weave.inline(code,['result','start','end'],compiler='gcc')\n\ndef Ramp_numeric2(result,start,end):\n code = \"\"\"\n const int size = Nresult[0];\n double step = (end-start)/(size-1);\n double val = start;\n for (int i = 0; i < size; i++)\n {\n result[i] = val;\n val += step; \n }\n \"\"\"\n weave.inline(code,['result','start','end'],compiler='gcc')\n\ndef Ramp_list1(result, start, end):\n code = \"\"\"\n const int size = result.len();\n const double step = (end-start)/(size-1);\n for (int i = 0; i < size; i++) \n result[i] = start + step*i;\n \"\"\"\n weave.inline(code, [\"result\",\"start\", \"end\"], verbose=2)\n\ndef Ramp_list2(result, start, end):\n code = \"\"\"\n const int size = result.len();\n const double step = (end-start)/(size-1);\n for (int i = 0; i < size; i++) \n {\n PyObject* val = PyFloat_FromDouble( start + step*i );\n PySequence_SetItem(py_result,i, val);\n }\n \"\"\"\n weave.inline(code, [\"result\", \"start\", \"end\"], verbose=2)\n \ndef main():\n N_array = 10000\n N_py = 200\n N_c = 10000\n \n ratio = float(N_c) / N_py \n \n arr = [0]*N_array\n t1 = time.time()\n for i in xrange(N_py):\n Ramp(arr, N_array, 0.0, 1.0)\n t2 = time.time()\n py_time = (t2 - t1) * ratio\n print 'python (seconds*ratio):', py_time\n print 'arr[500]:', arr[500]\n \n arr1 = array([0]*N_array,Float64)\n # First call compiles function or loads from cache.\n # I'm not including this in the timing.\n Ramp_numeric1(arr1, 0.0, 1.0)\n t1 = time.time()\n for i in xrange(N_c):\n Ramp_numeric1(arr1, 0.0, 1.0)\n t2 = time.time()\n c_time = (t2 - t1)\n print 'compiled numeric1 (seconds, speed up):', c_time, py_time/ c_time\n print 'arr[500]:', arr1[500]\n\n arr2 = array([0]*N_array,Float64)\n # First call compiles function or loads from cache.\n # I'm not including this in the timing.\n Ramp_numeric2(arr2, 0.0, 1.0)\n t1 = time.time()\n for i in xrange(N_c):\n Ramp_numeric2(arr2, 0.0, 1.0)\n t2 = time.time()\n c_time = (t2 - t1) \n print 'compiled numeric2 (seconds, speed up):', c_time, py_time/ c_time\n print 'arr[500]:', arr2[500]\n\n arr3 = [0]*N_array\n # First call compiles function or loads from cache.\n # I'm not including this in the timing.\n Ramp_list1(arr3, 0.0, 1.0)\n t1 = time.time()\n for i in xrange(N_py):\n Ramp_list1(arr3, 0.0, 1.0)\n t2 = time.time()\n c_time = (t2 - t1) * ratio \n print 'compiled list1 (seconds, speed up):', c_time, py_time/ c_time\n print 'arr[500]:', arr3[500]\n \n arr4 = [0]*N_array\n # First call compiles function or loads from cache.\n # I'm not including this in the timing.\n Ramp_list2(arr4, 0.0, 1.0)\n t1 = time.time()\n for i in xrange(N_py):\n Ramp_list2(arr4, 0.0, 1.0)\n t2 = time.time()\n c_time = (t2 - t1) * ratio \n print 'compiled list4 (seconds, speed up):', c_time, py_time/ c_time\n print 'arr[500]:', arr4[500]\n \n \nif __name__ == '__main__':\n main()", "source_code_before": "\"\"\" Comparison of several different ways of calculating a \"ramp\"\n function.\n \n C:\\home\\ej\\wrk\\junk\\scipy\\weave\\examples>python ramp.py \n python (seconds*ratio): 128.149998188\n arr[500]: 0.0500050005001\n compiled numeric1 (seconds, speed up): 1.42199993134 90.1195530071\n arr[500]: 0.0500050005001\n compiled numeric2 (seconds, speed up): 0.950999975204 134.752893301\n arr[500]: 0.0500050005001\n compiled list1 (seconds, speed up): 53.100001812 2.41337088164\n arr[500]: 0.0500050005001\n compiled list4 (seconds, speed up): 30.5500030518 4.19476220578\n arr[500]: 0.0500050005001 \n\n\"\"\"\n\nimport time\nimport weave\nfrom Numeric import *\n\ndef Ramp(result, size, start, end):\n step = (end-start)/(size-1)\n for i in xrange(size):\n result[i] = start + step*i\n\ndef Ramp_numeric1(result,start,end):\n code = \"\"\"\n const int size = Nresult[0];\n const double step = (end-start)/(size-1);\n double val = start;\n for (int i = 0; i < size; i++)\n *result++ = start + step*i;\n \"\"\"\n weave.inline(code,['result','start','end'],compiler='gcc')\n\ndef Ramp_numeric2(result,start,end):\n code = \"\"\"\n const int size = Nresult[0];\n double step = (end-start)/(size-1);\n double val = start;\n for (int i = 0; i < size; i++)\n {\n result[i] = val;\n val += step; \n }\n \"\"\"\n weave.inline(code,['result','start','end'],compiler='gcc')\n\ndef Ramp_list1(result, start, end):\n code = \"\"\"\n const int size = result.len();\n const double step = (end-start)/(size-1);\n for (int i = 0; i < size; i++) \n result[i] = PWONumber(start + step*i);\n \"\"\"\n weave.inline(code, [\"result\",\"start\", \"end\"], verbose=2)\n\ndef Ramp_list2(result, start, end):\n code = \"\"\"\n const int size = result.len();\n const double step = (end-start)/(size-1);\n for (int i = 0; i < size; i++) \n {\n PyObject* val = PyFloat_FromDouble( start + step*i );\n PySequence_SetItem(py_result,i, val);\n }\n \"\"\"\n weave.inline(code, [\"result\", \"start\", \"end\"], verbose=2)\n \ndef main():\n N_array = 10000\n N_py = 200\n N_c = 10000\n \n ratio = float(N_c) / N_py \n \n arr = [0]*N_array\n t1 = time.time()\n for i in xrange(N_py):\n Ramp(arr, N_array, 0.0, 1.0)\n t2 = time.time()\n py_time = (t2 - t1) * ratio\n print 'python (seconds*ratio):', py_time\n print 'arr[500]:', arr[500]\n \n arr1 = array([0]*N_array,Float64)\n # First call compiles function or loads from cache.\n # I'm not including this in the timing.\n Ramp_numeric1(arr1, 0.0, 1.0)\n t1 = time.time()\n for i in xrange(N_c):\n Ramp_numeric1(arr1, 0.0, 1.0)\n t2 = time.time()\n c_time = (t2 - t1)\n print 'compiled numeric1 (seconds, speed up):', c_time, py_time/ c_time\n print 'arr[500]:', arr1[500]\n\n arr2 = array([0]*N_array,Float64)\n # First call compiles function or loads from cache.\n # I'm not including this in the timing.\n Ramp_numeric2(arr2, 0.0, 1.0)\n t1 = time.time()\n for i in xrange(N_c):\n Ramp_numeric2(arr2, 0.0, 1.0)\n t2 = time.time()\n c_time = (t2 - t1) \n print 'compiled numeric2 (seconds, speed up):', c_time, py_time/ c_time\n print 'arr[500]:', arr2[500]\n\n arr3 = [0]*N_array\n # First call compiles function or loads from cache.\n # I'm not including this in the timing.\n Ramp_list1(arr3, 0.0, 1.0)\n t1 = time.time()\n for i in xrange(N_py):\n Ramp_list1(arr3, 0.0, 1.0)\n t2 = time.time()\n c_time = (t2 - t1) * ratio \n print 'compiled list1 (seconds, speed up):', c_time, py_time/ c_time\n print 'arr[500]:', arr3[500]\n \n arr4 = [0]*N_array\n # First call compiles function or loads from cache.\n # I'm not including this in the timing.\n Ramp_list2(arr4, 0.0, 1.0)\n t1 = time.time()\n for i in xrange(N_py):\n Ramp_list2(arr4, 0.0, 1.0)\n t2 = time.time()\n c_time = (t2 - t1) * ratio \n print 'compiled list4 (seconds, speed up):', c_time, py_time/ c_time\n print 'arr[500]:', arr4[500]\n \n \nif __name__ == '__main__':\n main()", "methods": [ { "name": "Ramp", "long_name": "Ramp( result , size , start , end )", "filename": "ramp.py", "nloc": 4, "complexity": 2, "token_count": 42, "parameters": [ "result", "size", "start", "end" ], "start_line": 22, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "Ramp_numeric1", "long_name": "Ramp_numeric1( result , start , end )", "filename": "ramp.py", "nloc": 9, "complexity": 1, "token_count": 30, "parameters": [ "result", "start", "end" ], "start_line": 27, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "Ramp_numeric2", "long_name": "Ramp_numeric2( result , start , end )", "filename": "ramp.py", "nloc": 12, "complexity": 1, "token_count": 30, "parameters": [ "result", "start", "end" ], "start_line": 37, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "Ramp_list1", "long_name": "Ramp_list1( result , start , end )", "filename": "ramp.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "result", "start", "end" ], "start_line": 50, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "Ramp_list2", "long_name": "Ramp_list2( result , start , end )", "filename": "ramp.py", "nloc": 11, "complexity": 1, "token_count": 30, "parameters": [ "result", "start", "end" ], "start_line": 59, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "main", "long_name": "main( )", "filename": "ramp.py", "nloc": 49, "complexity": 6, "token_count": 398, "parameters": [], "start_line": 71, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 } ], "methods_before": [ { "name": "Ramp", "long_name": "Ramp( result , size , start , end )", "filename": "ramp.py", "nloc": 4, "complexity": 2, "token_count": 42, "parameters": [ "result", "size", "start", "end" ], "start_line": 22, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "Ramp_numeric1", "long_name": "Ramp_numeric1( result , start , end )", "filename": "ramp.py", "nloc": 9, "complexity": 1, "token_count": 30, "parameters": [ "result", "start", "end" ], "start_line": 27, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "Ramp_numeric2", "long_name": "Ramp_numeric2( result , start , end )", "filename": "ramp.py", "nloc": 12, "complexity": 1, "token_count": 30, "parameters": [ "result", "start", "end" ], "start_line": 37, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "Ramp_list1", "long_name": "Ramp_list1( result , start , end )", "filename": "ramp.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "result", "start", "end" ], "start_line": 50, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "Ramp_list2", "long_name": "Ramp_list2( result , start , end )", "filename": "ramp.py", "nloc": 11, "complexity": 1, "token_count": 30, "parameters": [ "result", "start", "end" ], "start_line": 59, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "main", "long_name": "main( )", "filename": "ramp.py", "nloc": 49, "complexity": 6, "token_count": 398, "parameters": [], "start_line": 71, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "Ramp_list1", "long_name": "Ramp_list1( result , start , end )", "filename": "ramp.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "result", "start", "end" ], "start_line": 50, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "nloc": 114, "complexity": 12, "token_count": 583, "diff_parsed": { "added": [ " result[i] = start + step*i;" ], "deleted": [ " result[i] = PWONumber(start + step*i);" ] } }, { "old_path": "weave/examples/tuple_return.py", "new_path": "weave/examples/tuple_return.py", "filename": "tuple_return.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,10 +8,10 @@ def multi_return():\n def c_multi_return():\n \n code = \"\"\"\n- \t PWOTuple results(2);\n- \t results.setItem(0, PWONumber(1));\n- \t results.setItem(1, PWOString(\"2nd\"));\n- \t return_val = results.disOwn(); \t \n+ \t py::tuple results(2);\n+ \t results[0] = 1;\n+ \t results[1] = \"2nd\";\n+ \t return_val = results; \t \n \"\"\"\n return inline_tools.inline(code,[])\n \n", "added_lines": 4, "deleted_lines": 4, "source_code": "import sys\nsys.path.insert(0,'..')\nimport inline_tools\n\ndef multi_return():\n return 1, '2nd'\n\ndef c_multi_return():\n\n code = \"\"\"\n \t py::tuple results(2);\n \t results[0] = 1;\n \t results[1] = \"2nd\";\n \t return_val = results; \t \n \"\"\"\n return inline_tools.inline(code,[])\n\n\ndef compare(m):\n import time\n t1 = time.time()\n for i in range(m):\n py_result = multi_return()\n t2 = time.time()\n py = t2 - t1\n print 'python speed:', py\n \n #load cache\n result = c_multi_return()\n t1 = time.time()\n for i in range(m):\n c_result = c_multi_return()\n t2 = time.time()\n c = t2-t1\n print 'c speed:', c\n print 'speed up:', py / c\n print 'or slow down (more likely:', c / py\n print 'python result:', py_result\n print 'c result:', c_result\n \nif __name__ == \"__main__\":\n compare(10000)", "source_code_before": "import sys\nsys.path.insert(0,'..')\nimport inline_tools\n\ndef multi_return():\n return 1, '2nd'\n\ndef c_multi_return():\n\n code = \"\"\"\n \t PWOTuple results(2);\n \t results.setItem(0, PWONumber(1));\n \t results.setItem(1, PWOString(\"2nd\"));\n \t return_val = results.disOwn(); \t \n \"\"\"\n return inline_tools.inline(code,[])\n\n\ndef compare(m):\n import time\n t1 = time.time()\n for i in range(m):\n py_result = multi_return()\n t2 = time.time()\n py = t2 - t1\n print 'python speed:', py\n \n #load cache\n result = c_multi_return()\n t1 = time.time()\n for i in range(m):\n c_result = c_multi_return()\n t2 = time.time()\n c = t2-t1\n print 'c speed:', c\n print 'speed up:', py / c\n print 'or slow down (more likely:', c / py\n print 'python result:', py_result\n print 'c result:', c_result\n \nif __name__ == \"__main__\":\n compare(10000)", "methods": [ { "name": "multi_return", "long_name": "multi_return( )", "filename": "tuple_return.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 5, "end_line": 6, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "c_multi_return", "long_name": "c_multi_return( )", "filename": "tuple_return.py", "nloc": 8, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 8, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "compare", "long_name": "compare( m )", "filename": "tuple_return.py", "nloc": 19, "complexity": 3, "token_count": 104, "parameters": [ "m" ], "start_line": 19, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 } ], "methods_before": [ { "name": "multi_return", "long_name": "multi_return( )", "filename": "tuple_return.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 5, "end_line": 6, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "c_multi_return", "long_name": "c_multi_return( )", "filename": "tuple_return.py", "nloc": 8, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 8, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "compare", "long_name": "compare( m )", "filename": "tuple_return.py", "nloc": 19, "complexity": 3, "token_count": 104, "parameters": [ "m" ], "start_line": 19, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "c_multi_return", "long_name": "c_multi_return( )", "filename": "tuple_return.py", "nloc": 8, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 8, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "nloc": 34, "complexity": 5, "token_count": 155, "diff_parsed": { "added": [ " \t py::tuple results(2);", " \t results[0] = 1;", " \t results[1] = \"2nd\";", " \t return_val = results;" ], "deleted": [ " \t PWOTuple results(2);", " \t results.setItem(0, PWONumber(1));", " \t results.setItem(1, PWOString(\"2nd\"));", " \t return_val = results.disOwn();" ] } }, { "old_path": "weave/ext_tools.py", "new_path": "weave/ext_tools.py", "filename": "ext_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -41,7 +41,7 @@ def parse_tuple_code(self):\n \"\"\"\n join = string.join\n \n- declare_return = 'PyObject *return_val = NULL;\\n' \\\n+ declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n@@ -128,18 +128,17 @@ def function_code(self):\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n- \" return_val = NULL; \\n\" \\\n+ \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n \n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n- ' if(!return_val && !exception_occured)\\n' \\\n+ ' if(!(PyObject*)return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n- ' Py_INCREF(Py_None); \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n- ' return return_val; \\n' \\\n+ ' return return_val.disown(); \\n' \\\n '} \\n'\n \n all_code = self.function_declaration_code() + \\\n", "added_lines": 4, "deleted_lines": 5, "source_code": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!(PyObject*)return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val.disown(); \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = [self.customize] + self._build_information + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n \n file = self.generate_file(location=location)\n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n sources = source_files, \n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "source_code_before": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'PyObject *return_val = NULL;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = NULL; \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' Py_INCREF(Py_None); \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val; \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = [self.customize] + self._build_information + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n \n file = self.generate_file(location=location)\n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n sources = source_files, \n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 36, "complexity": 1, "token_count": 160, "parameters": [ "self" ], "start_line": 110, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 152, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 165, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 183, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 193, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 202, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 227, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 232, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 237, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 259, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 277, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 22, "complexity": 4, "token_count": 206, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 287, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 331, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "module_string", "module_file" ], "start_line": 335, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 341, "end_line": 376, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 378, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 407, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 414, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 421, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 425, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 37, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 110, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 153, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 166, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 184, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 192, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 194, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 203, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 209, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 219, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 228, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 233, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 238, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 242, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 248, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 260, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 270, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 278, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 22, "complexity": 4, "token_count": 206, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 288, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 332, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "module_string", "module_file" ], "start_line": 336, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 342, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 379, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 408, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 415, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 422, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 426, "end_line": 428, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 36, "complexity": 1, "token_count": 160, "parameters": [ "self" ], "start_line": 110, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 } ], "nloc": 315, "complexity": 75, "token_count": 2016, "diff_parsed": { "added": [ " declare_return = 'py::object return_val;\\n' \\", " \" return_val = py::object(); \\n\" \\", " ' if(!(PyObject*)return_val && !exception_occured)\\n' \\", " ' return return_val.disown(); \\n' \\" ], "deleted": [ " declare_return = 'PyObject *return_val = NULL;\\n' \\", " \" return_val = NULL; \\n\" \\", " ' if(!return_val && !exception_occured)\\n' \\", " ' Py_INCREF(Py_None); \\n' \\", " ' return return_val; \\n' \\" ] } }, { "old_path": "weave/inline_tools.py", "new_path": "weave/inline_tools.py", "filename": "inline_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -29,7 +29,7 @@ def parse_tuple_code(self):\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n- declare_return = 'PyObject *return_val = NULL;\\n' \\\n+ declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py__locals = NULL;\\n' \\\n 'PyObject *py__globals = NULL;\\n'\n@@ -96,19 +96,18 @@ def function_code(self):\n ' /*I would like to fill in changed ' \\\n 'locals and globals here...*/ \\n' \\\n '\\n} \\n'\n- catch_code = \"catch(...) \\n\" \\\n- \"{ \\n\" + \\\n- \" return_val = NULL; \\n\" \\\n- \" exception_occured = 1; \\n\" \\\n- \"} \\n\" \n+ catch_code = \"catch(...) \\n\" \\\n+ \"{ \\n\" + \\\n+ \" return_val = py::object(); \\n\" \\\n+ \" exception_occured = 1; \\n\" \\\n+ \"} \\n\" \n return_code = \" /* cleanup code */ \\n\" + \\\n cleanup_code + \\\n- \" if(!return_val && !exception_occured)\\n\" \\\n+ \" if(!(PyObject*)return_val && !exception_occured)\\n\" \\\n \" {\\n \\n\" \\\n- \" Py_INCREF(Py_None); \\n\" \\\n \" return_val = Py_None; \\n\" \\\n \" }\\n \\n\" \\\n- \" return return_val; \\n\" \\\n+ \" return return_val.disown(); \\n\" \\\n \"} \\n\"\n \n all_code = self.function_declaration_code() + \\\n", "added_lines": 8, "deleted_lines": 9, "source_code": "# should re-write compiled functions to take a local and global dict\n# as input.\nimport sys,os\nimport ext_tools\nimport string\nimport catalog\nimport common_info\n\n# not an easy way for the user_path_list to come in here.\n# the PYTHONCOMPILED environment variable offers the most hope.\n\nfunction_catalog = catalog.catalog()\n\n\nclass inline_ext_function(ext_tools.ext_function):\n # Some specialization is needed for inline extension functions\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args)\\n{\\n'\n return code % self.name\n\n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n\n This code got a lot uglier when I added local_dict...\n \"\"\"\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py__locals = NULL;\\n' \\\n 'PyObject *py__globals = NULL;\\n'\n\n py_objects = ', '.join(self.arg_specs.py_pointers())\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n else:\n declare_py_objects = ''\n\n py_vars = ' = '.join(self.arg_specs.py_variables())\n if py_vars:\n init_values = py_vars + ' = NULL;\\n\\n'\n else:\n init_values = ''\n\n parse_tuple = 'if(!PyArg_ParseTuple(args,\"OO:compiled_func\",'\\\n '&py__locals,'\\\n '&py__globals))\\n'\\\n ' return NULL;\\n'\n\n return declare_return + declare_py_objects + \\\n init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code(inline=1))\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.cleanup_code())\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n\n\n def function_code(self):\n from ext_tools import indent\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n #local_dict_code = indent(self.arg_local_dict_code(),4)\n\n try_code = 'try \\n' \\\n '{ \\n' \\\n ' PyObject* raw_locals = py_to_raw_dict(' \\\n 'py__locals,\"_locals\");\\n' \\\n ' PyObject* raw_globals = py_to_raw_dict(' \\\n 'py__globals,\"_globals\");\\n' + \\\n ' /* argument conversion code */ \\n' + \\\n decl_code + \\\n ' /* inline code */ \\n' + \\\n function_code + \\\n ' /*I would like to fill in changed ' \\\n 'locals and globals here...*/ \\n' \\\n '\\n} \\n'\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\" \n return_code = \" /* cleanup code */ \\n\" + \\\n cleanup_code + \\\n \" if(!(PyObject*)return_val && !exception_occured)\\n\" \\\n \" {\\n \\n\" \\\n \" return_val = Py_None; \\n\" \\\n \" }\\n \\n\" \\\n \" return return_val.disown(); \\n\" \\\n \"} \\n\"\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS},\\n' % args\n return function_decls\n\nclass inline_ext_module(ext_tools.ext_module):\n def __init__(self,name,compiler=''):\n ext_tools.ext_module.__init__(self,name,compiler)\n self._build_information.append(common_info.inline_info())\n\nfunction_cache = {}\ndef inline(code,arg_names=[],local_dict = None, global_dict = None,\n force = 0,\n compiler='',\n verbose = 0,\n support_code = None,\n customize=None,\n type_converters = None,\n auto_downcast=1,\n **kw):\n \"\"\" Inline C/C++ code within Python scripts.\n\n inline() compiles and executes C/C++ code on the fly. Variables\n in the local and global Python scope are also available in the\n C/C++ code. Values are passed to the C/C++ code by assignment\n much like variables passed are passed into a standard Python\n function. Values are returned from the C/C++ code through a\n special argument called return_val. Also, the contents of\n mutable objects can be changed within the C/C++ code and the\n changes remain after the C code exits and returns to Python.\n\n inline has quite a few options as listed below. Also, the keyword\n arguments for distutils extension modules are accepted to\n specify extra information needed for compiling.\n\n code -- string. A string of valid C++ code. It should not specify a\n return statement. Instead it should assign results that\n need to be returned to Python in the return_val.\n arg_names -- optional. list of strings. A list of Python variable names \n that should be transferred from Python into the C/C++ \n code. It defaults to an empty string.\n local_dict -- optional. dictionary. If specified, it is a dictionary\n of values that should be used as the local scope for the\n C/C++ code. If local_dict is not specified the local\n dictionary of the calling function is used.\n global_dict -- optional. dictionary. If specified, it is a dictionary\n of values that should be used as the global scope for\n the C/C++ code. If global_dict is not specified the\n global dictionary of the calling function is used.\n force -- optional. 0 or 1. default 0. If 1, the C++ code is\n compiled every time inline is called. This is really\n only useful for debugging, and probably only useful if\n your editing support_code a lot.\n compiler -- optional. string. The name of compiler to use when\n compiling. On windows, it understands 'msvc' and 'gcc'\n as well as all the compiler names understood by\n distutils. On Unix, it'll only understand the values\n understoof by distutils. ( I should add 'gcc' though\n to this).\n\n On windows, the compiler defaults to the Microsoft C++\n compiler. If this isn't available, it looks for mingw32\n (the gcc compiler).\n\n On Unix, it'll probably use the same compiler that was\n used when compiling Python. Cygwin's behavior should be\n similar.\n verbose -- optional. 0,1, or 2. defualt 0. Speficies how much\n much information is printed during the compile phase\n of inlining code. 0 is silent (except on windows with\n msvc where it still prints some garbage). 1 informs\n you when compiling starts, finishes, and how long it\n took. 2 prints out the command lines for the compilation\n process and can be useful if your having problems\n getting code to work. Its handy for finding the name\n of the .cpp file if you need to examine it. verbose has\n no affect if the compilation isn't necessary.\n support_code -- optional. string. A string of valid C++ code declaring\n extra code that might be needed by your compiled\n function. This could be declarations of functions,\n classes, or structures.\n customize -- optional. base_info.custom_info object. An alternative\n way to specifiy support_code, headers, etc. needed by\n the function see the compiler.base_info module for more\n details. (not sure this'll be used much).\n type_converters -- optional. list of type converters. These\n guys are what convert Python data types to C/C++ data\n types. If you'd like to use a different set of type\n conversions than the default, specify them here. Look\n in the type conversions section of the main\n documentation for examples.\n auto_downcast -- optional. 0 or 1. default 1. This only affects\n functions that have Numeric arrays as input variables.\n Setting this to 1 will cause all floating point values\n to be cast as float instead of double if all the\n Numeric arrays are of type float. If even one of the\n arrays has type double or double complex, all\n variables maintain there standard types.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n\n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list\n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability)\n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line)\n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n # this grabs the local variables from the *previous* call\n # frame -- that is the locals from the function that called\n # inline.\n global function_catalog\n\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if force:\n module_dir = global_dict.get('__file__',None)\n func = compile_function(code,arg_names,local_dict,\n global_dict,module_dir,\n compiler=compiler,\n verbose=verbose,\n support_code = support_code,\n customize=customize,\n type_converters = type_converters,\n auto_downcast = auto_downcast,\n **kw)\n\n function_catalog.add_function(code,func,module_dir)\n results = attempt_function_call(code,local_dict,global_dict)\n else:\n # 1. try local cache\n try:\n results = apply(function_cache[code],(local_dict,global_dict))\n return results\n except TypeError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise TypeError, msg\n except NameError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise NameError, msg\n except KeyError:\n pass\n # 2. try function catalog\n try:\n results = attempt_function_call(code,local_dict,global_dict)\n # 3. build the function\n except ValueError:\n # compile the library\n module_dir = global_dict.get('__file__',None)\n func = compile_function(code,arg_names,local_dict,\n global_dict,module_dir,\n compiler=compiler,\n verbose=verbose,\n support_code = support_code,\n customize=customize,\n type_converters = type_converters,\n auto_downcast = auto_downcast,\n **kw)\n\n function_catalog.add_function(code,func,module_dir)\n results = attempt_function_call(code,local_dict,global_dict)\n return results\n\ndef attempt_function_call(code,local_dict,global_dict):\n # we try 3 levels here -- a local cache first, then the\n # catalog cache, and then persistent catalog.\n #\n global function_cache\n # 2. try catalog cache.\n function_list = function_catalog.get_functions_fast(code)\n for func in function_list:\n try:\n results = apply(func,(local_dict,global_dict))\n function_catalog.fast_cache(code,func)\n function_cache[code] = func\n return results\n except TypeError, msg: # should specify argument types here.\n # This should really have its own error type, instead of\n # checking the beginning of the message, but I don't know\n # how to define that yet.\n msg = str(msg)\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise TypeError, msg\n except NameError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise NameError, msg \n # 3. try persistent catalog\n module_dir = global_dict.get('__file__',None)\n function_list = function_catalog.get_functions(code,module_dir)\n for func in function_list:\n try:\n results = apply(func,(local_dict,global_dict))\n function_catalog.fast_cache(code,func)\n function_cache[code] = func\n return results\n except: # should specify argument types here.\n pass\n # if we get here, the function wasn't found\n raise ValueError, 'function with correct signature not found'\n\ndef inline_function_code(code,arg_names,local_dict=None,\n global_dict=None,auto_downcast = 1,\n type_converters=None,compiler=''):\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n ext_func = inline_ext_function('compiled_func',code,arg_names,\n local_dict,global_dict,auto_downcast,\n type_converters = type_converters)\n import build_tools\n compiler = build_tools.choose_compiler(compiler)\n ext_func.set_compiler(compiler)\n return ext_func.function_code()\n\ndef compile_function(code,arg_names,local_dict,global_dict,\n module_dir,\n compiler='',\n verbose = 0,\n support_code = None,\n customize = None,\n type_converters = None,\n auto_downcast=1,\n **kw):\n # figure out where to store and what to name the extension module\n # that will contain the function.\n #storage_dir = catalog.intermediate_dir()\n module_path = function_catalog.unique_module_name(code,module_dir)\n storage_dir, module_name = os.path.split(module_path)\n mod = inline_ext_module(module_name,compiler)\n\n # create the function. This relies on the auto_downcast and\n # type factories setting\n ext_func = inline_ext_function('compiled_func',code,arg_names,\n local_dict,global_dict,auto_downcast,\n type_converters = type_converters)\n mod.add_function(ext_func)\n\n # if customize (a custom_info object), then set the module customization.\n if customize:\n mod.customize = customize\n\n # add the extra \"support code\" needed by the function to the module.\n if support_code:\n mod.customize.add_support_code(support_code)\n \n # compile code in correct location, with the given compiler and verbosity\n # setting. All input keywords are passed through to distutils\n mod.compile(location=storage_dir,compiler=compiler,\n verbose=verbose, **kw)\n\n # import the module and return the function. Make sure\n # the directory where it lives is in the python path.\n try:\n sys.path.insert(0,storage_dir)\n exec 'import ' + module_name\n func = eval(module_name+'.compiled_func')\n finally:\n del sys.path[0]\n return func\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n test_function()\n\n", "source_code_before": "# should re-write compiled functions to take a local and global dict\n# as input.\nimport sys,os\nimport ext_tools\nimport string\nimport catalog\nimport common_info\n\n# not an easy way for the user_path_list to come in here.\n# the PYTHONCOMPILED environment variable offers the most hope.\n\nfunction_catalog = catalog.catalog()\n\n\nclass inline_ext_function(ext_tools.ext_function):\n # Some specialization is needed for inline extension functions\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args)\\n{\\n'\n return code % self.name\n\n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n\n This code got a lot uglier when I added local_dict...\n \"\"\"\n declare_return = 'PyObject *return_val = NULL;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py__locals = NULL;\\n' \\\n 'PyObject *py__globals = NULL;\\n'\n\n py_objects = ', '.join(self.arg_specs.py_pointers())\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n else:\n declare_py_objects = ''\n\n py_vars = ' = '.join(self.arg_specs.py_variables())\n if py_vars:\n init_values = py_vars + ' = NULL;\\n\\n'\n else:\n init_values = ''\n\n parse_tuple = 'if(!PyArg_ParseTuple(args,\"OO:compiled_func\",'\\\n '&py__locals,'\\\n '&py__globals))\\n'\\\n ' return NULL;\\n'\n\n return declare_return + declare_py_objects + \\\n init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code(inline=1))\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.cleanup_code())\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n\n\n def function_code(self):\n from ext_tools import indent\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n #local_dict_code = indent(self.arg_local_dict_code(),4)\n\n try_code = 'try \\n' \\\n '{ \\n' \\\n ' PyObject* raw_locals = py_to_raw_dict(' \\\n 'py__locals,\"_locals\");\\n' \\\n ' PyObject* raw_globals = py_to_raw_dict(' \\\n 'py__globals,\"_globals\");\\n' + \\\n ' /* argument conversion code */ \\n' + \\\n decl_code + \\\n ' /* inline code */ \\n' + \\\n function_code + \\\n ' /*I would like to fill in changed ' \\\n 'locals and globals here...*/ \\n' \\\n '\\n} \\n'\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = NULL; \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\" \n return_code = \" /* cleanup code */ \\n\" + \\\n cleanup_code + \\\n \" if(!return_val && !exception_occured)\\n\" \\\n \" {\\n \\n\" \\\n \" Py_INCREF(Py_None); \\n\" \\\n \" return_val = Py_None; \\n\" \\\n \" }\\n \\n\" \\\n \" return return_val; \\n\" \\\n \"} \\n\"\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS},\\n' % args\n return function_decls\n\nclass inline_ext_module(ext_tools.ext_module):\n def __init__(self,name,compiler=''):\n ext_tools.ext_module.__init__(self,name,compiler)\n self._build_information.append(common_info.inline_info())\n\nfunction_cache = {}\ndef inline(code,arg_names=[],local_dict = None, global_dict = None,\n force = 0,\n compiler='',\n verbose = 0,\n support_code = None,\n customize=None,\n type_converters = None,\n auto_downcast=1,\n **kw):\n \"\"\" Inline C/C++ code within Python scripts.\n\n inline() compiles and executes C/C++ code on the fly. Variables\n in the local and global Python scope are also available in the\n C/C++ code. Values are passed to the C/C++ code by assignment\n much like variables passed are passed into a standard Python\n function. Values are returned from the C/C++ code through a\n special argument called return_val. Also, the contents of\n mutable objects can be changed within the C/C++ code and the\n changes remain after the C code exits and returns to Python.\n\n inline has quite a few options as listed below. Also, the keyword\n arguments for distutils extension modules are accepted to\n specify extra information needed for compiling.\n\n code -- string. A string of valid C++ code. It should not specify a\n return statement. Instead it should assign results that\n need to be returned to Python in the return_val.\n arg_names -- optional. list of strings. A list of Python variable names \n that should be transferred from Python into the C/C++ \n code. It defaults to an empty string.\n local_dict -- optional. dictionary. If specified, it is a dictionary\n of values that should be used as the local scope for the\n C/C++ code. If local_dict is not specified the local\n dictionary of the calling function is used.\n global_dict -- optional. dictionary. If specified, it is a dictionary\n of values that should be used as the global scope for\n the C/C++ code. If global_dict is not specified the\n global dictionary of the calling function is used.\n force -- optional. 0 or 1. default 0. If 1, the C++ code is\n compiled every time inline is called. This is really\n only useful for debugging, and probably only useful if\n your editing support_code a lot.\n compiler -- optional. string. The name of compiler to use when\n compiling. On windows, it understands 'msvc' and 'gcc'\n as well as all the compiler names understood by\n distutils. On Unix, it'll only understand the values\n understoof by distutils. ( I should add 'gcc' though\n to this).\n\n On windows, the compiler defaults to the Microsoft C++\n compiler. If this isn't available, it looks for mingw32\n (the gcc compiler).\n\n On Unix, it'll probably use the same compiler that was\n used when compiling Python. Cygwin's behavior should be\n similar.\n verbose -- optional. 0,1, or 2. defualt 0. Speficies how much\n much information is printed during the compile phase\n of inlining code. 0 is silent (except on windows with\n msvc where it still prints some garbage). 1 informs\n you when compiling starts, finishes, and how long it\n took. 2 prints out the command lines for the compilation\n process and can be useful if your having problems\n getting code to work. Its handy for finding the name\n of the .cpp file if you need to examine it. verbose has\n no affect if the compilation isn't necessary.\n support_code -- optional. string. A string of valid C++ code declaring\n extra code that might be needed by your compiled\n function. This could be declarations of functions,\n classes, or structures.\n customize -- optional. base_info.custom_info object. An alternative\n way to specifiy support_code, headers, etc. needed by\n the function see the compiler.base_info module for more\n details. (not sure this'll be used much).\n type_converters -- optional. list of type converters. These\n guys are what convert Python data types to C/C++ data\n types. If you'd like to use a different set of type\n conversions than the default, specify them here. Look\n in the type conversions section of the main\n documentation for examples.\n auto_downcast -- optional. 0 or 1. default 1. This only affects\n functions that have Numeric arrays as input variables.\n Setting this to 1 will cause all floating point values\n to be cast as float instead of double if all the\n Numeric arrays are of type float. If even one of the\n arrays has type double or double complex, all\n variables maintain there standard types.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n\n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list\n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability)\n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line)\n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n # this grabs the local variables from the *previous* call\n # frame -- that is the locals from the function that called\n # inline.\n global function_catalog\n\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if force:\n module_dir = global_dict.get('__file__',None)\n func = compile_function(code,arg_names,local_dict,\n global_dict,module_dir,\n compiler=compiler,\n verbose=verbose,\n support_code = support_code,\n customize=customize,\n type_converters = type_converters,\n auto_downcast = auto_downcast,\n **kw)\n\n function_catalog.add_function(code,func,module_dir)\n results = attempt_function_call(code,local_dict,global_dict)\n else:\n # 1. try local cache\n try:\n results = apply(function_cache[code],(local_dict,global_dict))\n return results\n except TypeError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise TypeError, msg\n except NameError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise NameError, msg\n except KeyError:\n pass\n # 2. try function catalog\n try:\n results = attempt_function_call(code,local_dict,global_dict)\n # 3. build the function\n except ValueError:\n # compile the library\n module_dir = global_dict.get('__file__',None)\n func = compile_function(code,arg_names,local_dict,\n global_dict,module_dir,\n compiler=compiler,\n verbose=verbose,\n support_code = support_code,\n customize=customize,\n type_converters = type_converters,\n auto_downcast = auto_downcast,\n **kw)\n\n function_catalog.add_function(code,func,module_dir)\n results = attempt_function_call(code,local_dict,global_dict)\n return results\n\ndef attempt_function_call(code,local_dict,global_dict):\n # we try 3 levels here -- a local cache first, then the\n # catalog cache, and then persistent catalog.\n #\n global function_cache\n # 2. try catalog cache.\n function_list = function_catalog.get_functions_fast(code)\n for func in function_list:\n try:\n results = apply(func,(local_dict,global_dict))\n function_catalog.fast_cache(code,func)\n function_cache[code] = func\n return results\n except TypeError, msg: # should specify argument types here.\n # This should really have its own error type, instead of\n # checking the beginning of the message, but I don't know\n # how to define that yet.\n msg = str(msg)\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise TypeError, msg\n except NameError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise NameError, msg \n # 3. try persistent catalog\n module_dir = global_dict.get('__file__',None)\n function_list = function_catalog.get_functions(code,module_dir)\n for func in function_list:\n try:\n results = apply(func,(local_dict,global_dict))\n function_catalog.fast_cache(code,func)\n function_cache[code] = func\n return results\n except: # should specify argument types here.\n pass\n # if we get here, the function wasn't found\n raise ValueError, 'function with correct signature not found'\n\ndef inline_function_code(code,arg_names,local_dict=None,\n global_dict=None,auto_downcast = 1,\n type_converters=None,compiler=''):\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n ext_func = inline_ext_function('compiled_func',code,arg_names,\n local_dict,global_dict,auto_downcast,\n type_converters = type_converters)\n import build_tools\n compiler = build_tools.choose_compiler(compiler)\n ext_func.set_compiler(compiler)\n return ext_func.function_code()\n\ndef compile_function(code,arg_names,local_dict,global_dict,\n module_dir,\n compiler='',\n verbose = 0,\n support_code = None,\n customize = None,\n type_converters = None,\n auto_downcast=1,\n **kw):\n # figure out where to store and what to name the extension module\n # that will contain the function.\n #storage_dir = catalog.intermediate_dir()\n module_path = function_catalog.unique_module_name(code,module_dir)\n storage_dir, module_name = os.path.split(module_path)\n mod = inline_ext_module(module_name,compiler)\n\n # create the function. This relies on the auto_downcast and\n # type factories setting\n ext_func = inline_ext_function('compiled_func',code,arg_names,\n local_dict,global_dict,auto_downcast,\n type_converters = type_converters)\n mod.add_function(ext_func)\n\n # if customize (a custom_info object), then set the module customization.\n if customize:\n mod.customize = customize\n\n # add the extra \"support code\" needed by the function to the module.\n if support_code:\n mod.customize.add_support_code(support_code)\n \n # compile code in correct location, with the given compiler and verbosity\n # setting. All input keywords are passed through to distutils\n mod.compile(location=storage_dir,compiler=compiler,\n verbose=verbose, **kw)\n\n # import the module and return the function. Make sure\n # the directory where it lives is in the python path.\n try:\n sys.path.insert(0,storage_dir)\n exec 'import ' + module_name\n func = eval(module_name+'.compiled_func')\n finally:\n del sys.path[0]\n return func\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n test_function()\n\n", "methods": [ { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 17, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "inline_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 21, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "inline_tools.py", "nloc": 21, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 26, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 57, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 64, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "inline_tools.py", "nloc": 37, "complexity": 1, "token_count": 146, "parameters": [ "self" ], "start_line": 79, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "inline_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 121, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 35, "parameters": [ "self", "name", "compiler" ], "start_line": 127, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "inline", "long_name": "inline( code , arg_names = [ ] , local_dict = None , global_dict = None , force = 0 , compiler = '' , verbose = 0 , support_code = None , customize = None , type_converters = None , auto_downcast = 1 , ** kw )", "filename": "inline_tools.py", "nloc": 62, "complexity": 10, "token_count": 330, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "force", "compiler", "verbose", "support_code", "customize", "type_converters", "auto_downcast", "kw" ], "start_line": 132, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 200, "top_nesting_level": 0 }, { "name": "attempt_function_call", "long_name": "attempt_function_call( code , local_dict , global_dict )", "filename": "inline_tools.py", "nloc": 32, "complexity": 8, "token_count": 174, "parameters": [ "code", "local_dict", "global_dict" ], "start_line": 333, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "inline_function_code", "long_name": "inline_function_code( code , arg_names , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None , compiler = '' )", "filename": "inline_tools.py", "nloc": 15, "complexity": 3, "token_count": 98, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "auto_downcast", "type_converters", "compiler" ], "start_line": 375, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "compile_function", "long_name": "compile_function( code , arg_names , local_dict , global_dict , module_dir , compiler = '' , verbose = 0 , support_code = None , customize = None , type_converters = None , auto_downcast = 1 , ** kw )", "filename": "inline_tools.py", "nloc": 29, "complexity": 4, "token_count": 169, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "module_dir", "compiler", "verbose", "support_code", "customize", "type_converters", "auto_downcast", "kw" ], "start_line": 391, "end_line": 435, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 441, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 17, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "inline_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 21, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "inline_tools.py", "nloc": 21, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 26, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 57, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 64, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "inline_tools.py", "nloc": 38, "complexity": 1, "token_count": 148, "parameters": [ "self" ], "start_line": 79, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "inline_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 122, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 35, "parameters": [ "self", "name", "compiler" ], "start_line": 128, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "inline", "long_name": "inline( code , arg_names = [ ] , local_dict = None , global_dict = None , force = 0 , compiler = '' , verbose = 0 , support_code = None , customize = None , type_converters = None , auto_downcast = 1 , ** kw )", "filename": "inline_tools.py", "nloc": 62, "complexity": 10, "token_count": 330, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "force", "compiler", "verbose", "support_code", "customize", "type_converters", "auto_downcast", "kw" ], "start_line": 133, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 200, "top_nesting_level": 0 }, { "name": "attempt_function_call", "long_name": "attempt_function_call( code , local_dict , global_dict )", "filename": "inline_tools.py", "nloc": 32, "complexity": 8, "token_count": 174, "parameters": [ "code", "local_dict", "global_dict" ], "start_line": 334, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "inline_function_code", "long_name": "inline_function_code( code , arg_names , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None , compiler = '' )", "filename": "inline_tools.py", "nloc": 15, "complexity": 3, "token_count": 98, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "auto_downcast", "type_converters", "compiler" ], "start_line": 376, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "compile_function", "long_name": "compile_function( code , arg_names , local_dict , global_dict , module_dir , compiler = '' , verbose = 0 , support_code = None , customize = None , type_converters = None , auto_downcast = 1 , ** kw )", "filename": "inline_tools.py", "nloc": 29, "complexity": 4, "token_count": 169, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "module_dir", "compiler", "verbose", "support_code", "customize", "type_converters", "auto_downcast", "kw" ], "start_line": 392, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 438, "end_line": 440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 442, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "inline_tools.py", "nloc": 21, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 26, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "inline_tools.py", "nloc": 37, "complexity": 1, "token_count": 146, "parameters": [ "self" ], "start_line": 79, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 } ], "nloc": 245, "complexity": 41, "token_count": 1320, "diff_parsed": { "added": [ " declare_return = 'py::object return_val;\\n' \\", " catch_code = \"catch(...) \\n\" \\", " \"{ \\n\" + \\", " \" return_val = py::object(); \\n\" \\", " \" exception_occured = 1; \\n\" \\", " \"} \\n\"", " \" if(!(PyObject*)return_val && !exception_occured)\\n\" \\", " \" return return_val.disown(); \\n\" \\" ], "deleted": [ " declare_return = 'PyObject *return_val = NULL;\\n' \\", " catch_code = \"catch(...) \\n\" \\", " \"{ \\n\" + \\", " \" return_val = NULL; \\n\" \\", " \" exception_occured = 1; \\n\" \\", " \"} \\n\"", " \" if(!return_val && !exception_occured)\\n\" \\", " \" Py_INCREF(Py_None); \\n\" \\", " \" return return_val; \\n\" \\" ] } }, { "old_path": "weave/scxx/notes.txt", "new_path": "weave/scxx/notes.txt", "filename": "notes.txt", "extension": "txt", "change_type": "MODIFY", "diff": "@@ -1,3 +1,19 @@\n+For release:\n+ 1. Change return_val to be an py::object. This will get rid of \n+ of the need to handle incref/decref on your own most of the time.\n+ DONE\n+ 2. Flesh out object to handle all types of values in a generic way:\n+ a. sequence access.\n+ b. casting from/to standard types\n+ int, float, double, std::complex, char*, std::string.\n+ DONE\n+ c. attr should return a reference? Not sure about this.\n+ I DONT THINK SO\n+ 3. Tests that always through exceptions aren't getting cataloged.\n+ This isn't a big deal in practice, but it needs to be cleaned up.\n+ 4. Test file conversion for ref counts\n+ 5. Examine all examples and make sure they make sense (and work). \n+ \n base package\n scipy_base\n scipy_distutils\n@@ -10,6 +26,18 @@ chaco\n \n weave\n \n+Note on ref counts:\n+There is some ref count strangness in inline() *if it is called from\n+a function*. When called from the command line, the ref counts behave\n+correctly. When called from a function, the first call to a\n+inline() causes the ref count goes up an extra count. However,\n+subsequent calls don't cause any further refcount increases. Checks\n+put in py::object creation and destruction look like the C++ code is\n+not loosing a ref count. I'm thinking that some of the stack frame\n+limbo played in inline() might be to blame??? Anyway, this needs\n+further investigation. I'm not sure if the issue is leading to leaks\n+or not.\n+\n Proposed changes to weave:\n \n * change return_val to a py::object\n", "added_lines": 28, "deleted_lines": 0, "source_code": "For release:\n 1. Change return_val to be an py::object. This will get rid of \n of the need to handle incref/decref on your own most of the time.\n DONE\n 2. Flesh out object to handle all types of values in a generic way:\n a. sequence access.\n b. casting from/to standard types\n int, float, double, std::complex, char*, std::string.\n DONE\n c. attr should return a reference? Not sure about this.\n I DONT THINK SO\n 3. Tests that always through exceptions aren't getting cataloged.\n This isn't a big deal in practice, but it needs to be cleaned up.\n 4. Test file conversion for ref counts\n 5. Examine all examples and make sure they make sense (and work). \n \nbase package\n scipy_base\n scipy_distutils\n scipy_test\n gui_thread\n\nscipy\nweave\nchaco\n \nweave\n\nNote on ref counts:\nThere is some ref count strangness in inline() *if it is called from\na function*. When called from the command line, the ref counts behave\ncorrectly. When called from a function, the first call to a\ninline() causes the ref count goes up an extra count. However,\nsubsequent calls don't cause any further refcount increases. Checks\nput in py::object creation and destruction look like the C++ code is\nnot loosing a ref count. I'm thinking that some of the stack frame\nlimbo played in inline() might be to blame??? Anyway, this needs\nfurther investigation. I'm not sure if the issue is leading to leaks\nor not.\n\nProposed changes to weave:\n\n* change return_val to a py::object\n This could remove almost all of the need of handling PyObject*.\n* document changes. \n* review directory structure.\n* outline method of aggregating functions into a single file.\n\nEVERYTHING BELOW HERE IS DONE.\n* all classes moved to py:: namespace\n* made tuples mutable with indexing notation. (handy in weave)\n* converted camel case names (setItem -> set_item)\n* change class names to reflect boost like names and put each \n exposed class in its own header file.\n PWOBase -> py::object -- object.h \n PWOList -> py::list -- list.h \n PWOTuple -> py::tuple -- tuple.h \n PWOMapping -> py::dict -- dict.h \n PWOCallable -> py::callable -- callable.h \n PWOString -> py::str -- str.h \n PWONumber -> py::number -- number.h \n \n py::object public methods:\n int print(FILE *f, int flags) const DONE\n\n bool hasattr(const char* nm) const DONE\n\n py::object_attr attr(const char* nm) const\n py::object_attr attr(const py::object& nm) const\n\n ??\n int set_attr(const char* nm, py::object& val)\n int set_attr(PyObject* nm, py::object& val)\n\n int del(const char* nm)\n int del(const py::object& nm)\n \n int cmp(const py::object& other) const\n\n bool operator == (const py::object& other) const \n bool operator != (const py::object& other) const \n bool operator > (const py::object& other) const \n bool operator < (const py::object& other) const\n bool operator >= (const py::object& other) const\n bool operator <= (const py::object& other) const \n \n PyObject* repr() const\n /*PyObject* str() const*/ // conflicts with class named str\n PyObject* type() const\n \n int hash() const\n bool is_true() const\n bool is_callable() const\n \n PyObject* disown() \n\n\n py::sequence public methods:\n PWOSequence operator+(const PWOSequence& rhs) const\n //count\n int count(const py::object& value) const\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n py::object operator [] (int i) const\n py::sequence get_slice(int lo, int hi) const\n \n bool in(const py::object& value) const\n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n int index(const py::object& value) const\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n int len() const\n int length() const // compatible with std::string\n\n py::sequence operator * (int count) const //repeat\n\n class py::tuple\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n \n // make tuples mutable like lists\n // much easier to set up call lists, etc.\n py::tuple_member operator [] (int i)\n \n class py::list\n\n bool del(int i)\n bool del(int lo, int hi)\n\n py::list_member operator [] (int i)\n\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n\n void set_slice(int lo, int hi, const py::sequence& slice)\n\n py::list& append(const py::object& other)\n py::list& append(int other)\n py::list& append(double other)\n py::list& append(char* other)\n py::list& append(std::string other)\n \n py::list& insert(int ndx, py::object& other)\n py::list& insert(int ndx, int other);\n py::list& insert(int ndx, double other);\n py::list& insert(int ndx, char* other); \n py::list& insert(int ndx, std::string other);\n\n py::list& reverse()\n py::list& sort()\n\n class py::dict\n py::dict_member operator [] (const char* key)\n py::dict_member operator [] (std::string key)\n \n py::dict_member operator [] (PyObject* key)\n py::dict_member operator [] (int key) \n py::dict_member operator [] (double key)\n \n bool has_key(PyObject* key) const\n bool has_key(const char* key) const\n // needs int, std::string, and double versions\n \n int len() const\n int length() const\n\n void set_item(const char* key, PyObject* val)\n void set_item(PyObject* key, PyObject* val) const\n // need int, std::string and double versions\n void clear()\n \n void del(PyObject* key)\n void del(const char* key)\n // need int, std::string, and double versions\n \n py::list items() const\n py::list keys() const\n py::list values() const", "source_code_before": "base package\n scipy_base\n scipy_distutils\n scipy_test\n gui_thread\n\nscipy\nweave\nchaco\n \nweave\n\nProposed changes to weave:\n\n* change return_val to a py::object\n This could remove almost all of the need of handling PyObject*.\n* document changes. \n* review directory structure.\n* outline method of aggregating functions into a single file.\n\nEVERYTHING BELOW HERE IS DONE.\n* all classes moved to py:: namespace\n* made tuples mutable with indexing notation. (handy in weave)\n* converted camel case names (setItem -> set_item)\n* change class names to reflect boost like names and put each \n exposed class in its own header file.\n PWOBase -> py::object -- object.h \n PWOList -> py::list -- list.h \n PWOTuple -> py::tuple -- tuple.h \n PWOMapping -> py::dict -- dict.h \n PWOCallable -> py::callable -- callable.h \n PWOString -> py::str -- str.h \n PWONumber -> py::number -- number.h \n \n py::object public methods:\n int print(FILE *f, int flags) const DONE\n\n bool hasattr(const char* nm) const DONE\n\n py::object_attr attr(const char* nm) const\n py::object_attr attr(const py::object& nm) const\n\n ??\n int set_attr(const char* nm, py::object& val)\n int set_attr(PyObject* nm, py::object& val)\n\n int del(const char* nm)\n int del(const py::object& nm)\n \n int cmp(const py::object& other) const\n\n bool operator == (const py::object& other) const \n bool operator != (const py::object& other) const \n bool operator > (const py::object& other) const \n bool operator < (const py::object& other) const\n bool operator >= (const py::object& other) const\n bool operator <= (const py::object& other) const \n \n PyObject* repr() const\n /*PyObject* str() const*/ // conflicts with class named str\n PyObject* type() const\n \n int hash() const\n bool is_true() const\n bool is_callable() const\n \n PyObject* disown() \n\n\n py::sequence public methods:\n PWOSequence operator+(const PWOSequence& rhs) const\n //count\n int count(const py::object& value) const\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n py::object operator [] (int i) const\n py::sequence get_slice(int lo, int hi) const\n \n bool in(const py::object& value) const\n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n int index(const py::object& value) const\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n int len() const\n int length() const // compatible with std::string\n\n py::sequence operator * (int count) const //repeat\n\n class py::tuple\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n \n // make tuples mutable like lists\n // much easier to set up call lists, etc.\n py::tuple_member operator [] (int i)\n \n class py::list\n\n bool del(int i)\n bool del(int lo, int hi)\n\n py::list_member operator [] (int i)\n\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n\n void set_slice(int lo, int hi, const py::sequence& slice)\n\n py::list& append(const py::object& other)\n py::list& append(int other)\n py::list& append(double other)\n py::list& append(char* other)\n py::list& append(std::string other)\n \n py::list& insert(int ndx, py::object& other)\n py::list& insert(int ndx, int other);\n py::list& insert(int ndx, double other);\n py::list& insert(int ndx, char* other); \n py::list& insert(int ndx, std::string other);\n\n py::list& reverse()\n py::list& sort()\n\n class py::dict\n py::dict_member operator [] (const char* key)\n py::dict_member operator [] (std::string key)\n \n py::dict_member operator [] (PyObject* key)\n py::dict_member operator [] (int key) \n py::dict_member operator [] (double key)\n \n bool has_key(PyObject* key) const\n bool has_key(const char* key) const\n // needs int, std::string, and double versions\n \n int len() const\n int length() const\n\n void set_item(const char* key, PyObject* val)\n void set_item(PyObject* key, PyObject* val) const\n // need int, std::string and double versions\n void clear()\n \n void del(PyObject* key)\n void del(const char* key)\n // need int, std::string, and double versions\n \n py::list items() const\n py::list keys() const\n py::list values() const", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "For release:", " 1. Change return_val to be an py::object. This will get rid of", " of the need to handle incref/decref on your own most of the time.", " DONE", " 2. Flesh out object to handle all types of values in a generic way:", " a. sequence access.", " b. casting from/to standard types", " int, float, double, std::complex, char*, std::string.", " DONE", " c. attr should return a reference? Not sure about this.", " I DONT THINK SO", " 3. Tests that always through exceptions aren't getting cataloged.", " This isn't a big deal in practice, but it needs to be cleaned up.", " 4. Test file conversion for ref counts", " 5. Examine all examples and make sure they make sense (and work).", "", "Note on ref counts:", "There is some ref count strangness in inline() *if it is called from", "a function*. When called from the command line, the ref counts behave", "correctly. When called from a function, the first call to a", "inline() causes the ref count goes up an extra count. However,", "subsequent calls don't cause any further refcount increases. Checks", "put in py::object creation and destruction look like the C++ code is", "not loosing a ref count. I'm thinking that some of the stack frame", "limbo played in inline() might be to blame??? Anyway, this needs", "further investigation. I'm not sure if the issue is leading to leaks", "or not.", "" ], "deleted": [] } }, { "old_path": "weave/scxx/object.h", "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -11,6 +11,10 @@\n #include \n #include \n #include \n+#include \n+\n+// for debugging\n+#include \n \n namespace py {\n \n@@ -40,15 +44,67 @@ public:\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n- : _obj (0), _own (0) { GrabRef(obj); }\n+ : _obj (0), _own (0) { \n+ //std::cout << \"construct before: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;\n+ GrabRef(obj); \n+ //std::cout << \"construct after: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;\n+ }\n \n- virtual ~object()\n- { Py_XDECREF(_own); }\n+ //-------------------------------------------------------------------------\n+ // Numeric constructors\n+ //-------------------------------------------------------------------------\n+ /*\n+ object(bool val) : _obj (0), _own (0) { \n+ GrabRef(PyInt_FromLong((int)val)); \n+ LoseRef(_obj); \n+ };\n+ */\n+ object(int val) : _obj (0), _own (0) { \n+ GrabRef(PyInt_FromLong(val)); \n+ LoseRef(_obj); \n+ };\n+ object(long val) : _obj (0), _own (0) { \n+ GrabRef(PyInt_FromLong(val)); \n+ LoseRef(_obj); \n+ }; \n+ object(unsigned long val) : _obj (0), _own (0) { \n+ GrabRef(PyLong_FromUnsignedLong(val)); \n+ LoseRef(_obj); \n+ }; \n+ object(double val) : _obj (0), _own (0) { \n+ GrabRef(PyFloat_FromDouble(val)); \n+ LoseRef(_obj); \n+ };\n+ object(std::complex& val) : _obj (0), _own (0) { \n+ GrabRef(PyComplex_FromDoubles(val.real(),val.imag())); \n+ LoseRef(_obj); \n+ };\n \n- object& operator=(const object& other) {\n- GrabRef(other);\n- return *this;\n+ //-------------------------------------------------------------------------\n+ // string constructors\n+ //-------------------------------------------------------------------------\n+ object(char* val) : _obj (0), _own (0) { \n+ GrabRef(PyString_FromString(val)); \n+ LoseRef(_obj); \n };\n+ object(std::string& val) : _obj (0), _own (0) { \n+ GrabRef(PyString_FromString((char*)val.c_str())); \n+ LoseRef(_obj); \n+ };\n+ \n+ //-------------------------------------------------------------------------\n+ // destructor\n+ //-------------------------------------------------------------------------\n+ virtual ~object()\n+ { \n+ //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;\n+ Py_XDECREF(_own); \n+ //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;\n+ } \n+ \n+ //-------------------------------------------------------------------------\n+ // casting operators\n+ //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n@@ -60,7 +116,7 @@ public:\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n- Fail(PyExc_TypeError, \"cannot convert value to double\");\n+ Fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n@@ -68,21 +124,55 @@ public:\n Fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n-\n+ operator std::complex () const {\n+ if (!PyComplex_Check(_obj))\n+ Fail(PyExc_TypeError, \"cannot convert value to complex\");\n+ return std::complex(PyComplex_RealAsDouble(_obj),\n+ PyComplex_ImagAsDouble(_obj));\n+ }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n+ operator char* () const {\n+ if (!PyString_Check(_obj))\n+ Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n+ return PyString_AsString(_obj);\n+ }; \n \n+ //-------------------------------------------------------------------------\n+ // equal operator\n+ //-------------------------------------------------------------------------\n+ object& operator=(const object& other) {\n+ GrabRef(other);\n+ return *this;\n+ };\n+ \n+ //-------------------------------------------------------------------------\n+ // printing\n+ //\n+ // !! UNTESTED\n+ //-------------------------------------------------------------------------\n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n- bool hasattr(const char* nm) const {\n+\n+ //-------------------------------------------------------------------------\n+ // hasattr -- test if object has specified attribute\n+ //------------------------------------------------------------------------- \n+ int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n+ int hasattr(std::string nm) const {\n+ return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n+ };\n \n- // Need to change return type?\n+ //-------------------------------------------------------------------------\n+ // attribute access\n+ //\n+ // should this return a reference? Need to think about this.\n+ //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n@@ -101,6 +191,10 @@ public:\n return object(LoseRef(val)); \n }; \n \n+ //-------------------------------------------------------------------------\n+ // setting attributes\n+ // !! NOT TESTED\n+ //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n@@ -113,6 +207,9 @@ public:\n throw 1;\n };\n \n+ //-------------------------------------------------------------------------\n+ // calling methods\n+ //-------------------------------------------------------------------------\n object mcall(const char* nm);\n object mcall(const char* nm, tuple& args);\n object mcall(const char* nm, tuple& args, dict& kwargs);\n@@ -127,10 +224,27 @@ public:\n return mcall(nm.c_str(),args,kwargs);\n }\n \n+ //-------------------------------------------------------------------------\n+ // calling callable objects\n+ //-------------------------------------------------------------------------\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n \n+ //-------------------------------------------------------------------------\n+ // sequence methods\n+ // !! NOT TESTED\n+ //-------------------------------------------------------------------------\n+\n+ //-------------------------------------------------------------------------\n+ // iter methods\n+ // !! NOT TESTED\n+ //-------------------------------------------------------------------------\n+\n+ //-------------------------------------------------------------------------\n+ // del objects\n+ // !! NOT TESTED\n+ //-------------------------------------------------------------------------\n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n@@ -138,13 +252,17 @@ public:\n return PyObject_DelAttr(_obj, nm);\n };\n \n+ //-------------------------------------------------------------------------\n+ // comparison\n+ // !! NOT TESTED\n+ //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n- };\n+ }; \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n", "added_lines": 129, "deleted_lines": 11, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified heavily for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid Fail(PyObject*, const char* msg);\n\n// used in method call specification.\nclass tuple;\nclass dict;\n \nclass object \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n object()\n : _obj (0), _own (0) { }\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n : _obj (0), _own (0) { \n //std::cout << \"construct before: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;\n GrabRef(obj); \n //std::cout << \"construct after: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;\n }\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n /*\n object(bool val) : _obj (0), _own (0) { \n GrabRef(PyInt_FromLong((int)val)); \n LoseRef(_obj); \n };\n */\n object(int val) : _obj (0), _own (0) { \n GrabRef(PyInt_FromLong(val)); \n LoseRef(_obj); \n };\n object(long val) : _obj (0), _own (0) { \n GrabRef(PyInt_FromLong(val)); \n LoseRef(_obj); \n }; \n object(unsigned long val) : _obj (0), _own (0) { \n GrabRef(PyLong_FromUnsignedLong(val)); \n LoseRef(_obj); \n }; \n object(double val) : _obj (0), _own (0) { \n GrabRef(PyFloat_FromDouble(val)); \n LoseRef(_obj); \n };\n object(std::complex& val) : _obj (0), _own (0) { \n GrabRef(PyComplex_FromDoubles(val.real(),val.imag())); \n LoseRef(_obj); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(char* val) : _obj (0), _own (0) { \n GrabRef(PyString_FromString(val)); \n LoseRef(_obj); \n };\n object(std::string& val) : _obj (0), _own (0) { \n GrabRef(PyString_FromString((char*)val.c_str())); \n LoseRef(_obj); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object()\n { \n //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;\n Py_XDECREF(_own); \n //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;\n } \n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n GrabRef(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // !! UNTESTED\n //-------------------------------------------------------------------------\n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(std::string nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n\n //-------------------------------------------------------------------------\n // attribute access\n //\n // should this return a reference? Need to think about this.\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n };\n\n object attr(std::string nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // calling methods\n //-------------------------------------------------------------------------\n object mcall(const char* nm);\n object mcall(const char* nm, tuple& args);\n object mcall(const char* nm, tuple& args, dict& kwargs);\n\n object mcall(std::string nm) {\n return mcall(nm.c_str());\n }\n object mcall(std::string nm, tuple& args) {\n return mcall(nm.c_str(),args);\n }\n object mcall(std::string nm, tuple& args, dict& kwargs) {\n return mcall(nm.c_str(),args,kwargs);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //-------------------------------------------------------------------------\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n\n //-------------------------------------------------------------------------\n // sequence methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n\n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n\n //-------------------------------------------------------------------------\n // del objects\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int del(const object& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n /*\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n */\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n};\n\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified heavily for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n\nnamespace py {\n\nvoid Fail(PyObject*, const char* msg);\n\n// used in method call specification.\nclass tuple;\nclass dict;\n \nclass object \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n object()\n : _obj (0), _own (0) { }\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n : _obj (0), _own (0) { GrabRef(obj); }\n\n virtual ~object()\n { Py_XDECREF(_own); }\n \n object& operator=(const object& other) {\n GrabRef(other);\n return *this;\n };\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to double\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n\n operator std::string () const {\n if (!PyString_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n \n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n bool hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n\n // Need to change return type?\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n };\n\n object attr(std::string nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n }; \n \n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n object mcall(const char* nm);\n object mcall(const char* nm, tuple& args);\n object mcall(const char* nm, tuple& args, dict& kwargs);\n\n object mcall(std::string nm) {\n return mcall(nm.c_str());\n }\n object mcall(std::string nm, tuple& args) {\n return mcall(nm.c_str(),args);\n }\n object mcall(std::string nm, tuple& args, dict& kwargs) {\n return mcall(nm.c_str(),args,kwargs);\n }\n\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n\n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int del(const object& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n \n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n };\n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n /*\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n */\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n};\n\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "methods": [ { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 35, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 42, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 44, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 46, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "val" ], "start_line": 62, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "val" ], "start_line": 66, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "val" ], "start_line": 70, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "val" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( std :: complex & val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "std" ], "start_line": 78, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( char * val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "val" ], "start_line": 86, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( std :: string & val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "std" ], "start_line": 90, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 98, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 108, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 112, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 117, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 122, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 127, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 133, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 147, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 157, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 176, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "std" ], "start_line": 183, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 187, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 198, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 204, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std", "args" ], "start_line": 220, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args , dict & kwargs)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "std", "args", "kwargs" ], "start_line": 223, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 248, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 251, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 259, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 272, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 275, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 278, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 281, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 285, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 293, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 296, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 299, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 302, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 305, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 31, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 38, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 40, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 42, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 45, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 48, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 52, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 56, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 61, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 66, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 72, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 78, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 81, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "std" ], "start_line": 93, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 97, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 104, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 110, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 120, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std", "args" ], "start_line": 123, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args , dict & kwargs)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "std", "args", "kwargs" ], "start_line": 126, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 137, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 141, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 148, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 151, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 154, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 157, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 160, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 175, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 178, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 181, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 187, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "val" ], "start_line": 70, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "val" ], "start_line": 62, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "val" ], "start_line": 66, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 147, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( std :: string & val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "std" ], "start_line": 90, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( char * val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "val" ], "start_line": 86, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 98, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 46, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( std :: complex & val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "std" ], "start_line": 78, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 259, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 127, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "val" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 117, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 } ], "nloc": 198, "complexity": 58, "token_count": 1363, "diff_parsed": { "added": [ "#include ", "", "// for debugging", "#include ", " : _obj (0), _own (0) {", " //std::cout << \"construct before: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;", " GrabRef(obj);", " //std::cout << \"construct after: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;", " }", " //-------------------------------------------------------------------------", " // Numeric constructors", " //-------------------------------------------------------------------------", " /*", " object(bool val) : _obj (0), _own (0) {", " GrabRef(PyInt_FromLong((int)val));", " LoseRef(_obj);", " };", " */", " object(int val) : _obj (0), _own (0) {", " GrabRef(PyInt_FromLong(val));", " LoseRef(_obj);", " };", " object(long val) : _obj (0), _own (0) {", " GrabRef(PyInt_FromLong(val));", " LoseRef(_obj);", " };", " object(unsigned long val) : _obj (0), _own (0) {", " GrabRef(PyLong_FromUnsignedLong(val));", " LoseRef(_obj);", " };", " object(double val) : _obj (0), _own (0) {", " GrabRef(PyFloat_FromDouble(val));", " LoseRef(_obj);", " };", " object(std::complex& val) : _obj (0), _own (0) {", " GrabRef(PyComplex_FromDoubles(val.real(),val.imag()));", " LoseRef(_obj);", " };", " //-------------------------------------------------------------------------", " // string constructors", " //-------------------------------------------------------------------------", " object(char* val) : _obj (0), _own (0) {", " GrabRef(PyString_FromString(val));", " LoseRef(_obj);", " object(std::string& val) : _obj (0), _own (0) {", " GrabRef(PyString_FromString((char*)val.c_str()));", " LoseRef(_obj);", " };", "", " //-------------------------------------------------------------------------", " // destructor", " //-------------------------------------------------------------------------", " virtual ~object()", " {", " //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;", " Py_XDECREF(_own);", " //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;", " }", "", " //-------------------------------------------------------------------------", " // casting operators", " //-------------------------------------------------------------------------", " Fail(PyExc_TypeError, \"cannot convert value to float\");", " operator std::complex () const {", " if (!PyComplex_Check(_obj))", " Fail(PyExc_TypeError, \"cannot convert value to complex\");", " return std::complex(PyComplex_RealAsDouble(_obj),", " PyComplex_ImagAsDouble(_obj));", " };", " operator char* () const {", " if (!PyString_Check(_obj))", " Fail(PyExc_TypeError, \"cannot convert value to std::string\");", " return PyString_AsString(_obj);", " };", " //-------------------------------------------------------------------------", " // equal operator", " //-------------------------------------------------------------------------", " object& operator=(const object& other) {", " GrabRef(other);", " return *this;", " };", "", " //-------------------------------------------------------------------------", " // printing", " //", " // !! UNTESTED", " //-------------------------------------------------------------------------", "", " //-------------------------------------------------------------------------", " // hasattr -- test if object has specified attribute", " //-------------------------------------------------------------------------", " int hasattr(const char* nm) const {", " int hasattr(std::string nm) const {", " return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;", " };", " //-------------------------------------------------------------------------", " // attribute access", " //", " // should this return a reference? Need to think about this.", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // setting attributes", " // !! NOT TESTED", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // calling methods", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // calling callable objects", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // sequence methods", " // !! NOT TESTED", " //-------------------------------------------------------------------------", "", " //-------------------------------------------------------------------------", " // iter methods", " // !! NOT TESTED", " //-------------------------------------------------------------------------", "", " //-------------------------------------------------------------------------", " // del objects", " // !! NOT TESTED", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // comparison", " // !! NOT TESTED", " //-------------------------------------------------------------------------", " };" ], "deleted": [ " : _obj (0), _own (0) { GrabRef(obj); }", " virtual ~object()", " { Py_XDECREF(_own); }", " object& operator=(const object& other) {", " GrabRef(other);", " return *this;", " Fail(PyExc_TypeError, \"cannot convert value to double\");", "", " bool hasattr(const char* nm) const {", " // Need to change return type?", " };" ] } }, { "old_path": "weave/scxx/weave_imp.cpp", "new_path": "weave/scxx/weave_imp.cpp", "filename": "weave_imp.cpp", "extension": "cpp", "change_type": "MODIFY", "diff": "@@ -31,7 +31,7 @@ object object::mcall(const char* nm)\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n- return object(result);\n+ return object(LoseRef(result));\n }\n \n object object::mcall(const char* nm, tuple& args)\n@@ -40,7 +40,7 @@ object object::mcall(const char* nm, tuple& args)\n PyObject* result = PyEval_CallObjectWithKeywords(method,args,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n- return object(result);\n+ return object(LoseRef(result));\n }\n \n object object::mcall(const char* nm, tuple& args, dict& kwargs)\n@@ -49,26 +49,26 @@ object object::mcall(const char* nm, tuple& args, dict& kwargs)\n PyObject* result = PyEval_CallObjectWithKeywords(method,args,kwargs);\n if (!result)\n throw 1; // signal exception has occured.\n- return object(result);\n+ return object(LoseRef(result));\n }\n \n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n- return object(rslt);\n+ return object(LoseRef(rslt));\n }\n object object::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n- return object(rslt);\n+ return object(LoseRef(rslt));\n }\n object object::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n- return object(rslt);\n+ return object(LoseRef(rslt));\n }\n \n //---------------------------------------------------------------------------\n", "added_lines": 6, "deleted_lines": 6, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"sequence.h\"\n#include \"list.h\"\n#include \"tuple.h\"\n#include \"str.h\"\n#include \"dict.h\"\n#include \"callable.h\"\n#include \"number.h\"\n\nusing namespace py;\n \n//---------------------------------------------------------------------------\n// object\n//---------------------------------------------------------------------------\n\n// incref new owner, and decref old owner, and adjust to new owner\nvoid object::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\nobject object::mcall(const char* nm)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(LoseRef(result));\n}\n\nobject object::mcall(const char* nm, tuple& args)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(LoseRef(result));\n}\n\nobject object::mcall(const char* nm, tuple& args, dict& kwargs)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args,kwargs);\n if (!result)\n throw 1; // signal exception has occured.\n return object(LoseRef(result));\n}\n\nobject object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(LoseRef(rslt));\n}\nobject object::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return object(LoseRef(rslt));\n}\nobject object::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return object(LoseRef(rslt));\n}\n\n//---------------------------------------------------------------------------\n// sequence\n//---------------------------------------------------------------------------\n\nbool sequence::in(int value) {\n object val = number(value);\n return in(val);\n};\n \nbool sequence::in(double value) {\n object val = number(value);\n return in(val);\n};\n\nbool sequence::in(char* value) {\n object val = str(value);\n return in(val);\n};\n\nbool sequence::in(std::string value) {\n object val = str(value.c_str());\n return in(val);\n};\n \nint sequence::count(int value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(double value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(char* value) const {\n str val = str(value);\n return count(val);\n};\n\nint sequence::count(std::string value) const {\n str val = str(value.c_str());\n return count(val);\n};\n\nint sequence::index(int value) const {\n number val = number(value);\n return index(val);\n};\n\nint sequence::index(double value) const {\n number val = number(value);\n return index(val);\n};\nint sequence::index(char* value) const {\n str val = str(value);\n return index(val);\n};\n\nint sequence::index(std::string value) const {\n str val = str(value.c_str());\n return index(val);\n};\n\n//---------------------------------------------------------------------------\n// tuple\n//---------------------------------------------------------------------------\n\ntuple::tuple(const list& lst)\n : sequence (PyList_AsTuple(lst)) { LoseRef(_obj); }\n\n//---------------------------------------------------------------------------\n// tuple_member\n//---------------------------------------------------------------------------\n\ntuple_member::tuple_member(PyObject* obj, tuple& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\ntuple_member& tuple_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const tuple_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n//---------------------------------------------------------------------------\n// list\n//---------------------------------------------------------------------------\n \nlist& list::insert(int ndx, int other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, double other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, char* other) {\n str oth = str(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, std::string other) {\n str oth = str(other.c_str());\n return insert(ndx, oth);\n};\n\n//---------------------------------------------------------------------------\n// list_member\n//---------------------------------------------------------------------------\n\nlist_member::list_member(PyObject* obj, list& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\nlist_member& list_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const list_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// dict_member\n//---------------------------------------------------------------------------\n\ndict_member& dict_member::operator=(const object& other) {\n GrabRef(other);\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_key, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// callable\n//---------------------------------------------------------------------------\n\nobject callable::call() const {\n static tuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid py::Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"sequence.h\"\n#include \"list.h\"\n#include \"tuple.h\"\n#include \"str.h\"\n#include \"dict.h\"\n#include \"callable.h\"\n#include \"number.h\"\n\nusing namespace py;\n \n//---------------------------------------------------------------------------\n// object\n//---------------------------------------------------------------------------\n\n// incref new owner, and decref old owner, and adjust to new owner\nvoid object::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\nobject object::mcall(const char* nm)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(result);\n}\n\nobject object::mcall(const char* nm, tuple& args)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(result);\n}\n\nobject object::mcall(const char* nm, tuple& args, dict& kwargs)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args,kwargs);\n if (!result)\n throw 1; // signal exception has occured.\n return object(result);\n}\n\nobject object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(rslt);\n}\nobject object::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return object(rslt);\n}\nobject object::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return object(rslt);\n}\n\n//---------------------------------------------------------------------------\n// sequence\n//---------------------------------------------------------------------------\n\nbool sequence::in(int value) {\n object val = number(value);\n return in(val);\n};\n \nbool sequence::in(double value) {\n object val = number(value);\n return in(val);\n};\n\nbool sequence::in(char* value) {\n object val = str(value);\n return in(val);\n};\n\nbool sequence::in(std::string value) {\n object val = str(value.c_str());\n return in(val);\n};\n \nint sequence::count(int value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(double value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(char* value) const {\n str val = str(value);\n return count(val);\n};\n\nint sequence::count(std::string value) const {\n str val = str(value.c_str());\n return count(val);\n};\n\nint sequence::index(int value) const {\n number val = number(value);\n return index(val);\n};\n\nint sequence::index(double value) const {\n number val = number(value);\n return index(val);\n};\nint sequence::index(char* value) const {\n str val = str(value);\n return index(val);\n};\n\nint sequence::index(std::string value) const {\n str val = str(value.c_str());\n return index(val);\n};\n\n//---------------------------------------------------------------------------\n// tuple\n//---------------------------------------------------------------------------\n\ntuple::tuple(const list& lst)\n : sequence (PyList_AsTuple(lst)) { LoseRef(_obj); }\n\n//---------------------------------------------------------------------------\n// tuple_member\n//---------------------------------------------------------------------------\n\ntuple_member::tuple_member(PyObject* obj, tuple& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\ntuple_member& tuple_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const tuple_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n//---------------------------------------------------------------------------\n// list\n//---------------------------------------------------------------------------\n \nlist& list::insert(int ndx, int other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, double other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, char* other) {\n str oth = str(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, std::string other) {\n str oth = str(other.c_str());\n return insert(ndx, oth);\n};\n\n//---------------------------------------------------------------------------\n// list_member\n//---------------------------------------------------------------------------\n\nlist_member::list_member(PyObject* obj, list& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\nlist_member& list_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const list_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// dict_member\n//---------------------------------------------------------------------------\n\ndict_member& dict_member::operator=(const object& other) {\n GrabRef(other);\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_key, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// callable\n//---------------------------------------------------------------------------\n\nobject callable::call() const {\n static tuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid py::Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}", "methods": [ { "name": "object::GrabRef", "long_name": "object::GrabRef( PyObject * newObj)", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 20, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 28, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args" ], "start_line": 37, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args , dict & kwargs)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args", "kwargs" ], "start_line": 46, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call() const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args", "kws" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( int value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 78, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( double value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 83, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( char * value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 88, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( std :: string value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 93, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 103, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 113, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 118, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 123, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 127, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 132, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "tuple::tuple", "long_name": "tuple::tuple( const list & lst)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "lst" ], "start_line": 141, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::tuple_member", "long_name": "tuple_member::tuple_member( PyObject * obj , tuple & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 151, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const tuple_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 158, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 165, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 183, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , int other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , double other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 197, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , char * other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 202, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , std :: string other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 207, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::list_member", "long_name": "list_member::list_member( PyObject * obj , list & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 216, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 219, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const list_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 226, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 245, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 251, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 261, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 267, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 273, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 279, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 285, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call() const", "filename": "weave_imp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 295, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 302, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 308, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "py::Fail", "long_name": "py::Fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 315, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "object::GrabRef", "long_name": "object::GrabRef( PyObject * newObj)", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 20, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 46, "parameters": [ "nm" ], "start_line": 28, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 50, "parameters": [ "nm", "args" ], "start_line": 37, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args , dict & kwargs)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 54, "parameters": [ "nm", "args", "kwargs" ], "start_line": 46, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call() const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "args" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "args", "kws" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( int value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 78, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( double value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 83, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( char * value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 88, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( std :: string value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 93, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 103, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 113, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 118, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 123, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 127, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 132, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "tuple::tuple", "long_name": "tuple::tuple( const list & lst)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "lst" ], "start_line": 141, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::tuple_member", "long_name": "tuple_member::tuple_member( PyObject * obj , tuple & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 151, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const tuple_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 158, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 165, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 183, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , int other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , double other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 197, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , char * other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 202, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , std :: string other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 207, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::list_member", "long_name": "list_member::list_member( PyObject * obj , list & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 216, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 219, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const list_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 226, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 245, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 251, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 261, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 267, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 273, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 279, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 285, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call() const", "filename": "weave_imp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 295, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 302, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 308, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "py::Fail", "long_name": "py::Fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 315, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args" ], "start_line": 37, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args , dict & kwargs)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args", "kwargs" ], "start_line": 46, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 28, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args", "kws" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call() const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "nloc": 235, "complexity": 56, "token_count": 1630, "diff_parsed": { "added": [ " return object(LoseRef(result));", " return object(LoseRef(result));", " return object(LoseRef(result));", " return object(LoseRef(rslt));", " return object(LoseRef(rslt));", " return object(LoseRef(rslt));" ], "deleted": [ " return object(result);", " return object(result);", " return object(result);", " return object(rslt);", " return object(rslt);", " return object(rslt);" ] } }, { "old_path": "weave/standard_array_spec.py", "new_path": "weave/standard_array_spec.py", "filename": "standard_array_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -120,6 +120,7 @@ def init_info(self):\n self.type_name = 'numpy'\n self.check_func = 'PyArray_Check' \n self.c_type = 'PyArrayObject*'\n+ self.return_type = 'PyArrayObject*'\n self.to_c_return = '(PyArrayObject*) py_obj'\n self.matching_types = [ArrayType]\n self.headers = ['\"Numeric/arrayobject.h\"','','']\n", "added_lines": 1, "deleted_lines": 0, "source_code": "from c_spec import common_base_converter\nfrom c_spec import num_to_c_types\nfrom Numeric import *\nfrom types import *\nimport os\n\nnum_typecode = {}\nnum_typecode['c'] = 'PyArray_CHAR'\nnum_typecode['1'] = 'PyArray_SBYTE'\nnum_typecode['b'] = 'PyArray_UBYTE'\nnum_typecode['s'] = 'PyArray_SHORT'\nnum_typecode['i'] = 'PyArray_INT' # PyArray_INT has troubles ?? What does this note mean ??\nnum_typecode['l'] = 'PyArray_LONG'\nnum_typecode['f'] = 'PyArray_FLOAT'\nnum_typecode['d'] = 'PyArray_DOUBLE'\nnum_typecode['F'] = 'PyArray_CFLOAT'\nnum_typecode['D'] = 'PyArray_CDOUBLE'\n\ntype_check_code = \\\n\"\"\"\nclass numpy_type_handler\n{\npublic:\n void conversion_numpy_check_type(PyArrayObject* arr_obj, int numeric_type,\n const char* name)\n {\n // Make sure input has correct numeric type.\n // allow character and byte to match\n // also allow int and long to match\n int arr_type = arr_obj->descr->type_num;\n if ( arr_type != numeric_type &&\n !(numeric_type == PyArray_CHAR && arr_type == PyArray_SBYTE) &&\n !(numeric_type == PyArray_SBYTE && arr_type == PyArray_CHAR) &&\n !(numeric_type == PyArray_INT && arr_type == PyArray_LONG) &&\n !(numeric_type == PyArray_LONG && arr_type == PyArray_INT)) \n {\n char* type_names[20] = {\"char\",\"unsigned byte\",\"byte\", \"short\", \"int\", \n \"long\", \"float\", \"double\", \"complex float\",\n \"complex double\", \"object\",\"ntype\",\"unkown\"};\n char msg[500];\n sprintf(msg,\"Conversion Error: received '%s' typed array instead of '%s' typed array for variable '%s'\",\n type_names[arr_type],type_names[numeric_type],name);\n throw_error(PyExc_TypeError,msg); \n }\n }\n \n void numpy_check_type(PyArrayObject* arr_obj, int numeric_type, const char* name)\n {\n // Make sure input has correct numeric type.\n int arr_type = arr_obj->descr->type_num;\n if ( arr_type != numeric_type &&\n !(numeric_type == PyArray_CHAR && arr_type == PyArray_SBYTE) &&\n !(numeric_type == PyArray_SBYTE && arr_type == PyArray_CHAR) &&\n !(numeric_type == PyArray_INT && arr_type == PyArray_LONG) &&\n !(numeric_type == PyArray_LONG && arr_type == PyArray_INT)) \n {\n char* type_names[13] = {\"char\",\"unsigned byte\",\"byte\", \"short\", \"int\", \n \"long\", \"float\", \"double\", \"complex float\",\n \"complex double\", \"object\",\"ntype\",\"unkown\"};\n char msg[500];\n sprintf(msg,\"received '%s' typed array instead of '%s' typed array for variable '%s'\",\n type_names[arr_type],type_names[numeric_type],name);\n throw_error(PyExc_TypeError,msg); \n }\n }\n};\n\nnumpy_type_handler x__numpy_type_handler = numpy_type_handler();\n#define conversion_numpy_check_type x__numpy_type_handler.conversion_numpy_check_type\n#define numpy_check_type x__numpy_type_handler.numpy_check_type\n\n\"\"\"\n\nsize_check_code = \\\n\"\"\"\nclass numpy_size_handler\n{\npublic:\n void conversion_numpy_check_size(PyArrayObject* arr_obj, int Ndims, \n const char* name)\n {\n if (arr_obj->nd != Ndims)\n {\n char msg[500];\n sprintf(msg,\"Conversion Error: received '%d' dimensional array instead of '%d' dimensional array for variable '%s'\",\n arr_obj->nd,Ndims,name);\n throw_error(PyExc_TypeError,msg);\n } \n }\n \n void numpy_check_size(PyArrayObject* arr_obj, int Ndims, const char* name)\n {\n if (arr_obj->nd != Ndims)\n {\n char msg[500];\n sprintf(msg,\"received '%d' dimensional array instead of '%d' dimensional array for variable '%s'\",\n arr_obj->nd,Ndims,name);\n throw_error(PyExc_TypeError,msg);\n } \n }\n};\n\nnumpy_size_handler x__numpy_size_handler = numpy_size_handler();\n#define conversion_numpy_check_size x__numpy_size_handler.conversion_numpy_check_size\n#define numpy_check_size x__numpy_size_handler.numpy_check_size\n\n\"\"\"\n\nnumeric_init_code = \\\n\"\"\"\nPy_Initialize();\nimport_array();\nPyImport_ImportModule(\"Numeric\");\n\"\"\"\n \nclass array_converter(common_base_converter):\n\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'numpy'\n self.check_func = 'PyArray_Check' \n self.c_type = 'PyArrayObject*'\n self.return_type = 'PyArrayObject*'\n self.to_c_return = '(PyArrayObject*) py_obj'\n self.matching_types = [ArrayType]\n self.headers = ['\"Numeric/arrayobject.h\"','','']\n self.support_code = [size_check_code, type_check_code]\n self.module_init_code = [numeric_init_code] \n \n def get_var_type(self,value):\n return value.typecode()\n \n def template_vars(self,inline=0):\n res = common_base_converter.template_vars(self,inline) \n if hasattr(self,'var_type'):\n res['num_type'] = num_to_c_types[self.var_type]\n res['num_typecode'] = num_typecode[self.var_type]\n res['array_name'] = self.name + \"_array\"\n return res\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(array_name)s = %(var_convert)s;\\n' \\\n 'conversion_numpy_check_type(%(array_name)s,%(num_typecode)s,\"%(name)s\");\\n' \\\n 'int* N%(name)s = %(array_name)s->dimensions;\\n' \\\n 'int* S%(name)s = %(array_name)s->strides;\\n' \\\n 'int D%(name)s = %(array_name)s->nd;\\n' \\\n '%(num_type)s* %(name)s = (%(num_type)s*) %(array_name)s->data;\\n' \n code = code % self.template_vars(inline=inline)\n return code\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "source_code_before": "from c_spec import common_base_converter\nfrom c_spec import num_to_c_types\nfrom Numeric import *\nfrom types import *\nimport os\n\nnum_typecode = {}\nnum_typecode['c'] = 'PyArray_CHAR'\nnum_typecode['1'] = 'PyArray_SBYTE'\nnum_typecode['b'] = 'PyArray_UBYTE'\nnum_typecode['s'] = 'PyArray_SHORT'\nnum_typecode['i'] = 'PyArray_INT' # PyArray_INT has troubles ?? What does this note mean ??\nnum_typecode['l'] = 'PyArray_LONG'\nnum_typecode['f'] = 'PyArray_FLOAT'\nnum_typecode['d'] = 'PyArray_DOUBLE'\nnum_typecode['F'] = 'PyArray_CFLOAT'\nnum_typecode['D'] = 'PyArray_CDOUBLE'\n\ntype_check_code = \\\n\"\"\"\nclass numpy_type_handler\n{\npublic:\n void conversion_numpy_check_type(PyArrayObject* arr_obj, int numeric_type,\n const char* name)\n {\n // Make sure input has correct numeric type.\n // allow character and byte to match\n // also allow int and long to match\n int arr_type = arr_obj->descr->type_num;\n if ( arr_type != numeric_type &&\n !(numeric_type == PyArray_CHAR && arr_type == PyArray_SBYTE) &&\n !(numeric_type == PyArray_SBYTE && arr_type == PyArray_CHAR) &&\n !(numeric_type == PyArray_INT && arr_type == PyArray_LONG) &&\n !(numeric_type == PyArray_LONG && arr_type == PyArray_INT)) \n {\n char* type_names[20] = {\"char\",\"unsigned byte\",\"byte\", \"short\", \"int\", \n \"long\", \"float\", \"double\", \"complex float\",\n \"complex double\", \"object\",\"ntype\",\"unkown\"};\n char msg[500];\n sprintf(msg,\"Conversion Error: received '%s' typed array instead of '%s' typed array for variable '%s'\",\n type_names[arr_type],type_names[numeric_type],name);\n throw_error(PyExc_TypeError,msg); \n }\n }\n \n void numpy_check_type(PyArrayObject* arr_obj, int numeric_type, const char* name)\n {\n // Make sure input has correct numeric type.\n int arr_type = arr_obj->descr->type_num;\n if ( arr_type != numeric_type &&\n !(numeric_type == PyArray_CHAR && arr_type == PyArray_SBYTE) &&\n !(numeric_type == PyArray_SBYTE && arr_type == PyArray_CHAR) &&\n !(numeric_type == PyArray_INT && arr_type == PyArray_LONG) &&\n !(numeric_type == PyArray_LONG && arr_type == PyArray_INT)) \n {\n char* type_names[13] = {\"char\",\"unsigned byte\",\"byte\", \"short\", \"int\", \n \"long\", \"float\", \"double\", \"complex float\",\n \"complex double\", \"object\",\"ntype\",\"unkown\"};\n char msg[500];\n sprintf(msg,\"received '%s' typed array instead of '%s' typed array for variable '%s'\",\n type_names[arr_type],type_names[numeric_type],name);\n throw_error(PyExc_TypeError,msg); \n }\n }\n};\n\nnumpy_type_handler x__numpy_type_handler = numpy_type_handler();\n#define conversion_numpy_check_type x__numpy_type_handler.conversion_numpy_check_type\n#define numpy_check_type x__numpy_type_handler.numpy_check_type\n\n\"\"\"\n\nsize_check_code = \\\n\"\"\"\nclass numpy_size_handler\n{\npublic:\n void conversion_numpy_check_size(PyArrayObject* arr_obj, int Ndims, \n const char* name)\n {\n if (arr_obj->nd != Ndims)\n {\n char msg[500];\n sprintf(msg,\"Conversion Error: received '%d' dimensional array instead of '%d' dimensional array for variable '%s'\",\n arr_obj->nd,Ndims,name);\n throw_error(PyExc_TypeError,msg);\n } \n }\n \n void numpy_check_size(PyArrayObject* arr_obj, int Ndims, const char* name)\n {\n if (arr_obj->nd != Ndims)\n {\n char msg[500];\n sprintf(msg,\"received '%d' dimensional array instead of '%d' dimensional array for variable '%s'\",\n arr_obj->nd,Ndims,name);\n throw_error(PyExc_TypeError,msg);\n } \n }\n};\n\nnumpy_size_handler x__numpy_size_handler = numpy_size_handler();\n#define conversion_numpy_check_size x__numpy_size_handler.conversion_numpy_check_size\n#define numpy_check_size x__numpy_size_handler.numpy_check_size\n\n\"\"\"\n\nnumeric_init_code = \\\n\"\"\"\nPy_Initialize();\nimport_array();\nPyImport_ImportModule(\"Numeric\");\n\"\"\"\n \nclass array_converter(common_base_converter):\n\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'numpy'\n self.check_func = 'PyArray_Check' \n self.c_type = 'PyArrayObject*'\n self.to_c_return = '(PyArrayObject*) py_obj'\n self.matching_types = [ArrayType]\n self.headers = ['\"Numeric/arrayobject.h\"','','']\n self.support_code = [size_check_code, type_check_code]\n self.module_init_code = [numeric_init_code] \n \n def get_var_type(self,value):\n return value.typecode()\n \n def template_vars(self,inline=0):\n res = common_base_converter.template_vars(self,inline) \n if hasattr(self,'var_type'):\n res['num_type'] = num_to_c_types[self.var_type]\n res['num_typecode'] = num_typecode[self.var_type]\n res['array_name'] = self.name + \"_array\"\n return res\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(array_name)s = %(var_convert)s;\\n' \\\n 'conversion_numpy_check_type(%(array_name)s,%(num_typecode)s,\"%(name)s\");\\n' \\\n 'int* N%(name)s = %(array_name)s->dimensions;\\n' \\\n 'int* S%(name)s = %(array_name)s->strides;\\n' \\\n 'int D%(name)s = %(array_name)s->nd;\\n' \\\n '%(num_type)s* %(name)s = (%(num_type)s*) %(array_name)s->data;\\n' \n code = code % self.template_vars(inline=inline)\n return code\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "standard_array_spec.py", "nloc": 11, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 118, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "standard_array_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "value" ], "start_line": 130, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "standard_array_spec.py", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "self", "inline" ], "start_line": 133, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "standard_array_spec.py", "nloc": 10, "complexity": 1, "token_count": 42, "parameters": [ "self", "templatize", "inline" ], "start_line": 141, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "standard_array_spec.py", "nloc": 10, "complexity": 1, "token_count": 65, "parameters": [ "self" ], "start_line": 118, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "standard_array_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "value" ], "start_line": 129, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "standard_array_spec.py", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "self", "inline" ], "start_line": 132, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "standard_array_spec.py", "nloc": 10, "complexity": 1, "token_count": 42, "parameters": [ "self", "templatize", "inline" ], "start_line": 140, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 151, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 155, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "standard_array_spec.py", "nloc": 11, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 118, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "nloc": 147, "complexity": 7, "token_count": 339, "diff_parsed": { "added": [ " self.return_type = 'PyArrayObject*'" ], "deleted": [] } }, { "old_path": "weave/tests/test_c_spec.py", "new_path": "weave/tests/test_c_spec.py", "filename": "test_c_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -242,7 +242,6 @@ def check_file_to_py(self):\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n- Py_XINCREF(return_val);\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n@@ -275,7 +274,7 @@ def check_call_function(self):\n py::tuple args(2);\n args[0] = search_str;\n args[1] = sub_str;\n- return_val = func.call(args).disown();\n+ return_val = func.call(args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n@@ -393,7 +392,7 @@ def check_return(self):\n code = \"\"\"\n a=py::list();\n a.append(\"hello\");\n- return_val = a.disown();\n+ return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n@@ -507,7 +506,7 @@ def check_return(self):\n a=py::tuple(2);\n a[0] = \"hello\";\n a.set_item(1,py::None);\n- return_val = a.disown();\n+ return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n@@ -558,7 +557,7 @@ def check_return(self):\n code = \"\"\"\n a=py::dict();\n a[\"hello\"] = 5;\n- return_val = a.disown();\n+ return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n", "added_lines": 4, "deleted_lines": 5, "source_code": "import unittest\nimport time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nimport ext_tools\nfrom catalog import unique_file\nfrom build_tools import msvc_exists, gcc_exists\nimport c_spec\nrestore_path()\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n compiler = ''\n def check_py_to_file(self):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n compiler=''\n def check_call_function(self):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n py::tuple args(2);\n args[0] = search_str;\n args[1] = sub_str;\n return_val = func.call(args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(unittest.TestCase): \n compiler = ''\n def check_convert_to_dict(self):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=py::list();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=py::list();\n a.append(\"hello\");\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n py::number v = py::number();\n int vv, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n vv = (int)v;\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=py::tuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=py::tuple(2);\n a[0] = \"hello\";\n a.set_item(1,py::None);\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=py::dict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=py::dict();\n a[\"hello\"] = 5;\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n \ndef test_suite(level=1):\n from unittest import makeSuite\n global test_dir\n test_dir = setup_test_location()\n suites = [] \n if level >= 5:\n if msvc_exists():\n suites.append( makeSuite(test_msvc_file_converter,'check_'))\n suites.append( makeSuite(test_msvc_instance_converter,'check_'))\n suites.append( makeSuite(test_msvc_callable_converter,'check_'))\n suites.append( makeSuite(test_msvc_sequence_converter,'check_'))\n suites.append( makeSuite(test_msvc_string_converter,'check_'))\n suites.append( makeSuite(test_msvc_list_converter,'check_'))\n suites.append( makeSuite(test_msvc_tuple_converter,'check_'))\n suites.append( makeSuite(test_msvc_dict_converter,'check_'))\n suites.append( makeSuite(test_msvc_int_converter,'check_'))\n suites.append( makeSuite(test_msvc_float_converter,'check_')) \n suites.append( makeSuite(test_msvc_complex_converter,'check_'))\n else: # unix\n suites.append( makeSuite(test_unix_file_converter,'check_'))\n suites.append( makeSuite(test_unix_instance_converter,'check_'))\n suites.append( makeSuite(test_unix_callable_converter,'check_'))\n suites.append( makeSuite(test_unix_sequence_converter,'check_'))\n suites.append( makeSuite(test_unix_string_converter,'check_'))\n suites.append( makeSuite(test_unix_list_converter,'check_'))\n suites.append( makeSuite(test_unix_tuple_converter,'check_'))\n suites.append( makeSuite(test_unix_dict_converter,'check_'))\n suites.append( makeSuite(test_unix_int_converter,'check_'))\n suites.append( makeSuite(test_unix_float_converter,'check_')) \n suites.append( makeSuite(test_unix_complex_converter,'check_')) \n # run gcc tests also on windows\n if gcc_exists() and sys.platform == 'win32': \n suites.append( makeSuite(test_gcc_file_converter,'check_'))\n suites.append( makeSuite(test_gcc_instance_converter,'check_'))\n suites.append( makeSuite(test_gcc_callable_converter,'check_'))\n suites.append( makeSuite(test_gcc_sequence_converter,'check_'))\n suites.append( makeSuite(test_gcc_string_converter,'check_'))\n suites.append( makeSuite(test_gcc_list_converter,'check_'))\n suites.append( makeSuite(test_gcc_tuple_converter,'check_'))\n suites.append( makeSuite(test_gcc_dict_converter,'check_'))\n suites.append( makeSuite(test_gcc_int_converter,'check_'))\n suites.append( makeSuite(test_gcc_float_converter,'check_')) \n suites.append( makeSuite(test_gcc_complex_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "import unittest\nimport time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nimport ext_tools\nfrom catalog import unique_file\nfrom build_tools import msvc_exists, gcc_exists\nimport c_spec\nrestore_path()\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n compiler = ''\n def check_py_to_file(self):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n Py_XINCREF(return_val);\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n compiler=''\n def check_call_function(self):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n py::tuple args(2);\n args[0] = search_str;\n args[1] = sub_str;\n return_val = func.call(args).disown();\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(unittest.TestCase): \n compiler = ''\n def check_convert_to_dict(self):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=py::list();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=py::list();\n a.append(\"hello\");\n return_val = a.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n py::number v = py::number();\n int vv, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n vv = (int)v;\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=py::tuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=py::tuple(2);\n a[0] = \"hello\";\n a.set_item(1,py::None);\n return_val = a.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=py::dict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=py::dict();\n a[\"hello\"] = 5;\n return_val = a.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n \ndef test_suite(level=1):\n from unittest import makeSuite\n global test_dir\n test_dir = setup_test_location()\n suites = [] \n if level >= 5:\n if msvc_exists():\n suites.append( makeSuite(test_msvc_file_converter,'check_'))\n suites.append( makeSuite(test_msvc_instance_converter,'check_'))\n suites.append( makeSuite(test_msvc_callable_converter,'check_'))\n suites.append( makeSuite(test_msvc_sequence_converter,'check_'))\n suites.append( makeSuite(test_msvc_string_converter,'check_'))\n suites.append( makeSuite(test_msvc_list_converter,'check_'))\n suites.append( makeSuite(test_msvc_tuple_converter,'check_'))\n suites.append( makeSuite(test_msvc_dict_converter,'check_'))\n suites.append( makeSuite(test_msvc_int_converter,'check_'))\n suites.append( makeSuite(test_msvc_float_converter,'check_')) \n suites.append( makeSuite(test_msvc_complex_converter,'check_'))\n else: # unix\n suites.append( makeSuite(test_unix_file_converter,'check_'))\n suites.append( makeSuite(test_unix_instance_converter,'check_'))\n suites.append( makeSuite(test_unix_callable_converter,'check_'))\n suites.append( makeSuite(test_unix_sequence_converter,'check_'))\n suites.append( makeSuite(test_unix_string_converter,'check_'))\n suites.append( makeSuite(test_unix_list_converter,'check_'))\n suites.append( makeSuite(test_unix_tuple_converter,'check_'))\n suites.append( makeSuite(test_unix_dict_converter,'check_'))\n suites.append( makeSuite(test_unix_int_converter,'check_'))\n suites.append( makeSuite(test_unix_float_converter,'check_')) \n suites.append( makeSuite(test_unix_complex_converter,'check_')) \n # run gcc tests also on windows\n if gcc_exists() and sys.platform == 'win32': \n suites.append( makeSuite(test_gcc_file_converter,'check_'))\n suites.append( makeSuite(test_gcc_instance_converter,'check_'))\n suites.append( makeSuite(test_gcc_callable_converter,'check_'))\n suites.append( makeSuite(test_gcc_sequence_converter,'check_'))\n suites.append( makeSuite(test_gcc_string_converter,'check_'))\n suites.append( makeSuite(test_gcc_list_converter,'check_'))\n suites.append( makeSuite(test_gcc_tuple_converter,'check_'))\n suites.append( makeSuite(test_gcc_dict_converter,'check_'))\n suites.append( makeSuite(test_gcc_int_converter,'check_'))\n suites.append( makeSuite(test_gcc_float_converter,'check_')) \n suites.append( makeSuite(test_gcc_complex_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "unique_mod", "long_name": "unique_mod( d , file_name )", "filename": "test_c_spec.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "d", "file_name" ], "start_line": 23, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 28, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_c_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 35, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 69, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 118, "parameters": [ "self" ], "start_line": 124, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 148, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 179, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 106, "parameters": [ "self" ], "start_line": 202, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 225, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 14, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 266, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 286, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 289, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 292, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 295, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 301, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 304, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 307, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 310, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 313, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 89, "parameters": [ "self" ], "start_line": 337, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 356, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 361, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 114, "parameters": [ "self" ], "start_line": 364, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 387, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 61, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 405, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 469, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 474, "end_line": 476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 115, "parameters": [ "self" ], "start_line": 477, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 500, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 521, "end_line": 525, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 526, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 529, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 552, "end_line": 568, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [], "start_line": 650, "end_line": 657, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 661, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 44, "complexity": 5, "token_count": 418, "parameters": [ "level" ], "start_line": 671, "end_line": 716, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 718, "end_line": 722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "unique_mod", "long_name": "unique_mod( d , file_name )", "filename": "test_c_spec.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "d", "file_name" ], "start_line": 23, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 28, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_c_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 35, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 69, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 118, "parameters": [ "self" ], "start_line": 124, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 148, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 179, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 106, "parameters": [ "self" ], "start_line": 202, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 225, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 267, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 287, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 290, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 293, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 296, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 302, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 308, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 311, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 314, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 89, "parameters": [ "self" ], "start_line": 338, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 357, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 362, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 114, "parameters": [ "self" ], "start_line": 365, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 388, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 61, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 406, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 470, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 475, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 115, "parameters": [ "self" ], "start_line": 478, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 501, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 522, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 527, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 530, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 553, "end_line": 569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [], "start_line": 651, "end_line": 658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 662, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 44, "complexity": 5, "token_count": 418, "parameters": [ "level" ], "start_line": 672, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 719, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 387, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 266, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "nloc": 647, "complexity": 79, "token_count": 3824, "diff_parsed": { "added": [ " return_val = func.call(args);", " return_val = a;", " return_val = a;", " return_val = a;" ], "deleted": [ " Py_XINCREF(return_val);", " return_val = func.call(args).disown();", " return_val = a.disown();", " return_val = a.disown();", " return_val = a.disown();" ] } }, { "old_path": "weave/tests/test_ext_tools.py", "new_path": "weave/tests/test_ext_tools.py", "filename": "test_ext_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -87,7 +87,7 @@ def check_return_tuple(self):\n py::tuple returned(2);\n returned[0] = a;\n returned[1] = b;\n- return_val = returned.disown();\n+ return_val = returned;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n", "added_lines": 1, "deleted_lines": 1, "source_code": "import unittest\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport ext_tools\ntry:\n from standard_array_spec import array_converter\nexcept ImportError:\n pass # requires Numeric \nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\nbuild_dir = empty_temp_dir()\nprint 'building extensions here:', build_dir \n\nclass test_ext_module(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self):\n \"\"\" Simplest possible module \"\"\"\n mod = ext_tools.ext_module('simple_ext_module')\n mod.compile(location = build_dir)\n import simple_ext_module\n def check_multi_functions(self):\n mod = ext_tools.ext_module('module_multi_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n test2 = ext_tools.ext_function_from_specs('test2',code,var_specs)\n mod.add_function(test2)\n mod.compile(location = build_dir)\n import module_multi_function\n module_multi_function.test()\n module_multi_function.test2()\n def check_with_include(self):\n # decalaring variables\n a = 2.;\n \n # declare module\n mod = ext_tools.ext_module('ext_module_with_include')\n mod.customize.add_header('')\n \n # function 2 --> a little more complex expression\n var_specs = ext_tools.assign_variable_types(['a'],locals(),globals())\n code = \"\"\"\n std::cout << std::endl;\n std::cout << \"test printing a value:\" << a << std::endl;\n \"\"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n # build module\n mod.compile(location = build_dir)\n import ext_module_with_include\n ext_module_with_include.test(a)\n\n def check_string_and_int(self): \n # decalaring variables\n a = 2;b = 'string' \n # declare module\n mod = ext_tools.ext_module('ext_string_and_int')\n code = \"\"\"\n a=b.length();\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a','b'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_string_and_int\n c = ext_string_and_int.test(a,b)\n assert(c == len(b))\n \n def check_return_tuple(self): \n # decalaring variables\n a = 2 \n # declare module\n mod = ext_tools.ext_module('ext_return_tuple')\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n int b;\n b = a + 1;\n py::tuple returned(2);\n returned[0] = a;\n returned[1] = b;\n return_val = returned;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_return_tuple\n c,d = ext_return_tuple.test(a)\n assert(c==a and d == a+1)\n \nclass test_ext_function(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self):\n \"\"\" Simplest possible function \"\"\"\n mod = ext_tools.ext_module('simple_ext_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n mod.compile(location = build_dir)\n import simple_ext_function\n simple_ext_function.test()\n \nclass test_assign_variable_types(unittest.TestCase): \n def check_assign_variable_types(self):\n try:\n from Numeric import arange, Float32, Float64\n except:\n # skip this test if Numeric not installed\n return\n \n import types\n a = arange(10,typecode = Float32)\n b = arange(5,typecode = Float64)\n c = 5\n arg_list = ['a','b','c']\n actual = ext_tools.assign_variable_types(arg_list,locals()) \n #desired = {'a':(Float32,1),'b':(Float32,1),'i':(Int32,0)}\n \n ad = array_converter()\n ad.name, ad.var_type, ad.dims = 'a', Float32, 1\n bd = array_converter()\n bd.name, bd.var_type, bd.dims = 'b', Float64, 1\n import c_spec\n cd = c_spec.int_converter()\n cd.name, cd.var_type = 'c', types.IntType \n desired = [ad,bd,cd]\n expr = \"\"\n print_assert_equal(expr,actual,desired)\n\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_assign_variable_types,'check_'))\n if level >= 5: \n suites.append( unittest.makeSuite(test_ext_module,'check_'))\n suites.append( unittest.makeSuite(test_ext_function,'check_')) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "import unittest\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport ext_tools\ntry:\n from standard_array_spec import array_converter\nexcept ImportError:\n pass # requires Numeric \nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\nbuild_dir = empty_temp_dir()\nprint 'building extensions here:', build_dir \n\nclass test_ext_module(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self):\n \"\"\" Simplest possible module \"\"\"\n mod = ext_tools.ext_module('simple_ext_module')\n mod.compile(location = build_dir)\n import simple_ext_module\n def check_multi_functions(self):\n mod = ext_tools.ext_module('module_multi_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n test2 = ext_tools.ext_function_from_specs('test2',code,var_specs)\n mod.add_function(test2)\n mod.compile(location = build_dir)\n import module_multi_function\n module_multi_function.test()\n module_multi_function.test2()\n def check_with_include(self):\n # decalaring variables\n a = 2.;\n \n # declare module\n mod = ext_tools.ext_module('ext_module_with_include')\n mod.customize.add_header('')\n \n # function 2 --> a little more complex expression\n var_specs = ext_tools.assign_variable_types(['a'],locals(),globals())\n code = \"\"\"\n std::cout << std::endl;\n std::cout << \"test printing a value:\" << a << std::endl;\n \"\"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n # build module\n mod.compile(location = build_dir)\n import ext_module_with_include\n ext_module_with_include.test(a)\n\n def check_string_and_int(self): \n # decalaring variables\n a = 2;b = 'string' \n # declare module\n mod = ext_tools.ext_module('ext_string_and_int')\n code = \"\"\"\n a=b.length();\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a','b'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_string_and_int\n c = ext_string_and_int.test(a,b)\n assert(c == len(b))\n \n def check_return_tuple(self): \n # decalaring variables\n a = 2 \n # declare module\n mod = ext_tools.ext_module('ext_return_tuple')\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n int b;\n b = a + 1;\n py::tuple returned(2);\n returned[0] = a;\n returned[1] = b;\n return_val = returned.disown();\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_return_tuple\n c,d = ext_return_tuple.test(a)\n assert(c==a and d == a+1)\n \nclass test_ext_function(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self):\n \"\"\" Simplest possible function \"\"\"\n mod = ext_tools.ext_module('simple_ext_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n mod.compile(location = build_dir)\n import simple_ext_function\n simple_ext_function.test()\n \nclass test_assign_variable_types(unittest.TestCase): \n def check_assign_variable_types(self):\n try:\n from Numeric import arange, Float32, Float64\n except:\n # skip this test if Numeric not installed\n return\n \n import types\n a = arange(10,typecode = Float32)\n b = arange(5,typecode = Float64)\n c = 5\n arg_list = ['a','b','c']\n actual = ext_tools.assign_variable_types(arg_list,locals()) \n #desired = {'a':(Float32,1),'b':(Float32,1),'i':(Int32,0)}\n \n ad = array_converter()\n ad.name, ad.var_type, ad.dims = 'a', Float32, 1\n bd = array_converter()\n bd.name, bd.var_type, bd.dims = 'b', Float64, 1\n import c_spec\n cd = c_spec.int_converter()\n cd.name, cd.var_type = 'c', types.IntType \n desired = [ad,bd,cd]\n expr = \"\"\n print_assert_equal(expr,actual,desired)\n\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_assign_variable_types,'check_'))\n if level >= 5: \n suites.append( unittest.makeSuite(test_ext_module,'check_'))\n suites.append( unittest.makeSuite(test_ext_function,'check_')) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 24, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_multi_functions", "long_name": "check_multi_functions( self )", "filename": "test_ext_tools.py", "nloc": 12, "complexity": 1, "token_count": 76, "parameters": [ "self" ], "start_line": 29, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_with_include", "long_name": "check_with_include( self )", "filename": "test_ext_tools.py", "nloc": 14, "complexity": 1, "token_count": 81, "parameters": [ "self" ], "start_line": 41, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_string_and_int", "long_name": "check_string_and_int( self )", "filename": "test_ext_tools.py", "nloc": 13, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 62, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_return_tuple", "long_name": "check_return_tuple( self )", "filename": "test_ext_tools.py", "nloc": 18, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 78, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 101, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_assign_variable_types", "long_name": "check_assign_variable_types( self )", "filename": "test_ext_tools.py", "nloc": 21, "complexity": 2, "token_count": 150, "parameters": [ "self" ], "start_line": 113, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 3, "token_count": 70, "parameters": [ "level" ], "start_line": 140, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 24, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_multi_functions", "long_name": "check_multi_functions( self )", "filename": "test_ext_tools.py", "nloc": 12, "complexity": 1, "token_count": 76, "parameters": [ "self" ], "start_line": 29, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_with_include", "long_name": "check_with_include( self )", "filename": "test_ext_tools.py", "nloc": 14, "complexity": 1, "token_count": 81, "parameters": [ "self" ], "start_line": 41, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_string_and_int", "long_name": "check_string_and_int( self )", "filename": "test_ext_tools.py", "nloc": 13, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 62, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_return_tuple", "long_name": "check_return_tuple( self )", "filename": "test_ext_tools.py", "nloc": 18, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 78, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 101, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_assign_variable_types", "long_name": "check_assign_variable_types( self )", "filename": "test_ext_tools.py", "nloc": 21, "complexity": 2, "token_count": 150, "parameters": [ "self" ], "start_line": 113, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 3, "token_count": 70, "parameters": [ "level" ], "start_line": 140, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_return_tuple", "long_name": "check_return_tuple( self )", "filename": "test_ext_tools.py", "nloc": 18, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 78, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "nloc": 126, "complexity": 13, "token_count": 740, "diff_parsed": { "added": [ " return_val = returned;" ], "deleted": [ " return_val = returned.disown();" ] } }, { "old_path": "weave/tests/test_scxx.py", "new_path": "weave/tests/test_scxx.py", "filename": "test_scxx.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -24,11 +24,12 @@ def check_conversion(self):\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n- \n+ print 'first:',before\n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n+ print '2nd,3rd:', before, after\n assert(after == before)\n \n def check_append_passed_item(self):\n@@ -193,7 +194,6 @@ def check_in(self):\n \"\"\"\n a = [1,2,'alpha',3.1416]\n \n- # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n@@ -240,7 +240,6 @@ def check_count(self):\n \"\"\"\n a = [1,2,'alpha',3.1416]\n \n- # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n@@ -321,7 +320,7 @@ def check_access_set_speed(self):\n print 'weave:', t2 - t1\n assert b == a \n \n- def _check_string_add_speed(self):\n+ def check_string_add_speed(self):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n@@ -373,29 +372,95 @@ def check_int_add_speed(self):\n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n+\n+class test_object_construct(unittest.TestCase):\n+ #------------------------------------------------------------------------\n+ # Check that construction from basic types is allowed and have correct\n+ # reference counts\n+ #------------------------------------------------------------------------\n+ def check_int(self):\n+ # strange int value used to try and make sure refcount is 2.\n+ code = \"\"\"\n+ py::object val = 1001;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == 1001\n+ def check_float(self):\n+ code = \"\"\"\n+ py::object val = (float)1.0;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == 1.0\n+ def check_double(self):\n+ code = \"\"\"\n+ py::object val = 1.0;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == 1.0\n+ def check_complex(self):\n+ code = \"\"\"\n+ std::complex num = std::complex(1.0,1.0);\n+ py::object val = num;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == 1.0+1.0j\n+ def check_string(self):\n+ code = \"\"\"\n+ py::object val = \"hello\";\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == \"hello\"\n+\n+ def check_std_string(self):\n+ code = \"\"\"\n+ std::string s = std::string(\"hello\");\n+ py::object val = s;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == \"hello\"\n+ \n \n class test_object_cast(unittest.TestCase):\n def check_int_cast(self):\n code = \"\"\"\n- py::object val = py::number(1);\n+ py::object val = 1;\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self):\n code = \"\"\"\n- py::object val = py::number(1.0);\n+ py::object val = 1.0;\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self):\n code = \"\"\"\n- py::object val = py::number(1.0);\n+ py::object val = 1.0;\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n+ def check_complex_cast(self):\n+ code = \"\"\"\n+ std::complex num = std::complex(1.0,1.0);\n+ py::object val = num;\n+ std::complex raw_val = val;\n+ \"\"\"\n+ inline_tools.inline(code)\n def check_string_cast(self):\n code = \"\"\"\n- py::object val = py::str(\"hello\");\n+ py::object val = \"hello\";\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n@@ -404,11 +469,71 @@ def check_string_cast(self):\n class foo:\n def bar(self):\n return \"bar results\"\n+ def bar2(self,val1,val2):\n+ return val1, val2\n+ def bar3(self,val1,val2,val3=1):\n+ return val1, val2, val3\n \n class str_obj:\n def __str__(self):\n return \"b\"\n \n+class test_object_hasattr(unittest.TestCase):\n+ def check_string(self):\n+ a = foo()\n+ a.b = 12345\n+ code = \"\"\"\n+ return_val = a.hasattr(\"b\"); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res\n+ def check_std_string(self):\n+ a = foo()\n+ a.b = 12345\n+ attr_name = \"b\"\n+ code = \"\"\"\n+ return_val = a.hasattr(attr_name); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a','attr_name'])\n+ assert res \n+ def check_string_fail(self):\n+ a = foo()\n+ a.b = 12345\n+ code = \"\"\"\n+ return_val = a.hasattr(\"c\"); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert not res\n+ def check_inline(self):\n+ \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n+ \"\"\"\n+ a = foo()\n+ a.b = 12345\n+ code = \"\"\"\n+ throw_error(PyExc_AttributeError,\"bummer\"); \n+ \"\"\"\n+ try:\n+ before = sys.getrefcount(a)\n+ res = inline_tools.inline(code,['a'])\n+ except AttributeError:\n+ after = sys.getrefcount(a)\n+ try: \n+ res = inline_tools.inline(code,['a'])\n+ except:\n+ after2 = sys.getrefcount(a)\n+ print \"after and after2 should be equal in the following\" \n+ print 'before, after, after2:', before, after, after2\n+ pass \n+\n+ def check_func(self):\n+ a = foo()\n+ a.b = 12345\n+ code = \"\"\"\n+ return_val = a.hasattr(\"bar\"); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res\n+\n class test_object_attr(unittest.TestCase):\n \n def generic_attr(self,code,args=['a']):\n@@ -423,35 +548,191 @@ def generic_attr(self,code,args=['a']):\n assert after == before\n \n def check_char(self):\n- self.generic_attr('return_val = a.attr(\"b\").disown();')\n+ self.generic_attr('return_val = a.attr(\"b\");')\n \n def check_string(self):\n- self.generic_attr('return_val = a.attr(std::string(\"b\")).disown();')\n+ self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n \n def check_obj(self):\n code = \"\"\"\n py::str name = py::str(\"b\");\n- return_val = a.attr(name).disown();\n+ return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n- \n-class test_attr_call(unittest.TestCase):\n+ def check_attr_call(self):\n+ a = foo()\n+ res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n+ first = sys.getrefcount(res)\n+ del res\n+ res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n+ second = sys.getrefcount(res)\n+ assert res == \"bar results\"\n+ assert first == second\n \n- def check_call(self):\n- a = foo() \n- res = inline_tools.inline('return_val = a.attr(\"bar\").call().disown();',['a'])\n+class test_object_mcall(unittest.TestCase):\n+ def check_noargs(self):\n+ a = foo()\n+ res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n+ assert res == \"bar results\"\n+ first = sys.getrefcount(res)\n+ del res\n+ res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n+ assert res == \"bar results\"\n+ second = sys.getrefcount(res)\n+ assert first == second\n+ def check_args(self):\n+ a = foo()\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ return_val = a.mcall(\"bar2\",args);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == (1,\"hello\")\n+ assert sys.getrefcount(res) == 2\n+ def check_args_kw(self):\n+ a = foo()\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ py::dict kw;\n+ kw[\"val3\"] = 3;\n+ return_val = a.mcall(\"bar3\",args,kw);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == (1,\"hello\",3)\n+ assert sys.getrefcount(res) == 2\n+ def check_std_noargs(self):\n+ a = foo()\n+ method = \"bar\"\n+ res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n+ assert res == \"bar results\"\n+ first = sys.getrefcount(res)\n+ del res\n+ res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n+ second = sys.getrefcount(res)\n+ assert first == second\n+ def check_std_args(self):\n+ a = foo()\n+ method = \"bar2\"\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ return_val = a.mcall(method,args);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a','method'])\n+ assert res == (1,\"hello\")\n+ assert sys.getrefcount(res) == 2\n+ def check_std_args_kw(self):\n+ a = foo()\n+ method = \"bar3\"\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ py::dict kw;\n+ kw[\"val3\"] = 3;\n+ return_val = a.mcall(method,args,kw);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a','method'])\n+ assert res == (1,\"hello\",3)\n+ assert sys.getrefcount(res) == 2\n+ def check_noargs_with_args(self):\n+ # calling a function that does take args with args \n+ # should fail.\n+ a = foo()\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ return_val = a.mcall(\"bar\",args);\n+ \"\"\"\n+ try:\n+ first = sys.getrefcount(a)\n+ res = inline_tools.inline(code,['a'])\n+ except TypeError:\n+ second = sys.getrefcount(a) \n+ try:\n+ res = inline_tools.inline(code,['a'])\n+ except TypeError:\n+ third = sys.getrefcount(a) \n+ # first should == second, but the weird refcount error \n+ assert second == third\n \n- \n- \n+class test_object_call(unittest.TestCase):\n+ def check_noargs(self):\n+ def foo():\n+ return (1,2,3)\n+ res = inline_tools.inline('return_val = foo.call();',['foo'])\n+ assert res == (1,2,3)\n+ assert sys.getrefcount(res) == 2\n+ def check_args(self):\n+ def foo(val1,val2):\n+ return (val1,val2)\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ return_val = foo.call(args);\n+ \"\"\"\n+ res = inline_tools.inline(code,['foo'])\n+ assert res == (1,\"hello\")\n+ assert sys.getrefcount(res) == 2\n+ def check_args_kw(self):\n+ def foo(val1,val2,val3=1):\n+ return (val1,val2,val3)\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ py::dict kw;\n+ kw[\"val3\"] = 3; \n+ return_val = foo.call(args,kw);\n+ \"\"\"\n+ res = inline_tools.inline(code,['foo'])\n+ assert res == (1,\"hello\",3)\n+ assert sys.getrefcount(res) == 2\n+ def check_noargs_with_args(self):\n+ # calling a function that does take args with args \n+ # should fail.\n+ def foo():\n+ return \"blah\"\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ return_val = foo.call(args);\n+ \"\"\"\n+ try:\n+ first = sys.getrefcount(foo)\n+ res = inline_tools.inline(code,['foo'])\n+ except TypeError:\n+ second = sys.getrefcount(foo) \n+ try:\n+ res = inline_tools.inline(code,['foo'])\n+ except TypeError:\n+ third = sys.getrefcount(foo) \n+ # first should == second, but the weird refcount error \n+ assert second == third\n+ \n def test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n- suites.append( makeSuite(test_list,'check_'))\n- suites.append( makeSuite(test_object_cast,'check_'))\n- suites.append( makeSuite(test_object_attr,'check_'))\n- suites.append( makeSuite(test_attr_call,'check_'))\n+ #suites.append( makeSuite(test_list,'check_'))\n+ \n+ #suites.append( makeSuite(test_object_construct,'check_'))\n+ #suites.append( makeSuite(test_object_cast,'check_'))\n+ #suites.append( makeSuite(test_object_hasattr,'check_')) \n+ #suites.append( makeSuite(test_object_attr,'check_'))\n+ suites.append( makeSuite(test_object_mcall,'check_'))\n+ suites.append( makeSuite(test_object_call,'check_'))\n+ \n+\n total_suite = unittest.TestSuite(suites)\n return total_suite\n \n", "added_lines": 303, "deleted_lines": 22, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n print 'first:',before\n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n print '2nd,3rd:', before, after\n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\n def check_access_speed(self):\n N = 1000000\n print 'list access -- val = a[i] for N =', N\n a = [0] * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self):\n N = 1000000\n print 'list access/set -- b[i] = a[i] for N =', N \n a = [0] * N\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == a \n\n def check_string_add_speed(self):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 'blah'\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [\"blah\"] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n std::string blah = std::string(\"blah\");\n for(int i=0; i < N; i++)\n b[i] = (std::string)a[i] + blah; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\n def check_int_add_speed(self):\n N = 1000000\n print 'int add -- b[i] = a[i] + 1 for N =', N \n a = [0] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 1\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [0] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = (int)a[i] + 1; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\nclass test_object_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_int(self):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::object val = 1001;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1001\n def check_float(self):\n code = \"\"\"\n py::object val = (float)1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_double(self):\n code = \"\"\"\n py::object val = 1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_complex(self):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0+1.0j\n def check_string(self):\n code = \"\"\"\n py::object val = \"hello\";\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n\n def check_std_string(self):\n code = \"\"\"\n std::string s = std::string(\"hello\");\n py::object val = s;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n \n \nclass test_object_cast(unittest.TestCase):\n def check_int_cast(self):\n code = \"\"\"\n py::object val = 1;\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self):\n code = \"\"\"\n py::object val = 1.0;\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self):\n code = \"\"\"\n py::object val = 1.0;\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_complex_cast(self):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n std::complex raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self):\n code = \"\"\"\n py::object val = \"hello\";\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n def bar2(self,val1,val2):\n return val1, val2\n def bar3(self,val1,val2,val3=1):\n return val1, val2, val3\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_hasattr(unittest.TestCase):\n def check_string(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self):\n a = foo()\n a.b = 12345\n attr_name = \"b\"\n code = \"\"\"\n return_val = a.hasattr(attr_name); \n \"\"\"\n res = inline_tools.inline(code,['a','attr_name'])\n assert res \n def check_string_fail(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n def check_inline(self):\n \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n \"\"\"\n a = foo()\n a.b = 12345\n code = \"\"\"\n throw_error(PyExc_AttributeError,\"bummer\"); \n \"\"\"\n try:\n before = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except AttributeError:\n after = sys.getrefcount(a)\n try: \n res = inline_tools.inline(code,['a'])\n except:\n after2 = sys.getrefcount(a)\n print \"after and after2 should be equal in the following\" \n print 'before, after, after2:', before, after, after2\n pass \n\n def check_func(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"bar\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self):\n self.generic_attr('return_val = a.attr(\"b\");')\n\n def check_string(self):\n self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n\n def check_obj(self):\n code = \"\"\"\n py::str name = py::str(\"b\");\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n def check_attr_call(self):\n a = foo()\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n second = sys.getrefcount(res)\n assert res == \"bar results\"\n assert first == second\n\nclass test_object_mcall(unittest.TestCase):\n def check_noargs(self):\n a = foo()\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_args(self):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar2\",args);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(\"bar3\",args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_std_noargs(self):\n a = foo()\n method = \"bar\"\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_std_args(self):\n a = foo()\n method = \"bar2\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(method,args);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_std_args_kw(self):\n a = foo()\n method = \"bar3\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(method,args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self):\n # calling a function that does take args with args \n # should fail.\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar\",args);\n \"\"\"\n try:\n first = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except TypeError:\n second = sys.getrefcount(a) \n try:\n res = inline_tools.inline(code,['a'])\n except TypeError:\n third = sys.getrefcount(a) \n # first should == second, but the weird refcount error \n assert second == third\n\nclass test_object_call(unittest.TestCase):\n def check_noargs(self):\n def foo():\n return (1,2,3)\n res = inline_tools.inline('return_val = foo.call();',['foo'])\n assert res == (1,2,3)\n assert sys.getrefcount(res) == 2\n def check_args(self):\n def foo(val1,val2):\n return (val1,val2)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self):\n def foo(val1,val2,val3=1):\n return (val1,val2,val3)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3; \n return_val = foo.call(args,kw);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self):\n # calling a function that does take args with args \n # should fail.\n def foo():\n return \"blah\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n try:\n first = sys.getrefcount(foo)\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n second = sys.getrefcount(foo) \n try:\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n third = sys.getrefcount(foo) \n # first should == second, but the weird refcount error \n assert second == third\n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n #suites.append( makeSuite(test_list,'check_'))\n \n #suites.append( makeSuite(test_object_construct,'check_'))\n #suites.append( makeSuite(test_object_cast,'check_'))\n #suites.append( makeSuite(test_object_hasattr,'check_')) \n #suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_object_mcall,'check_'))\n suites.append( makeSuite(test_object_call,'check_'))\n \n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n \n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded in(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n # check overloaded count(PWOBase& val) method\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\n def check_access_speed(self):\n N = 1000000\n print 'list access -- val = a[i] for N =', N\n a = [0] * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self):\n N = 1000000\n print 'list access/set -- b[i] = a[i] for N =', N \n a = [0] * N\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == a \n\n def _check_string_add_speed(self):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 'blah'\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [\"blah\"] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n std::string blah = std::string(\"blah\");\n for(int i=0; i < N; i++)\n b[i] = (std::string)a[i] + blah; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\n def check_int_add_speed(self):\n N = 1000000\n print 'int add -- b[i] = a[i] + 1 for N =', N \n a = [0] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 1\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [0] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = (int)a[i] + 1; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n \nclass test_object_cast(unittest.TestCase):\n def check_int_cast(self):\n code = \"\"\"\n py::object val = py::number(1);\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self):\n code = \"\"\"\n py::object val = py::number(1.0);\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self):\n code = \"\"\"\n py::object val = py::number(1.0);\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self):\n code = \"\"\"\n py::object val = py::str(\"hello\");\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self):\n self.generic_attr('return_val = a.attr(\"b\").disown();')\n\n def check_string(self):\n self.generic_attr('return_val = a.attr(std::string(\"b\")).disown();')\n\n def check_obj(self):\n code = \"\"\"\n py::str name = py::str(\"b\");\n return_val = a.attr(name).disown();\n \"\"\" \n self.generic_attr(code,['a'])\n \nclass test_attr_call(unittest.TestCase):\n\n def check_call(self):\n a = foo() \n res = inline_tools.inline('return_val = a.attr(\"bar\").call().disown();',['a'])\n assert res == \"bar results\"\n\n \n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_list,'check_'))\n suites.append( makeSuite(test_object_cast,'check_'))\n suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_attr_call,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 22, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 35, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 54, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 90, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 129, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 160, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 191, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx.py", "nloc": 26, "complexity": 3, "token_count": 127, "parameters": [ "self" ], "start_line": 268, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 128, "parameters": [ "self" ], "start_line": 297, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_string_add_speed", "long_name": "check_string_add_speed( self )", "filename": "test_scxx.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 323, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 350, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 381, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_float", "long_name": "check_float( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 390, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 398, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 406, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 415, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 424, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 436, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 442, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 448, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_cast", "long_name": "check_complex_cast( self )", "filename": "test_scxx.py", "nloc": 7, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 454, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 461, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 470, "end_line": 471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar2", "long_name": "bar2( self , val1 , val2 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "val1", "val2" ], "start_line": 472, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar3", "long_name": "bar3( self , val1 , val2 , val3 = 1 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val1", "val2", "val3" ], "start_line": 474, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 478, "end_line": 479, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 482, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 490, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 499, "end_line": 506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_inline", "long_name": "check_inline( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 507, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_func", "long_name": "check_func( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 528, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 539, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 550, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 553, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 556, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_attr_call", "long_name": "check_attr_call( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 562, "end_line": 570, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx.py", "nloc": 10, "complexity": 1, "token_count": 64, "parameters": [ "self" ], "start_line": 573, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 583, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx.py", "nloc": 13, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 594, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_std_noargs", "long_name": "check_std_noargs( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 607, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_std_args", "long_name": "check_std_args( self )", "filename": "test_scxx.py", "nloc": 12, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 618, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_std_args_kw", "long_name": "check_std_args_kw( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 630, "end_line": 643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 3, "token_count": 75, "parameters": [ "self" ], "start_line": 644, "end_line": 664, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "check_noargs.foo", "long_name": "check_noargs.foo( )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 667, "end_line": 672, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_args.foo", "long_name": "check_args.foo( val1 , val2 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "val1", "val2" ], "start_line": 674, "end_line": 675, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 673, "end_line": 684, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_args_kw.foo", "long_name": "check_args_kw.foo( val1 , val2 , val3 = 1 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "val1", "val2", "val3" ], "start_line": 686, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx.py", "nloc": 13, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 685, "end_line": 698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_noargs_with_args.foo", "long_name": "check_noargs_with_args.foo( )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 702, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 699, "end_line": 720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 8, "complexity": 2, "token_count": 52, "parameters": [ "level" ], "start_line": 722, "end_line": 737, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 739, "end_line": 743, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 22, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 34, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 53, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 89, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 128, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 159, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx.py", "nloc": 26, "complexity": 3, "token_count": 127, "parameters": [ "self" ], "start_line": 269, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 128, "parameters": [ "self" ], "start_line": 298, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "_check_string_add_speed", "long_name": "_check_string_add_speed( self )", "filename": "test_scxx.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 324, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 351, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 378, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 384, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 390, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 396, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 405, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 414, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 425, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 428, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 431, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_call", "long_name": "check_call( self )", "filename": "test_scxx.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 440, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 10, "complexity": 2, "token_count": 74, "parameters": [ "level" ], "start_line": 447, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 458, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_attr_call", "long_name": "check_attr_call( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 562, "end_line": 570, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 22, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_noargs_with_args.foo", "long_name": "check_noargs_with_args.foo( )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 702, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 381, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 556, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_inline", "long_name": "check_inline( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 507, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 190, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_check_string_add_speed", "long_name": "_check_string_add_speed( self )", "filename": "test_scxx.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 324, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_std_noargs", "long_name": "check_std_noargs( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 607, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_std_args", "long_name": "check_std_args( self )", "filename": "test_scxx.py", "nloc": 12, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 618, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx.py", "nloc": 13, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 594, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "check_func", "long_name": "check_func( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 528, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_args_kw", "long_name": "check_std_args_kw( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 630, "end_line": 643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 499, "end_line": 506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_string_add_speed", "long_name": "check_string_add_speed( self )", "filename": "test_scxx.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 323, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 424, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 406, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_noargs.foo", "long_name": "check_noargs.foo( )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 415, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "bar3", "long_name": "bar3( self , val1 , val2 , val3 = 1 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val1", "val2", "val3" ], "start_line": 474, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 8, "complexity": 2, "token_count": 52, "parameters": [ "level" ], "start_line": 722, "end_line": 737, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 550, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx.py", "nloc": 10, "complexity": 1, "token_count": 64, "parameters": [ "self" ], "start_line": 573, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 398, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 583, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 442, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 448, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar2", "long_name": "bar2( self , val1 , val2 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "val1", "val2" ], "start_line": 472, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_args.foo", "long_name": "check_args.foo( val1 , val2 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "val1", "val2" ], "start_line": 674, "end_line": 675, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_call", "long_name": "check_call( self )", "filename": "test_scxx.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 440, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_args_kw.foo", "long_name": "check_args_kw.foo( val1 , val2 , val3 = 1 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "val1", "val2", "val3" ], "start_line": 686, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 3, "token_count": 75, "parameters": [ "self" ], "start_line": 644, "end_line": 664, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "check_float", "long_name": "check_float( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 390, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex_cast", "long_name": "check_complex_cast( self )", "filename": "test_scxx.py", "nloc": 7, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 454, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 436, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 461, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": 597, "complexity": 66, "token_count": 3260, "diff_parsed": { "added": [ " print 'first:',before", " print '2nd,3rd:', before, after", " def check_string_add_speed(self):", "", "class test_object_construct(unittest.TestCase):", " #------------------------------------------------------------------------", " # Check that construction from basic types is allowed and have correct", " # reference counts", " #------------------------------------------------------------------------", " def check_int(self):", " # strange int value used to try and make sure refcount is 2.", " code = \"\"\"", " py::object val = 1001;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1001", " def check_float(self):", " code = \"\"\"", " py::object val = (float)1.0;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1.0", " def check_double(self):", " code = \"\"\"", " py::object val = 1.0;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1.0", " def check_complex(self):", " code = \"\"\"", " std::complex num = std::complex(1.0,1.0);", " py::object val = num;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1.0+1.0j", " def check_string(self):", " code = \"\"\"", " py::object val = \"hello\";", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == \"hello\"", "", " def check_std_string(self):", " code = \"\"\"", " std::string s = std::string(\"hello\");", " py::object val = s;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == \"hello\"", "", " py::object val = 1;", " py::object val = 1.0;", " py::object val = 1.0;", " def check_complex_cast(self):", " code = \"\"\"", " std::complex num = std::complex(1.0,1.0);", " py::object val = num;", " std::complex raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " py::object val = \"hello\";", " def bar2(self,val1,val2):", " return val1, val2", " def bar3(self,val1,val2,val3=1):", " return val1, val2, val3", "class test_object_hasattr(unittest.TestCase):", " def check_string(self):", " a = foo()", " a.b = 12345", " code = \"\"\"", " return_val = a.hasattr(\"b\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res", " def check_std_string(self):", " a = foo()", " a.b = 12345", " attr_name = \"b\"", " code = \"\"\"", " return_val = a.hasattr(attr_name);", " \"\"\"", " res = inline_tools.inline(code,['a','attr_name'])", " assert res", " def check_string_fail(self):", " a = foo()", " a.b = 12345", " code = \"\"\"", " return_val = a.hasattr(\"c\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert not res", " def check_inline(self):", " \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE", " \"\"\"", " a = foo()", " a.b = 12345", " code = \"\"\"", " throw_error(PyExc_AttributeError,\"bummer\");", " \"\"\"", " try:", " before = sys.getrefcount(a)", " res = inline_tools.inline(code,['a'])", " except AttributeError:", " after = sys.getrefcount(a)", " try:", " res = inline_tools.inline(code,['a'])", " except:", " after2 = sys.getrefcount(a)", " print \"after and after2 should be equal in the following\"", " print 'before, after, after2:', before, after, after2", " pass", "", " def check_func(self):", " a = foo()", " a.b = 12345", " code = \"\"\"", " return_val = a.hasattr(\"bar\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res", "", " self.generic_attr('return_val = a.attr(\"b\");')", " self.generic_attr('return_val = a.attr(std::string(\"b\"));')", " return_val = a.attr(name);", " def check_attr_call(self):", " a = foo()", " res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])", " second = sys.getrefcount(res)", " assert res == \"bar results\"", " assert first == second", "class test_object_mcall(unittest.TestCase):", " def check_noargs(self):", " a = foo()", " res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])", " assert res == \"bar results\"", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])", " assert res == \"bar results\"", " second = sys.getrefcount(res)", " assert first == second", " def check_args(self):", " a = foo()", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = a.mcall(\"bar2\",args);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res == (1,\"hello\")", " assert sys.getrefcount(res) == 2", " def check_args_kw(self):", " a = foo()", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " py::dict kw;", " kw[\"val3\"] = 3;", " return_val = a.mcall(\"bar3\",args,kw);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res == (1,\"hello\",3)", " assert sys.getrefcount(res) == 2", " def check_std_noargs(self):", " a = foo()", " method = \"bar\"", " res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])", " assert res == \"bar results\"", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])", " second = sys.getrefcount(res)", " assert first == second", " def check_std_args(self):", " a = foo()", " method = \"bar2\"", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = a.mcall(method,args);", " \"\"\"", " res = inline_tools.inline(code,['a','method'])", " assert res == (1,\"hello\")", " assert sys.getrefcount(res) == 2", " def check_std_args_kw(self):", " a = foo()", " method = \"bar3\"", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " py::dict kw;", " kw[\"val3\"] = 3;", " return_val = a.mcall(method,args,kw);", " \"\"\"", " res = inline_tools.inline(code,['a','method'])", " assert res == (1,\"hello\",3)", " assert sys.getrefcount(res) == 2", " def check_noargs_with_args(self):", " # calling a function that does take args with args", " # should fail.", " a = foo()", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = a.mcall(\"bar\",args);", " \"\"\"", " try:", " first = sys.getrefcount(a)", " res = inline_tools.inline(code,['a'])", " except TypeError:", " second = sys.getrefcount(a)", " try:", " res = inline_tools.inline(code,['a'])", " except TypeError:", " third = sys.getrefcount(a)", " # first should == second, but the weird refcount error", " assert second == third", "class test_object_call(unittest.TestCase):", " def check_noargs(self):", " def foo():", " return (1,2,3)", " res = inline_tools.inline('return_val = foo.call();',['foo'])", " assert res == (1,2,3)", " assert sys.getrefcount(res) == 2", " def check_args(self):", " def foo(val1,val2):", " return (val1,val2)", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = foo.call(args);", " \"\"\"", " res = inline_tools.inline(code,['foo'])", " assert res == (1,\"hello\")", " assert sys.getrefcount(res) == 2", " def check_args_kw(self):", " def foo(val1,val2,val3=1):", " return (val1,val2,val3)", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " py::dict kw;", " kw[\"val3\"] = 3;", " return_val = foo.call(args,kw);", " \"\"\"", " res = inline_tools.inline(code,['foo'])", " assert res == (1,\"hello\",3)", " assert sys.getrefcount(res) == 2", " def check_noargs_with_args(self):", " # calling a function that does take args with args", " # should fail.", " def foo():", " return \"blah\"", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = foo.call(args);", " \"\"\"", " try:", " first = sys.getrefcount(foo)", " res = inline_tools.inline(code,['foo'])", " except TypeError:", " second = sys.getrefcount(foo)", " try:", " res = inline_tools.inline(code,['foo'])", " except TypeError:", " third = sys.getrefcount(foo)", " # first should == second, but the weird refcount error", " assert second == third", "", " #suites.append( makeSuite(test_list,'check_'))", "", " #suites.append( makeSuite(test_object_construct,'check_'))", " #suites.append( makeSuite(test_object_cast,'check_'))", " #suites.append( makeSuite(test_object_hasattr,'check_'))", " #suites.append( makeSuite(test_object_attr,'check_'))", " suites.append( makeSuite(test_object_mcall,'check_'))", " suites.append( makeSuite(test_object_call,'check_'))", "", "" ], "deleted": [ "", " # check overloaded in(PWOBase& val) method", " # check overloaded count(PWOBase& val) method", " def _check_string_add_speed(self):", " py::object val = py::number(1);", " py::object val = py::number(1.0);", " py::object val = py::number(1.0);", " py::object val = py::str(\"hello\");", " self.generic_attr('return_val = a.attr(\"b\").disown();')", " self.generic_attr('return_val = a.attr(std::string(\"b\")).disown();')", " return_val = a.attr(name).disown();", "", "class test_attr_call(unittest.TestCase):", " def check_call(self):", " a = foo()", " res = inline_tools.inline('return_val = a.attr(\"bar\").call().disown();',['a'])", "", "", " suites.append( makeSuite(test_list,'check_'))", " suites.append( makeSuite(test_object_cast,'check_'))", " suites.append( makeSuite(test_object_attr,'check_'))", " suites.append( makeSuite(test_attr_call,'check_'))" ] } }, { "old_path": "weave/vtk_spec.py", "new_path": "weave/vtk_spec.py", "filename": "vtk_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -73,6 +73,7 @@ def init_info(self):\n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n+ self.return_type = self.c_type \n self.to_c_return = None # not used\n self.check_func = None # not used\n hdr = self.class_name + \".h\"\n", "added_lines": 1, "deleted_lines": 0, "source_code": "\"\"\"\nVTK type converter.\n\nThis module handles conversion between VTK C++ and VTK Python objects\nso that one can write inline C++ code to manipulate VTK Python\nobjects. It requires that you have VTK and the VTK-Python wrappers\ninstalled. It has been tested with VTK 4.0 and above. The code is\nbased on wx_spec.py. You will need to call inline with include_dirs,\nlibrary_dirs and often even libraries appropriately set for this to\nwork without errors. Sometimes you might need to include additional\nheaders.\n\nDistributed under the SciPy License.\n\nAuthors:\n Prabhu Ramachandran \n Eric Jones \n\"\"\"\n\nimport common_info\nfrom c_spec import common_base_converter\n\n\nvtk_py_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic:\n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s vtk_ptr = (%(c_type)s) vtkPythonGetPointerFromObject(py_obj, \"%(type_name)s\");\n if (!vtk_ptr)\n handle_conversion_error(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return vtk_ptr;\n }\n\n %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s vtk_ptr = (%(c_type)s) vtkPythonGetPointerFromObject(py_obj, \"%(type_name)s\");\n if (!vtk_ptr)\n handle_bad_type(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return vtk_ptr;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\nvtk_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(vtkObjectBase* obj)\n{\n return vtkPythonGetObjectFromPointer(obj);\n}\n\"\"\"\n \n\nclass vtk_converter(common_base_converter):\n def __init__(self,class_name=\"undefined\"):\n self.class_name = class_name\n common_base_converter.__init__(self)\n\n def init_info(self):\n common_base_converter.init_info(self)\n # These are generated on the fly instead of defined at \n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n self.return_type = self.c_type \n self.to_c_return = None # not used\n self.check_func = None # not used\n hdr = self.class_name + \".h\"\n # Remember that you need both the quotes!\n self.headers.extend(['\"vtkPythonUtil.h\"', '\"vtkObject.h\"',\n '\"%s\"'%hdr])\n #self.include_dirs.extend(vtk_inc)\n #self.define_macros.append(('SOME_VARIABLE', '1'))\n #self.library_dirs.extend(vtk_lib)\n self.libraries.extend(['vtkCommonPython', 'vtkCommon'])\n #self.support_code.append(common_info.swig_support_code)\n \n def type_match(self,value):\n is_match = 0\n try:\n if value.IsA('vtkObject'):\n is_match = 1\n except AttributeError:\n pass\n return is_match\n\n def generate_build_info(self):\n if self.class_name != \"undefined\":\n res = common_base_converter.generate_build_info(self)\n else:\n # if there isn't a class_name, we don't want the\n # we don't want the support_code to be included\n import base_info\n res = base_info.base_info()\n return res\n \n def py_to_c_code(self):\n return vtk_py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return vtk_c_to_py_template % self.template_vars()\n \n def type_spec(self,name,value):\n # factory\n class_name = value.__class__.__name__\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n\n def __cmp__(self,other):\n #only works for equal\n res = -1\n try:\n res = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.class_name, other.class_name) or \\\n cmp(self.type_name,other.type_name)\n except:\n pass\n return res\n\n\"\"\"\n# this should only be enabled on machines with access to a display device\n# It'll cause problems otherwise.\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\"\"\"\n", "source_code_before": "\"\"\"\nVTK type converter.\n\nThis module handles conversion between VTK C++ and VTK Python objects\nso that one can write inline C++ code to manipulate VTK Python\nobjects. It requires that you have VTK and the VTK-Python wrappers\ninstalled. It has been tested with VTK 4.0 and above. The code is\nbased on wx_spec.py. You will need to call inline with include_dirs,\nlibrary_dirs and often even libraries appropriately set for this to\nwork without errors. Sometimes you might need to include additional\nheaders.\n\nDistributed under the SciPy License.\n\nAuthors:\n Prabhu Ramachandran \n Eric Jones \n\"\"\"\n\nimport common_info\nfrom c_spec import common_base_converter\n\n\nvtk_py_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic:\n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s vtk_ptr = (%(c_type)s) vtkPythonGetPointerFromObject(py_obj, \"%(type_name)s\");\n if (!vtk_ptr)\n handle_conversion_error(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return vtk_ptr;\n }\n\n %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s vtk_ptr = (%(c_type)s) vtkPythonGetPointerFromObject(py_obj, \"%(type_name)s\");\n if (!vtk_ptr)\n handle_bad_type(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return vtk_ptr;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\nvtk_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(vtkObjectBase* obj)\n{\n return vtkPythonGetObjectFromPointer(obj);\n}\n\"\"\"\n \n\nclass vtk_converter(common_base_converter):\n def __init__(self,class_name=\"undefined\"):\n self.class_name = class_name\n common_base_converter.__init__(self)\n\n def init_info(self):\n common_base_converter.init_info(self)\n # These are generated on the fly instead of defined at \n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n self.to_c_return = None # not used\n self.check_func = None # not used\n hdr = self.class_name + \".h\"\n # Remember that you need both the quotes!\n self.headers.extend(['\"vtkPythonUtil.h\"', '\"vtkObject.h\"',\n '\"%s\"'%hdr])\n #self.include_dirs.extend(vtk_inc)\n #self.define_macros.append(('SOME_VARIABLE', '1'))\n #self.library_dirs.extend(vtk_lib)\n self.libraries.extend(['vtkCommonPython', 'vtkCommon'])\n #self.support_code.append(common_info.swig_support_code)\n \n def type_match(self,value):\n is_match = 0\n try:\n if value.IsA('vtkObject'):\n is_match = 1\n except AttributeError:\n pass\n return is_match\n\n def generate_build_info(self):\n if self.class_name != \"undefined\":\n res = common_base_converter.generate_build_info(self)\n else:\n # if there isn't a class_name, we don't want the\n # we don't want the support_code to be included\n import base_info\n res = base_info.base_info()\n return res\n \n def py_to_c_code(self):\n return vtk_py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return vtk_c_to_py_template % self.template_vars()\n \n def type_spec(self,name,value):\n # factory\n class_name = value.__class__.__name__\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n\n def __cmp__(self,other):\n #only works for equal\n res = -1\n try:\n res = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.class_name, other.class_name) or \\\n cmp(self.type_name,other.type_name)\n except:\n pass\n return res\n\n\"\"\"\n# this should only be enabled on machines with access to a display device\n# It'll cause problems otherwise.\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\"\"\"\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , class_name = \"undefined\" )", "filename": "vtk_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "class_name" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "vtk_spec.py", "nloc": 11, "complexity": 1, "token_count": 79, "parameters": [ "self" ], "start_line": 70, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "vtk_spec.py", "nloc": 8, "complexity": 3, "token_count": 29, "parameters": [ "self", "value" ], "start_line": 89, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "vtk_spec.py", "nloc": 7, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 98, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "vtk_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 108, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "vtk_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 111, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "vtk_spec.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self", "name", "value" ], "start_line": 114, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "vtk_spec.py", "nloc": 10, "complexity": 5, "token_count": 66, "parameters": [ "self", "other" ], "start_line": 121, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , class_name = \"undefined\" )", "filename": "vtk_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "class_name" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "vtk_spec.py", "nloc": 10, "complexity": 1, "token_count": 72, "parameters": [ "self" ], "start_line": 70, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "vtk_spec.py", "nloc": 8, "complexity": 3, "token_count": 29, "parameters": [ "self", "value" ], "start_line": 88, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "vtk_spec.py", "nloc": 7, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 97, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "vtk_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 107, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "vtk_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 110, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "vtk_spec.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self", "name", "value" ], "start_line": 113, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "vtk_spec.py", "nloc": 10, "complexity": 5, "token_count": 66, "parameters": [ "self", "other" ], "start_line": 120, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "vtk_spec.py", "nloc": 11, "complexity": 1, "token_count": 79, "parameters": [ "self" ], "start_line": 70, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "nloc": 118, "complexity": 15, "token_count": 314, "diff_parsed": { "added": [ " self.return_type = self.c_type" ], "deleted": [] } }, { "old_path": "weave/wx_spec.py", "new_path": "weave/wx_spec.py", "filename": "wx_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -48,6 +48,7 @@ def init_info(self):\n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n+ self.return_type = self.class_name + \"*\"\n self.to_c_return = None # not used\n self.check_func = None # not used\n self.headers.extend(['\"wx/wx.h\"',''])\n", "added_lines": 1, "deleted_lines": 0, "source_code": "import common_info\nfrom c_spec import common_base_converter\n\nwx_dir = 'C:\\\\wx232\\\\include'\n\nwx_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_conversion_error(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj,const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_bad_type(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n } \n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\nclass wx_converter(common_base_converter):\n def __init__(self,class_name=\"undefined\"):\n self.class_name = class_name\n common_base_converter.__init__(self)\n\n def init_info(self):\n common_base_converter.init_info(self)\n # These are generated on the fly instead of defined at \n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n self.return_type = self.class_name + \"*\"\n self.to_c_return = None # not used\n self.check_func = None # not used\n self.headers.extend(['\"wx/wx.h\"',''])\n self.include_dirs.append(wx_dir)\n self.define_macros.append(('wxUSE_GUI', '1'))\n self.library_dirs.append('c:\\wx232\\lib')\n self.libraries.append('gdi32')\n self.libraries.append('wxmsw232')\n self.support_code.append(common_info.swig_support_code)\n \n def type_match(self,value):\n is_match = 0\n try:\n wx_class = value.this.split('_')[-2]\n if wx_class[:2] == 'wx':\n is_match = 1\n except AttributeError:\n pass\n return is_match\n\n def generate_build_info(self):\n if self.class_name != \"undefined\":\n res = common_base_converter.generate_build_info(self)\n else:\n # if there isn't a class_name, we don't want the\n # we don't want the support_code to be included\n import base_info\n res = base_info.base_info()\n return res\n \n def py_to_c_code(self):\n return wx_to_c_template % self.template_vars()\n\n #def c_to_py_code(self):\n # return simple_c_to_py_template % self.template_vars()\n \n def type_spec(self,name,value):\n # factory\n class_name = value.this.split('_')[-2]\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n\n def __cmp__(self,other):\n #only works for equal\n res = -1\n try:\n res = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.class_name, other.class_name) or \\\n cmp(self.type_name,other.type_name)\n except:\n pass\n return res\n\"\"\"\n# this should only be enabled on machines with access to a display device\n# It'll cause problems otherwise.\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\"\"\" ", "source_code_before": "import common_info\nfrom c_spec import common_base_converter\n\nwx_dir = 'C:\\\\wx232\\\\include'\n\nwx_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_conversion_error(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj,const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_bad_type(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n } \n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\nclass wx_converter(common_base_converter):\n def __init__(self,class_name=\"undefined\"):\n self.class_name = class_name\n common_base_converter.__init__(self)\n\n def init_info(self):\n common_base_converter.init_info(self)\n # These are generated on the fly instead of defined at \n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n self.to_c_return = None # not used\n self.check_func = None # not used\n self.headers.extend(['\"wx/wx.h\"',''])\n self.include_dirs.append(wx_dir)\n self.define_macros.append(('wxUSE_GUI', '1'))\n self.library_dirs.append('c:\\wx232\\lib')\n self.libraries.append('gdi32')\n self.libraries.append('wxmsw232')\n self.support_code.append(common_info.swig_support_code)\n \n def type_match(self,value):\n is_match = 0\n try:\n wx_class = value.this.split('_')[-2]\n if wx_class[:2] == 'wx':\n is_match = 1\n except AttributeError:\n pass\n return is_match\n\n def generate_build_info(self):\n if self.class_name != \"undefined\":\n res = common_base_converter.generate_build_info(self)\n else:\n # if there isn't a class_name, we don't want the\n # we don't want the support_code to be included\n import base_info\n res = base_info.base_info()\n return res\n \n def py_to_c_code(self):\n return wx_to_c_template % self.template_vars()\n\n #def c_to_py_code(self):\n # return simple_c_to_py_template % self.template_vars()\n \n def type_spec(self,name,value):\n # factory\n class_name = value.this.split('_')[-2]\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n\n def __cmp__(self,other):\n #only works for equal\n res = -1\n try:\n res = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.class_name, other.class_name) or \\\n cmp(self.type_name,other.type_name)\n except:\n pass\n return res\n\"\"\"\n# this should only be enabled on machines with access to a display device\n# It'll cause problems otherwise.\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\"\"\" ", "methods": [ { "name": "__init__", "long_name": "__init__( self , class_name = \"undefined\" )", "filename": "wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "class_name" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "wx_spec.py", "nloc": 14, "complexity": 1, "token_count": 112, "parameters": [ "self" ], "start_line": 45, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "wx_spec.py", "nloc": 9, "complexity": 3, "token_count": 44, "parameters": [ "self", "value" ], "start_line": 62, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "wx_spec.py", "nloc": 7, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 72, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "wx_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 82, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "wx_spec.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 88, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "wx_spec.py", "nloc": 10, "complexity": 5, "token_count": 66, "parameters": [ "self", "other" ], "start_line": 95, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , class_name = \"undefined\" )", "filename": "wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "class_name" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "wx_spec.py", "nloc": 13, "complexity": 1, "token_count": 103, "parameters": [ "self" ], "start_line": 45, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "wx_spec.py", "nloc": 9, "complexity": 3, "token_count": 44, "parameters": [ "self", "value" ], "start_line": 61, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "wx_spec.py", "nloc": 7, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 71, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "wx_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 81, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "wx_spec.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 87, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "wx_spec.py", "nloc": 10, "complexity": 5, "token_count": 66, "parameters": [ "self", "other" ], "start_line": 94, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "wx_spec.py", "nloc": 14, "complexity": 1, "token_count": 112, "parameters": [ "self" ], "start_line": 45, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 } ], "nloc": 98, "complexity": 14, "token_count": 353, "diff_parsed": { "added": [ " self.return_type = self.class_name + \"*\"" ], "deleted": [] } } ] }, { "hash": "f8c6e2ff4d30a7d2f8dd35be7d6e87eceed65a0c", "msg": "Fixed assert_approx_equal for negative input", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-09-30T13:47:24+00:00", "author_timezone": 0, "committer_date": "2002-09-30T13:47:24+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "920b35a1c9a88595384d4ff0f4a90ddf594ffedd" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 2, "insertions": 2, "lines": 4, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -343,8 +343,8 @@ def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n- sc_desired = desired/pow(10,math.floor(math.log10(desired)))\n- sc_actual = actual/pow(10,math.floor(math.log10(actual)))\n+ sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n+ sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n try:\n if ( verbose and len(str(desired)) < 100 and len(str(actual)) ):\n msg = msg \\\n", "added_lines": 2, "deleted_lines": 2, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path():\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n del sys.path[0]\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(1)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i//test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n del sys.path[0]\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(1)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i)\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, int)\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n #info['size_liblapack'] = sz\n flag = 0 #os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert type(self.search_static_first) is type(0)\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n #info['size_liblapack'] = sz\n flag = 0 #os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 179, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 52, "complexity": 11, "token_count": 265, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 491, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 508, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 515, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 606, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 623, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 630, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 670, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 675, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 696, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 719, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 729, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 52, "complexity": 11, "token_count": 265, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 491, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 508, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 515, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 606, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 623, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 630, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 670, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 675, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 696, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 719, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 729, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 179, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "nloc": 648, "complexity": 124, "token_count": 3178, "diff_parsed": { "added": [ " assert isinstance(self.search_static_first, int)" ], "deleted": [ " assert type(self.search_static_first) is type(0)" ] } } ] }, { "hash": "00dce9d64845208b4b984c29a32c3ce4ba1a8c5c", "msg": "kill trailing CR characters", "author": { "name": "skip", "email": "skip@localhost" }, "committer": { "name": "skip", "email": "skip@localhost" }, "author_date": "2002-10-01T18:07:03+00:00", "author_timezone": 0, "committer_date": "2002-10-01T18:07:03+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "e62572e0c1cbcf99eb9da25b00fd76bbaabe00cd" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_test/__init__.py", "new_path": "scipy_test/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,2 +1,2 @@\n # nothing done here currently \n-# __init__.py file just used to mark the directory as a package.\n\\ No newline at end of file\n+# __init__.py file just used to mark the directory as a package.\n", "added_lines": 1, "deleted_lines": 1, "source_code": "# nothing done here currently \n# __init__.py file just used to mark the directory as a package.\n", "source_code_before": "# nothing done here currently \n# __init__.py file just used to mark the directory as a package.", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 0, "complexity": 0, "token_count": 0, "diff_parsed": { "added": [ "# __init__.py file just used to mark the directory as a package." ], "deleted": [ "# __init__.py file just used to mark the directory as a package." ] } } ] }, { "hash": "95056afcb4ef5d7c70ebf575f0477aef7bd28dac", "msg": "Setting up sun compiler goes too far on non Sun platforms that also have f77 compiler. So, first check if f77 is a Sun compiler and if affirmative then bother with lib_dirs. Removed also -fixed flag from f90 compiler, it just shouldn't be there.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-01T21:54:19+00:00", "author_timezone": 0, "committer_date": "2002-10-01T21:54:19+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "00dce9d64845208b4b984c29a32c3ce4ba1a8c5c" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 5, "insertions": 6, "lines": 11, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -619,18 +619,19 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n \n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n- self.f90_switches = ' -fixed -pic'\n+ self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n \n self.ver_cmd = self.f90_compiler + ' -V'\n \n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n- \n+\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n- self.library_dirs = self.find_lib_dir()\n+ if self.is_available():\n+ self.library_dirs = self.find_lib_dir()\n \n def build_module_switch(self,module_dirs):\n res = ''\n@@ -648,14 +649,14 @@ def find_lib_dir(self):\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n- if libs[0] == \"(null)\":\n+ if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n- self.version,'lib'))\n+ self.version,'lib'))\n return library_dirs\n \n def get_runtime_library_dirs(self):\n", "added_lines": 6, "deleted_lines": 5, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Is there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (?P[^\\s*]*)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n \n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if self.version >= '0.5.26': # is gcc >= 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f50/linux/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Is there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -fixed -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n \n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (?P[^\\s*]*)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n \n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if self.version >= '0.5.26': # is gcc >= 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f50/linux/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 80, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 11, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 114, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 130, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 154, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 165, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 174, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 212, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 233, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 246, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 259, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 312, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 337, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 354, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 366, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 392, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 397, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 402, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 405, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 426, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 468, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 477, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 480, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 505, "end_line": 506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 507, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 509, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 511, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 520, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 529, "end_line": 568, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 577, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 608, "end_line": 634, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 636, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 643, "end_line": 660, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 662, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 665, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 678, "end_line": 699, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 702, "end_line": 704, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 705, "end_line": 707, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 708, "end_line": 709, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 710, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 718, "end_line": 737, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 739, "end_line": 757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 765, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 21, "complexity": 10, "token_count": 117, "parameters": [ "self" ], "start_line": 798, "end_line": 820, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 822, "end_line": 839, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 841, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 850, "end_line": 858, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 860, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 871, "end_line": 899, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 901, "end_line": 915, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 918, "end_line": 919, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 929, "end_line": 932, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 940, "end_line": 959, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 961, "end_line": 963, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 965, "end_line": 966, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 980, "end_line": 1008, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1014, "end_line": 1015, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1024, "end_line": 1048, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1052, "end_line": 1053, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1061, "end_line": 1083, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1085, "end_line": 1088, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1090, "end_line": 1091, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1108, "end_line": 1131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1133, "end_line": 1135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1138, "end_line": 1140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1142, "end_line": 1143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1148, "end_line": 1149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1151, "end_line": 1159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 80, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 11, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 114, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 130, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 154, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 165, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 174, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 212, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 233, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 246, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 259, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 312, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 337, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 354, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 366, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 392, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 397, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 402, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 405, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 426, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 468, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 477, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 480, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 505, "end_line": 506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 507, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 509, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 511, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 520, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 529, "end_line": 568, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 577, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 110, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 608, "end_line": 633, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 635, "end_line": 640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 122, "parameters": [ "self" ], "start_line": 642, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 664, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 667, "end_line": 668, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 677, "end_line": 698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 701, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 704, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 707, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 709, "end_line": 710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 717, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 738, "end_line": 756, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 764, "end_line": 795, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 21, "complexity": 10, "token_count": 117, "parameters": [ "self" ], "start_line": 797, "end_line": 819, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 821, "end_line": 838, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 840, "end_line": 847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 849, "end_line": 857, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 859, "end_line": 860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 870, "end_line": 898, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 900, "end_line": 914, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 917, "end_line": 918, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 928, "end_line": 931, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 939, "end_line": 958, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 960, "end_line": 962, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 964, "end_line": 965, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 979, "end_line": 1007, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1013, "end_line": 1014, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1023, "end_line": 1047, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1051, "end_line": 1052, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1060, "end_line": 1082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1084, "end_line": 1087, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1089, "end_line": 1090, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1107, "end_line": 1130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1132, "end_line": 1134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1137, "end_line": 1139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1141, "end_line": 1142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1144, "end_line": 1145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1147, "end_line": 1148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1150, "end_line": 1158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 608, "end_line": 634, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 643, "end_line": 660, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 } ], "nloc": 845, "complexity": 209, "token_count": 4942, "diff_parsed": { "added": [ " self.f90_switches = ' -pic'", "", " if self.is_available():", " self.library_dirs = self.find_lib_dir()", " if libs and libs[0] == \"(null)\":", " self.version,'lib'))" ], "deleted": [ " self.f90_switches = ' -fixed -pic'", "", " self.library_dirs = self.find_lib_dir()", " if libs[0] == \"(null)\":", " self.version,'lib'))" ] } } ] }, { "hash": "4fa288b6450b86343571e40830e44e6f02c64764", "msg": "Fixed int check: works with Python 1.5, 2.1, 2.2; haven't tested with 2.0 or 2.3", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-02T13:50:11+00:00", "author_timezone": 0, "committer_date": "2002-10-02T13:50:11+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "95056afcb4ef5d7c70ebf575f0477aef7bd28dac" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -221,7 +221,7 @@ def __init__ (self,\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n- assert isinstance(self.search_static_first, int)\n+ assert isinstance(self.search_static_first, type(0))\n \n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n", "added_lines": 1, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n #info['size_liblapack'] = sz\n flag = 0 #os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, int)\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n #info['size_liblapack'] = sz\n flag = 0 #os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 52, "complexity": 11, "token_count": 265, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 491, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 508, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 515, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 606, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 623, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 630, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 670, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 675, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 696, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 719, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 729, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 179, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 52, "complexity": 11, "token_count": 265, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 491, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 508, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 515, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 606, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 623, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 630, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 670, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 675, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 696, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 719, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 729, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "nloc": 648, "complexity": 124, "token_count": 3181, "diff_parsed": { "added": [ " assert isinstance(self.search_static_first, type(0))" ], "deleted": [ " assert isinstance(self.search_static_first, int)" ] } } ] }, { "hash": "1a6151300cfe4730e886db99b1536fca75f51bba", "msg": "Generating __cvs__version__.py file", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-02T20:57:31+00:00", "author_timezone": 0, "committer_date": "2002-10-02T20:57:31+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "4fa288b6450b86343571e40830e44e6f02c64764" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/__init__.py", "new_path": "scipy_base/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n-\"\"\"Basic functions used by several sub-packages and useful to have in the\n+\"\"\" Basic functions used by several sub-packages and useful to have in the\n main name-space\n \n Type handling\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "source_code_before": "\"\"\"Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "methods": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 121, "complexity": 2, "token_count": 139, "diff_parsed": { "added": [ "\"\"\" Basic functions used by several sub-packages and useful to have in the" ], "deleted": [ "\"\"\"Basic functions used by several sub-packages and useful to have in the" ] } } ] }, { "hash": "6331702192daa6bc24111667eaea4cd72ba488f9", "msg": "Generating __cvs__version__.py file, another try", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-02T21:01:02+00:00", "author_timezone": 0, "committer_date": "2002-10-02T21:01:02+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "1a6151300cfe4730e886db99b1536fca75f51bba" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/__init__.py", "new_path": "scipy_base/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n-\"\"\" Basic functions used by several sub-packages and useful to have in the\n+\"\"\"Basic functions used by several sub-packages and useful to have in the\n main name-space\n \n Type handling\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\"Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "source_code_before": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "methods": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 121, "complexity": 2, "token_count": 139, "diff_parsed": { "added": [ "\"\"\"Basic functions used by several sub-packages and useful to have in the" ], "deleted": [ "\"\"\" Basic functions used by several sub-packages and useful to have in the" ] } } ] }, { "hash": "6a1436b512be4156be255b37f8a9c068a07c066d", "msg": "Testing __cvs__version__.py", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-02T21:07:39+00:00", "author_timezone": 0, "committer_date": "2002-10-02T21:07:39+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "6331702192daa6bc24111667eaea4cd72ba488f9" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/__init__.py", "new_path": "scipy_base/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n-\"\"\"Basic functions used by several sub-packages and useful to have in the\n+\"\"\" Basic functions used by several sub-packages and useful to have in the\n main name-space\n \n Type handling\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "source_code_before": "\"\"\"Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "methods": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 121, "complexity": 2, "token_count": 139, "diff_parsed": { "added": [ "\"\"\" Basic functions used by several sub-packages and useful to have in the" ], "deleted": [ "\"\"\"Basic functions used by several sub-packages and useful to have in the" ] } } ] }, { "hash": "7f771f7324290e78be41cd4e0c9c73d48864c651", "msg": "Testing __cvs__version__.py", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-02T21:10:34+00:00", "author_timezone": 0, "committer_date": "2002-10-02T21:10:34+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "6a1436b512be4156be255b37f8a9c068a07c066d" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/__init__.py", "new_path": "scipy_base/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n-\"\"\" Basic functions used by several sub-packages and useful to have in the\n+\"\"\"Basic functions used by several sub-packages and useful to have in the\n main name-space\n \n Type handling\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\"Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "source_code_before": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "methods": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 121, "complexity": 2, "token_count": 139, "diff_parsed": { "added": [ "\"\"\"Basic functions used by several sub-packages and useful to have in the" ], "deleted": [ "\"\"\" Basic functions used by several sub-packages and useful to have in the" ] } } ] }, { "hash": "97b20f1216ddc6a1ecc8b0713048e21ffa8e275d", "msg": "Testing __cvs__version__.py (2)", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-02T21:15:04+00:00", "author_timezone": 0, "committer_date": "2002-10-02T21:15:04+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "7f771f7324290e78be41cd4e0c9c73d48864c651" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/__init__.py", "new_path": "scipy_base/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n-\"\"\"Basic functions used by several sub-packages and useful to have in the\n+\"\"\" Basic functions used by several sub-packages and useful to have in the\n main name-space\n \n Type handling\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "source_code_before": "\"\"\"Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "methods": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 121, "complexity": 2, "token_count": 139, "diff_parsed": { "added": [ "\"\"\" Basic functions used by several sub-packages and useful to have in the" ], "deleted": [ "\"\"\"Basic functions used by several sub-packages and useful to have in the" ] } } ] }, { "hash": "24a2ee5af8223c3870c51696eb2197129c24e172", "msg": "Exposed version to imported module, filled setup arguments for sdist command", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-02T21:46:18+00:00", "author_timezone": 0, "committer_date": "2002-10-02T21:46:18+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "97b20f1216ddc6a1ecc8b0713048e21ffa8e275d" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 3, "insertions": 13, "lines": 16, "files": 2, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/__init__.py", "new_path": "scipy_base/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -92,6 +92,8 @@\n polyval -- Evaluate polynomial at given argument\n \"\"\"\n \n+from scipy_base_version import scipy_base_version as __version__\n+\n import Numeric\n from Numeric import *\n import fastumath\n@@ -130,5 +132,3 @@ def test_suite(level=1):\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n-\n-\n", "added_lines": 2, "deleted_lines": 2, "source_code": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nfrom scipy_base_version import scipy_base_version as __version__\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n", "source_code_before": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\"\"\"\n\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\n\n# needs scipy_base.fastumath\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF - fastumath.PINF\n\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", "methods": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 121, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 127, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 122, "complexity": 2, "token_count": 145, "diff_parsed": { "added": [ "from scipy_base_version import scipy_base_version as __version__", "" ], "deleted": [ "", "" ] } }, { "old_path": "scipy_base/setup_scipy_base.py", "new_path": "scipy_base/setup_scipy_base.py", "filename": "setup_scipy_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -50,7 +50,17 @@ def configuration(parent_package=''):\n return config\n \n if __name__ == '__main__': \n+ from scipy_base_version import scipy_base_version\n+ print 'scipy_base Version',scipy_base_version\n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n- setup(**configuration())\n+ setup(name = 'scipy_base',\n+ version = scipy_base_version,\n+ maintainer = \"SciPy Developers\",\n+ maintainer_email = \"scipy-dev@scipy.org\",\n+ description = \"SciPy base module\",\n+ url = \"http://www.scipy.org\",\n+ license = \"SciPy License (BSD Style)\",\n+ **configuration()\n+ )\n", "added_lines": 11, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nfrom scipy_distutils.core import Extension\nfrom scipy_distutils.misc_util import get_path, default_config_dict,dot_join\nimport shutil\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n config['packages'].append(parent_package+'scipy_base')\n config['package_dir'][parent_package+'scipy_base'] = local_path\n\n config['packages'].append(dot_join(parent_package,'scipy_base.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['scipy_base.tests'] = test_path\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n sources = ['fastumathmodule.c','isnan.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension('scipy_base.fastumath',sources,libraries=[],\n extra_compile_args=extra_compile_args)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension('scipy_base._compiled_base',sources,libraries=[])\n config['ext_modules'].append(ext)\n\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),os.path.join(local_path,'mconf_lite.h'))\n\n return config\n\nif __name__ == '__main__': \n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n setup(name = 'scipy_base',\n version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nfrom scipy_distutils.core import Extension\nfrom scipy_distutils.misc_util import get_path, default_config_dict,dot_join\nimport shutil\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n config['packages'].append(parent_package+'scipy_base')\n config['package_dir'][parent_package+'scipy_base'] = local_path\n\n config['packages'].append(dot_join(parent_package,'scipy_base.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['scipy_base.tests'] = test_path\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n sources = ['fastumathmodule.c','isnan.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension('scipy_base.fastumath',sources,libraries=[],\n extra_compile_args=extra_compile_args)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension('scipy_base._compiled_base',sources,libraries=[])\n config['ext_modules'].append(ext)\n\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),os.path.join(local_path,'mconf_lite.h'))\n\n return config\n\nif __name__ == '__main__': \n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n setup(**configuration())\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 28, "complexity": 5, "token_count": 251, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 28, "complexity": 5, "token_count": 251, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 48, "complexity": 5, "token_count": 345, "diff_parsed": { "added": [ " from scipy_base_version import scipy_base_version", " print 'scipy_base Version',scipy_base_version", " setup(name = 'scipy_base',", " version = scipy_base_version,", " maintainer = \"SciPy Developers\",", " maintainer_email = \"scipy-dev@scipy.org\",", " description = \"SciPy base module\",", " url = \"http://www.scipy.org\",", " license = \"SciPy License (BSD Style)\",", " **configuration()", " )" ], "deleted": [ " setup(**configuration())" ] } } ] }, { "hash": "fa6606c4fb540c21f94a5c2bf76753277ac0e466", "msg": "Exposed version to imported module, filled setup arguments for sdist command, fixed typos", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-02T21:58:25+00:00", "author_timezone": 0, "committer_date": "2002-10-02T21:58:25+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "24a2ee5af8223c3870c51696eb2197129c24e172" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 8, "insertions": 23, "lines": 31, "files": 4, "dmm_unit_size": 1.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/__init__.py", "new_path": "scipy_distutils/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -5,3 +5,5 @@\n \"\"\"\n \n # Need to do something here to get distutils subsumed...\n+\n+from scipy_distutils_version import scipy_distutils_version as __version__\n", "added_lines": 2, "deleted_lines": 0, "source_code": "\"\"\"scipy_distutils\n\n Modified version of distutils to handle fortran source code, f2py,\n and other issues in the scipy build process.\n\"\"\"\n\n# Need to do something here to get distutils subsumed...\n\nfrom scipy_distutils_version import scipy_distutils_version as __version__\n", "source_code_before": "\"\"\"scipy_distutils\n\n Modified version of distutils to handle fortran source code, f2py,\n and other issues in the scipy build process.\n\"\"\"\n\n# Need to do something here to get distutils subsumed...\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 6, "complexity": 0, "token_count": 7, "diff_parsed": { "added": [ "", "from scipy_distutils_version import scipy_distutils_version as __version__" ], "deleted": [] } }, { "old_path": "scipy_distutils/scipy_distutils_version.py", "new_path": "scipy_distutils/scipy_distutils_version.py", "filename": "scipy_distutils_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,4 +8,4 @@\n cvs_serial = cvs_version[-1]\n \n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 2\nmicro = 0\nrelease_level = 'alpha'\n\nfrom __cvs_version__ import cvs_version\ncvs_minor = cvs_version[-3]\ncvs_serial = cvs_version[-1]\n\nscipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 2\nmicro = 0\nrelease_level = 'alpha'\n\nfrom __cvs_version__ import cvs_version\ncvs_minor = cvs_version[-3]\ncvs_serial = cvs_version[-1]\n\nscipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 9, "complexity": 0, "token_count": 41, "diff_parsed": { "added": [ " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ], "deleted": [ " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ] } }, { "old_path": "scipy_distutils/setup.py", "new_path": "scipy_distutils/setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,6 +3,7 @@\n \n from distutils.core import setup\n from misc_util import get_path, update_version\n+from scipy_distutils_version import scipy_distutils_version\n \n def install_package():\n \"\"\" Install the scipy_distutils. The dance with the current directory is done\n@@ -13,16 +14,13 @@ def install_package():\n old_path = os.getcwd()\n os.chdir(path)\n try:\n-\n- version = update_version('alpha')\n- print 'scipy_distutils',version\n-\n+ print 'scipy_distutils Version',scipy_distutils_version\n setup (name = \"scipy_distutils\",\n- version = version,\n+ version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n- author_email = \"scipy-devel@scipy.org\",\n- licence = \"BSD Style\",\n+ author_email = \"scipy-dev@scipy.org\",\n+ license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n packages = ['scipy_distutils','scipy_distutils.command'],\n package_dir = {'scipy_distutils':path}\n", "added_lines": 5, "deleted_lines": 7, "source_code": "#!/usr/bin/env python\nimport os\n\nfrom distutils.core import setup\nfrom misc_util import get_path, update_version\nfrom scipy_distutils_version import scipy_distutils_version\n\ndef install_package():\n \"\"\" Install the scipy_distutils. The dance with the current directory is done\n to fool distutils into thinking it is run from the scipy_distutils directory\n even if it was invoked from another script located in a different location.\n \"\"\"\n path = get_path(__name__)\n old_path = os.getcwd()\n os.chdir(path)\n try:\n print 'scipy_distutils Version',scipy_distutils_version\n setup (name = \"scipy_distutils\",\n version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n packages = ['scipy_distutils','scipy_distutils.command'],\n package_dir = {'scipy_distutils':path}\n )\n finally:\n os.chdir(old_path)\n \nif __name__ == '__main__':\n install_package()\n", "source_code_before": "#!/usr/bin/env python\nimport os\n\nfrom distutils.core import setup\nfrom misc_util import get_path, update_version\n\ndef install_package():\n \"\"\" Install the scipy_distutils. The dance with the current directory is done\n to fool distutils into thinking it is run from the scipy_distutils directory\n even if it was invoked from another script located in a different location.\n \"\"\"\n path = get_path(__name__)\n old_path = os.getcwd()\n os.chdir(path)\n try:\n\n version = update_version('alpha')\n print 'scipy_distutils',version\n\n setup (name = \"scipy_distutils\",\n version = version,\n description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-devel@scipy.org\",\n licence = \"BSD Style\",\n url = 'http://www.scipy.org',\n packages = ['scipy_distutils','scipy_distutils.command'],\n package_dir = {'scipy_distutils':path}\n )\n finally:\n os.chdir(old_path)\n \nif __name__ == '__main__':\n install_package()\n", "methods": [ { "name": "install_package", "long_name": "install_package( )", "filename": "setup.py", "nloc": 18, "complexity": 2, "token_count": 84, "parameters": [], "start_line": 8, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "methods_before": [ { "name": "install_package", "long_name": "install_package( )", "filename": "setup.py", "nloc": 19, "complexity": 2, "token_count": 90, "parameters": [], "start_line": 7, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "install_package", "long_name": "install_package( )", "filename": "setup.py", "nloc": 18, "complexity": 2, "token_count": 84, "parameters": [], "start_line": 8, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "nloc": 24, "complexity": 2, "token_count": 111, "diff_parsed": { "added": [ "from scipy_distutils_version import scipy_distutils_version", " print 'scipy_distutils Version',scipy_distutils_version", " version = scipy_distutils_version,", " author_email = \"scipy-dev@scipy.org\",", " license = \"SciPy License (BSD Style)\"," ], "deleted": [ "", " version = update_version('alpha')", " print 'scipy_distutils',version", "", " version = version,", " author_email = \"scipy-devel@scipy.org\",", " licence = \"BSD Style\"," ] } }, { "old_path": "scipy_distutils/setup_scipy_distutils.py", "new_path": "scipy_distutils/setup_scipy_distutils.py", "filename": "setup_scipy_distutils.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -15,3 +15,18 @@ def configuration(parent_package=''):\n config['packages'].append(parent_package+package),\n config['package_dir'][package] = os.path.join(local_path,'command') \n return config\n+\n+if __name__ == '__main__':\n+ from scipy_distutils_version import scipy_distutils_version\n+ print 'scipy_distutils Version',scipy_distutils_version\n+ from scipy_distutils.core import setup\n+ print 'scipy_distutils Version',scipy_distutils_version\n+ setup (name = \"scipy_distutils\",\n+ version = scipy_distutils_version,\n+ description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n+ author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n+ author_email = \"scipy-dev@scipy.org\",\n+ license = \"SciPy License (BSD Style)\",\n+ url = 'http://www.scipy.org',\n+ **configuration()\n+ )\n", "added_lines": 15, "deleted_lines": 0, "source_code": "import os\nfrom scipy_distutils.misc_util import get_path, default_config_dict\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n package = 'scipy_distutils'\n config['packages'].append(parent_package+package)\n config['package_dir'][package] = local_path \n package = 'scipy_distutils.command' \n config['packages'].append(parent_package+package),\n config['package_dir'][package] = os.path.join(local_path,'command') \n return config\n\nif __name__ == '__main__':\n from scipy_distutils_version import scipy_distutils_version\n print 'scipy_distutils Version',scipy_distutils_version\n from scipy_distutils.core import setup\n print 'scipy_distutils Version',scipy_distutils_version\n setup (name = \"scipy_distutils\",\n version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **configuration()\n )\n", "source_code_before": "import os\nfrom scipy_distutils.misc_util import get_path, default_config_dict\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n package = 'scipy_distutils'\n config['packages'].append(parent_package+package)\n config['package_dir'][package] = local_path \n package = 'scipy_distutils.command' \n config['packages'].append(parent_package+package),\n config['package_dir'][package] = os.path.join(local_path,'command') \n return config\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 13, "complexity": 2, "token_count": 85, "parameters": [ "parent_package" ], "start_line": 4, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 13, "complexity": 2, "token_count": 85, "parameters": [ "parent_package" ], "start_line": 4, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 29, "complexity": 2, "token_count": 154, "diff_parsed": { "added": [ "", "if __name__ == '__main__':", " from scipy_distutils_version import scipy_distutils_version", " print 'scipy_distutils Version',scipy_distutils_version", " from scipy_distutils.core import setup", " print 'scipy_distutils Version',scipy_distutils_version", " setup (name = \"scipy_distutils\",", " version = scipy_distutils_version,", " description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",", " author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",", " author_email = \"scipy-dev@scipy.org\",", " license = \"SciPy License (BSD Style)\",", " url = 'http://www.scipy.org',", " **configuration()", " )" ], "deleted": [] } } ] }, { "hash": "d458416e2eddc09e28f8d1e1973e19d32ab3d831", "msg": "Carried out major unification of xxx/setup_xxx.py files. Discussion: some modules contain setup.py files that repeat the functionality of the corresponding setup_xxx.py files. Are there any objections if setup.py and setup_xxx.py will be merged into setup_xxx.py and setup.py files will be removed from CVS?", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-03T00:19:55+00:00", "author_timezone": 0, "committer_date": "2002-10-03T00:19:55+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "fa6606c4fb540c21f94a5c2bf76753277ac0e466" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 63, "insertions": 65, "lines": 128, "files": 8, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_base/scipy_base_version.py", "new_path": "scipy_base/scipy_base_version.py", "filename": "scipy_base_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,4 +8,4 @@\n cvs_serial = cvs_version[-1]\n \n scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 2\nmicro = 0\nrelease_level = 'alpha'\n\nfrom __cvs_version__ import cvs_version\ncvs_minor = cvs_version[-3]\ncvs_serial = cvs_version[-1]\n\nscipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 2\nmicro = 0\nrelease_level = 'alpha'\n\nfrom __cvs_version__ import cvs_version\ncvs_minor = cvs_version[-3]\ncvs_serial = cvs_version[-1]\n\nscipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 9, "complexity": 0, "token_count": 41, "diff_parsed": { "added": [ " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ], "deleted": [ " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ] } }, { "old_path": "scipy_base/setup_scipy_base.py", "new_path": "scipy_base/setup_scipy_base.py", "filename": "setup_scipy_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,22 +3,13 @@\n import os, sys\n from glob import glob\n from scipy_distutils.core import Extension\n-from scipy_distutils.misc_util import get_path, default_config_dict,dot_join\n+from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n import shutil\n \n def configuration(parent_package=''):\n- parent_path = parent_package\n- if parent_package:\n- parent_package += '.'\n+ package = 'scipy_base'\n local_path = get_path(__name__)\n-\n- config = default_config_dict()\n- config['packages'].append(parent_package+'scipy_base')\n- config['package_dir'][parent_package+'scipy_base'] = local_path\n-\n- config['packages'].append(dot_join(parent_package,'scipy_base.tests'))\n- test_path = os.path.join(local_path,'tests')\n- config['package_dir']['scipy_base.tests'] = test_path\n+ config = default_config_dict(package,parent_package)\n \n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n@@ -28,35 +19,35 @@ def configuration(parent_package=''):\n # scipy_base.fastumath module\n sources = ['fastumathmodule.c','isnan.c']\n sources = [os.path.join(local_path,x) for x in sources]\n- ext = Extension('scipy_base.fastumath',sources,libraries=[],\n+ ext = Extension(dot_join(package,'fastumath'),sources,libraries=[],\n extra_compile_args=extra_compile_args)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n- ext = Extension('scipy_base._compiled_base',sources,libraries=[])\n+ ext = Extension(dot_join(package,'_compiled_base'),sources,libraries=[])\n config['ext_modules'].append(ext)\n \n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n- shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),os.path.join(local_path,'mconf_lite.h'))\n+ shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),\n+ os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n- shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),os.path.join(local_path,'mconf_lite.h'))\n-\n+ shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),\n+ os.path.join(local_path,'mconf_lite.h'))\n return config\n \n-if __name__ == '__main__': \n+if __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n- setup(name = 'scipy_base',\n- version = scipy_base_version,\n+ setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n", "added_lines": 11, "deleted_lines": 20, "source_code": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nfrom scipy_distutils.core import Extension\nfrom scipy_distutils.misc_util import get_path,default_config_dict,dot_join\nimport shutil\n\ndef configuration(parent_package=''):\n package = 'scipy_base'\n local_path = get_path(__name__)\n config = default_config_dict(package,parent_package)\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n sources = ['fastumathmodule.c','isnan.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'fastumath'),sources,libraries=[],\n extra_compile_args=extra_compile_args)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'_compiled_base'),sources,libraries=[])\n config['ext_modules'].append(ext)\n\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),\n os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),\n os.path.join(local_path,'mconf_lite.h'))\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nfrom scipy_distutils.core import Extension\nfrom scipy_distutils.misc_util import get_path, default_config_dict,dot_join\nimport shutil\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n config['packages'].append(parent_package+'scipy_base')\n config['package_dir'][parent_package+'scipy_base'] = local_path\n\n config['packages'].append(dot_join(parent_package,'scipy_base.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['scipy_base.tests'] = test_path\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n sources = ['fastumathmodule.c','isnan.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension('scipy_base.fastumath',sources,libraries=[],\n extra_compile_args=extra_compile_args)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension('scipy_base._compiled_base',sources,libraries=[])\n config['ext_modules'].append(ext)\n\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),os.path.join(local_path,'mconf_lite.h'))\n\n return config\n\nif __name__ == '__main__': \n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n setup(name = 'scipy_base',\n version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 23, "complexity": 4, "token_count": 201, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 28, "complexity": 5, "token_count": 251, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 23, "complexity": 4, "token_count": 201, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 } ], "nloc": 42, "complexity": 4, "token_count": 291, "diff_parsed": { "added": [ "from scipy_distutils.misc_util import get_path,default_config_dict,dot_join", " package = 'scipy_base'", " config = default_config_dict(package,parent_package)", " ext = Extension(dot_join(package,'fastumath'),sources,libraries=[],", " ext = Extension(dot_join(package,'_compiled_base'),sources,libraries=[])", " shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),", " os.path.join(local_path,'mconf_lite.h'))", " shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),", " os.path.join(local_path,'mconf_lite.h'))", "if __name__ == '__main__':", " setup(version = scipy_base_version," ], "deleted": [ "from scipy_distutils.misc_util import get_path, default_config_dict,dot_join", " parent_path = parent_package", " if parent_package:", " parent_package += '.'", "", " config = default_config_dict()", " config['packages'].append(parent_package+'scipy_base')", " config['package_dir'][parent_package+'scipy_base'] = local_path", "", " config['packages'].append(dot_join(parent_package,'scipy_base.tests'))", " test_path = os.path.join(local_path,'tests')", " config['package_dir']['scipy_base.tests'] = test_path", " ext = Extension('scipy_base.fastumath',sources,libraries=[],", " ext = Extension('scipy_base._compiled_base',sources,libraries=[])", " shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),os.path.join(local_path,'mconf_lite.h'))", " shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),os.path.join(local_path,'mconf_lite.h'))", "", "if __name__ == '__main__':", " setup(name = 'scipy_base',", " version = scipy_base_version," ] } }, { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -262,7 +262,7 @@ def package_config(primary,dependencies=[]):\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n- has a configuration() file in it. \n+ has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n@@ -273,9 +273,12 @@ def package_config(primary,dependencies=[]):\n list_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\n-dict_keys = ['package_dir'] \n+dict_keys = ['package_dir']\n \n def default_config_dict(name = None, parent_name = None):\n+ \"\"\" Return a configuration dictionary for usage in\n+ configuration() function defined in file setup_.py.\n+ \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n@@ -285,18 +288,22 @@ def default_config_dict(name = None, parent_name = None):\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n+ # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n- if name and parent_name is None:\n+ test_path = os.path.join(local_path,'tests')\n+ if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n-\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n+ if os.path.exists(test_path):\n+ d['packages'].append(dot_join(full_name,'tests'))\n+ d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n- if not parent_name:\n+ if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n", "added_lines": 12, "deleted_lines": 5, "source_code": "import os,sys,string\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\n#XXX: update_version and related functions are not used\n# in the scipy project. Should we remove them?\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with the old version information. To get\n # __version__.py also up to date, a second commit of the\n # __version__.py file is required after you re-run\n # update_version(..). To summarize:\n # 1) cvs commit ...\n # 2) python setup.py # that should call update_version\n # 3) cvs commit -m \"updating version\" __version__.py\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version_info != old_version_info:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with update_version\\n'\\\n '# function from scipy_distutils.misc_util.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . Does not change /__version__.py.\n See also update_version(..) function.\n \"\"\"\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n\t\tlast_numbers = map(eval,string.split(items[2],'.')[-2:])\n\t\tif len(last_numbers)==2:\n\t\t d1,d2 = last_numbers\n\t\telse: # this is when 'cvs add' but not yet 'cvs commit'\n\t\t d1,d2 = 0,0\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n", "source_code_before": "import os,sys,string\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\n#XXX: update_version and related functions are not used\n# in the scipy project. Should we remove them?\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with the old version information. To get\n # __version__.py also up to date, a second commit of the\n # __version__.py file is required after you re-run\n # update_version(..). To summarize:\n # 1) cvs commit ...\n # 2) python setup.py # that should call update_version\n # 3) cvs commit -m \"updating version\" __version__.py\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version_info != old_version_info:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with update_version\\n'\\\n '# function from scipy_distutils.misc_util.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . Does not change /__version__.py.\n See also update_version(..) function.\n \"\"\"\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n\t\tlast_numbers = map(eval,string.split(items[2],'.')[-2:])\n\t\tif len(last_numbers)==2:\n\t\t d1,d2 = last_numbers\n\t\telse: # this is when 'cvs add' but not yet 'cvs commit'\n\t\t d1,d2 = 0,0\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() file in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir'] \n\ndef default_config_dict(name = None, parent_name = None):\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n if name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n d['name'] = full_name\n if not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n", "methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 5, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 40, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 43, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 48, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 107, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "release_level", "path", "major" ], "start_line": 156, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 21, "complexity": 10, "token_count": 190, "parameters": [ "path" ], "start_line": 172, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 201, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 218, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 223, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 228, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 231, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 259, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 278, "end_line": 316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 318, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 327, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 336, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 343, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 346, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 } ], "methods_before": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 5, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 40, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 43, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 48, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 107, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "release_level", "path", "major" ], "start_line": 156, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 21, "complexity": 10, "token_count": 190, "parameters": [ "path" ], "start_line": 172, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 201, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 218, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 223, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 228, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 231, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 259, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 25, "complexity": 10, "token_count": 211, "parameters": [ "name", "parent_name" ], "start_line": 278, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 311, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 320, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 329, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 336, "end_line": 337, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 339, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 278, "end_line": 316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 259, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 } ], "nloc": 238, "complexity": 75, "token_count": 1703, "diff_parsed": { "added": [ " has a configuration() function in it.", "dict_keys = ['package_dir']", " \"\"\" Return a configuration dictionary for usage in", " configuration() function defined in file setup_.py.", " \"\"\"", " # Todo: implement check for this assumption.", " test_path = os.path.join(local_path,'tests')", " if 0 and name and parent_name is None:", " if os.path.exists(test_path):", " d['packages'].append(dot_join(full_name,'tests'))", " d['package_dir'][dot_join(full_name,'tests')] = test_path", " if 0 and not parent_name:" ], "deleted": [ " has a configuration() file in it.", "dict_keys = ['package_dir']", " if name and parent_name is None:", "", " if not parent_name:" ] } }, { "old_path": "scipy_distutils/setup.py", "new_path": "scipy_distutils/setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -6,9 +6,10 @@\n from scipy_distutils_version import scipy_distutils_version\n \n def install_package():\n- \"\"\" Install the scipy_distutils. The dance with the current directory is done\n- to fool distutils into thinking it is run from the scipy_distutils directory\n- even if it was invoked from another script located in a different location.\n+ \"\"\" Install the scipy_distutils. The dance with the current directory\n+ is done to fool distutils into thinking it is run from the\n+ scipy_distutils directory even if it was invoked from another\n+ script located in a different location.\n \"\"\"\n path = get_path(__name__)\n old_path = os.getcwd()\n@@ -17,7 +18,8 @@ def install_package():\n print 'scipy_distutils Version',scipy_distutils_version\n setup (name = \"scipy_distutils\",\n version = scipy_distutils_version,\n- description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n+ description = \"Changes to distutils needed for SciPy\"\\\n+ \" -- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n", "added_lines": 6, "deleted_lines": 4, "source_code": "#!/usr/bin/env python\nimport os\n\nfrom distutils.core import setup\nfrom misc_util import get_path, update_version\nfrom scipy_distutils_version import scipy_distutils_version\n\ndef install_package():\n \"\"\" Install the scipy_distutils. The dance with the current directory\n is done to fool distutils into thinking it is run from the\n scipy_distutils directory even if it was invoked from another\n script located in a different location.\n \"\"\"\n path = get_path(__name__)\n old_path = os.getcwd()\n os.chdir(path)\n try:\n print 'scipy_distutils Version',scipy_distutils_version\n setup (name = \"scipy_distutils\",\n version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy\"\\\n \" -- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n packages = ['scipy_distutils','scipy_distutils.command'],\n package_dir = {'scipy_distutils':path}\n )\n finally:\n os.chdir(old_path)\n \nif __name__ == '__main__':\n install_package()\n", "source_code_before": "#!/usr/bin/env python\nimport os\n\nfrom distutils.core import setup\nfrom misc_util import get_path, update_version\nfrom scipy_distutils_version import scipy_distutils_version\n\ndef install_package():\n \"\"\" Install the scipy_distutils. The dance with the current directory is done\n to fool distutils into thinking it is run from the scipy_distutils directory\n even if it was invoked from another script located in a different location.\n \"\"\"\n path = get_path(__name__)\n old_path = os.getcwd()\n os.chdir(path)\n try:\n print 'scipy_distutils Version',scipy_distutils_version\n setup (name = \"scipy_distutils\",\n version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n packages = ['scipy_distutils','scipy_distutils.command'],\n package_dir = {'scipy_distutils':path}\n )\n finally:\n os.chdir(old_path)\n \nif __name__ == '__main__':\n install_package()\n", "methods": [ { "name": "install_package", "long_name": "install_package( )", "filename": "setup.py", "nloc": 19, "complexity": 2, "token_count": 86, "parameters": [], "start_line": 8, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 } ], "methods_before": [ { "name": "install_package", "long_name": "install_package( )", "filename": "setup.py", "nloc": 18, "complexity": 2, "token_count": 84, "parameters": [], "start_line": 8, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "install_package", "long_name": "install_package( )", "filename": "setup.py", "nloc": 19, "complexity": 2, "token_count": 86, "parameters": [], "start_line": 8, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 } ], "nloc": 25, "complexity": 2, "token_count": 113, "diff_parsed": { "added": [ " \"\"\" Install the scipy_distutils. The dance with the current directory", " is done to fool distutils into thinking it is run from the", " scipy_distutils directory even if it was invoked from another", " script located in a different location.", " description = \"Changes to distutils needed for SciPy\"\\", " \" -- mostly Fortran support\"," ], "deleted": [ " \"\"\" Install the scipy_distutils. The dance with the current directory is done", " to fool distutils into thinking it is run from the scipy_distutils directory", " even if it was invoked from another script located in a different location.", " description = \"Changes to distutils needed for SciPy -- mostly Fortran support\"," ] } }, { "old_path": "scipy_distutils/setup_scipy_distutils.py", "new_path": "scipy_distutils/setup_scipy_distutils.py", "filename": "setup_scipy_distutils.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,32 +1,30 @@\n+#!/usr/bin/env python\n+\n import os\n-from scipy_distutils.misc_util import get_path, default_config_dict\n+from misc_util import get_path, default_config_dict, dot_join\n \n def configuration(parent_package=''):\n- parent_path = parent_package\n- if parent_package:\n- parent_package += '.'\n+ package = 'scipy_distutils'\n local_path = get_path(__name__)\n+ config = default_config_dict(package,parent_package)\n \n- config = default_config_dict()\n- package = 'scipy_distutils'\n- config['packages'].append(parent_package+package)\n- config['package_dir'][package] = local_path \n- package = 'scipy_distutils.command' \n- config['packages'].append(parent_package+package),\n- config['package_dir'][package] = os.path.join(local_path,'command') \n+ sub_package = dot_join(package,'command')\n+ config['packages'].append(dot_join(parent_package,sub_package))\n+ config['package_dir'][sub_package] = os.path.join(local_path,'command')\n return config\n \n if __name__ == '__main__':\n from scipy_distutils_version import scipy_distutils_version\n print 'scipy_distutils Version',scipy_distutils_version\n- from scipy_distutils.core import setup\n- print 'scipy_distutils Version',scipy_distutils_version\n- setup (name = \"scipy_distutils\",\n- version = scipy_distutils_version,\n- description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n- author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n- author_email = \"scipy-dev@scipy.org\",\n- license = \"SciPy License (BSD Style)\",\n- url = 'http://www.scipy.org',\n- **configuration()\n- )\n+ from distutils.core import setup\n+ config = configuration()\n+ [config.__delitem__(k) for k,v in config.items() if not v]\n+ setup(version = scipy_distutils_version,\n+ description = \"Changes to distutils needed for SciPy \"\\\n+ \"-- mostly Fortran support\",\n+ author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n+ author_email = \"scipy-dev@scipy.org\",\n+ license = \"SciPy License (BSD Style)\",\n+ url = 'http://www.scipy.org',\n+ **config\n+ )\n", "added_lines": 20, "deleted_lines": 22, "source_code": "#!/usr/bin/env python\n\nimport os\nfrom misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n package = 'scipy_distutils'\n local_path = get_path(__name__)\n config = default_config_dict(package,parent_package)\n\n sub_package = dot_join(package,'command')\n config['packages'].append(dot_join(parent_package,sub_package))\n config['package_dir'][sub_package] = os.path.join(local_path,'command')\n return config\n\nif __name__ == '__main__':\n from scipy_distutils_version import scipy_distutils_version\n print 'scipy_distutils Version',scipy_distutils_version\n from distutils.core import setup\n config = configuration()\n [config.__delitem__(k) for k,v in config.items() if not v]\n setup(version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy \"\\\n \"-- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **config\n )\n", "source_code_before": "import os\nfrom scipy_distutils.misc_util import get_path, default_config_dict\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n package = 'scipy_distutils'\n config['packages'].append(parent_package+package)\n config['package_dir'][package] = local_path \n package = 'scipy_distutils.command' \n config['packages'].append(parent_package+package),\n config['package_dir'][package] = os.path.join(local_path,'command') \n return config\n\nif __name__ == '__main__':\n from scipy_distutils_version import scipy_distutils_version\n print 'scipy_distutils Version',scipy_distutils_version\n from scipy_distutils.core import setup\n print 'scipy_distutils Version',scipy_distutils_version\n setup (name = \"scipy_distutils\",\n version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **configuration()\n )\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 8, "complexity": 1, "token_count": 66, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 13, "complexity": 2, "token_count": 85, "parameters": [ "parent_package" ], "start_line": 4, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 8, "complexity": 1, "token_count": 66, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "nloc": 25, "complexity": 1, "token_count": 153, "diff_parsed": { "added": [ "#!/usr/bin/env python", "", "from misc_util import get_path, default_config_dict, dot_join", " package = 'scipy_distutils'", " config = default_config_dict(package,parent_package)", " sub_package = dot_join(package,'command')", " config['packages'].append(dot_join(parent_package,sub_package))", " config['package_dir'][sub_package] = os.path.join(local_path,'command')", " from distutils.core import setup", " config = configuration()", " [config.__delitem__(k) for k,v in config.items() if not v]", " setup(version = scipy_distutils_version,", " description = \"Changes to distutils needed for SciPy \"\\", " \"-- mostly Fortran support\",", " author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",", " author_email = \"scipy-dev@scipy.org\",", " license = \"SciPy License (BSD Style)\",", " url = 'http://www.scipy.org',", " **config", " )" ], "deleted": [ "from scipy_distutils.misc_util import get_path, default_config_dict", " parent_path = parent_package", " if parent_package:", " parent_package += '.'", " config = default_config_dict()", " package = 'scipy_distutils'", " config['packages'].append(parent_package+package)", " config['package_dir'][package] = local_path", " package = 'scipy_distutils.command'", " config['packages'].append(parent_package+package),", " config['package_dir'][package] = os.path.join(local_path,'command')", " from scipy_distutils.core import setup", " print 'scipy_distutils Version',scipy_distutils_version", " setup (name = \"scipy_distutils\",", " version = scipy_distutils_version,", " description = \"Changes to distutils needed for SciPy -- mostly Fortran support\",", " author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",", " author_email = \"scipy-dev@scipy.org\",", " license = \"SciPy License (BSD Style)\",", " url = 'http://www.scipy.org',", " **configuration()", " )" ] } }, { "old_path": "scipy_test/__init__.py", "new_path": "scipy_test/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,2 +1,2 @@\n-# nothing done here currently \n-# __init__.py file just used to mark the directory as a package.\n+\n+from scipy_test_version import scipy_test_version as __version__\n", "added_lines": 2, "deleted_lines": 2, "source_code": "\nfrom scipy_test_version import scipy_test_version as __version__\n", "source_code_before": "# nothing done here currently \n# __init__.py file just used to mark the directory as a package.\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 1, "complexity": 0, "token_count": 6, "diff_parsed": { "added": [ "", "from scipy_test_version import scipy_test_version as __version__" ], "deleted": [ "# nothing done here currently", "# __init__.py file just used to mark the directory as a package." ] } }, { "old_path": "scipy_test/scipy_test_version.py", "new_path": "scipy_test/scipy_test_version.py", "filename": "scipy_test_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,4 +8,4 @@\n cvs_serial = cvs_version[-1]\n \n scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 2\nmicro = 0\nrelease_level = 'alpha'\n\nfrom __cvs_version__ import cvs_version\ncvs_minor = cvs_version[-3]\ncvs_serial = cvs_version[-1]\n\nscipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 2\nmicro = 0\nrelease_level = 'alpha'\n\nfrom __cvs_version__ import cvs_version\ncvs_minor = cvs_version[-3]\ncvs_serial = cvs_version[-1]\n\nscipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 9, "complexity": 0, "token_count": 41, "diff_parsed": { "added": [ " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ], "deleted": [ " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ] } }, { "old_path": "scipy_test/setup_scipy_test.py", "new_path": "scipy_test/setup_scipy_test.py", "filename": "setup_scipy_test.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,18 +1,22 @@\n #!/usr/bin/env python\n \n import os\n-from scipy_distutils.misc_util import get_path, default_config_dict,\\\n- dot_join\n+from scipy_distutils.misc_util import default_config_dict\n \n def configuration(parent_package=''):\n package = 'scipy_test'\n- local_path = get_path(__name__)\n-\n config = default_config_dict(package,parent_package)\n- config['packages'].append(dot_join(parent_package,package))\n- config['package_dir'][package] = local_path \n return config\n \n-if __name__ == '__main__': \n+if __name__ == '__main__':\n+ from scipy_test_version import scipy_test_version\n+ print 'scipy_test Version',scipy_test_version\n from scipy_distutils.core import setup\n- setup(**configuration())\n+ setup(version = scipy_test_version,\n+ maintainer = \"SciPy Developers\",\n+ maintainer_email = \"scipy-dev@scipy.org\",\n+ description = \"SciPy test module\",\n+ url = \"http://www.scipy.org\",\n+ license = \"SciPy License (BSD Style)\",\n+ **configuration()\n+ )\n", "added_lines": 12, "deleted_lines": 8, "source_code": "#!/usr/bin/env python\n\nimport os\nfrom scipy_distutils.misc_util import default_config_dict\n\ndef configuration(parent_package=''):\n package = 'scipy_test'\n config = default_config_dict(package,parent_package)\n return config\n\nif __name__ == '__main__':\n from scipy_test_version import scipy_test_version\n print 'scipy_test Version',scipy_test_version\n from scipy_distutils.core import setup\n setup(version = scipy_test_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy test module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os\nfrom scipy_distutils.misc_util import get_path, default_config_dict,\\\n dot_join\n\ndef configuration(parent_package=''):\n package = 'scipy_test'\n local_path = get_path(__name__)\n\n config = default_config_dict(package,parent_package)\n config['packages'].append(dot_join(parent_package,package))\n config['package_dir'][package] = local_path \n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_test.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 9, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_test.py", "nloc": 7, "complexity": 1, "token_count": 49, "parameters": [ "parent_package" ], "start_line": 7, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_test.py", "nloc": 7, "complexity": 1, "token_count": 49, "parameters": [ "parent_package" ], "start_line": 7, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "nloc": 18, "complexity": 1, "token_count": 79, "diff_parsed": { "added": [ "from scipy_distutils.misc_util import default_config_dict", "if __name__ == '__main__':", " from scipy_test_version import scipy_test_version", " print 'scipy_test Version',scipy_test_version", " setup(version = scipy_test_version,", " maintainer = \"SciPy Developers\",", " maintainer_email = \"scipy-dev@scipy.org\",", " description = \"SciPy test module\",", " url = \"http://www.scipy.org\",", " license = \"SciPy License (BSD Style)\",", " **configuration()", " )" ], "deleted": [ "from scipy_distutils.misc_util import get_path, default_config_dict,\\", " dot_join", " local_path = get_path(__name__)", "", " config['packages'].append(dot_join(parent_package,package))", " config['package_dir'][package] = local_path", "if __name__ == '__main__':", " setup(**configuration())" ] } } ] }, { "hash": "507ed7c92d75388bc78ba7cffe383d31406c5d6d", "msg": "Added +ppy (postpend underscores on globals for BSD compatibility) option to HP Fortran compilers", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-10-03T12:55:59+00:00", "author_timezone": 0, "committer_date": "2002-10-03T12:55:59+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d458416e2eddc09e28f8d1e1973e19d32ab3d831" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 2, "insertions": 2, "lines": 4, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -724,11 +724,11 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n f90c = 'f90'\n \n self.f77_compiler = fc\n- self.f77_switches = ' +pic=long '\n+ self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n \n self.f90_compiler = f90c\n- self.f90_switches = ' +pic=long '\n+ self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n \n self.ver_cmd = self.f77_compiler + ' +version '\n", "added_lines": 2, "deleted_lines": 2, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Is there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (?P[^\\s*]*)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n \n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if self.version >= '0.5.26': # is gcc >= 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f50/linux/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Is there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (?P[^\\s*]*)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n \n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if self.version >= '0.5.26': # is gcc >= 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f50/linux/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 80, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 11, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 114, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 130, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 154, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 165, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 174, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 212, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 233, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 246, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 259, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 312, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 337, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 354, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 366, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 392, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 397, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 402, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 405, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 426, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 468, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 477, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 480, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 505, "end_line": 506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 507, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 509, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 511, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 520, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 529, "end_line": 568, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 577, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 608, "end_line": 634, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 636, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 643, "end_line": 660, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 662, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 665, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 678, "end_line": 699, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 702, "end_line": 704, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 705, "end_line": 707, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 708, "end_line": 709, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 710, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 718, "end_line": 737, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 739, "end_line": 757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 765, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 21, "complexity": 10, "token_count": 117, "parameters": [ "self" ], "start_line": 798, "end_line": 820, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 822, "end_line": 839, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 841, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 850, "end_line": 858, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 860, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 871, "end_line": 899, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 901, "end_line": 915, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 918, "end_line": 919, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 929, "end_line": 932, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 940, "end_line": 959, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 961, "end_line": 963, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 965, "end_line": 966, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 980, "end_line": 1008, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1014, "end_line": 1015, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1024, "end_line": 1048, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1052, "end_line": 1053, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1061, "end_line": 1083, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1085, "end_line": 1088, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1090, "end_line": 1091, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1108, "end_line": 1131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1133, "end_line": 1135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1138, "end_line": 1140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1142, "end_line": 1143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1148, "end_line": 1149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1151, "end_line": 1159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 80, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 11, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 114, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 130, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 154, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 165, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 174, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 212, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 233, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 246, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 259, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 312, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 337, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 354, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 366, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 392, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 397, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 402, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 405, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 426, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 468, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 477, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 480, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 505, "end_line": 506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 507, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 509, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 511, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 513, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 520, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 529, "end_line": 568, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 577, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 608, "end_line": 634, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 636, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 643, "end_line": 660, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 662, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 665, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 678, "end_line": 699, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 702, "end_line": 704, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 705, "end_line": 707, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 708, "end_line": 709, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 710, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 718, "end_line": 737, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 739, "end_line": 757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 765, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 21, "complexity": 10, "token_count": 117, "parameters": [ "self" ], "start_line": 798, "end_line": 820, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 822, "end_line": 839, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 841, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 850, "end_line": 858, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 860, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 871, "end_line": 899, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 901, "end_line": 915, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 918, "end_line": 919, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 929, "end_line": 932, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 940, "end_line": 959, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 961, "end_line": 963, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 965, "end_line": 966, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 980, "end_line": 1008, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1014, "end_line": 1015, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1024, "end_line": 1048, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1052, "end_line": 1053, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1061, "end_line": 1083, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1085, "end_line": 1088, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1090, "end_line": 1091, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1108, "end_line": 1131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1133, "end_line": 1135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1138, "end_line": 1140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1142, "end_line": 1143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1148, "end_line": 1149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1151, "end_line": 1159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 718, "end_line": 737, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "nloc": 845, "complexity": 209, "token_count": 4942, "diff_parsed": { "added": [ " self.f77_switches = ' +pic=long +ppu '", " self.f90_switches = ' +pic=long +ppu '" ], "deleted": [ " self.f77_switches = ' +pic=long '", " self.f90_switches = ' +pic=long '" ] } } ] }, { "hash": "cdb55e38ca3f4d0870df7ac136cd65b0bda448e8", "msg": "use os.stat() to check file info instead of os.open() followed by\nos.fstat(). Cleaner and a bit more portable.", "author": { "name": "skip", "email": "skip@localhost" }, "committer": { "name": "skip", "email": "skip@localhost" }, "author_date": "2002-10-03T22:09:50+00:00", "author_timezone": 0, "committer_date": "2002-10-03T22:09:50+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "507ed7c92d75388bc78ba7cffe383d31406c5d6d" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 3, "insertions": 1, "lines": 4, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -453,9 +453,7 @@ def calc_info(self):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n- fd = os.open(lapack_lib,os.O_RDONLY)\n- sz = os.fstat(fd)[6]\n- os.close(fd)\n+ sz = os.stat(lapack_lib)[6]\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n", "added_lines": 1, "deleted_lines": 3, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n #info['size_liblapack'] = sz\n flag = 0 #os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbose - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['fftw','rfftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFTW'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n\n atlas_libs = self.get_libs('atlas_libs',\n ['lapack','f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n info = atlas\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = info['library_dirs'][0]\n lapack_name = info['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n fd = os.open(lapack_lib,os.O_RDONLY)\n sz = os.fstat(fd)[6]\n os.close(fd)\n import warnings\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n #info['size_liblapack'] = sz\n flag = 0 #os.system('nm %s | grep clapack_sgetri '%lapack_lib)\n #info['has_clapack_sgetri'] = not flag\n if flag:\n message = \"\"\"\n*********************************************************************\n Using probably old ATLAS version (<3.3.??):\n nm %s | grep clapack_sgetri\n returned %s\n ATLAS update is recommended. See scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,flag)\n warnings.warn(message)\n self.set_info(**info)\n\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 50, "complexity": 11, "token_count": 247, "parameters": [ "self" ], "start_line": 426, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 57, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 489, "end_line": 500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 506, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 513, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 604, "end_line": 615, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 621, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 628, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 668, "end_line": 671, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 673, "end_line": 692, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 694, "end_line": 715, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 717, "end_line": 725, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 727, "end_line": 734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 112, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 205, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 147, "parameters": [ "self" ], "start_line": 232, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 258, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 277, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 295, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 309, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 148, "parameters": [ "self" ], "start_line": 330, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 396, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 52, "complexity": 11, "token_count": 265, "parameters": [ "self" ], "start_line": 426, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 491, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 508, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 515, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 606, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 64, "parameters": [ "self", "section", "key" ], "start_line": 623, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 630, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 670, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 110, "parameters": [ "self" ], "start_line": 675, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 696, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 719, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 729, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 50, "complexity": 11, "token_count": 247, "parameters": [ "self" ], "start_line": 426, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 57, "top_nesting_level": 1 } ], "nloc": 646, "complexity": 124, "token_count": 3163, "diff_parsed": { "added": [ " sz = os.stat(lapack_lib)[6]" ], "deleted": [ " fd = os.open(lapack_lib,os.O_RDONLY)", " sz = os.fstat(fd)[6]", " os.close(fd)" ] } } ] }, { "hash": "6978ceae6b1f69395d700f7c5a464dd45665ec88", "msg": "added fastumath_xxx versions of complex number loops so that we don't have\nuse the ones built into Numeric. This is important because MSVC compiled\nversions of Numeric have incompatible complex numbers with the gcc compiled\nfastumath modules. the nounsigned.inc files had these fixes already.\nThey were just missing from the unsigned.inc versions.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-10-04T03:28:13+00:00", "author_timezone": 0, "committer_date": "2002-10-04T03:28:13+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "cdb55e38ca3f4d0870df7ac136cd65b0bda448e8" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 8, "insertions": 7, "lines": 15, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/fastumath_unsigned.inc", "new_path": "scipy_base/fastumath_unsigned.inc", "filename": "fastumath_unsigned.inc", "extension": "inc", "change_type": "MODIFY", "diff": "@@ -335,7 +335,6 @@ static Py_complex c_quot_fast(Py_complex a, Py_complex b)\n /* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n \treturn r;\n }\n- \n if (abs_breal >= abs_bimag) {\n \t/* divide tops and bottom by b.real */\n \tconst double ratio = b.imag / b.real;\n@@ -2835,15 +2834,15 @@ static void InitOperators(PyObject *dictionary) {\n \n add_functions[11] = PyUFunc_OO_O;\n subtract_functions[11] = PyUFunc_OO_O;\n- multiply_functions[9] = PyUFunc_FF_F_As_DD_D;\n- multiply_functions[10] = PyUFunc_DD_D;\n+ multiply_functions[9] = fastumath_FF_F_As_DD_D;\n+ multiply_functions[10] = fastumath_DD_D;\n multiply_functions[11] = PyUFunc_OO_O;\n- divide_functions[9] = PyUFunc_FF_F_As_DD_D;\n- divide_functions[10] = PyUFunc_DD_D;\n+ divide_functions[9] = fastumath_FF_F_As_DD_D;\n+ divide_functions[10] = fastumath_DD_D;\n divide_functions[11] = PyUFunc_OO_O;\n \n- true_divide_functions[9] = PyUFunc_FF_F_As_DD_D;\n- true_divide_functions[10] = PyUFunc_DD_D;\n+ true_divide_functions[9] = fastumath_FF_F_As_DD_D;\n+ true_divide_functions[10] = fastumath_DD_D;\n true_divide_functions[11] = PyUFunc_OO_O;\n \n conjugate_functions[11] = PyUFunc_O_O_method;\n@@ -2852,7 +2851,7 @@ static void InitOperators(PyObject *dictionary) {\n remainder_functions[10] = PyUFunc_OO_O;\n power_functions[7] = PyUFunc_ff_f_As_dd_d;\n power_functions[8] = PyUFunc_dd_d;\n- power_functions[9] = PyUFunc_FF_F_As_DD_D;\n+ power_functions[9] = fastumath_FF_F_As_DD_D;\n power_functions[10] = PyUFunc_DD_D;\n power_functions[11] = PyUFunc_OO_O;\n absolute_functions[11] = PyUFunc_O_O;\n", "added_lines": 7, "deleted_lines": 8, "source_code": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares the \n real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n\n This version supports unsigned types. \n */\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n#ifndef UINT_BIT\n#define UINT_BIT (CHAR_BIT * sizeof(unsigned int))\n#endif\n\n#ifndef USHORT_BIT\n#define USHORT_BIT (CHAR_BIT * sizeof(unsigned short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void USHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int x;\n for(i=0; i 65535) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned short *)op)=(unsigned short) x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void UINT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int a, b, ah, bh, x, y;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) { /* result should fit into bits available. */\n *((unsigned int *)op)=x;\n continue;\n }\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n /* Otherwise one and only one of ah or bh is non-zero. Make it so a > b (ah >0 and bh=0) */\n\tif (a < b) { \n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n /* Now a = ah */\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^(INT_BIT/2) -- shifted_version won't fit in unsigned int.\n\n Then compute al*bl (this should fit in the allotated space)\n\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1; /* mask off ah so a is now al */\n\tx = a*b; /* al * bl */\n\tx += y << (INT_BIT/2); /* add ah * bl * 2^SHIFT */\n /* This could have caused overflow. One way to know is to check to see if x < al \n Not sure if this get's all cases */\n\tif (x < a) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned int *)op)=x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void USHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void UINT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void USHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void UINT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void USHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2) ? *((unsigned short *)i1) : *((unsigned short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void UINT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2) ? *((unsigned int *)i1) : *((unsigned int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void USHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void UINT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, USHORT_add, INT_add, UINT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, USHORT_subtract, INT_subtract, UINT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, USHORT_multiply, INT_multiply, UINT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, USHORT_divide, INT_divide, UINT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, USHORT_floor_divide, INT_floor_divide, UINT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, USHORT_true_divide, INT_true_divide, UINT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, USHORT_divide_safe, INT_divide_safe, UINT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, USHORT_conjugate, INT_conjugate, UINT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, USHORT_remainder, INT_remainder, UINT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, USHORT_power, INT_power, UINT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { UBYTE_absolute, SBYTE_absolute, SHORT_absolute, USHORT_absolute, INT_absolute, UINT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { UBYTE_negative, SBYTE_negative, SHORT_negative, USHORT_negative, INT_negative, UINT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, USHORT_greater, INT_greater, UINT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, USHORT_greater_equal, INT_greater_equal, UINT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, USHORT_less, INT_less, UINT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, USHORT_less_equal, INT_less_equal, UINT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, USHORT_equal, INT_equal, UINT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, USHORT_not_equal, INT_not_equal, UINT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, USHORT_logical_and, INT_logical_and, UINT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, USHORT_logical_or, INT_logical_or, UINT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, USHORT_logical_xor, INT_logical_xor, UINT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, USHORT_logical_not, INT_logical_not, UINT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, USHORT_maximum, INT_maximum, UINT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, USHORT_bitwise_and, INT_bitwise_and, UINT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, USHORT_bitwise_or, INT_bitwise_or, UINT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, USHORT_bitwise_xor, INT_bitwise_xor, UINT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, USHORT_invert, INT_invert, UINT_invert, LONG_invert, NULL, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, USHORT_left_shift, INT_left_shift, UINT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, USHORT_right_shift, INT_right_shift, UINT_right_shift, LONG_right_shift, NULL, };\n\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\n\n\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, }; \nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\n\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_USHORT, PyArray_USHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_FLOAT, PyArray_UINT, PyArray_UINT, PyArray_FLOAT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE,};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[11] =(void *)PyNumber_Add;\n subtract_data[11] = (void *)PyNumber_Subtract;\n multiply_data[9] = (void *)c_prod;\n multiply_data[10] = (void *)c_prod;\n multiply_data[11] = (void *)PyNumber_Multiply;\n divide_data[9] = (void *)c_quot_fast;\n divide_data[10] = (void *)c_quot_fast;\n divide_data[11] = (void *)PyNumber_Divide;\n divide_safe_data[9] = (void *)c_quot;\n divide_safe_data[10] = (void *)c_quot;\n divide_safe_data[11] = (void *)PyNumber_Divide;\n conjugate_data[11] = (void *)\"conjugate\";\n remainder_data[8] = (void *)fmod;\n remainder_data[9] = (void *)fmod;\n remainder_data[10] = (void *)PyNumber_Remainder;\n power_data[7] = (void *)pow;\n power_data[8] = (void *)pow;\n power_data[9] = (void *)c_pow;\n power_data[10] = (void *)c_pow;\n power_data[11] = (void *)PyNumber_Power;\n absolute_data[11] = (void *)PyNumber_Absolute;\n negative_data[11] = (void *)PyNumber_Negative;\n bitwise_and_data[7] = (void *)PyNumber_And;\n bitwise_or_data[7] = (void *)PyNumber_Or;\n bitwise_xor_data[7] = (void *)PyNumber_Xor;\n invert_data[7] = (void *)PyNumber_Invert;\n left_shift_data[7] = (void *)PyNumber_Lshift;\n right_shift_data[7] = (void *)PyNumber_Rshift;\n\n add_functions[11] = PyUFunc_OO_O;\n subtract_functions[11] = PyUFunc_OO_O;\n multiply_functions[9] = fastumath_FF_F_As_DD_D;\n multiply_functions[10] = fastumath_DD_D;\n multiply_functions[11] = PyUFunc_OO_O;\n divide_functions[9] = fastumath_FF_F_As_DD_D;\n divide_functions[10] = fastumath_DD_D;\n divide_functions[11] = PyUFunc_OO_O;\n\n true_divide_functions[9] = fastumath_FF_F_As_DD_D;\n true_divide_functions[10] = fastumath_DD_D;\n true_divide_functions[11] = PyUFunc_OO_O;\n\n conjugate_functions[11] = PyUFunc_O_O_method;\n remainder_functions[8] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[9] = PyUFunc_dd_d;\n remainder_functions[10] = PyUFunc_OO_O;\n power_functions[7] = PyUFunc_ff_f_As_dd_d;\n power_functions[8] = PyUFunc_dd_d;\n power_functions[9] = fastumath_FF_F_As_DD_D;\n power_functions[10] = PyUFunc_DD_D;\n power_functions[11] = PyUFunc_OO_O;\n absolute_functions[11] = PyUFunc_O_O;\n negative_functions[11] = PyUFunc_O_O;\n bitwise_and_functions[7] = PyUFunc_OO_O;\n bitwise_or_functions[7] = PyUFunc_OO_O;\n bitwise_xor_functions[7] = PyUFunc_OO_O;\n invert_functions[7] = PyUFunc_O_O;\n left_shift_functions[7] = PyUFunc_OO_O;\n right_shift_functions[7] = PyUFunc_OO_O;\n\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 12, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t11, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t8, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "source_code_before": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares the \n real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n\n This version supports unsigned types. \n */\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n#ifndef UINT_BIT\n#define UINT_BIT (CHAR_BIT * sizeof(unsigned int))\n#endif\n\n#ifndef USHORT_BIT\n#define USHORT_BIT (CHAR_BIT * sizeof(unsigned short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n \n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void USHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int x;\n for(i=0; i 65535) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned short *)op)=(unsigned short) x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void UINT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int a, b, ah, bh, x, y;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) { /* result should fit into bits available. */\n *((unsigned int *)op)=x;\n continue;\n }\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n /* Otherwise one and only one of ah or bh is non-zero. Make it so a > b (ah >0 and bh=0) */\n\tif (a < b) { \n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n /* Now a = ah */\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^(INT_BIT/2) -- shifted_version won't fit in unsigned int.\n\n Then compute al*bl (this should fit in the allotated space)\n\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1; /* mask off ah so a is now al */\n\tx = a*b; /* al * bl */\n\tx += y << (INT_BIT/2); /* add ah * bl * 2^SHIFT */\n /* This could have caused overflow. One way to know is to check to see if x < al \n Not sure if this get's all cases */\n\tif (x < a) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned int *)op)=x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void USHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void UINT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void USHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void UINT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void USHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2) ? *((unsigned short *)i1) : *((unsigned short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void UINT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2) ? *((unsigned int *)i1) : *((unsigned int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void USHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void UINT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, USHORT_add, INT_add, UINT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, USHORT_subtract, INT_subtract, UINT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, USHORT_multiply, INT_multiply, UINT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, USHORT_divide, INT_divide, UINT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, USHORT_floor_divide, INT_floor_divide, UINT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, USHORT_true_divide, INT_true_divide, UINT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, USHORT_divide_safe, INT_divide_safe, UINT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, USHORT_conjugate, INT_conjugate, UINT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, USHORT_remainder, INT_remainder, UINT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, USHORT_power, INT_power, UINT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { UBYTE_absolute, SBYTE_absolute, SHORT_absolute, USHORT_absolute, INT_absolute, UINT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { UBYTE_negative, SBYTE_negative, SHORT_negative, USHORT_negative, INT_negative, UINT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, USHORT_greater, INT_greater, UINT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, USHORT_greater_equal, INT_greater_equal, UINT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, USHORT_less, INT_less, UINT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, USHORT_less_equal, INT_less_equal, UINT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, USHORT_equal, INT_equal, UINT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, USHORT_not_equal, INT_not_equal, UINT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, USHORT_logical_and, INT_logical_and, UINT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, USHORT_logical_or, INT_logical_or, UINT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, USHORT_logical_xor, INT_logical_xor, UINT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, USHORT_logical_not, INT_logical_not, UINT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, USHORT_maximum, INT_maximum, UINT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, USHORT_bitwise_and, INT_bitwise_and, UINT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, USHORT_bitwise_or, INT_bitwise_or, UINT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, USHORT_bitwise_xor, INT_bitwise_xor, UINT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, USHORT_invert, INT_invert, UINT_invert, LONG_invert, NULL, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, USHORT_left_shift, INT_left_shift, UINT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, USHORT_right_shift, INT_right_shift, UINT_right_shift, LONG_right_shift, NULL, };\n\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\n\n\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, }; \nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\n\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_USHORT, PyArray_USHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_FLOAT, PyArray_UINT, PyArray_UINT, PyArray_FLOAT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE,};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[11] =(void *)PyNumber_Add;\n subtract_data[11] = (void *)PyNumber_Subtract;\n multiply_data[9] = (void *)c_prod;\n multiply_data[10] = (void *)c_prod;\n multiply_data[11] = (void *)PyNumber_Multiply;\n divide_data[9] = (void *)c_quot_fast;\n divide_data[10] = (void *)c_quot_fast;\n divide_data[11] = (void *)PyNumber_Divide;\n divide_safe_data[9] = (void *)c_quot;\n divide_safe_data[10] = (void *)c_quot;\n divide_safe_data[11] = (void *)PyNumber_Divide;\n conjugate_data[11] = (void *)\"conjugate\";\n remainder_data[8] = (void *)fmod;\n remainder_data[9] = (void *)fmod;\n remainder_data[10] = (void *)PyNumber_Remainder;\n power_data[7] = (void *)pow;\n power_data[8] = (void *)pow;\n power_data[9] = (void *)c_pow;\n power_data[10] = (void *)c_pow;\n power_data[11] = (void *)PyNumber_Power;\n absolute_data[11] = (void *)PyNumber_Absolute;\n negative_data[11] = (void *)PyNumber_Negative;\n bitwise_and_data[7] = (void *)PyNumber_And;\n bitwise_or_data[7] = (void *)PyNumber_Or;\n bitwise_xor_data[7] = (void *)PyNumber_Xor;\n invert_data[7] = (void *)PyNumber_Invert;\n left_shift_data[7] = (void *)PyNumber_Lshift;\n right_shift_data[7] = (void *)PyNumber_Rshift;\n\n add_functions[11] = PyUFunc_OO_O;\n subtract_functions[11] = PyUFunc_OO_O;\n multiply_functions[9] = PyUFunc_FF_F_As_DD_D;\n multiply_functions[10] = PyUFunc_DD_D;\n multiply_functions[11] = PyUFunc_OO_O;\n divide_functions[9] = PyUFunc_FF_F_As_DD_D;\n divide_functions[10] = PyUFunc_DD_D;\n divide_functions[11] = PyUFunc_OO_O;\n\n true_divide_functions[9] = PyUFunc_FF_F_As_DD_D;\n true_divide_functions[10] = PyUFunc_DD_D;\n true_divide_functions[11] = PyUFunc_OO_O;\n\n conjugate_functions[11] = PyUFunc_O_O_method;\n remainder_functions[8] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[9] = PyUFunc_dd_d;\n remainder_functions[10] = PyUFunc_OO_O;\n power_functions[7] = PyUFunc_ff_f_As_dd_d;\n power_functions[8] = PyUFunc_dd_d;\n power_functions[9] = PyUFunc_FF_F_As_DD_D;\n power_functions[10] = PyUFunc_DD_D;\n power_functions[11] = PyUFunc_OO_O;\n absolute_functions[11] = PyUFunc_O_O;\n negative_functions[11] = PyUFunc_O_O;\n bitwise_and_functions[7] = PyUFunc_OO_O;\n bitwise_or_functions[7] = PyUFunc_OO_O;\n bitwise_xor_functions[7] = PyUFunc_OO_O;\n invert_functions[7] = PyUFunc_O_O;\n left_shift_functions[7] = PyUFunc_OO_O;\n right_shift_functions[7] = PyUFunc_OO_O;\n\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 12, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t11, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t8, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ " multiply_functions[9] = fastumath_FF_F_As_DD_D;", " multiply_functions[10] = fastumath_DD_D;", " divide_functions[9] = fastumath_FF_F_As_DD_D;", " divide_functions[10] = fastumath_DD_D;", " true_divide_functions[9] = fastumath_FF_F_As_DD_D;", " true_divide_functions[10] = fastumath_DD_D;", " power_functions[9] = fastumath_FF_F_As_DD_D;" ], "deleted": [ "", " multiply_functions[9] = PyUFunc_FF_F_As_DD_D;", " multiply_functions[10] = PyUFunc_DD_D;", " divide_functions[9] = PyUFunc_FF_F_As_DD_D;", " divide_functions[10] = PyUFunc_DD_D;", " true_divide_functions[9] = PyUFunc_FF_F_As_DD_D;", " true_divide_functions[10] = PyUFunc_DD_D;", " power_functions[9] = PyUFunc_FF_F_As_DD_D;" ] } } ] }, { "hash": "b9e184cb5bc0f9c2fa2aa4d4e78b6c45541fa73a", "msg": "This checkin marks a fairly substantial change in the C++ classes for\nweave. The original SCXX code has been augmented and mutated to the\npoint of not be recognizable as SCXX any more. File and class names\nhave moved more toward boost naming conventions.\n\nThe most significant change is that, when writing standard inline()\ncode, end users are not responsible for reference counting at all.\n\nAdditionally, casting functions have been added and methods have\nbeen overloaded so that conversions between python types and C\ntypes are handled transparently for the basic types (char*,int,float,\ndouble,std::string,std::complex, etc.)\n\npy::object has been augmented to handle attribute access, function\ncalling, method calling, and pretty much all of the rest of the\nPyObject_xxx API.\n\nThis is near feature complete for weave 0.3. The remaining tasks are\nto test on other platforms and re-write the documentation.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-10-10T09:05:34+00:00", "author_timezone": 0, "committer_date": "2002-10-10T09:05:34+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "6978ceae6b1f69395d700f7c5a464dd45665ec88" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 1646, "insertions": 3078, "lines": 4724, "files": 23, "dmm_unit_size": 0.875219683655536, "dmm_unit_complexity": 0.9859402460456942, "dmm_unit_interfacing": 0.945518453427065, "modified_files": [ { "old_path": "weave/c_spec.py", "new_path": "weave/c_spec.py", "filename": "c_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -13,6 +13,13 @@\n # a class method to solve this error.\n #----------------------------------------------------------------------------\n \n+#----------------------------------------------------------------------------\n+# speed note\n+# the convert_to_int macro below takes about 25 ns per conversion on my\n+# 850 MHz PIII. A slightly more sophisticated macro version can trim this\n+# to 20 ns, but this savings is dang near useless because the other \n+# overhead swamps it...\n+#----------------------------------------------------------------------------\n py_to_c_template = \\\n \"\"\"\n class %(type_name)s_handler\n@@ -351,8 +358,7 @@ class scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n- '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n- '']\n+ '\"scxx/dict.h\"','']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n \n", "added_lines": 8, "deleted_lines": 2, "source_code": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\n#----------------------------------------------------------------------------\n# speed note\n# the convert_to_int macro below takes about 25 ns per conversion on my\n# 850 MHz PIII. A slightly more sophisticated macro version can trim this\n# to 20 ns, but this savings is dang near useless because the other \n# overhead swamps it...\n#----------------------------------------------------------------------------\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(return_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(return_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.return_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['return_type'] = self.return_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.return_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.return_type = self.c_type\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.return_type = self.c_type\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['i'] = 'int'\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.return_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.return_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.return_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.return_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/dict.h\"','']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.return_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.return_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.return_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#\n# catch all now handles callable objects\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()\n", "source_code_before": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(return_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(return_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.return_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['return_type'] = self.return_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.return_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.return_type = self.c_type\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.return_type = self.c_type\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['i'] = 'int'\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.return_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.return_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.return_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.return_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',\n '']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.return_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.return_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.return_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#\n# catch all now handles callable objects\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 16, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 77, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 94, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 23, "complexity": 10, "token_count": 151, "parameters": [ "self" ], "start_line": 97, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 121, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 124, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 127, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 17, "complexity": 2, "token_count": 114, "parameters": [ "self", "inline" ], "start_line": 134, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 152, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 158, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 164, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 175, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 189, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 200, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 209, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 223, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 239, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 249, "end_line": 259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 298, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 305, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 315, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 326, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 337, "end_line": 345, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 358, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 366, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 378, "end_line": 387, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 390, "end_line": 399, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 405, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 422, "end_line": 430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 431, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 438, "end_line": 440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 16, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 70, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 23, "complexity": 10, "token_count": 151, "parameters": [ "self" ], "start_line": 90, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 114, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 117, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 120, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 17, "complexity": 2, "token_count": 114, "parameters": [ "self", "inline" ], "start_line": 127, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 145, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 157, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 165, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 168, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 182, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 193, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 202, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 216, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 232, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 242, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 291, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 298, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 308, "end_line": 316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 319, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 330, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 351, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 360, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 372, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 384, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 399, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 416, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 425, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 428, "end_line": 430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 432, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 358, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": 328, "complexity": 47, "token_count": 1670, "diff_parsed": { "added": [ "#----------------------------------------------------------------------------", "# speed note", "# the convert_to_int macro below takes about 25 ns per conversion on my", "# 850 MHz PIII. A slightly more sophisticated macro version can trim this", "# to 20 ns, but this savings is dang near useless because the other", "# overhead swamps it...", "#----------------------------------------------------------------------------", " '\"scxx/dict.h\"','']" ], "deleted": [ " '\"scxx/number.h\"','\"scxx/dict.h\"','\"scxx/str.h\"',", " '']" ] } }, { "old_path": "weave/common_info.py", "new_path": "weave/common_info.py", "filename": "common_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -60,9 +60,11 @@\n }\n \n \"\"\"\n+#include \"compile.h\" /* Scary dangerous stuff */\n+#include \"frameobject.h\" /* Scary dangerous stuff */\n \n class basic_module_info(base_info.base_info):\n- _headers = ['\"Python.h\"']\n+ _headers = ['\"Python.h\"','\"compile.h\"','\"frameobject.h\"']\n _support_code = [module_support_code]\n \n #----------------------------------------------------------------------------\n", "added_lines": 3, "deleted_lines": 1, "source_code": "\"\"\" Generic support code for: \n error handling code found in every weave module \n local/global dictionary access code for inline() modules\n swig pointer (old style) conversion support\n \n\"\"\"\n\nimport base_info\n\nmodule_support_code = \\\n\"\"\"\n\n// global None value for use in functions.\nnamespace py {\nobject None = object(Py_None);\n}\n\nchar* find_type(PyObject* py_obj)\n{\n if(py_obj == NULL) return \"C NULL value\";\n if(PyCallable_Check(py_obj)) return \"callable\";\n if(PyString_Check(py_obj)) return \"string\";\n if(PyInt_Check(py_obj)) return \"int\";\n if(PyFloat_Check(py_obj)) return \"float\";\n if(PyDict_Check(py_obj)) return \"dict\";\n if(PyList_Check(py_obj)) return \"list\";\n if(PyTuple_Check(py_obj)) return \"tuple\";\n if(PyFile_Check(py_obj)) return \"file\";\n if(PyModule_Check(py_obj)) return \"module\";\n \n //should probably do more intergation (and thinking) on these.\n if(PyCallable_Check(py_obj) && PyInstance_Check(py_obj)) return \"callable\";\n if(PyInstance_Check(py_obj)) return \"instance\"; \n if(PyCallable_Check(py_obj)) return \"callable\";\n return \"unkown type\";\n}\n\nvoid throw_error(PyObject* exc, const char* msg)\n{\n //printf(\"setting python error: %s\\\\n\",msg);\n PyErr_SetString(exc, msg);\n //printf(\"throwing error\\\\n\");\n throw 1;\n}\n\nvoid handle_bad_type(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg); \n}\n\nvoid handle_conversion_error(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error:, received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg);\n}\n\n\"\"\"\n#include \"compile.h\" /* Scary dangerous stuff */\n#include \"frameobject.h\" /* Scary dangerous stuff */\n\nclass basic_module_info(base_info.base_info):\n _headers = ['\"Python.h\"','\"compile.h\"','\"frameobject.h\"']\n _support_code = [module_support_code]\n\n#----------------------------------------------------------------------------\n# inline() generated support code\n#\n# The following two function declarations handle access to variables in the \n# global and local dictionaries for inline functions.\n#----------------------------------------------------------------------------\n\nget_variable_support_code = \\\n\"\"\"\nvoid handle_variable_not_found(char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error: variable '%s' not found in local or global scope.\",var_name);\n throw_error(PyExc_NameError,msg);\n}\nPyObject* get_variable(char* name,PyObject* locals, PyObject* globals)\n{\n // no checking done for error -- locals and globals should\n // already be validated as dictionaries. If var is NULL, the\n // function calling this should handle it.\n PyObject* var = NULL;\n var = PyDict_GetItemString(locals,name);\n if (!var)\n {\n var = PyDict_GetItemString(globals,name);\n }\n if (!var)\n handle_variable_not_found(name);\n return var;\n}\n\"\"\"\n\npy_to_raw_dict_support_code = \\\n\"\"\"\nPyObject* py_to_raw_dict(PyObject* py_obj, char* name)\n{\n // simply check that the value is a valid dictionary pointer.\n if(!py_obj || !PyDict_Check(py_obj))\n handle_bad_type(py_obj, \"dictionary\", name);\n return py_obj;\n}\n\"\"\"\n\nclass inline_info(base_info.base_info):\n _support_code = [get_variable_support_code, py_to_raw_dict_support_code]\n\n\n#----------------------------------------------------------------------------\n# swig pointer support code\n#\n# The support code for swig is just slirped in from the swigptr.c file \n# from the *old* swig distribution. New style swig pointers are not\n# yet supported.\n#----------------------------------------------------------------------------\n\nimport os, common_info\nlocal_dir,junk = os.path.split(os.path.abspath(common_info.__file__)) \nf = open(os.path.join(local_dir,'swig','swigptr.c'))\nswig_support_code = f.read()\nf.close()\n\nclass swig_info(base_info.base_info):\n _support_code = [swig_support_code]\n", "source_code_before": "\"\"\" Generic support code for: \n error handling code found in every weave module \n local/global dictionary access code for inline() modules\n swig pointer (old style) conversion support\n \n\"\"\"\n\nimport base_info\n\nmodule_support_code = \\\n\"\"\"\n\n// global None value for use in functions.\nnamespace py {\nobject None = object(Py_None);\n}\n\nchar* find_type(PyObject* py_obj)\n{\n if(py_obj == NULL) return \"C NULL value\";\n if(PyCallable_Check(py_obj)) return \"callable\";\n if(PyString_Check(py_obj)) return \"string\";\n if(PyInt_Check(py_obj)) return \"int\";\n if(PyFloat_Check(py_obj)) return \"float\";\n if(PyDict_Check(py_obj)) return \"dict\";\n if(PyList_Check(py_obj)) return \"list\";\n if(PyTuple_Check(py_obj)) return \"tuple\";\n if(PyFile_Check(py_obj)) return \"file\";\n if(PyModule_Check(py_obj)) return \"module\";\n \n //should probably do more intergation (and thinking) on these.\n if(PyCallable_Check(py_obj) && PyInstance_Check(py_obj)) return \"callable\";\n if(PyInstance_Check(py_obj)) return \"instance\"; \n if(PyCallable_Check(py_obj)) return \"callable\";\n return \"unkown type\";\n}\n\nvoid throw_error(PyObject* exc, const char* msg)\n{\n //printf(\"setting python error: %s\\\\n\",msg);\n PyErr_SetString(exc, msg);\n //printf(\"throwing error\\\\n\");\n throw 1;\n}\n\nvoid handle_bad_type(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg); \n}\n\nvoid handle_conversion_error(PyObject* py_obj, const char* good_type, const char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error:, received '%s' type instead of '%s' for variable '%s'\",\n find_type(py_obj),good_type,var_name);\n throw_error(PyExc_TypeError,msg);\n}\n\n\"\"\"\n\nclass basic_module_info(base_info.base_info):\n _headers = ['\"Python.h\"']\n _support_code = [module_support_code]\n\n#----------------------------------------------------------------------------\n# inline() generated support code\n#\n# The following two function declarations handle access to variables in the \n# global and local dictionaries for inline functions.\n#----------------------------------------------------------------------------\n\nget_variable_support_code = \\\n\"\"\"\nvoid handle_variable_not_found(char* var_name)\n{\n char msg[500];\n sprintf(msg,\"Conversion Error: variable '%s' not found in local or global scope.\",var_name);\n throw_error(PyExc_NameError,msg);\n}\nPyObject* get_variable(char* name,PyObject* locals, PyObject* globals)\n{\n // no checking done for error -- locals and globals should\n // already be validated as dictionaries. If var is NULL, the\n // function calling this should handle it.\n PyObject* var = NULL;\n var = PyDict_GetItemString(locals,name);\n if (!var)\n {\n var = PyDict_GetItemString(globals,name);\n }\n if (!var)\n handle_variable_not_found(name);\n return var;\n}\n\"\"\"\n\npy_to_raw_dict_support_code = \\\n\"\"\"\nPyObject* py_to_raw_dict(PyObject* py_obj, char* name)\n{\n // simply check that the value is a valid dictionary pointer.\n if(!py_obj || !PyDict_Check(py_obj))\n handle_bad_type(py_obj, \"dictionary\", name);\n return py_obj;\n}\n\"\"\"\n\nclass inline_info(base_info.base_info):\n _support_code = [get_variable_support_code, py_to_raw_dict_support_code]\n\n\n#----------------------------------------------------------------------------\n# swig pointer support code\n#\n# The support code for swig is just slirped in from the swigptr.c file \n# from the *old* swig distribution. New style swig pointers are not\n# yet supported.\n#----------------------------------------------------------------------------\n\nimport os, common_info\nlocal_dir,junk = os.path.split(os.path.abspath(common_info.__file__)) \nf = open(os.path.join(local_dir,'swig','swigptr.c'))\nswig_support_code = f.read()\nf.close()\n\nclass swig_info(base_info.base_info):\n _support_code = [swig_support_code]\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 106, "complexity": 0, "token_count": 119, "diff_parsed": { "added": [ "#include \"compile.h\" /* Scary dangerous stuff */", "#include \"frameobject.h\" /* Scary dangerous stuff */", " _headers = ['\"Python.h\"','\"compile.h\"','\"frameobject.h\"']" ], "deleted": [ " _headers = ['\"Python.h\"']" ] } }, { "old_path": "weave/examples/binary_search.py", "new_path": "weave/examples/binary_search.py", "filename": "binary_search.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -55,6 +55,39 @@ def c_int_search(seq,t,chk=1):\n #return inline_tools.inline(code,['seq','t'],compiler='msvc')\n return inline_tools.inline(code,['seq','t'],verbose = 2)\n \n+def c_int_search_scxx(seq,t,chk=1):\n+ # do partial type checking in Python.\n+ # checking that list items are ints should happen in py_to_scalar\n+ if chk:\n+ assert(type(t) == type(1))\n+ assert(type(seq) == type([]))\n+ code = \"\"\" \n+ #line 29 \"binary_search.py\"\n+ int val, m, min = 0; \n+ int max = seq.len()- 1;\n+ for(;;) \n+ { \n+ if (max < min )\n+ {\n+ return_val = -1;\n+ break;\n+ }\n+ m = (min + max) / 2;\n+ val = seq[m];\n+ if (val < t) \n+ min = m + 1;\n+ else if (val > t) \n+ max = m - 1;\n+ else\n+ {\n+ return_val = m;\n+ break;\n+ }\n+ } \n+ \"\"\" \n+ #return inline_tools.inline(code,['seq','t'],compiler='msvc')\n+ return inline_tools.inline(code,['seq','t'],verbose = 2)\n+\n try:\n from Numeric import *\n def c_array_int_search(seq,t):\n@@ -142,6 +175,26 @@ def search_compare(a,n):\n print ' speed in c(no asserts):',sp \n print ' speed up: %3.2f' % (py/sp)\n \n+ # get it in cache\n+ c_int_search_scxx(a,i)\n+ t1 = time.time()\n+ for i in range(n):\n+ c_int_search_scxx(a,i,chk=1)\n+ t2 = time.time()\n+ sp = (t2-t1)+1e-20 # protect against div by zero\n+ print ' speed for scxx:',sp\n+ print ' speed up: %3.2f' % (py/sp)\n+\n+ # get it in cache\n+ c_int_search_scxx(a,i)\n+ t1 = time.time()\n+ for i in range(n):\n+ c_int_search_scxx(a,i,chk=0)\n+ t2 = time.time()\n+ sp = (t2-t1)+1e-20 # protect against div by zero\n+ print ' speed for scxx(no asserts):',sp \n+ print ' speed up: %3.2f' % (py/sp)\n+\n # get it in cache\n a = array(a)\n try:\n", "added_lines": 53, "deleted_lines": 0, "source_code": "# Offers example of inline C for binary search algorithm.\n# Borrowed from Kalle Svensson in the Python Cookbook.\n# The results are nearly in the \"not worth it\" catagory.\n#\n# C:\\home\\ej\\wrk\\scipy\\compiler\\examples>python binary_search.py\n# Binary search for 3000 items in 100000 length list of integers:\n# speed in python: 0.139999985695\n# speed in c: 0.0900000333786\n# speed up: 1.41\n# search(a,3450) 3450 3450\n# search(a,-1) -1 -1\n# search(a,10001) 10001 10001\n#\n# Note -- really need to differentiate between conversion errors and\n# run time errors. This would reduce useless compiles and provide a\n# more intelligent control of things.\n\nimport sys\nsys.path.insert(0,'..')\n#from compiler import inline_tools\nimport inline_tools\nfrom bisect import bisect\n\ndef c_int_search(seq,t,chk=1):\n # do partial type checking in Python.\n # checking that list items are ints should happen in py_to_scalar\n if chk:\n assert(type(t) == type(1))\n assert(type(seq) == type([]))\n code = \"\"\" \n #line 29 \"binary_search.py\"\n int val, m, min = 0; \n int max = seq.len()- 1;\n PyObject *py_val;\n for(;;) \n { \n if (max < min )\n {\n return_val = PyInt_FromLong(-1);\n break;\n }\n m = (min + max) / 2;\n val = py_to_int(PyList_GetItem(py_seq,m),\"val\");\n if (val < t) \n min = m + 1;\n else if (val > t) \n max = m - 1;\n else\n {\n return_val = PyInt_FromLong(m);\n break;\n }\n } \n \"\"\" \n #return inline_tools.inline(code,['seq','t'],compiler='msvc')\n return inline_tools.inline(code,['seq','t'],verbose = 2)\n\ndef c_int_search_scxx(seq,t,chk=1):\n # do partial type checking in Python.\n # checking that list items are ints should happen in py_to_scalar\n if chk:\n assert(type(t) == type(1))\n assert(type(seq) == type([]))\n code = \"\"\" \n #line 29 \"binary_search.py\"\n int val, m, min = 0; \n int max = seq.len()- 1;\n for(;;) \n { \n if (max < min )\n {\n return_val = -1;\n break;\n }\n m = (min + max) / 2;\n val = seq[m];\n if (val < t) \n min = m + 1;\n else if (val > t) \n max = m - 1;\n else\n {\n return_val = m;\n break;\n }\n } \n \"\"\" \n #return inline_tools.inline(code,['seq','t'],compiler='msvc')\n return inline_tools.inline(code,['seq','t'],verbose = 2)\n\ntry:\n from Numeric import *\n def c_array_int_search(seq,t):\n code = \"\"\" \n #line 62 \"binary_search.py\"\n int val, m, min = 0; \n int max = Nseq[0] - 1;\n PyObject *py_val;\n for(;;) \n { \n if (max < min )\n {\n return_val = PyInt_FromLong(-1);\n break;\n }\n m = (min + max) / 2;\n val = seq[m];\n if (val < t) \n min = m + 1;\n else if (val > t) \n max = m - 1;\n else\n {\n return_val = PyInt_FromLong(m);\n break;\n }\n } \n \"\"\" \n #return inline_tools.inline(code,['seq','t'],compiler='msvc')\n return inline_tools.inline(code,['seq','t'],verbose = 2,\n extra_compile_args=['-O2','-G6'])\nexcept:\n pass\n \ndef py_int_search(seq, t):\n min = 0; max = len(seq) - 1\n while 1:\n if max < min:\n return -1\n m = (min + max) / 2\n if seq[m] < t:\n min = m + 1\n elif seq[m] > t:\n max = m - 1\n else:\n return m\n\nimport time\n\ndef search_compare(a,n):\n print 'Binary search for %d items in %d length list of integers:'%(n,m)\n t1 = time.time()\n for i in range(n):\n py_int_search(a,i)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)\n\n # bisect\n t1 = time.time()\n for i in range(n):\n bisect(a,i)\n t2 = time.time()\n bi = (t2-t1) +1e-20 # protect against div by zero\n print ' speed of bisect:', bi\n print ' speed up: %3.2f' % (py/bi)\n\n # get it in cache\n c_int_search(a,i)\n t1 = time.time()\n for i in range(n):\n c_int_search(a,i,chk=1)\n t2 = time.time()\n sp = (t2-t1)+1e-20 # protect against div by zero\n print ' speed in c:',sp\n print ' speed up: %3.2f' % (py/sp)\n\n # get it in cache\n c_int_search(a,i)\n t1 = time.time()\n for i in range(n):\n c_int_search(a,i,chk=0)\n t2 = time.time()\n sp = (t2-t1)+1e-20 # protect against div by zero\n print ' speed in c(no asserts):',sp \n print ' speed up: %3.2f' % (py/sp)\n\n # get it in cache\n c_int_search_scxx(a,i)\n t1 = time.time()\n for i in range(n):\n c_int_search_scxx(a,i,chk=1)\n t2 = time.time()\n sp = (t2-t1)+1e-20 # protect against div by zero\n print ' speed for scxx:',sp\n print ' speed up: %3.2f' % (py/sp)\n\n # get it in cache\n c_int_search_scxx(a,i)\n t1 = time.time()\n for i in range(n):\n c_int_search_scxx(a,i,chk=0)\n t2 = time.time()\n sp = (t2-t1)+1e-20 # protect against div by zero\n print ' speed for scxx(no asserts):',sp \n print ' speed up: %3.2f' % (py/sp)\n\n # get it in cache\n a = array(a)\n try:\n a = array(a)\n c_array_int_search(a,i)\n t1 = time.time()\n for i in range(n):\n c_array_int_search(a,i)\n t2 = time.time()\n sp = (t2-t1)+1e-20 # protect against div by zero\n print ' speed in c(Numeric arrays):',sp \n print ' speed up: %3.2f' % (py/sp)\n except:\n pass\n \nif __name__ == \"__main__\":\n # note bisect returns index+1 compared to other algorithms\n m= 100000\n a = range(m)\n n = 50000\n search_compare(a,n) \n print 'search(a,3450)', c_int_search(a,3450), py_int_search(a,3450), bisect(a,3450)\n print 'search(a,-1)', c_int_search(a,-1), py_int_search(a,-1), bisect(a,-1)\n print 'search(a,10001)', c_int_search(a,10001), py_int_search(a,10001),bisect(a,10001)", "source_code_before": "# Offers example of inline C for binary search algorithm.\n# Borrowed from Kalle Svensson in the Python Cookbook.\n# The results are nearly in the \"not worth it\" catagory.\n#\n# C:\\home\\ej\\wrk\\scipy\\compiler\\examples>python binary_search.py\n# Binary search for 3000 items in 100000 length list of integers:\n# speed in python: 0.139999985695\n# speed in c: 0.0900000333786\n# speed up: 1.41\n# search(a,3450) 3450 3450\n# search(a,-1) -1 -1\n# search(a,10001) 10001 10001\n#\n# Note -- really need to differentiate between conversion errors and\n# run time errors. This would reduce useless compiles and provide a\n# more intelligent control of things.\n\nimport sys\nsys.path.insert(0,'..')\n#from compiler import inline_tools\nimport inline_tools\nfrom bisect import bisect\n\ndef c_int_search(seq,t,chk=1):\n # do partial type checking in Python.\n # checking that list items are ints should happen in py_to_scalar\n if chk:\n assert(type(t) == type(1))\n assert(type(seq) == type([]))\n code = \"\"\" \n #line 29 \"binary_search.py\"\n int val, m, min = 0; \n int max = seq.len()- 1;\n PyObject *py_val;\n for(;;) \n { \n if (max < min )\n {\n return_val = PyInt_FromLong(-1);\n break;\n }\n m = (min + max) / 2;\n val = py_to_int(PyList_GetItem(py_seq,m),\"val\");\n if (val < t) \n min = m + 1;\n else if (val > t) \n max = m - 1;\n else\n {\n return_val = PyInt_FromLong(m);\n break;\n }\n } \n \"\"\" \n #return inline_tools.inline(code,['seq','t'],compiler='msvc')\n return inline_tools.inline(code,['seq','t'],verbose = 2)\n\ntry:\n from Numeric import *\n def c_array_int_search(seq,t):\n code = \"\"\" \n #line 62 \"binary_search.py\"\n int val, m, min = 0; \n int max = Nseq[0] - 1;\n PyObject *py_val;\n for(;;) \n { \n if (max < min )\n {\n return_val = PyInt_FromLong(-1);\n break;\n }\n m = (min + max) / 2;\n val = seq[m];\n if (val < t) \n min = m + 1;\n else if (val > t) \n max = m - 1;\n else\n {\n return_val = PyInt_FromLong(m);\n break;\n }\n } \n \"\"\" \n #return inline_tools.inline(code,['seq','t'],compiler='msvc')\n return inline_tools.inline(code,['seq','t'],verbose = 2,\n extra_compile_args=['-O2','-G6'])\nexcept:\n pass\n \ndef py_int_search(seq, t):\n min = 0; max = len(seq) - 1\n while 1:\n if max < min:\n return -1\n m = (min + max) / 2\n if seq[m] < t:\n min = m + 1\n elif seq[m] > t:\n max = m - 1\n else:\n return m\n\nimport time\n\ndef search_compare(a,n):\n print 'Binary search for %d items in %d length list of integers:'%(n,m)\n t1 = time.time()\n for i in range(n):\n py_int_search(a,i)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)\n\n # bisect\n t1 = time.time()\n for i in range(n):\n bisect(a,i)\n t2 = time.time()\n bi = (t2-t1) +1e-20 # protect against div by zero\n print ' speed of bisect:', bi\n print ' speed up: %3.2f' % (py/bi)\n\n # get it in cache\n c_int_search(a,i)\n t1 = time.time()\n for i in range(n):\n c_int_search(a,i,chk=1)\n t2 = time.time()\n sp = (t2-t1)+1e-20 # protect against div by zero\n print ' speed in c:',sp\n print ' speed up: %3.2f' % (py/sp)\n\n # get it in cache\n c_int_search(a,i)\n t1 = time.time()\n for i in range(n):\n c_int_search(a,i,chk=0)\n t2 = time.time()\n sp = (t2-t1)+1e-20 # protect against div by zero\n print ' speed in c(no asserts):',sp \n print ' speed up: %3.2f' % (py/sp)\n\n # get it in cache\n a = array(a)\n try:\n a = array(a)\n c_array_int_search(a,i)\n t1 = time.time()\n for i in range(n):\n c_array_int_search(a,i)\n t2 = time.time()\n sp = (t2-t1)+1e-20 # protect against div by zero\n print ' speed in c(Numeric arrays):',sp \n print ' speed up: %3.2f' % (py/sp)\n except:\n pass\n \nif __name__ == \"__main__\":\n # note bisect returns index+1 compared to other algorithms\n m= 100000\n a = range(m)\n n = 50000\n search_compare(a,n) \n print 'search(a,3450)', c_int_search(a,3450), py_int_search(a,3450), bisect(a,3450)\n print 'search(a,-1)', c_int_search(a,-1), py_int_search(a,-1), bisect(a,-1)\n print 'search(a,10001)', c_int_search(a,10001), py_int_search(a,10001),bisect(a,10001)", "methods": [ { "name": "c_int_search", "long_name": "c_int_search( seq , t , chk = 1 )", "filename": "binary_search.py", "nloc": 30, "complexity": 2, "token_count": 59, "parameters": [ "seq", "t", "chk" ], "start_line": 24, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "c_int_search_scxx", "long_name": "c_int_search_scxx( seq , t , chk = 1 )", "filename": "binary_search.py", "nloc": 29, "complexity": 2, "token_count": 59, "parameters": [ "seq", "t", "chk" ], "start_line": 58, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "c_array_int_search", "long_name": "c_array_int_search( seq , t )", "filename": "binary_search.py", "nloc": 28, "complexity": 1, "token_count": 35, "parameters": [ "seq", "t" ], "start_line": 93, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "py_int_search", "long_name": "py_int_search( seq , t )", "filename": "binary_search.py", "nloc": 12, "complexity": 5, "token_count": 69, "parameters": [ "seq", "t" ], "start_line": 125, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "search_compare", "long_name": "search_compare( a , n )", "filename": "binary_search.py", "nloc": 60, "complexity": 9, "token_count": 427, "parameters": [ "a", "n" ], "start_line": 140, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 } ], "methods_before": [ { "name": "c_int_search", "long_name": "c_int_search( seq , t , chk = 1 )", "filename": "binary_search.py", "nloc": 30, "complexity": 2, "token_count": 59, "parameters": [ "seq", "t", "chk" ], "start_line": 24, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "c_array_int_search", "long_name": "c_array_int_search( seq , t )", "filename": "binary_search.py", "nloc": 28, "complexity": 1, "token_count": 35, "parameters": [ "seq", "t" ], "start_line": 60, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "py_int_search", "long_name": "py_int_search( seq , t )", "filename": "binary_search.py", "nloc": 12, "complexity": 5, "token_count": 69, "parameters": [ "seq", "t" ], "start_line": 92, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "search_compare", "long_name": "search_compare( a , n )", "filename": "binary_search.py", "nloc": 44, "complexity": 7, "token_count": 305, "parameters": [ "a", "n" ], "start_line": 107, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "c_int_search_scxx", "long_name": "c_int_search_scxx( seq , t , chk = 1 )", "filename": "binary_search.py", "nloc": 29, "complexity": 2, "token_count": 59, "parameters": [ "seq", "t", "chk" ], "start_line": 58, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "search_compare", "long_name": "search_compare( a , n )", "filename": "binary_search.py", "nloc": 60, "complexity": 9, "token_count": 427, "parameters": [ "a", "n" ], "start_line": 140, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 72, "top_nesting_level": 0 } ], "nloc": 176, "complexity": 19, "token_count": 778, "diff_parsed": { "added": [ "def c_int_search_scxx(seq,t,chk=1):", " # do partial type checking in Python.", " # checking that list items are ints should happen in py_to_scalar", " if chk:", " assert(type(t) == type(1))", " assert(type(seq) == type([]))", " code = \"\"\"", " #line 29 \"binary_search.py\"", " int val, m, min = 0;", " int max = seq.len()- 1;", " for(;;)", " {", " if (max < min )", " {", " return_val = -1;", " break;", " }", " m = (min + max) / 2;", " val = seq[m];", " if (val < t)", " min = m + 1;", " else if (val > t)", " max = m - 1;", " else", " {", " return_val = m;", " break;", " }", " }", " \"\"\"", " #return inline_tools.inline(code,['seq','t'],compiler='msvc')", " return inline_tools.inline(code,['seq','t'],verbose = 2)", "", " # get it in cache", " c_int_search_scxx(a,i)", " t1 = time.time()", " for i in range(n):", " c_int_search_scxx(a,i,chk=1)", " t2 = time.time()", " sp = (t2-t1)+1e-20 # protect against div by zero", " print ' speed for scxx:',sp", " print ' speed up: %3.2f' % (py/sp)", "", " # get it in cache", " c_int_search_scxx(a,i)", " t1 = time.time()", " for i in range(n):", " c_int_search_scxx(a,i,chk=0)", " t2 = time.time()", " sp = (t2-t1)+1e-20 # protect against div by zero", " print ' speed for scxx(no asserts):',sp", " print ' speed up: %3.2f' % (py/sp)", "" ], "deleted": [] } }, { "old_path": "weave/examples/cast_copy_transpose.py", "new_path": "weave/examples/cast_copy_transpose.py", "filename": "cast_copy_transpose.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -19,20 +19,20 @@\n import sys\n sys.path.insert(0,'..')\n import inline_tools\n-import scalar_spec\n+import c_spec\n import converters\n blitz_type_converters = converters.blitz\n \n def _cast_copy_transpose(type,a_2d):\n assert(len(shape(a_2d)) == 2)\n new_array = zeros(shape(a_2d),type)\n+ numeric_type = c_spec.num_to_c_types[a_2d.typecode()]\n #trans_a_2d = transpose(a_2d)\n- numeric_type = scalar_spec.numeric_to_c_type_mapping[type]\n code = \"\"\"\n for(int i = 0; i < Na_2d[0]; i++)\n for(int j = 0; j < Na_2d[1]; j++)\n new_array(i,j) = (%s) a_2d(j,i);\n- \"\"\" % numeric_type\n+ \"\"\" % numeric_type \n inline_tools.inline(code,['new_array','a_2d'],\n type_converters = blitz_type_converters,\n compiler='gcc',\n@@ -41,11 +41,11 @@ def _cast_copy_transpose(type,a_2d):\n \n def _inplace_transpose(a_2d):\n assert(len(shape(a_2d)) == 2)\n- numeric_type = scalar_spec.numeric_to_c_type_mapping[a_2d.typecode()]\n+ numeric_type = c_spec.num_to_c_types[a_2d.typecode()]\n code = \"\"\"\n %s temp;\n- for(int i = 0; i < _Na_2d[0]; i++)\n- for(int j = 0; j < _Na_2d[1]; j++)\n+ for(int i = 0; i < Na_2d[0]; i++)\n+ for(int j = 0; j < Na_2d[1]; j++)\n {\n temp = a_2d(i,j);\n a_2d(i,j) = a_2d(j,i);\n@@ -59,10 +59,10 @@ def _inplace_transpose(a_2d):\n type = a_2d.typecode()\n new_array = zeros(shape(a_2d),type)\n #trans_a_2d = transpose(a_2d)\n- numeric_type = scalar_spec.numeric_to_c_type_mapping[type]\n+ numeric_type = c_spec.num_to_c_types[type]\n code = \"\"\"\n- for(int i = 0; i < _Na_2d[0]; i++)\n- for(int j = 0; j < _Na_2d[1]; j++)\n+ for(int i = 0; i < Na_2d[0]; i++)\n+ for(int j = 0; j < Na_2d[1]; j++)\n new_array(i,j) = (%s) a_2d(j,i);\n \"\"\" % numeric_type\n inline_tools.inline(code,['new_array','a_2d'],\n", "added_lines": 9, "deleted_lines": 9, "source_code": "\"\"\" Cast Copy Tranpose is used in Numeric's LinearAlgebra.py to convert\n C ordered arrays to Fortran order arrays before calling Fortran\n functions. A couple of C implementations are provided here that \n show modest speed improvements. One is an \"inplace\" transpose that\n does an in memory transpose of an arrays elements. This is the\n fastest approach and is beneficial if you don't need to keep the\n original array. \n\"\"\"\n# C:\\home\\ej\\wrk\\scipy\\compiler\\examples>python cast_copy_transpose.py\n# Cast/Copy/Transposing (150,150)array 1 times\n# speed in python: 0.870999932289\n# speed in c: 0.25\n# speed up: 3.48\n# inplace transpose c: 0.129999995232\n# speed up: 6.70\n\nimport Numeric\nfrom Numeric import *\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\nimport c_spec\nimport converters\nblitz_type_converters = converters.blitz\n\ndef _cast_copy_transpose(type,a_2d):\n assert(len(shape(a_2d)) == 2)\n new_array = zeros(shape(a_2d),type)\n numeric_type = c_spec.num_to_c_types[a_2d.typecode()]\n #trans_a_2d = transpose(a_2d)\n code = \"\"\"\n for(int i = 0; i < Na_2d[0]; i++)\n for(int j = 0; j < Na_2d[1]; j++)\n new_array(i,j) = (%s) a_2d(j,i);\n \"\"\" % numeric_type \n inline_tools.inline(code,['new_array','a_2d'],\n type_converters = blitz_type_converters,\n compiler='gcc',\n verbose = 1)\n return new_array\n\ndef _inplace_transpose(a_2d):\n assert(len(shape(a_2d)) == 2)\n numeric_type = c_spec.num_to_c_types[a_2d.typecode()]\n code = \"\"\"\n %s temp;\n for(int i = 0; i < Na_2d[0]; i++)\n for(int j = 0; j < Na_2d[1]; j++)\n {\n temp = a_2d(i,j);\n a_2d(i,j) = a_2d(j,i);\n a_2d(j,i) = temp;\n } \n \"\"\" % numeric_type\n inline_tools.inline(code,['a_2d'],\n type_converters = blitz_type_converters,\n compiler='gcc')\n assert(len(shape(a_2d)) == 2)\n type = a_2d.typecode()\n new_array = zeros(shape(a_2d),type)\n #trans_a_2d = transpose(a_2d)\n numeric_type = c_spec.num_to_c_types[type]\n code = \"\"\"\n for(int i = 0; i < Na_2d[0]; i++)\n for(int j = 0; j < Na_2d[1]; j++)\n new_array(i,j) = (%s) a_2d(j,i);\n \"\"\" % numeric_type\n inline_tools.inline(code,['new_array','a_2d'],\n type_converters = blitz_type_converters,\n compiler='gcc',\n verbose = 1)\n return new_array\n\ndef cast_copy_transpose(type,*arrays):\n results = []\n for a in arrays:\n results.append(_cast_copy_transpose(type,a))\n if len(results) == 1:\n return results[0]\n else:\n return results\n\ndef inplace_cast_copy_transpose(*arrays):\n results = []\n for a in arrays:\n results.append(_inplace_transpose(a))\n if len(results) == 1:\n return results[0]\n else:\n return results\n\ndef _castCopyAndTranspose(type, *arrays):\n cast_arrays = ()\n for a in arrays:\n if a.typecode() == type:\n cast_arrays = cast_arrays + (copy.copy(Numeric.transpose(a)),)\n else:\n cast_arrays = cast_arrays + (copy.copy(\n Numeric.transpose(a).astype(type)),)\n if len(cast_arrays) == 1:\n return cast_arrays[0]\n else:\n return cast_arrays\n\nimport time\n\n\ndef compare(m,n):\n a = ones((n,n),Float64)\n type = Float32\n print 'Cast/Copy/Transposing (%d,%d)array %d times' % (n,n,m)\n t1 = time.time()\n for i in range(m):\n for i in range(n):\n b = _castCopyAndTranspose(type,a)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)/m\n \n\n # load into cache \n b = cast_copy_transpose(type,a)\n t1 = time.time()\n for i in range(m):\n for i in range(n):\n b = cast_copy_transpose(type,a)\n t2 = time.time()\n print ' speed in c:',(t2 - t1)/ m \n print ' speed up: %3.2f' % (py/(t2-t1))\n\n # inplace tranpose\n b = _inplace_transpose(a)\n t1 = time.time()\n for i in range(m):\n for i in range(n):\n b = _inplace_transpose(a)\n t2 = time.time()\n print ' inplace transpose c:',(t2 - t1)/ m \n print ' speed up: %3.2f' % (py/(t2-t1))\n \nif __name__ == \"__main__\":\n m,n = 1,150\n compare(m,n) \n", "source_code_before": "\"\"\" Cast Copy Tranpose is used in Numeric's LinearAlgebra.py to convert\n C ordered arrays to Fortran order arrays before calling Fortran\n functions. A couple of C implementations are provided here that \n show modest speed improvements. One is an \"inplace\" transpose that\n does an in memory transpose of an arrays elements. This is the\n fastest approach and is beneficial if you don't need to keep the\n original array. \n\"\"\"\n# C:\\home\\ej\\wrk\\scipy\\compiler\\examples>python cast_copy_transpose.py\n# Cast/Copy/Transposing (150,150)array 1 times\n# speed in python: 0.870999932289\n# speed in c: 0.25\n# speed up: 3.48\n# inplace transpose c: 0.129999995232\n# speed up: 6.70\n\nimport Numeric\nfrom Numeric import *\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\nimport scalar_spec\nimport converters\nblitz_type_converters = converters.blitz\n\ndef _cast_copy_transpose(type,a_2d):\n assert(len(shape(a_2d)) == 2)\n new_array = zeros(shape(a_2d),type)\n #trans_a_2d = transpose(a_2d)\n numeric_type = scalar_spec.numeric_to_c_type_mapping[type]\n code = \"\"\"\n for(int i = 0; i < Na_2d[0]; i++)\n for(int j = 0; j < Na_2d[1]; j++)\n new_array(i,j) = (%s) a_2d(j,i);\n \"\"\" % numeric_type\n inline_tools.inline(code,['new_array','a_2d'],\n type_converters = blitz_type_converters,\n compiler='gcc',\n verbose = 1)\n return new_array\n\ndef _inplace_transpose(a_2d):\n assert(len(shape(a_2d)) == 2)\n numeric_type = scalar_spec.numeric_to_c_type_mapping[a_2d.typecode()]\n code = \"\"\"\n %s temp;\n for(int i = 0; i < _Na_2d[0]; i++)\n for(int j = 0; j < _Na_2d[1]; j++)\n {\n temp = a_2d(i,j);\n a_2d(i,j) = a_2d(j,i);\n a_2d(j,i) = temp;\n } \n \"\"\" % numeric_type\n inline_tools.inline(code,['a_2d'],\n type_converters = blitz_type_converters,\n compiler='gcc')\n assert(len(shape(a_2d)) == 2)\n type = a_2d.typecode()\n new_array = zeros(shape(a_2d),type)\n #trans_a_2d = transpose(a_2d)\n numeric_type = scalar_spec.numeric_to_c_type_mapping[type]\n code = \"\"\"\n for(int i = 0; i < _Na_2d[0]; i++)\n for(int j = 0; j < _Na_2d[1]; j++)\n new_array(i,j) = (%s) a_2d(j,i);\n \"\"\" % numeric_type\n inline_tools.inline(code,['new_array','a_2d'],\n type_converters = blitz_type_converters,\n compiler='gcc',\n verbose = 1)\n return new_array\n\ndef cast_copy_transpose(type,*arrays):\n results = []\n for a in arrays:\n results.append(_cast_copy_transpose(type,a))\n if len(results) == 1:\n return results[0]\n else:\n return results\n\ndef inplace_cast_copy_transpose(*arrays):\n results = []\n for a in arrays:\n results.append(_inplace_transpose(a))\n if len(results) == 1:\n return results[0]\n else:\n return results\n\ndef _castCopyAndTranspose(type, *arrays):\n cast_arrays = ()\n for a in arrays:\n if a.typecode() == type:\n cast_arrays = cast_arrays + (copy.copy(Numeric.transpose(a)),)\n else:\n cast_arrays = cast_arrays + (copy.copy(\n Numeric.transpose(a).astype(type)),)\n if len(cast_arrays) == 1:\n return cast_arrays[0]\n else:\n return cast_arrays\n\nimport time\n\n\ndef compare(m,n):\n a = ones((n,n),Float64)\n type = Float32\n print 'Cast/Copy/Transposing (%d,%d)array %d times' % (n,n,m)\n t1 = time.time()\n for i in range(m):\n for i in range(n):\n b = _castCopyAndTranspose(type,a)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)/m\n \n\n # load into cache \n b = cast_copy_transpose(type,a)\n t1 = time.time()\n for i in range(m):\n for i in range(n):\n b = cast_copy_transpose(type,a)\n t2 = time.time()\n print ' speed in c:',(t2 - t1)/ m \n print ' speed up: %3.2f' % (py/(t2-t1))\n\n # inplace tranpose\n b = _inplace_transpose(a)\n t1 = time.time()\n for i in range(m):\n for i in range(n):\n b = _inplace_transpose(a)\n t2 = time.time()\n print ' inplace transpose c:',(t2 - t1)/ m \n print ' speed up: %3.2f' % (py/(t2-t1))\n \nif __name__ == \"__main__\":\n m,n = 1,150\n compare(m,n) \n", "methods": [ { "name": "_cast_copy_transpose", "long_name": "_cast_copy_transpose( type , a_2d )", "filename": "cast_copy_transpose.py", "nloc": 14, "complexity": 1, "token_count": 73, "parameters": [ "type", "a_2d" ], "start_line": 26, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "_inplace_transpose", "long_name": "_inplace_transpose( a_2d )", "filename": "cast_copy_transpose.py", "nloc": 30, "complexity": 1, "token_count": 121, "parameters": [ "a_2d" ], "start_line": 42, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "cast_copy_transpose", "long_name": "cast_copy_transpose( type , * arrays )", "filename": "cast_copy_transpose.py", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "type", "arrays" ], "start_line": 74, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "inplace_cast_copy_transpose", "long_name": "inplace_cast_copy_transpose( * arrays )", "filename": "cast_copy_transpose.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "arrays" ], "start_line": 83, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_castCopyAndTranspose", "long_name": "_castCopyAndTranspose( type , * arrays )", "filename": "cast_copy_transpose.py", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "type", "arrays" ], "start_line": 92, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "compare", "long_name": "compare( m , n )", "filename": "cast_copy_transpose.py", "nloc": 27, "complexity": 7, "token_count": 219, "parameters": [ "m", "n" ], "start_line": 108, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 } ], "methods_before": [ { "name": "_cast_copy_transpose", "long_name": "_cast_copy_transpose( type , a_2d )", "filename": "cast_copy_transpose.py", "nloc": 14, "complexity": 1, "token_count": 69, "parameters": [ "type", "a_2d" ], "start_line": 26, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "_inplace_transpose", "long_name": "_inplace_transpose( a_2d )", "filename": "cast_copy_transpose.py", "nloc": 30, "complexity": 1, "token_count": 121, "parameters": [ "a_2d" ], "start_line": 42, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "cast_copy_transpose", "long_name": "cast_copy_transpose( type , * arrays )", "filename": "cast_copy_transpose.py", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "type", "arrays" ], "start_line": 74, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "inplace_cast_copy_transpose", "long_name": "inplace_cast_copy_transpose( * arrays )", "filename": "cast_copy_transpose.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "arrays" ], "start_line": 83, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_castCopyAndTranspose", "long_name": "_castCopyAndTranspose( type , * arrays )", "filename": "cast_copy_transpose.py", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "type", "arrays" ], "start_line": 92, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "compare", "long_name": "compare( m , n )", "filename": "cast_copy_transpose.py", "nloc": 27, "complexity": 7, "token_count": 219, "parameters": [ "m", "n" ], "start_line": 108, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_inplace_transpose", "long_name": "_inplace_transpose( a_2d )", "filename": "cast_copy_transpose.py", "nloc": 30, "complexity": 1, "token_count": 121, "parameters": [ "a_2d" ], "start_line": 42, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "_cast_copy_transpose", "long_name": "_cast_copy_transpose( type , a_2d )", "filename": "cast_copy_transpose.py", "nloc": 14, "complexity": 1, "token_count": 73, "parameters": [ "type", "a_2d" ], "start_line": 26, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 } ], "nloc": 119, "complexity": 19, "token_count": 641, "diff_parsed": { "added": [ "import c_spec", " numeric_type = c_spec.num_to_c_types[a_2d.typecode()]", " \"\"\" % numeric_type", " numeric_type = c_spec.num_to_c_types[a_2d.typecode()]", " for(int i = 0; i < Na_2d[0]; i++)", " for(int j = 0; j < Na_2d[1]; j++)", " numeric_type = c_spec.num_to_c_types[type]", " for(int i = 0; i < Na_2d[0]; i++)", " for(int j = 0; j < Na_2d[1]; j++)" ], "deleted": [ "import scalar_spec", " numeric_type = scalar_spec.numeric_to_c_type_mapping[type]", " \"\"\" % numeric_type", " numeric_type = scalar_spec.numeric_to_c_type_mapping[a_2d.typecode()]", " for(int i = 0; i < _Na_2d[0]; i++)", " for(int j = 0; j < _Na_2d[1]; j++)", " numeric_type = scalar_spec.numeric_to_c_type_mapping[type]", " for(int i = 0; i < _Na_2d[0]; i++)", " for(int j = 0; j < _Na_2d[1]; j++)" ] } }, { "old_path": "weave/examples/dict_sort.py", "new_path": "weave/examples/dict_sort.py", "filename": "dict_sort.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -43,10 +43,9 @@ def c_sort2(adict):\n assert(type(adict) == type({}))\n code = \"\"\"\n #line 21 \"dict_sort.py\" \n- PWOList keys = adict.keys();\n- PWOList items(keys.len());\n+ py::list keys = adict.keys();\n+ py::list items(keys.len());\n keys.sort(); // surely this isn't any slower than raw API calls\n- PyObject* item = NULL;\n int N = keys.length();\n for(int i = 0; i < N;i++)\n items[i] = adict[keys[i]];\n", "added_lines": 2, "deleted_lines": 3, "source_code": "# Borrowed from Alex Martelli's sort from Python cookbook using inlines\n# 2x over fastest Python version -- again, maybe not worth the effort...\n# Then again, 2x is 2x...\n#\n# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python dict_sort.py\n# Dict sort of 1000 items for 300 iterations:\n# speed in python: 0.250999927521\n# [0, 1, 2, 3, 4]\n# speed in c: 0.110000014305\n# speed up: 2.28\n# [0, 1, 2, 3, 4]\n# speed in c (scxx): 0.200000047684\n# speed up: 1.25\n# [0, 1, 2, 3, 4] \n\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\n\ndef c_sort(adict):\n assert(type(adict) == type({}))\n code = \"\"\"\n #line 21 \"dict_sort.py\" \n py::list keys = adict.keys();\n PyObject* py_keys = (PyObject*)keys;\n py::list items(keys.len());\n PyObject* py_items = (PyObject*)items;\n keys.sort(); // surely this isn't any slower than raw API calls\n PyObject* item = NULL;\n int N = keys.len();\n for(int i = 0; i < N;i++)\n {\n item = PyList_GET_ITEM(py_keys,i);\n item = PyDict_GetItem(py_adict,item);\n Py_XINCREF(item);\n PyList_SetItem(py_items,i,item); \n } \n return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n\ndef c_sort2(adict):\n assert(type(adict) == type({}))\n code = \"\"\"\n #line 21 \"dict_sort.py\" \n py::list keys = adict.keys();\n py::list items(keys.len());\n keys.sort(); // surely this isn't any slower than raw API calls\n int N = keys.length();\n for(int i = 0; i < N;i++)\n items[i] = adict[keys[i]];\n return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n\n# (IMHO) the simplest approach:\ndef sortedDictValues1(adict):\n items = adict.items()\n items.sort()\n return [value for key, value in items]\n\n# an alternative implementation, which\n# happens to run a bit faster for large\n# dictionaries on my machine:\ndef sortedDictValues2(adict):\n keys = adict.keys()\n keys.sort()\n return [adict[key] for key in keys]\n\n# a further slight speed-up on my box\n# is to map a bound-method:\ndef sortedDictValues3(adict):\n keys = adict.keys()\n keys.sort()\n return map(adict.get, keys)\n\nimport time\n\ndef sort_compare(a,n):\n print 'Dict sort of %d items for %d iterations:'%(len(a),n)\n t1 = time.time()\n for i in range(n):\n b=sortedDictValues3(a)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)\n print b[:5]\n \n b=c_sort(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort(a)\n t2 = time.time()\n print ' speed in c:',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\n b=c_sort2(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort2(a)\n t2 = time.time()\n print ' speed in c (scxx):',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\ndef setup_dict(m):\n \" does insertion order matter?\"\n import whrandom\n a = range(m)\n d = {}\n for i in range(m):\n key = whrandom.choice(a)\n a.remove(key)\n d[key]=key\n return d \nif __name__ == \"__main__\":\n m = 1000\n a = setup_dict(m)\n n = 300\n sort_compare(a,n) \n", "source_code_before": "# Borrowed from Alex Martelli's sort from Python cookbook using inlines\n# 2x over fastest Python version -- again, maybe not worth the effort...\n# Then again, 2x is 2x...\n#\n# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python dict_sort.py\n# Dict sort of 1000 items for 300 iterations:\n# speed in python: 0.250999927521\n# [0, 1, 2, 3, 4]\n# speed in c: 0.110000014305\n# speed up: 2.28\n# [0, 1, 2, 3, 4]\n# speed in c (scxx): 0.200000047684\n# speed up: 1.25\n# [0, 1, 2, 3, 4] \n\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\n\ndef c_sort(adict):\n assert(type(adict) == type({}))\n code = \"\"\"\n #line 21 \"dict_sort.py\" \n py::list keys = adict.keys();\n PyObject* py_keys = (PyObject*)keys;\n py::list items(keys.len());\n PyObject* py_items = (PyObject*)items;\n keys.sort(); // surely this isn't any slower than raw API calls\n PyObject* item = NULL;\n int N = keys.len();\n for(int i = 0; i < N;i++)\n {\n item = PyList_GET_ITEM(py_keys,i);\n item = PyDict_GetItem(py_adict,item);\n Py_XINCREF(item);\n PyList_SetItem(py_items,i,item); \n } \n return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n\ndef c_sort2(adict):\n assert(type(adict) == type({}))\n code = \"\"\"\n #line 21 \"dict_sort.py\" \n PWOList keys = adict.keys();\n PWOList items(keys.len());\n keys.sort(); // surely this isn't any slower than raw API calls\n PyObject* item = NULL;\n int N = keys.length();\n for(int i = 0; i < N;i++)\n items[i] = adict[keys[i]];\n return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n\n# (IMHO) the simplest approach:\ndef sortedDictValues1(adict):\n items = adict.items()\n items.sort()\n return [value for key, value in items]\n\n# an alternative implementation, which\n# happens to run a bit faster for large\n# dictionaries on my machine:\ndef sortedDictValues2(adict):\n keys = adict.keys()\n keys.sort()\n return [adict[key] for key in keys]\n\n# a further slight speed-up on my box\n# is to map a bound-method:\ndef sortedDictValues3(adict):\n keys = adict.keys()\n keys.sort()\n return map(adict.get, keys)\n\nimport time\n\ndef sort_compare(a,n):\n print 'Dict sort of %d items for %d iterations:'%(len(a),n)\n t1 = time.time()\n for i in range(n):\n b=sortedDictValues3(a)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)\n print b[:5]\n \n b=c_sort(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort(a)\n t2 = time.time()\n print ' speed in c:',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\n b=c_sort2(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort2(a)\n t2 = time.time()\n print ' speed in c (scxx):',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\ndef setup_dict(m):\n \" does insertion order matter?\"\n import whrandom\n a = range(m)\n d = {}\n for i in range(m):\n key = whrandom.choice(a)\n a.remove(key)\n d[key]=key\n return d \nif __name__ == \"__main__\":\n m = 1000\n a = setup_dict(m)\n n = 300\n sort_compare(a,n) \n", "methods": [ { "name": "c_sort", "long_name": "c_sort( adict )", "filename": "dict_sort.py", "nloc": 21, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 20, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "c_sort2", "long_name": "c_sort2( adict )", "filename": "dict_sort.py", "nloc": 13, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 42, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "sortedDictValues1", "long_name": "sortedDictValues1( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 27, "parameters": [ "adict" ], "start_line": 57, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues2", "long_name": "sortedDictValues2( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "adict" ], "start_line": 65, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues3", "long_name": "sortedDictValues3( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "adict" ], "start_line": 72, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sort_compare", "long_name": "sort_compare( a , n )", "filename": "dict_sort.py", "nloc": 25, "complexity": 4, "token_count": 187, "parameters": [ "a", "n" ], "start_line": 79, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "setup_dict", "long_name": "setup_dict( m )", "filename": "dict_sort.py", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "m" ], "start_line": 107, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "methods_before": [ { "name": "c_sort", "long_name": "c_sort( adict )", "filename": "dict_sort.py", "nloc": 21, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 20, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "c_sort2", "long_name": "c_sort2( adict )", "filename": "dict_sort.py", "nloc": 14, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 42, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "sortedDictValues1", "long_name": "sortedDictValues1( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 27, "parameters": [ "adict" ], "start_line": 58, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues2", "long_name": "sortedDictValues2( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "adict" ], "start_line": 66, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues3", "long_name": "sortedDictValues3( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "adict" ], "start_line": 73, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sort_compare", "long_name": "sort_compare( a , n )", "filename": "dict_sort.py", "nloc": 25, "complexity": 4, "token_count": 187, "parameters": [ "a", "n" ], "start_line": 80, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "setup_dict", "long_name": "setup_dict( m )", "filename": "dict_sort.py", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "m" ], "start_line": 108, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "c_sort2", "long_name": "c_sort2( adict )", "filename": "dict_sort.py", "nloc": 13, "complexity": 1, "token_count": 36, "parameters": [ "adict" ], "start_line": 42, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 } ], "nloc": 90, "complexity": 13, "token_count": 434, "diff_parsed": { "added": [ " py::list keys = adict.keys();", " py::list items(keys.len());" ], "deleted": [ " PWOList keys = adict.keys();", " PWOList items(keys.len());", " PyObject* item = NULL;" ] } }, { "old_path": "weave/examples/fibonacci.py", "new_path": "weave/examples/fibonacci.py", "filename": "fibonacci.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,13 +1,13 @@\n # Typical run:\n-# C:\\home\\ej\\wrk\\scipy\\compiler\\examples>python fibonacci.py\n+# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python fibonacci.py\n # Recursively computing the first 30 fibonacci numbers:\n-# speed in python: 3.98599994183\n-# speed in c: 0.0800000429153\n-# speed up: 49.82\n-# Loopin to compute the first 30 fibonacci numbers:\n-# speed in python: 0.00053100001812\n-# speed in c: 5.99999427795e-005\n-# speed up: 8.85\n+# speed in python: 4.31599998474\n+# speed in c: 0.0499999523163\n+# speed up: 86.32\n+# Looping to compute the first 30 fibonacci numbers:\n+# speed in python: 0.000520999908447\n+# speed in c: 5.00000715256e-005\n+# speed up: 10.42\n # fib(30) 832040 832040 832040 832040\n \n import sys\n@@ -31,8 +31,7 @@ def build_fibonacci():\n } \n \"\"\"\n ext_code = \"\"\"\n- int val = fib1(a);\n- return_val = PyInt_FromLong(val);\n+ return_val = fib1(a);\n \"\"\" \n fib = ext_tools.ext_function('c_fib1',ext_code,['a'])\n fib.customize.add_support_code(fib_code)\n@@ -58,8 +57,7 @@ def build_fibonacci():\n } \n \"\"\"\n ext_code = \"\"\"\n- int val = fib2(a);\n- return_val = PyInt_FromLong(val);\n+ return_val = fib2(a);\n \"\"\" \n fib = ext_tools.ext_function('c_fib2',ext_code,['a'])\n fib.customize.add_support_code(fib_code)\n", "added_lines": 10, "deleted_lines": 12, "source_code": "# Typical run:\n# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python fibonacci.py\n# Recursively computing the first 30 fibonacci numbers:\n# speed in python: 4.31599998474\n# speed in c: 0.0499999523163\n# speed up: 86.32\n# Looping to compute the first 30 fibonacci numbers:\n# speed in python: 0.000520999908447\n# speed in c: 5.00000715256e-005\n# speed up: 10.42\n# fib(30) 832040 832040 832040 832040\n\nimport sys\nsys.path.insert(0,'..')\nimport ext_tools\n\ndef build_fibonacci():\n \"\"\" Builds an extension module with fibonacci calculators.\n \"\"\"\n mod = ext_tools.ext_module('fibonacci_ext')\n a = 1 # this is effectively a type declaration\n \n # recursive fibonacci in C \n fib_code = \"\"\"\n int fib1(int a)\n { \n if(a <= 2)\n return 1;\n else\n return fib1(a-2) + fib1(a-1); \n } \n \"\"\"\n ext_code = \"\"\"\n return_val = fib1(a);\n \"\"\" \n fib = ext_tools.ext_function('c_fib1',ext_code,['a'])\n fib.customize.add_support_code(fib_code)\n mod.add_function(fib)\n\n # looping fibonacci in C\n fib_code = \"\"\"\n int fib2( int a )\n {\n int last, next_to_last, result;\n \n if( a <= 2 )\n return 1; \n last = next_to_last = 1;\n for(int i = 2; i < a; i++ )\n {\n result = last + next_to_last;\n next_to_last = last;\n last = result;\n }\n \n return result;\n } \n \"\"\"\n ext_code = \"\"\"\n return_val = fib2(a);\n \"\"\" \n fib = ext_tools.ext_function('c_fib2',ext_code,['a'])\n fib.customize.add_support_code(fib_code)\n mod.add_function(fib) \n mod.compile()\n\ntry:\n import fibonacci_ext\nexcept ImportError:\n build_fibonacci()\n import fibonacci_ext\nc_fib1 = fibonacci_ext.c_fib1\nc_fib2 = fibonacci_ext.c_fib2\n\n#################################################################\n# This where it might normally end, but we've added some timings\n# below. Recursive solutions are much slower, and C is 10-50x faster\n# than equivalent in Python for this simple little routine\n#\n#################################################################\n\ndef py_fib1(a):\n if a <= 2:\n return 1\n else:\n return py_fib1(a-2) + py_fib1(a-1)\n\ndef py_fib2(a):\n if a <= 2:\n return 1 \n last = next_to_last = 1\n for i in range(2,a):\n result = last + next_to_last\n next_to_last = last\n last = result\n return result;\n\nimport time\n\ndef recurse_compare(n):\n print 'Recursively computing the first %d fibonacci numbers:' % n\n t1 = time.time()\n for i in range(n):\n py_fib1(i)\n t2 = time.time()\n py = t2- t1\n print ' speed in python:', t2 - t1\n \n #load into cache\n c_fib1(i)\n t1 = time.time()\n for i in range(n):\n c_fib1(i)\n t2 = time.time() \n print ' speed in c:',t2 - t1 \n print ' speed up: %3.2f' % (py/(t2-t1))\n\ndef loop_compare(m,n):\n print 'Looping to compute the first %d fibonacci numbers:' % n\n t1 = time.time()\n for i in range(m):\n for i in range(n):\n py_fib2(i)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)/m\n \n #load into cache\n c_fib2(i)\n t1 = time.time()\n for i in range(m):\n for i in range(n):\n c_fib2(i)\n t2 = time.time()\n print ' speed in c:',(t2 - t1)/ m \n print ' speed up: %3.2f' % (py/(t2-t1))\n \nif __name__ == \"__main__\":\n n = 30\n recurse_compare(n)\n m= 1000 \n loop_compare(m,n) \n print 'fib(30)', c_fib1(30),py_fib1(30),c_fib2(30),py_fib2(30)", "source_code_before": "# Typical run:\n# C:\\home\\ej\\wrk\\scipy\\compiler\\examples>python fibonacci.py\n# Recursively computing the first 30 fibonacci numbers:\n# speed in python: 3.98599994183\n# speed in c: 0.0800000429153\n# speed up: 49.82\n# Loopin to compute the first 30 fibonacci numbers:\n# speed in python: 0.00053100001812\n# speed in c: 5.99999427795e-005\n# speed up: 8.85\n# fib(30) 832040 832040 832040 832040\n\nimport sys\nsys.path.insert(0,'..')\nimport ext_tools\n\ndef build_fibonacci():\n \"\"\" Builds an extension module with fibonacci calculators.\n \"\"\"\n mod = ext_tools.ext_module('fibonacci_ext')\n a = 1 # this is effectively a type declaration\n \n # recursive fibonacci in C \n fib_code = \"\"\"\n int fib1(int a)\n { \n if(a <= 2)\n return 1;\n else\n return fib1(a-2) + fib1(a-1); \n } \n \"\"\"\n ext_code = \"\"\"\n int val = fib1(a);\n return_val = PyInt_FromLong(val);\n \"\"\" \n fib = ext_tools.ext_function('c_fib1',ext_code,['a'])\n fib.customize.add_support_code(fib_code)\n mod.add_function(fib)\n\n # looping fibonacci in C\n fib_code = \"\"\"\n int fib2( int a )\n {\n int last, next_to_last, result;\n \n if( a <= 2 )\n return 1; \n last = next_to_last = 1;\n for(int i = 2; i < a; i++ )\n {\n result = last + next_to_last;\n next_to_last = last;\n last = result;\n }\n \n return result;\n } \n \"\"\"\n ext_code = \"\"\"\n int val = fib2(a);\n return_val = PyInt_FromLong(val);\n \"\"\" \n fib = ext_tools.ext_function('c_fib2',ext_code,['a'])\n fib.customize.add_support_code(fib_code)\n mod.add_function(fib) \n mod.compile()\n\ntry:\n import fibonacci_ext\nexcept ImportError:\n build_fibonacci()\n import fibonacci_ext\nc_fib1 = fibonacci_ext.c_fib1\nc_fib2 = fibonacci_ext.c_fib2\n\n#################################################################\n# This where it might normally end, but we've added some timings\n# below. Recursive solutions are much slower, and C is 10-50x faster\n# than equivalent in Python for this simple little routine\n#\n#################################################################\n\ndef py_fib1(a):\n if a <= 2:\n return 1\n else:\n return py_fib1(a-2) + py_fib1(a-1)\n\ndef py_fib2(a):\n if a <= 2:\n return 1 \n last = next_to_last = 1\n for i in range(2,a):\n result = last + next_to_last\n next_to_last = last\n last = result\n return result;\n\nimport time\n\ndef recurse_compare(n):\n print 'Recursively computing the first %d fibonacci numbers:' % n\n t1 = time.time()\n for i in range(n):\n py_fib1(i)\n t2 = time.time()\n py = t2- t1\n print ' speed in python:', t2 - t1\n \n #load into cache\n c_fib1(i)\n t1 = time.time()\n for i in range(n):\n c_fib1(i)\n t2 = time.time() \n print ' speed in c:',t2 - t1 \n print ' speed up: %3.2f' % (py/(t2-t1))\n\ndef loop_compare(m,n):\n print 'Looping to compute the first %d fibonacci numbers:' % n\n t1 = time.time()\n for i in range(m):\n for i in range(n):\n py_fib2(i)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)/m\n \n #load into cache\n c_fib2(i)\n t1 = time.time()\n for i in range(m):\n for i in range(n):\n c_fib2(i)\n t2 = time.time()\n print ' speed in c:',(t2 - t1)/ m \n print ' speed up: %3.2f' % (py/(t2-t1))\n \nif __name__ == \"__main__\":\n n = 30\n recurse_compare(n)\n m= 1000 \n loop_compare(m,n) \n print 'fib(30)', c_fib1(30),py_fib1(30),c_fib2(30),py_fib2(30)", "methods": [ { "name": "build_fibonacci", "long_name": "build_fibonacci( )", "filename": "fibonacci.py", "nloc": 43, "complexity": 1, "token_count": 89, "parameters": [], "start_line": 17, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "py_fib1", "long_name": "py_fib1( a )", "filename": "fibonacci.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "a" ], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "py_fib2", "long_name": "py_fib2( a )", "filename": "fibonacci.py", "nloc": 9, "complexity": 3, "token_count": 41, "parameters": [ "a" ], "start_line": 88, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "recurse_compare", "long_name": "recurse_compare( n )", "filename": "fibonacci.py", "nloc": 15, "complexity": 3, "token_count": 94, "parameters": [ "n" ], "start_line": 100, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "loop_compare", "long_name": "loop_compare( m , n )", "filename": "fibonacci.py", "nloc": 17, "complexity": 5, "token_count": 122, "parameters": [ "m", "n" ], "start_line": 118, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "methods_before": [ { "name": "build_fibonacci", "long_name": "build_fibonacci( )", "filename": "fibonacci.py", "nloc": 45, "complexity": 1, "token_count": 89, "parameters": [], "start_line": 17, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "py_fib1", "long_name": "py_fib1( a )", "filename": "fibonacci.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "a" ], "start_line": 84, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "py_fib2", "long_name": "py_fib2( a )", "filename": "fibonacci.py", "nloc": 9, "complexity": 3, "token_count": 41, "parameters": [ "a" ], "start_line": 90, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "recurse_compare", "long_name": "recurse_compare( n )", "filename": "fibonacci.py", "nloc": 15, "complexity": 3, "token_count": 94, "parameters": [ "n" ], "start_line": 102, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "loop_compare", "long_name": "loop_compare( m , n )", "filename": "fibonacci.py", "nloc": 17, "complexity": 5, "token_count": 122, "parameters": [ "m", "n" ], "start_line": 120, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_fibonacci", "long_name": "build_fibonacci( )", "filename": "fibonacci.py", "nloc": 43, "complexity": 1, "token_count": 89, "parameters": [], "start_line": 17, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 } ], "nloc": 106, "complexity": 14, "token_count": 460, "diff_parsed": { "added": [ "# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python fibonacci.py", "# speed in python: 4.31599998474", "# speed in c: 0.0499999523163", "# speed up: 86.32", "# Looping to compute the first 30 fibonacci numbers:", "# speed in python: 0.000520999908447", "# speed in c: 5.00000715256e-005", "# speed up: 10.42", " return_val = fib1(a);", " return_val = fib2(a);" ], "deleted": [ "# C:\\home\\ej\\wrk\\scipy\\compiler\\examples>python fibonacci.py", "# speed in python: 3.98599994183", "# speed in c: 0.0800000429153", "# speed up: 49.82", "# Loopin to compute the first 30 fibonacci numbers:", "# speed in python: 0.00053100001812", "# speed in c: 5.99999427795e-005", "# speed up: 8.85", " int val = fib1(a);", " return_val = PyInt_FromLong(val);", " int val = fib2(a);", " return_val = PyInt_FromLong(val);" ] } }, { "old_path": "weave/examples/functional.py", "new_path": "weave/examples/functional.py", "filename": "functional.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -18,8 +18,8 @@ def c_list_map(func,seq):\n \"\"\"\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n- #line 12 \"functional.py\"\n- py::tuple = args(1);\n+ #line 22 \"functional.py\"\n+ py::tuple args(1);\n int N = seq.len(); \n py::list result(N);\n for(int i = 0; i < N;i++)\n@@ -37,7 +37,7 @@ def c_list_map2(func,seq):\n \"\"\"\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n- #line 32 \"functional.py\"\n+ #line 40 \"functional.py\"\n py::tuple args(1); \n PyObject* py_args = (PyObject*)args;\n py::list result(seq.len());\n", "added_lines": 3, "deleted_lines": 3, "source_code": "# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python functional.py\n# desired: [2, 3, 4]\n# actual: [2, 3, 4]\n# actual2: [2, 3, 4]\n# python speed: 0.039999961853\n# SCXX speed: 0.0599999427795\n# speed up: 0.666666666667\n# c speed: 0.0200001001358\n# speed up: 1.99998807913\n\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\nfrom types import *\ndef c_list_map(func,seq):\n \"\"\" Uses CXX C code to implement a simple map-like function.\n It does not provide any error checking.\n \"\"\"\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n #line 22 \"functional.py\"\n py::tuple args(1);\n int N = seq.len(); \n py::list result(N);\n for(int i = 0; i < N;i++)\n {\n args[0] = seq[i];\n result[i] = func.call(args);\n } \n return_val = result;\n \"\"\" \n return inline_tools.inline(code,['func','seq'])\n\ndef c_list_map2(func,seq):\n \"\"\" Uses Python API more than CXX to implement a simple map-like function.\n It does not provide any error checking.\n \"\"\"\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n #line 40 \"functional.py\"\n py::tuple args(1); \n PyObject* py_args = (PyObject*)args;\n py::list result(seq.len());\n PyObject* py_result = (PyObject*)result;\n PyObject* item = NULL;\n PyObject* this_result = NULL;\n int N = seq.len();\n for(int i = 0; i < N;i++)\n {\n item = PyList_GET_ITEM(py_seq,i);\n Py_INCREF(item);\n PyTuple_SetItem(py_args,0,item);\n this_result = PyEval_CallObject(py_func,py_args);\n PyList_SetItem(py_result,i,this_result); \n } \n return_val = result;\n \"\"\" \n return inline_tools.inline(code,['func','seq'])\n \ndef main():\n seq = ['aa','bbb','cccc']\n print 'desired:', map(len,seq)\n print 'actual:', c_list_map(len,seq)\n print 'actual2:', c_list_map2(len,seq)\n\ndef time_it(m,n):\n import time\n seq = ['aadasdf'] * n\n t1 = time.time()\n for i in range(m):\n result = map(len,seq)\n t2 = time.time()\n py = t2 - t1\n print 'python speed:', py\n \n #load cache\n result = c_list_map(len,seq)\n t1 = time.time()\n for i in range(m):\n result = c_list_map(len,seq)\n t2 = time.time()\n c = t2-t1\n print 'SCXX speed:', c\n print 'speed up:', py / c\n\n #load cache\n result = c_list_map2(len,seq)\n t1 = time.time()\n for i in range(m):\n result = c_list_map2(len,seq)\n t2 = time.time()\n c = t2-t1\n print 'c speed:', c\n print 'speed up:', py / c\n\nif __name__ == \"__main__\":\n main()\n time_it(100,1000)", "source_code_before": "# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python functional.py\n# desired: [2, 3, 4]\n# actual: [2, 3, 4]\n# actual2: [2, 3, 4]\n# python speed: 0.039999961853\n# SCXX speed: 0.0599999427795\n# speed up: 0.666666666667\n# c speed: 0.0200001001358\n# speed up: 1.99998807913\n\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\nfrom types import *\ndef c_list_map(func,seq):\n \"\"\" Uses CXX C code to implement a simple map-like function.\n It does not provide any error checking.\n \"\"\"\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n #line 12 \"functional.py\"\n py::tuple = args(1);\n int N = seq.len(); \n py::list result(N);\n for(int i = 0; i < N;i++)\n {\n args[0] = seq[i];\n result[i] = func.call(args);\n } \n return_val = result;\n \"\"\" \n return inline_tools.inline(code,['func','seq'])\n\ndef c_list_map2(func,seq):\n \"\"\" Uses Python API more than CXX to implement a simple map-like function.\n It does not provide any error checking.\n \"\"\"\n assert(type(func) in [FunctionType,MethodType,type(len)])\n code = \"\"\"\n #line 32 \"functional.py\"\n py::tuple args(1); \n PyObject* py_args = (PyObject*)args;\n py::list result(seq.len());\n PyObject* py_result = (PyObject*)result;\n PyObject* item = NULL;\n PyObject* this_result = NULL;\n int N = seq.len();\n for(int i = 0; i < N;i++)\n {\n item = PyList_GET_ITEM(py_seq,i);\n Py_INCREF(item);\n PyTuple_SetItem(py_args,0,item);\n this_result = PyEval_CallObject(py_func,py_args);\n PyList_SetItem(py_result,i,this_result); \n } \n return_val = result;\n \"\"\" \n return inline_tools.inline(code,['func','seq'])\n \ndef main():\n seq = ['aa','bbb','cccc']\n print 'desired:', map(len,seq)\n print 'actual:', c_list_map(len,seq)\n print 'actual2:', c_list_map2(len,seq)\n\ndef time_it(m,n):\n import time\n seq = ['aadasdf'] * n\n t1 = time.time()\n for i in range(m):\n result = map(len,seq)\n t2 = time.time()\n py = t2 - t1\n print 'python speed:', py\n \n #load cache\n result = c_list_map(len,seq)\n t1 = time.time()\n for i in range(m):\n result = c_list_map(len,seq)\n t2 = time.time()\n c = t2-t1\n print 'SCXX speed:', c\n print 'speed up:', py / c\n\n #load cache\n result = c_list_map2(len,seq)\n t1 = time.time()\n for i in range(m):\n result = c_list_map2(len,seq)\n t2 = time.time()\n c = t2-t1\n print 'c speed:', c\n print 'speed up:', py / c\n\nif __name__ == \"__main__\":\n main()\n time_it(100,1000)", "methods": [ { "name": "c_list_map", "long_name": "c_list_map( func , seq )", "filename": "functional.py", "nloc": 15, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 15, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "c_list_map2", "long_name": "c_list_map2( func , seq )", "filename": "functional.py", "nloc": 22, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 34, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "main", "long_name": "main( )", "filename": "functional.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [], "start_line": 60, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "time_it", "long_name": "time_it( m , n )", "filename": "functional.py", "nloc": 25, "complexity": 4, "token_count": 161, "parameters": [ "m", "n" ], "start_line": 66, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 } ], "methods_before": [ { "name": "c_list_map", "long_name": "c_list_map( func , seq )", "filename": "functional.py", "nloc": 15, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 15, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "c_list_map2", "long_name": "c_list_map2( func , seq )", "filename": "functional.py", "nloc": 22, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 34, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "main", "long_name": "main( )", "filename": "functional.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [], "start_line": 60, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "time_it", "long_name": "time_it( m , n )", "filename": "functional.py", "nloc": 25, "complexity": 4, "token_count": 161, "parameters": [ "m", "n" ], "start_line": 66, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "c_list_map", "long_name": "c_list_map( func , seq )", "filename": "functional.py", "nloc": 15, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 15, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "c_list_map2", "long_name": "c_list_map2( func , seq )", "filename": "functional.py", "nloc": 22, "complexity": 1, "token_count": 42, "parameters": [ "func", "seq" ], "start_line": 34, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "nloc": 74, "complexity": 7, "token_count": 321, "diff_parsed": { "added": [ " #line 22 \"functional.py\"", " py::tuple args(1);", " #line 40 \"functional.py\"" ], "deleted": [ " #line 12 \"functional.py\"", " py::tuple = args(1);", " #line 32 \"functional.py\"" ] } }, { "old_path": "weave/examples/vq.py", "new_path": "weave/examples/vq.py", "filename": "vq.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -21,7 +21,7 @@\n import inline_tools\n import converters\n blitz_type_converters = converters.blitz\n-import scalar_spec\n+import c_spec\n \n def vq(obs,code_book):\n # make sure we're looking at arrays.\n@@ -32,31 +32,31 @@ def vq(obs,code_book):\n code_book_sh = shape(code_book)\n assert(len(obs_sh) == 2 and len(code_book_sh) == 2) \n assert(obs_sh[1] == code_book_sh[1]) \n- type = scalar_spec.numeric_to_c_type_mapping[obs.typecode()]\n+ type = c_spec.num_to_c_types[obs.typecode()]\n # band aid for now.\n ar_type = 'PyArray_FLOAT'\n code = \"\"\"\n #line 37 \"vq.py\"\n // Use tensor notation. \n- blitz::Array<%(type)s,2> dist_sq(_Ncode_book[0],_Nobs[0]);\n+ blitz::Array<%(type)s,2> dist_sq(Ncode_book[0],Nobs[0]);\n \t blitz::firstIndex i; \n blitz::secondIndex j; \n blitz::thirdIndex k;\n dist_sq = sum(pow2(obs(j,k) - code_book(i,k)),k);\n // Surely there is a better way to do this...\n- PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_LONG);\n+ PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_LONG);\n \t blitz::Array code((int*)(py_code->data),\n- blitz::shape(_Nobs[0]), blitz::neverDeleteData);\n+ blitz::shape(Nobs[0]), blitz::neverDeleteData);\n \t code = minIndex(dist_sq(j,i),j);\n \t \n- \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_FLOAT);\n+ \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_FLOAT);\n \t blitz::Array min_dist((float*)(py_min_dist->data),\n- \t blitz::shape(_Nobs[0]), blitz::neverDeleteData);\n+ \t blitz::shape(Nobs[0]), blitz::neverDeleteData);\n \t min_dist = sqrt(min(dist_sq(j,i),j));\n- \t Py::Tuple results(2);\n- \t results[0] = Py::Object((PyObject*)py_code);\n- \t results[1] = Py::Object((PyObject*)py_min_dist);\n- \t return_val = Py::new_reference_to(results); \t \n+ \t py::tuple results(2);\n+ \t results[0] = py_code;\n+ \t results[1] = py_min_dist;\n+ \t return_val = results; \t \n \"\"\" % locals()\n code, distortion = inline_tools.inline(code,['obs','code_book'],\n type_converters = blitz_type_converters,\n@@ -77,15 +77,15 @@ def vq2(obs,code_book):\n assert(len(obs_sh) == 2 and len(code_book_sh) == 2) \n assert(obs_sh[1] == code_book_sh[1]) \n assert(obs.typecode() == code_book.typecode()) \n- type = scalar_spec.numeric_to_c_type_mapping[obs.typecode()]\n+ type = c_spec.num_to_c_types[obs.typecode()]\n # band aid for now.\n ar_type = 'PyArray_FLOAT'\n code = \"\"\"\n #line 83 \"vq.py\"\n // THIS DOES NOT HANDLE STRIDED ARRAYS CORRECTLY\n // Surely there is a better way to do this...\n- PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_LONG);\t \n- \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_FLOAT);\n+ PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_LONG);\t \n+ \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_FLOAT);\n \t \n int* raw_code = (int*)(py_code->data);\n float* raw_min_dist = (float*)(py_min_dist->data);\n@@ -117,10 +117,10 @@ def vq2(obs,code_book):\n }\n raw_min_dist[i] = sqrt(raw_min_dist[i]);\n \t }\n- \t Py::Tuple results(2);\n- \t results[0] = Py::Object((PyObject*)py_code);\n- \t results[1] = Py::Object((PyObject*)py_min_dist);\n- \t return_val = Py::new_reference_to(results); \t \n+ \t py::tuple results(2);\n+ \t results[0] = py_code;\n+ \t results[1] = py_min_dist;\n+ \t return_val = results; \t \n \"\"\" % locals()\n code, distortion = inline_tools.inline(code,['obs','code_book'],\n type_converters = blitz_type_converters,\n@@ -142,25 +142,25 @@ def vq3(obs,code_book):\n assert(len(obs_sh) == 2 and len(code_book_sh) == 2) \n assert(obs_sh[1] == code_book_sh[1]) \n assert(obs.typecode() == code_book.typecode()) \n- type = scalar_spec.numeric_to_c_type_mapping[obs.typecode()]\n+ type = c_spec.num_to_c_types[obs.typecode()]\n code = \"\"\"\n #line 139 \"vq.py\"\n // Surely there is a better way to do this...\n- PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_LONG);\t \n- \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_FLOAT);\n+ PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_LONG);\t \n+ \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_FLOAT);\n \t \n int* code_data = (int*)(py_code->data);\n float* min_dist_data = (float*)(py_min_dist->data);\n %(type)s* this_obs = NULL;\n %(type)s* this_code = NULL; \n- int Nfeatures = _Nobs[1];\n+ int Nfeatures = Nobs[1];\n float diff,dist;\n \n- for(int i=0; i < _Nobs[0]; i++)\n+ for(int i=0; i < Nobs[0]; i++)\n {\n this_obs = &obs_data[i*Nfeatures];\n min_dist_data[i] = (float)10000000.; // big number\n- for(int j=0; j < _Ncode_book[0]; j++)\n+ for(int j=0; j < Ncode_book[0]; j++)\n {\n this_code = &code_book_data[j*Nfeatures];\n dist = 0;\n@@ -177,10 +177,10 @@ def vq3(obs,code_book):\n }\n min_dist_data[i] = sqrt(min_dist_data[i]);\n \t }\n- \t Py::Tuple results(2);\n- \t results[0] = Py::Object((PyObject*)py_code);\n- \t results[1] = Py::Object((PyObject*)py_min_dist);\n- \t return Py::new_reference_to(results); \t \n+ \t py::tuple results(2);\n+ \t results[0] = py_code;\n+ \t results[1] = py_min_dist;\n+ \t return_val = results; \t \n \"\"\" % locals()\n # this is an unpleasant way to specify type factories -- work on it.\n import ext_tools\n", "added_lines": 28, "deleted_lines": 28, "source_code": "\"\"\" \n\"\"\"\n# C:\\home\\ej\\wrk\\scipy\\weave\\examples>python vq.py\n# vq with 1000 observation, 10 features and 30 codes fo 100 iterations\n# speed in python: 0.150119999647\n# [25 29] [ 2.49147266 3.83021032]\n# speed in standard c: 0.00710999965668\n# [25 29] [ 2.49147266 3.83021032]\n# speed up: 21.11\n# speed inline/blitz: 0.0186300003529\n# [25 29] [ 2.49147272 3.83021021]\n# speed up: 8.06\n# speed inline/blitz2: 0.00461000084877\n# [25 29] [ 2.49147272 3.83021021]\n# speed up: 32.56\n \nimport Numeric\nfrom Numeric import *\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\nimport converters\nblitz_type_converters = converters.blitz\nimport c_spec\n\ndef vq(obs,code_book):\n # make sure we're looking at arrays.\n obs = asarray(obs)\n code_book = asarray(code_book)\n # check for 2d arrays and compatible sizes.\n obs_sh = shape(obs)\n code_book_sh = shape(code_book)\n assert(len(obs_sh) == 2 and len(code_book_sh) == 2) \n assert(obs_sh[1] == code_book_sh[1]) \n type = c_spec.num_to_c_types[obs.typecode()]\n # band aid for now.\n ar_type = 'PyArray_FLOAT'\n code = \"\"\"\n #line 37 \"vq.py\"\n // Use tensor notation. \n blitz::Array<%(type)s,2> dist_sq(Ncode_book[0],Nobs[0]);\n \t blitz::firstIndex i; \n blitz::secondIndex j; \n blitz::thirdIndex k;\n dist_sq = sum(pow2(obs(j,k) - code_book(i,k)),k);\n // Surely there is a better way to do this...\n PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_LONG);\n \t blitz::Array code((int*)(py_code->data),\n blitz::shape(Nobs[0]), blitz::neverDeleteData);\n \t code = minIndex(dist_sq(j,i),j);\n \t \n \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_FLOAT);\n \t blitz::Array min_dist((float*)(py_min_dist->data),\n \t blitz::shape(Nobs[0]), blitz::neverDeleteData);\n \t min_dist = sqrt(min(dist_sq(j,i),j));\n \t py::tuple results(2);\n \t results[0] = py_code;\n \t results[1] = py_min_dist;\n \t return_val = results; \t \n \"\"\" % locals()\n code, distortion = inline_tools.inline(code,['obs','code_book'],\n type_converters = blitz_type_converters,\n compiler = 'gcc',\n verbose = 1)\n return code, distortion\n\ndef vq2(obs,code_book):\n \"\"\" doesn't use blitz (except in conversion)\n ALSO DOES NOT HANDLE STRIDED ARRAYS CORRECTLY\n \"\"\"\n # make sure we're looking at arrays.\n obs = asarray(obs)\n code_book = asarray(code_book)\n # check for 2d arrays and compatible sizes.\n obs_sh = shape(obs)\n code_book_sh = shape(code_book)\n assert(len(obs_sh) == 2 and len(code_book_sh) == 2) \n assert(obs_sh[1] == code_book_sh[1]) \n assert(obs.typecode() == code_book.typecode()) \n type = c_spec.num_to_c_types[obs.typecode()]\n # band aid for now.\n ar_type = 'PyArray_FLOAT'\n code = \"\"\"\n #line 83 \"vq.py\"\n // THIS DOES NOT HANDLE STRIDED ARRAYS CORRECTLY\n // Surely there is a better way to do this...\n PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_LONG);\t \n \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_FLOAT);\n \t \n int* raw_code = (int*)(py_code->data);\n float* raw_min_dist = (float*)(py_min_dist->data);\n %(type)s* raw_obs = obs.data();\n %(type)s* raw_code_book = code_book.data(); \n %(type)s* this_obs = NULL;\n %(type)s* this_code = NULL; \n int Nfeatures = Nobs[1];\n float diff,dist;\n for(int i=0; i < Nobs[0]; i++)\n {\n this_obs = &raw_obs[i*Nfeatures];\n raw_min_dist[i] = (%(type)s)10000000.; // big number\n for(int j=0; j < Ncode_book[0]; j++)\n {\n this_code = &raw_code_book[j*Nfeatures];\n dist = 0;\n for(int k=0; k < Nfeatures; k++)\n {\n diff = this_obs[k] - this_code[k];\n dist += diff*diff;\n }\n dist = dist;\n if (dist < raw_min_dist[i])\n {\n raw_code[i] = j;\n raw_min_dist[i] = dist; \n } \n }\n raw_min_dist[i] = sqrt(raw_min_dist[i]);\n \t }\n \t py::tuple results(2);\n \t results[0] = py_code;\n \t results[1] = py_min_dist;\n \t return_val = results; \t \n \"\"\" % locals()\n code, distortion = inline_tools.inline(code,['obs','code_book'],\n type_converters = blitz_type_converters,\n compiler = 'gcc',\n verbose = 1)\n return code, distortion\n\n\ndef vq3(obs,code_book):\n \"\"\" Uses standard array conversion completely bi-passing blitz.\n THIS DOES NOT HANDLE STRIDED ARRAYS CORRECTLY\n \"\"\"\n # make sure we're looking at arrays.\n obs = asarray(obs)\n code_book = asarray(code_book)\n # check for 2d arrays and compatible sizes.\n obs_sh = shape(obs)\n code_book_sh = shape(code_book)\n assert(len(obs_sh) == 2 and len(code_book_sh) == 2) \n assert(obs_sh[1] == code_book_sh[1]) \n assert(obs.typecode() == code_book.typecode()) \n type = c_spec.num_to_c_types[obs.typecode()]\n code = \"\"\"\n #line 139 \"vq.py\"\n // Surely there is a better way to do this...\n PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_LONG);\t \n \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_FLOAT);\n \t \n int* code_data = (int*)(py_code->data);\n float* min_dist_data = (float*)(py_min_dist->data);\n %(type)s* this_obs = NULL;\n %(type)s* this_code = NULL; \n int Nfeatures = Nobs[1];\n float diff,dist;\n\n for(int i=0; i < Nobs[0]; i++)\n {\n this_obs = &obs_data[i*Nfeatures];\n min_dist_data[i] = (float)10000000.; // big number\n for(int j=0; j < Ncode_book[0]; j++)\n {\n this_code = &code_book_data[j*Nfeatures];\n dist = 0;\n for(int k=0; k < Nfeatures; k++)\n {\n diff = this_obs[k] - this_code[k];\n dist += diff*diff;\n }\n if (dist < min_dist_data[i])\n {\n code_data[i] = j;\n min_dist_data[i] = dist; \n } \n }\n min_dist_data[i] = sqrt(min_dist_data[i]);\n \t }\n \t py::tuple results(2);\n \t results[0] = py_code;\n \t results[1] = py_min_dist;\n \t return_val = results; \t \n \"\"\" % locals()\n # this is an unpleasant way to specify type factories -- work on it.\n import ext_tools\n code, distortion = inline_tools.inline(code,['obs','code_book'])\n return code, distortion\n\nimport time\nimport RandomArray\ndef compare(m,Nobs,Ncodes,Nfeatures):\n obs = RandomArray.normal(0.,1.,(Nobs,Nfeatures))\n codes = RandomArray.normal(0.,1.,(Ncodes,Nfeatures))\n import scipy.cluster.vq\n scipy.cluster.vq\n print 'vq with %d observation, %d features and %d codes for %d iterations' % \\\n (Nobs,Nfeatures,Ncodes,m)\n t1 = time.time()\n for i in range(m):\n code,dist = scipy.cluster.vq.py_vq(obs,codes)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)/m\n print code[:2],dist[:2]\n \n t1 = time.time()\n for i in range(m):\n code,dist = scipy.cluster.vq.vq(obs,codes)\n t2 = time.time()\n print ' speed in standard c:', (t2 - t1)/m\n print code[:2],dist[:2]\n print ' speed up: %3.2f' % (py/(t2-t1))\n \n # load into cache \n b = vq(obs,codes)\n t1 = time.time()\n for i in range(m):\n code,dist = vq(obs,codes)\n t2 = time.time()\n print ' speed inline/blitz:',(t2 - t1)/ m \n print code[:2],dist[:2]\n print ' speed up: %3.2f' % (py/(t2-t1))\n\n # load into cache \n b = vq2(obs,codes)\n t1 = time.time()\n for i in range(m):\n code,dist = vq2(obs,codes)\n t2 = time.time()\n print ' speed inline/blitz2:',(t2 - t1)/ m \n print code[:2],dist[:2]\n print ' speed up: %3.2f' % (py/(t2-t1))\n\n # load into cache \n b = vq3(obs,codes)\n t1 = time.time()\n for i in range(m):\n code,dist = vq3(obs,codes)\n t2 = time.time()\n print ' speed using C arrays:',(t2 - t1)/ m \n print code[:2],dist[:2]\n print ' speed up: %3.2f' % (py/(t2-t1))\n \nif __name__ == \"__main__\":\n compare(100,1000,30,10) \n #compare(1,10,2,10) \n", "source_code_before": "\"\"\" \n\"\"\"\n# C:\\home\\ej\\wrk\\scipy\\weave\\examples>python vq.py\n# vq with 1000 observation, 10 features and 30 codes fo 100 iterations\n# speed in python: 0.150119999647\n# [25 29] [ 2.49147266 3.83021032]\n# speed in standard c: 0.00710999965668\n# [25 29] [ 2.49147266 3.83021032]\n# speed up: 21.11\n# speed inline/blitz: 0.0186300003529\n# [25 29] [ 2.49147272 3.83021021]\n# speed up: 8.06\n# speed inline/blitz2: 0.00461000084877\n# [25 29] [ 2.49147272 3.83021021]\n# speed up: 32.56\n \nimport Numeric\nfrom Numeric import *\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\nimport converters\nblitz_type_converters = converters.blitz\nimport scalar_spec\n\ndef vq(obs,code_book):\n # make sure we're looking at arrays.\n obs = asarray(obs)\n code_book = asarray(code_book)\n # check for 2d arrays and compatible sizes.\n obs_sh = shape(obs)\n code_book_sh = shape(code_book)\n assert(len(obs_sh) == 2 and len(code_book_sh) == 2) \n assert(obs_sh[1] == code_book_sh[1]) \n type = scalar_spec.numeric_to_c_type_mapping[obs.typecode()]\n # band aid for now.\n ar_type = 'PyArray_FLOAT'\n code = \"\"\"\n #line 37 \"vq.py\"\n // Use tensor notation. \n blitz::Array<%(type)s,2> dist_sq(_Ncode_book[0],_Nobs[0]);\n \t blitz::firstIndex i; \n blitz::secondIndex j; \n blitz::thirdIndex k;\n dist_sq = sum(pow2(obs(j,k) - code_book(i,k)),k);\n // Surely there is a better way to do this...\n PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_LONG);\n \t blitz::Array code((int*)(py_code->data),\n blitz::shape(_Nobs[0]), blitz::neverDeleteData);\n \t code = minIndex(dist_sq(j,i),j);\n \t \n \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_FLOAT);\n \t blitz::Array min_dist((float*)(py_min_dist->data),\n \t blitz::shape(_Nobs[0]), blitz::neverDeleteData);\n \t min_dist = sqrt(min(dist_sq(j,i),j));\n \t Py::Tuple results(2);\n \t results[0] = Py::Object((PyObject*)py_code);\n \t results[1] = Py::Object((PyObject*)py_min_dist);\n \t return_val = Py::new_reference_to(results); \t \n \"\"\" % locals()\n code, distortion = inline_tools.inline(code,['obs','code_book'],\n type_converters = blitz_type_converters,\n compiler = 'gcc',\n verbose = 1)\n return code, distortion\n\ndef vq2(obs,code_book):\n \"\"\" doesn't use blitz (except in conversion)\n ALSO DOES NOT HANDLE STRIDED ARRAYS CORRECTLY\n \"\"\"\n # make sure we're looking at arrays.\n obs = asarray(obs)\n code_book = asarray(code_book)\n # check for 2d arrays and compatible sizes.\n obs_sh = shape(obs)\n code_book_sh = shape(code_book)\n assert(len(obs_sh) == 2 and len(code_book_sh) == 2) \n assert(obs_sh[1] == code_book_sh[1]) \n assert(obs.typecode() == code_book.typecode()) \n type = scalar_spec.numeric_to_c_type_mapping[obs.typecode()]\n # band aid for now.\n ar_type = 'PyArray_FLOAT'\n code = \"\"\"\n #line 83 \"vq.py\"\n // THIS DOES NOT HANDLE STRIDED ARRAYS CORRECTLY\n // Surely there is a better way to do this...\n PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_LONG);\t \n \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_FLOAT);\n \t \n int* raw_code = (int*)(py_code->data);\n float* raw_min_dist = (float*)(py_min_dist->data);\n %(type)s* raw_obs = obs.data();\n %(type)s* raw_code_book = code_book.data(); \n %(type)s* this_obs = NULL;\n %(type)s* this_code = NULL; \n int Nfeatures = Nobs[1];\n float diff,dist;\n for(int i=0; i < Nobs[0]; i++)\n {\n this_obs = &raw_obs[i*Nfeatures];\n raw_min_dist[i] = (%(type)s)10000000.; // big number\n for(int j=0; j < Ncode_book[0]; j++)\n {\n this_code = &raw_code_book[j*Nfeatures];\n dist = 0;\n for(int k=0; k < Nfeatures; k++)\n {\n diff = this_obs[k] - this_code[k];\n dist += diff*diff;\n }\n dist = dist;\n if (dist < raw_min_dist[i])\n {\n raw_code[i] = j;\n raw_min_dist[i] = dist; \n } \n }\n raw_min_dist[i] = sqrt(raw_min_dist[i]);\n \t }\n \t Py::Tuple results(2);\n \t results[0] = Py::Object((PyObject*)py_code);\n \t results[1] = Py::Object((PyObject*)py_min_dist);\n \t return_val = Py::new_reference_to(results); \t \n \"\"\" % locals()\n code, distortion = inline_tools.inline(code,['obs','code_book'],\n type_converters = blitz_type_converters,\n compiler = 'gcc',\n verbose = 1)\n return code, distortion\n\n\ndef vq3(obs,code_book):\n \"\"\" Uses standard array conversion completely bi-passing blitz.\n THIS DOES NOT HANDLE STRIDED ARRAYS CORRECTLY\n \"\"\"\n # make sure we're looking at arrays.\n obs = asarray(obs)\n code_book = asarray(code_book)\n # check for 2d arrays and compatible sizes.\n obs_sh = shape(obs)\n code_book_sh = shape(code_book)\n assert(len(obs_sh) == 2 and len(code_book_sh) == 2) \n assert(obs_sh[1] == code_book_sh[1]) \n assert(obs.typecode() == code_book.typecode()) \n type = scalar_spec.numeric_to_c_type_mapping[obs.typecode()]\n code = \"\"\"\n #line 139 \"vq.py\"\n // Surely there is a better way to do this...\n PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_LONG);\t \n \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_FLOAT);\n \t \n int* code_data = (int*)(py_code->data);\n float* min_dist_data = (float*)(py_min_dist->data);\n %(type)s* this_obs = NULL;\n %(type)s* this_code = NULL; \n int Nfeatures = _Nobs[1];\n float diff,dist;\n\n for(int i=0; i < _Nobs[0]; i++)\n {\n this_obs = &obs_data[i*Nfeatures];\n min_dist_data[i] = (float)10000000.; // big number\n for(int j=0; j < _Ncode_book[0]; j++)\n {\n this_code = &code_book_data[j*Nfeatures];\n dist = 0;\n for(int k=0; k < Nfeatures; k++)\n {\n diff = this_obs[k] - this_code[k];\n dist += diff*diff;\n }\n if (dist < min_dist_data[i])\n {\n code_data[i] = j;\n min_dist_data[i] = dist; \n } \n }\n min_dist_data[i] = sqrt(min_dist_data[i]);\n \t }\n \t Py::Tuple results(2);\n \t results[0] = Py::Object((PyObject*)py_code);\n \t results[1] = Py::Object((PyObject*)py_min_dist);\n \t return Py::new_reference_to(results); \t \n \"\"\" % locals()\n # this is an unpleasant way to specify type factories -- work on it.\n import ext_tools\n code, distortion = inline_tools.inline(code,['obs','code_book'])\n return code, distortion\n\nimport time\nimport RandomArray\ndef compare(m,Nobs,Ncodes,Nfeatures):\n obs = RandomArray.normal(0.,1.,(Nobs,Nfeatures))\n codes = RandomArray.normal(0.,1.,(Ncodes,Nfeatures))\n import scipy.cluster.vq\n scipy.cluster.vq\n print 'vq with %d observation, %d features and %d codes for %d iterations' % \\\n (Nobs,Nfeatures,Ncodes,m)\n t1 = time.time()\n for i in range(m):\n code,dist = scipy.cluster.vq.py_vq(obs,codes)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)/m\n print code[:2],dist[:2]\n \n t1 = time.time()\n for i in range(m):\n code,dist = scipy.cluster.vq.vq(obs,codes)\n t2 = time.time()\n print ' speed in standard c:', (t2 - t1)/m\n print code[:2],dist[:2]\n print ' speed up: %3.2f' % (py/(t2-t1))\n \n # load into cache \n b = vq(obs,codes)\n t1 = time.time()\n for i in range(m):\n code,dist = vq(obs,codes)\n t2 = time.time()\n print ' speed inline/blitz:',(t2 - t1)/ m \n print code[:2],dist[:2]\n print ' speed up: %3.2f' % (py/(t2-t1))\n\n # load into cache \n b = vq2(obs,codes)\n t1 = time.time()\n for i in range(m):\n code,dist = vq2(obs,codes)\n t2 = time.time()\n print ' speed inline/blitz2:',(t2 - t1)/ m \n print code[:2],dist[:2]\n print ' speed up: %3.2f' % (py/(t2-t1))\n\n # load into cache \n b = vq3(obs,codes)\n t1 = time.time()\n for i in range(m):\n code,dist = vq3(obs,codes)\n t2 = time.time()\n print ' speed using C arrays:',(t2 - t1)/ m \n print code[:2],dist[:2]\n print ' speed up: %3.2f' % (py/(t2-t1))\n \nif __name__ == \"__main__\":\n compare(100,1000,30,10) \n #compare(1,10,2,10) \n", "methods": [ { "name": "vq", "long_name": "vq( obs , code_book )", "filename": "vq.py", "nloc": 37, "complexity": 2, "token_count": 113, "parameters": [ "obs", "code_book" ], "start_line": 26, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "vq2", "long_name": "vq2( obs , code_book )", "filename": "vq.py", "nloc": 57, "complexity": 2, "token_count": 128, "parameters": [ "obs", "code_book" ], "start_line": 67, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "vq3", "long_name": "vq3( obs , code_book )", "filename": "vq.py", "nloc": 51, "complexity": 2, "token_count": 115, "parameters": [ "obs", "code_book" ], "start_line": 132, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 57, "top_nesting_level": 0 }, { "name": "compare", "long_name": "compare( m , Nobs , Ncodes , Nfeatures )", "filename": "vq.py", "nloc": 45, "complexity": 6, "token_count": 432, "parameters": [ "m", "Nobs", "Ncodes", "Nfeatures" ], "start_line": 192, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 } ], "methods_before": [ { "name": "vq", "long_name": "vq( obs , code_book )", "filename": "vq.py", "nloc": 37, "complexity": 2, "token_count": 113, "parameters": [ "obs", "code_book" ], "start_line": 26, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "vq2", "long_name": "vq2( obs , code_book )", "filename": "vq.py", "nloc": 57, "complexity": 2, "token_count": 128, "parameters": [ "obs", "code_book" ], "start_line": 67, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "vq3", "long_name": "vq3( obs , code_book )", "filename": "vq.py", "nloc": 51, "complexity": 2, "token_count": 115, "parameters": [ "obs", "code_book" ], "start_line": 132, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 57, "top_nesting_level": 0 }, { "name": "compare", "long_name": "compare( m , Nobs , Ncodes , Nfeatures )", "filename": "vq.py", "nloc": 45, "complexity": 6, "token_count": 432, "parameters": [ "m", "Nobs", "Ncodes", "Nfeatures" ], "start_line": 192, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 52, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "vq3", "long_name": "vq3( obs , code_book )", "filename": "vq.py", "nloc": 51, "complexity": 2, "token_count": 115, "parameters": [ "obs", "code_book" ], "start_line": 132, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 57, "top_nesting_level": 0 }, { "name": "vq", "long_name": "vq( obs , code_book )", "filename": "vq.py", "nloc": 37, "complexity": 2, "token_count": 113, "parameters": [ "obs", "code_book" ], "start_line": 26, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 }, { "name": "vq2", "long_name": "vq2( obs , code_book )", "filename": "vq.py", "nloc": 57, "complexity": 2, "token_count": 128, "parameters": [ "obs", "code_book" ], "start_line": 67, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 } ], "nloc": 204, "complexity": 12, "token_count": 841, "diff_parsed": { "added": [ "import c_spec", " type = c_spec.num_to_c_types[obs.typecode()]", " blitz::Array<%(type)s,2> dist_sq(Ncode_book[0],Nobs[0]);", " PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_LONG);", " blitz::shape(Nobs[0]), blitz::neverDeleteData);", " \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_FLOAT);", " \t blitz::shape(Nobs[0]), blitz::neverDeleteData);", " \t py::tuple results(2);", " \t results[0] = py_code;", " \t results[1] = py_min_dist;", " \t return_val = results;", " type = c_spec.num_to_c_types[obs.typecode()]", " PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_LONG);", " \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_FLOAT);", " \t py::tuple results(2);", " \t results[0] = py_code;", " \t results[1] = py_min_dist;", " \t return_val = results;", " type = c_spec.num_to_c_types[obs.typecode()]", " PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_LONG);", " \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&Nobs[0],PyArray_FLOAT);", " int Nfeatures = Nobs[1];", " for(int i=0; i < Nobs[0]; i++)", " for(int j=0; j < Ncode_book[0]; j++)", " \t py::tuple results(2);", " \t results[0] = py_code;", " \t results[1] = py_min_dist;", " \t return_val = results;" ], "deleted": [ "import scalar_spec", " type = scalar_spec.numeric_to_c_type_mapping[obs.typecode()]", " blitz::Array<%(type)s,2> dist_sq(_Ncode_book[0],_Nobs[0]);", " PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_LONG);", " blitz::shape(_Nobs[0]), blitz::neverDeleteData);", " \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_FLOAT);", " \t blitz::shape(_Nobs[0]), blitz::neverDeleteData);", " \t Py::Tuple results(2);", " \t results[0] = Py::Object((PyObject*)py_code);", " \t results[1] = Py::Object((PyObject*)py_min_dist);", " \t return_val = Py::new_reference_to(results);", " type = scalar_spec.numeric_to_c_type_mapping[obs.typecode()]", " PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_LONG);", " \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_FLOAT);", " \t Py::Tuple results(2);", " \t results[0] = Py::Object((PyObject*)py_code);", " \t results[1] = Py::Object((PyObject*)py_min_dist);", " \t return_val = Py::new_reference_to(results);", " type = scalar_spec.numeric_to_c_type_mapping[obs.typecode()]", " PyArrayObject* py_code = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_LONG);", " \t PyArrayObject* py_min_dist = (PyArrayObject*) PyArray_FromDims(1,&_Nobs[0],PyArray_FLOAT);", " int Nfeatures = _Nobs[1];", " for(int i=0; i < _Nobs[0]; i++)", " for(int j=0; j < _Ncode_book[0]; j++)", " \t Py::Tuple results(2);", " \t results[0] = Py::Object((PyObject*)py_code);", " \t results[1] = Py::Object((PyObject*)py_min_dist);", " \t return Py::new_reference_to(results);" ] } }, { "old_path": "weave/scxx/callable.h", "new_path": null, "filename": "callable.h", "extension": "h", "change_type": "DELETE", "diff": "@@ -1,46 +0,0 @@\n-/******************************************** \n- copyright 2000 McMillan Enterprises, Inc.\n- www.mcmillan-inc.com\n- \n- modified for weave by eric jones\n-*********************************************/\n-\n-#if !defined(CALLABLE_H_INCLUDED_)\n-#define CALLABLE_H_INCLUDED_\n-\n-#include \"object.h\"\n-#include \"tuple.h\"\n-#include \"dict.h\"\n-\n-namespace py {\n- \n-class callable : public object\n-{\n-public:\n- callable() : object() {};\n- callable(PyObject *obj) : object(obj) {\n- _violentTypeCheck();\n- };\n- virtual ~callable() {};\n- virtual callable& operator=(const callable& other) {\n- GrabRef(other);\n- return *this;\n- };\n- callable& operator=(const object& other) {\n- GrabRef(other);\n- _violentTypeCheck();\n- return *this;\n- };\n- virtual void _violentTypeCheck() {\n- if (!is_callable()) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a callable object\");\n- }\n- };\n- object call() const;\n- object call(tuple& args) const;\n- object call(tuple& args, dict& kws) const;\n-};\n-\n-} // namespace py\n-#endif\n", "added_lines": 0, "deleted_lines": 46, "source_code": null, "source_code_before": "/******************************************** \n copyright 2000 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n\n#if !defined(CALLABLE_H_INCLUDED_)\n#define CALLABLE_H_INCLUDED_\n\n#include \"object.h\"\n#include \"tuple.h\"\n#include \"dict.h\"\n\nnamespace py {\n \nclass callable : public object\n{\npublic:\n callable() : object() {};\n callable(PyObject *obj) : object(obj) {\n _violentTypeCheck();\n };\n virtual ~callable() {};\n virtual callable& operator=(const callable& other) {\n GrabRef(other);\n return *this;\n };\n callable& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!is_callable()) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a callable object\");\n }\n };\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n};\n\n} // namespace py\n#endif\n", "methods": [], "methods_before": [ { "name": "py::callable::callable", "long_name": "py::callable::callable()", "filename": "callable.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::callable::callable", "long_name": "py::callable::callable( PyObject * obj)", "filename": "callable.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::callable::~callable", "long_name": "py::callable::~callable()", "filename": "callable.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::callable::operator =", "long_name": "py::callable::operator =( const callable & other)", "filename": "callable.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 25, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::callable::operator =", "long_name": "py::callable::operator =( const object & other)", "filename": "callable.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 29, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::callable::_violentTypeCheck", "long_name": "py::callable::_violentTypeCheck()", "filename": "callable.h", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [], "start_line": 34, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::callable::callable", "long_name": "py::callable::callable()", "filename": "callable.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::callable::operator =", "long_name": "py::callable::operator =( const callable & other)", "filename": "callable.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 25, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::callable::~callable", "long_name": "py::callable::~callable()", "filename": "callable.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::callable::_violentTypeCheck", "long_name": "py::callable::_violentTypeCheck()", "filename": "callable.h", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [], "start_line": 34, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::callable::callable", "long_name": "py::callable::callable( PyObject * obj)", "filename": "callable.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::callable::operator =", "long_name": "py::callable::operator =( const object & other)", "filename": "callable.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 29, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "/********************************************", " copyright 2000 McMillan Enterprises, Inc.", " www.mcmillan-inc.com", "", " modified for weave by eric jones", "*********************************************/", "", "#if !defined(CALLABLE_H_INCLUDED_)", "#define CALLABLE_H_INCLUDED_", "", "#include \"object.h\"", "#include \"tuple.h\"", "#include \"dict.h\"", "", "namespace py {", "", "class callable : public object", "{", "public:", " callable() : object() {};", " callable(PyObject *obj) : object(obj) {", " _violentTypeCheck();", " };", " virtual ~callable() {};", " virtual callable& operator=(const callable& other) {", " GrabRef(other);", " return *this;", " };", " callable& operator=(const object& other) {", " GrabRef(other);", " _violentTypeCheck();", " return *this;", " };", " virtual void _violentTypeCheck() {", " if (!is_callable()) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a callable object\");", " }", " };", " object call() const;", " object call(tuple& args) const;", " object call(tuple& args, dict& kws) const;", "};", "", "} // namespace py", "#endif" ] } }, { "old_path": "weave/scxx/dict.h", "new_path": "weave/scxx/dict.h", "filename": "dict.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -7,174 +7,210 @@\n \n #if !defined(DICT_H_INCLUDED_)\n #define DICT_H_INCLUDED_\n-\n+#include \n #include \"object.h\"\n-#include \"number.h\"\n #include \"list.h\"\n-#include \"str.h\"\n-#include \n \n namespace py {\n \n-class dict;\n- \n-class dict_member : public object\n-{\n- dict& _parent;\n- PyObject* _key;\n-public:\n- dict_member(PyObject* obj, dict& parent, PyObject* key)\n- : object(obj), _parent(parent), _key(key)\n- {\n- Py_XINCREF(_key);\n- };\n- virtual ~dict_member() {\n- Py_XDECREF(_key);\n- };\n- dict_member& operator=(const object& other);\n- dict_member& operator=(int other);\n- dict_member& operator=(double other);\n- dict_member& operator=(const char* other);\n- dict_member& operator=(std::string other);\n-};\n \n class dict : public object\n {\n public:\n- dict() : object (PyDict_New()) { LoseRef(_obj); }\n+\n+ //-------------------------------------------------------------------------\n+ // constructors\n+ //-------------------------------------------------------------------------\n+ dict() : object (PyDict_New()) { lose_ref(_obj); }\n dict(const dict& other) : object(other) {};\n dict(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n+ \n+ //-------------------------------------------------------------------------\n+ // destructor\n+ //-------------------------------------------------------------------------\n virtual ~dict() {};\n \n+ //-------------------------------------------------------------------------\n+ // operator= \n+ //-------------------------------------------------------------------------\n virtual dict& operator=(const dict& other) {\n- GrabRef(other);\n+ grab_ref(other);\n return *this;\n };\n dict& operator=(const object& other) {\n- GrabRef(other);\n+ grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n+\n+ //-------------------------------------------------------------------------\n+ // type checking\n+ //-------------------------------------------------------------------------\n virtual void _violentTypeCheck() {\n- if (!PyMapping_Check(_obj)) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a mapping\");\n+ if (!PyDict_Check(_obj)) {\n+ grab_ref(0);\n+ fail(PyExc_TypeError, \"Not a dictionary\");\n }\n };\n-\n- //PyMapping_GetItemString\n- //PyDict_GetItemString\n- dict_member operator [] (const char* key) {\n- PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);\n- if (rslt==0)\n- PyErr_Clear();\n- // ?? why do I need py:: here?\n- str _key(key);\n- return dict_member(rslt, *this, _key);\n+ \n+ //-------------------------------------------------------------------------\n+ // operator[] -- object and numeric versions\n+ //------------------------------------------------------------------------- \n+ keyed_ref operator [] (object& key) {\n+ object rslt = PyDict_GetItem(_obj, key);\n+ if (!(PyObject*)rslt)\n+ PyErr_Clear(); // Ignore key errors\n+ return keyed_ref(rslt, *this, key);\n+ };\n+ keyed_ref operator [] (int key) {\n+ object _key = object(key);\n+ return operator [](_key);\n+ };\n+ keyed_ref operator [] (double key) {\n+ object _key = object(key);\n+ return operator [](_key);\n+ };\n+ keyed_ref operator [] (const std::complex& key) {\n+ object _key = object(key);\n+ return operator [](_key);\n };\n-\n- dict_member operator [] (std::string key) {\n- PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());\n- if (rslt==0)\n- PyErr_Clear();\n- str _key(key.c_str());\n- return dict_member(rslt, *this, _key);\n+ \n+ //-------------------------------------------------------------------------\n+ // operator[] non-const -- string versions\n+ //-------------------------------------------------------------------------\n+ keyed_ref operator [] (const char* key) {\n+ object rslt = PyDict_GetItemString(_obj, (char*) key);\n+ if (!(PyObject*)rslt)\n+ PyErr_Clear(); // Ignore key errors\n+ object _key = key; \n+ return keyed_ref(rslt, *this, _key);\n+ };\n+ keyed_ref operator [] (const std::string& key) {\n+ return operator [](key.c_str());\n };\n \n- //PyDict_GetItem\n- dict_member operator [] (PyObject* key) {\n- PyObject* rslt = PyDict_GetItem(_obj, key);\n- //if (rslt==0)\n- // Fail(PyExc_KeyError, \"Key not found\");\n- return dict_member(rslt, *this, key);\n+ //-------------------------------------------------------------------------\n+ // has_key -- object and numeric versions\n+ //------------------------------------------------------------------------- \n+ bool has_key(object& key) const {\n+ return PyMapping_HasKey(_obj, key)==1;\n };\n-\n- //PyDict_GetItem\n- dict_member operator [] (int key) {\n- number _key = number(key);\n- PyObject* rslt = PyDict_GetItem(_obj, _key);\n- //if (rslt==0)\n- // Fail(PyExc_KeyError, \"Key not found\");\n- return dict_member(rslt, *this, _key);\n+ bool has_key(int key) const {\n+ object _key = key; \n+ return has_key(_key);\n };\n- \n- dict_member operator [] (double key) {\n- number _key = number(key);\n- PyObject* rslt = PyDict_GetItem(_obj, _key);\n- //if (rslt==0)\n- // Fail(PyExc_KeyError, \"Key not found\");\n- return dict_member(rslt, *this, _key);\n+ bool has_key(double key) const {\n+ object _key = key; \n+ return has_key(_key);\n };\n- \n- //PyMapping_HasKey\n- bool has_key(PyObject* key) const {\n- return PyMapping_HasKey(_obj, key)==1;\n+ bool has_key(const std::complex& key) const {\n+ object _key = key; \n+ return has_key(_key);\n };\n- //PyMapping_HasKeyString\n+\n+ //-------------------------------------------------------------------------\n+ // has_key -- string versions\n+ //-------------------------------------------------------------------------\n bool has_key(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n- //PyMapping_Length\n- //PyDict_Size\n+ bool has_key(const std::string& key) const {\n+ return has_key(key.c_str());\n+ };\n+\n+ //-------------------------------------------------------------------------\n+ // len and length methods\n+ //------------------------------------------------------------------------- \n int len() const {\n- return PyMapping_Length(_obj);\n+ return PyDict_Size(_obj);\n } \n int length() const {\n- return PyMapping_Length(_obj);\n+ return PyDict_Size(_obj);\n };\n- //PyMapping_SetItemString\n- //PyDict_SetItemString\n- void set_item(const char* key, PyObject* val) {\n- int rslt = PyMapping_SetItemString(_obj, (char*) key, val);\n+\n+ //-------------------------------------------------------------------------\n+ // set_item\n+ //-------------------------------------------------------------------------\n+ virtual void set_item(const char* key, object& val) {\n+ int rslt = PyDict_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n- Fail(PyExc_RuntimeError, \"Cannot add key / value\");\n+ fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n- //PyDict_SetItem\n- void set_item(PyObject* key, PyObject* val) const {\n+\n+ virtual void set_item(object& key, object& val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n- Fail(PyExc_KeyError, \"Key must be hashable\");\n+ fail(PyExc_KeyError, \"Key must be hashable\");\n };\n- //PyDict_Clear\n+\n+ //-------------------------------------------------------------------------\n+ // clear\n+ //------------------------------------------------------------------------- \n void clear() {\n PyDict_Clear(_obj);\n };\n- //PyDict_DelItem\n- void del(PyObject* key) {\n- int rslt = PyMapping_DelItem(_obj, key);\n+ \n+ //-------------------------------------------------------------------------\n+ // update\n+ //------------------------------------------------------------------------- \n+ void update(dict& other) {\n+ PyDict_Merge(_obj,other,1);\n+ };\n+ \n+ //-------------------------------------------------------------------------\n+ // del -- remove key from dictionary\n+ // overloaded to take all common weave types\n+ //-------------------------------------------------------------------------\n+ void del(object& key) {\n+ int rslt = PyDict_DelItem(_obj, key);\n if (rslt==-1)\n- Fail(PyExc_KeyError, \"Key not found\");\n+ fail(PyExc_KeyError, \"Key not found\");\n+ };\n+ void del(int key) {\n+ object _key = key;\n+ del(_key);\n+ };\n+ void del(double key) {\n+ object _key = key;\n+ del(_key);\n+ };\n+ void del(const std::complex& key) {\n+ object _key = key;\n+ del(_key);\n };\n- //PyDict_DelItemString\n void del(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n- Fail(PyExc_KeyError, \"Key not found\");\n+ fail(PyExc_KeyError, \"Key not found\");\n };\n- //PyDict_Items\n+ void del(const std::string key) {\n+ del(key.c_str());\n+ };\n+\n+ //-------------------------------------------------------------------------\n+ // items, keys, and values\n+ //-------------------------------------------------------------------------\n list items() const {\n- PyObject* rslt = PyMapping_Items(_obj);\n+ PyObject* rslt = PyDict_Items(_obj);\n if (rslt==0)\n- Fail(PyExc_RuntimeError, \"Failed to get items\");\n- return LoseRef(rslt);\n+ fail(PyExc_RuntimeError, \"failed to get items\");\n+ return lose_ref(rslt);\n };\n- //PyDict_Keys\n+\n list keys() const {\n- PyObject* rslt = PyMapping_Keys(_obj);\n+ PyObject* rslt = PyDict_Keys(_obj);\n if (rslt==0)\n- Fail(PyExc_RuntimeError, \"Failed to get keys\");\n- return LoseRef(rslt);\n+ fail(PyExc_RuntimeError, \"failed to get keys\");\n+ return lose_ref(rslt);\n };\n- //PyDict_New - default constructor\n- //PyDict_Next\n- //PyDict_Values\n+\n list values() const {\n- PyObject* rslt = PyMapping_Values(_obj);\n+ PyObject* rslt = PyDict_Values(_obj);\n if (rslt==0)\n- Fail(PyExc_RuntimeError, \"Failed to get values\");\n- return LoseRef(rslt);\n+ fail(PyExc_RuntimeError, \"failed to get values\");\n+ return lose_ref(rslt);\n };\n };\n \n", "added_lines": 143, "deleted_lines": 107, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n\n#if !defined(DICT_H_INCLUDED_)\n#define DICT_H_INCLUDED_\n#include \n#include \"object.h\"\n#include \"list.h\"\n\nnamespace py {\n\n\nclass dict : public object\n{\npublic:\n\n //-------------------------------------------------------------------------\n // constructors\n //-------------------------------------------------------------------------\n dict() : object (PyDict_New()) { lose_ref(_obj); }\n dict(const dict& other) : object(other) {};\n dict(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~dict() {};\n\n //-------------------------------------------------------------------------\n // operator= \n //-------------------------------------------------------------------------\n virtual dict& operator=(const dict& other) {\n grab_ref(other);\n return *this;\n };\n dict& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n\n //-------------------------------------------------------------------------\n // type checking\n //-------------------------------------------------------------------------\n virtual void _violentTypeCheck() {\n if (!PyDict_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a dictionary\");\n }\n };\n \n //-------------------------------------------------------------------------\n // operator[] -- object and numeric versions\n //------------------------------------------------------------------------- \n keyed_ref operator [] (object& key) {\n object rslt = PyDict_GetItem(_obj, key);\n if (!(PyObject*)rslt)\n PyErr_Clear(); // Ignore key errors\n return keyed_ref(rslt, *this, key);\n };\n keyed_ref operator [] (int key) {\n object _key = object(key);\n return operator [](_key);\n };\n keyed_ref operator [] (double key) {\n object _key = object(key);\n return operator [](_key);\n };\n keyed_ref operator [] (const std::complex& key) {\n object _key = object(key);\n return operator [](_key);\n };\n \n //-------------------------------------------------------------------------\n // operator[] non-const -- string versions\n //-------------------------------------------------------------------------\n keyed_ref operator [] (const char* key) {\n object rslt = PyDict_GetItemString(_obj, (char*) key);\n if (!(PyObject*)rslt)\n PyErr_Clear(); // Ignore key errors\n object _key = key; \n return keyed_ref(rslt, *this, _key);\n };\n keyed_ref operator [] (const std::string& key) {\n return operator [](key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // has_key -- object and numeric versions\n //------------------------------------------------------------------------- \n bool has_key(object& key) const {\n return PyMapping_HasKey(_obj, key)==1;\n };\n bool has_key(int key) const {\n object _key = key; \n return has_key(_key);\n };\n bool has_key(double key) const {\n object _key = key; \n return has_key(_key);\n };\n bool has_key(const std::complex& key) const {\n object _key = key; \n return has_key(_key);\n };\n\n //-------------------------------------------------------------------------\n // has_key -- string versions\n //-------------------------------------------------------------------------\n bool has_key(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n bool has_key(const std::string& key) const {\n return has_key(key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // len and length methods\n //------------------------------------------------------------------------- \n int len() const {\n return PyDict_Size(_obj);\n } \n int length() const {\n return PyDict_Size(_obj);\n };\n\n //-------------------------------------------------------------------------\n // set_item\n //-------------------------------------------------------------------------\n virtual void set_item(const char* key, object& val) {\n int rslt = PyDict_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n\n virtual void set_item(object& key, object& val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key must be hashable\");\n };\n\n //-------------------------------------------------------------------------\n // clear\n //------------------------------------------------------------------------- \n void clear() {\n PyDict_Clear(_obj);\n };\n \n //-------------------------------------------------------------------------\n // update\n //------------------------------------------------------------------------- \n void update(dict& other) {\n PyDict_Merge(_obj,other,1);\n };\n \n //-------------------------------------------------------------------------\n // del -- remove key from dictionary\n // overloaded to take all common weave types\n //-------------------------------------------------------------------------\n void del(object& key) {\n int rslt = PyDict_DelItem(_obj, key);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key not found\");\n };\n void del(int key) {\n object _key = key;\n del(_key);\n };\n void del(double key) {\n object _key = key;\n del(_key);\n };\n void del(const std::complex& key) {\n object _key = key;\n del(_key);\n };\n void del(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key not found\");\n };\n void del(const std::string key) {\n del(key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // items, keys, and values\n //-------------------------------------------------------------------------\n list items() const {\n PyObject* rslt = PyDict_Items(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get items\");\n return lose_ref(rslt);\n };\n\n list keys() const {\n PyObject* rslt = PyDict_Keys(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get keys\");\n return lose_ref(rslt);\n };\n\n list values() const {\n PyObject* rslt = PyDict_Values(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get values\");\n return lose_ref(rslt);\n };\n};\n\n} // namespace\n#endif // DICT_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n\n#if !defined(DICT_H_INCLUDED_)\n#define DICT_H_INCLUDED_\n\n#include \"object.h\"\n#include \"number.h\"\n#include \"list.h\"\n#include \"str.h\"\n#include \n\nnamespace py {\n\nclass dict;\n \nclass dict_member : public object\n{\n dict& _parent;\n PyObject* _key;\npublic:\n dict_member(PyObject* obj, dict& parent, PyObject* key)\n : object(obj), _parent(parent), _key(key)\n {\n Py_XINCREF(_key);\n };\n virtual ~dict_member() {\n Py_XDECREF(_key);\n };\n dict_member& operator=(const object& other);\n dict_member& operator=(int other);\n dict_member& operator=(double other);\n dict_member& operator=(const char* other);\n dict_member& operator=(std::string other);\n};\n\nclass dict : public object\n{\npublic:\n dict() : object (PyDict_New()) { LoseRef(_obj); }\n dict(const dict& other) : object(other) {};\n dict(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n virtual ~dict() {};\n\n virtual dict& operator=(const dict& other) {\n GrabRef(other);\n return *this;\n };\n dict& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyMapping_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mapping\");\n }\n };\n\n //PyMapping_GetItemString\n //PyDict_GetItemString\n dict_member operator [] (const char* key) {\n PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);\n if (rslt==0)\n PyErr_Clear();\n // ?? why do I need py:: here?\n str _key(key);\n return dict_member(rslt, *this, _key);\n };\n\n dict_member operator [] (std::string key) {\n PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());\n if (rslt==0)\n PyErr_Clear();\n str _key(key.c_str());\n return dict_member(rslt, *this, _key);\n };\n\n //PyDict_GetItem\n dict_member operator [] (PyObject* key) {\n PyObject* rslt = PyDict_GetItem(_obj, key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return dict_member(rslt, *this, key);\n };\n\n //PyDict_GetItem\n dict_member operator [] (int key) {\n number _key = number(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return dict_member(rslt, *this, _key);\n };\n \n dict_member operator [] (double key) {\n number _key = number(key);\n PyObject* rslt = PyDict_GetItem(_obj, _key);\n //if (rslt==0)\n // Fail(PyExc_KeyError, \"Key not found\");\n return dict_member(rslt, *this, _key);\n };\n \n //PyMapping_HasKey\n bool has_key(PyObject* key) const {\n return PyMapping_HasKey(_obj, key)==1;\n };\n //PyMapping_HasKeyString\n bool has_key(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n //PyMapping_Length\n //PyDict_Size\n int len() const {\n return PyMapping_Length(_obj);\n } \n int length() const {\n return PyMapping_Length(_obj);\n };\n //PyMapping_SetItemString\n //PyDict_SetItemString\n void set_item(const char* key, PyObject* val) {\n int rslt = PyMapping_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n //PyDict_SetItem\n void set_item(PyObject* key, PyObject* val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key must be hashable\");\n };\n //PyDict_Clear\n void clear() {\n PyDict_Clear(_obj);\n };\n //PyDict_DelItem\n void del(PyObject* key) {\n int rslt = PyMapping_DelItem(_obj, key);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key not found\");\n };\n //PyDict_DelItemString\n void del(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n Fail(PyExc_KeyError, \"Key not found\");\n };\n //PyDict_Items\n list items() const {\n PyObject* rslt = PyMapping_Items(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get items\");\n return LoseRef(rslt);\n };\n //PyDict_Keys\n list keys() const {\n PyObject* rslt = PyMapping_Keys(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get keys\");\n return LoseRef(rslt);\n };\n //PyDict_New - default constructor\n //PyDict_Next\n //PyDict_Values\n list values() const {\n PyObject* rslt = PyMapping_Values(_obj);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"Failed to get values\");\n return LoseRef(rslt);\n };\n};\n\n} // namespace\n#endif // DICT_H_INCLUDED_\n", "methods": [ { "name": "py::dict::dict", "long_name": "py::dict::dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( const dict & other)", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( PyObject * obj)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 26, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::~dict", "long_name": "py::dict::~dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const dict & other)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const object & other)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 42, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::_violentTypeCheck", "long_name": "py::dict::_violentTypeCheck()", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 51, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( object & key)", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "key" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 71, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "std" ], "start_line": 75, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const char * key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 54, "parameters": [ "key" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: string & key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( object & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( int key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( double key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 104, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: complex & key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const char * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: string & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 119, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::len", "long_name": "py::dict::len() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 126, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::length", "long_name": "py::dict::length() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 129, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( const char * key , object & val)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 136, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( object & key , object & val) const", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 142, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::clear", "long_name": "py::dict::clear()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 151, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::update", "long_name": "py::dict::update( dict & other)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 158, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( object & key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 166, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 171, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 175, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 179, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const char * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 183, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: string key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::items", "long_name": "py::dict::items() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 195, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::keys", "long_name": "py::dict::keys() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 202, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::values", "long_name": "py::dict::values() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 209, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::dict_member::dict_member", "long_name": "py::dict_member::dict_member( PyObject * obj , dict & parent , PyObject * key)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "obj", "parent", "key" ], "start_line": 26, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict_member::~dict_member", "long_name": "py::dict_member::~dict_member()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 31, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 44, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( const dict & other)", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 45, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( PyObject * obj)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 46, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::~dict", "long_name": "py::dict::~dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 49, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const dict & other)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 51, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const object & other)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 55, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::_violentTypeCheck", "long_name": "py::dict::_violentTypeCheck()", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const char * key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "key" ], "start_line": 69, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( std :: string key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 78, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( PyObject * key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "key" ], "start_line": 87, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( int key)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 95, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( double key)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "key" ], "start_line": 103, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( PyObject * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const char * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::len", "long_name": "py::dict::len() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::length", "long_name": "py::dict::length() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( const char * key , PyObject * val)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 129, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( PyObject * key , PyObject * val) const", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::clear", "long_name": "py::dict::clear()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 141, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( PyObject * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 145, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const char * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::items", "long_name": "py::dict::items() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 157, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::keys", "long_name": "py::dict::keys() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 164, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::values", "long_name": "py::dict::values() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 173, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( object & key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 166, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 71, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( object & key , object & val) const", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 142, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( double key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 104, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::len", "long_name": "py::dict::len() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 126, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::length", "long_name": "py::dict::length() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 129, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const char * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 183, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( std :: string key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 78, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( PyObject * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 145, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( PyObject * key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "key" ], "start_line": 87, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 171, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( object & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( const char * key , PyObject * val)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 129, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: string & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 119, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( PyObject * key , PyObject * val) const", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 175, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const char * key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 54, "parameters": [ "key" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 179, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::values", "long_name": "py::dict::values() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 209, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( int key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::update", "long_name": "py::dict::update( dict & other)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 158, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict_member::~dict_member", "long_name": "py::dict_member::~dict_member()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 31, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: string key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( const char * key , object & val)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 136, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( PyObject * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: complex & key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "std" ], "start_line": 75, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict_member::dict_member", "long_name": "py::dict_member::dict_member( PyObject * obj , dict & parent , PyObject * key)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "obj", "parent", "key" ], "start_line": 26, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::_violentTypeCheck", "long_name": "py::dict::_violentTypeCheck()", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 51, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( object & key)", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "key" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const dict & other)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: string & key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::keys", "long_name": "py::dict::keys() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 202, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const object & other)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 42, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::items", "long_name": "py::dict::items() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 195, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "nloc": 144, "complexity": 44, "token_count": 926, "diff_parsed": { "added": [ "#include ", "", " //-------------------------------------------------------------------------", " // constructors", " //-------------------------------------------------------------------------", " dict() : object (PyDict_New()) { lose_ref(_obj); }", "", " //-------------------------------------------------------------------------", " // destructor", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // operator=", " //-------------------------------------------------------------------------", " grab_ref(other);", " grab_ref(other);", "", " //-------------------------------------------------------------------------", " // type checking", " //-------------------------------------------------------------------------", " if (!PyDict_Check(_obj)) {", " grab_ref(0);", " fail(PyExc_TypeError, \"Not a dictionary\");", "", " //-------------------------------------------------------------------------", " // operator[] -- object and numeric versions", " //-------------------------------------------------------------------------", " keyed_ref operator [] (object& key) {", " object rslt = PyDict_GetItem(_obj, key);", " if (!(PyObject*)rslt)", " PyErr_Clear(); // Ignore key errors", " return keyed_ref(rslt, *this, key);", " };", " keyed_ref operator [] (int key) {", " object _key = object(key);", " return operator [](_key);", " };", " keyed_ref operator [] (double key) {", " object _key = object(key);", " return operator [](_key);", " };", " keyed_ref operator [] (const std::complex& key) {", " object _key = object(key);", " return operator [](_key);", "", " //-------------------------------------------------------------------------", " // operator[] non-const -- string versions", " //-------------------------------------------------------------------------", " keyed_ref operator [] (const char* key) {", " object rslt = PyDict_GetItemString(_obj, (char*) key);", " if (!(PyObject*)rslt)", " PyErr_Clear(); // Ignore key errors", " object _key = key;", " return keyed_ref(rslt, *this, _key);", " };", " keyed_ref operator [] (const std::string& key) {", " return operator [](key.c_str());", " //-------------------------------------------------------------------------", " // has_key -- object and numeric versions", " //-------------------------------------------------------------------------", " bool has_key(object& key) const {", " return PyMapping_HasKey(_obj, key)==1;", " bool has_key(int key) const {", " object _key = key;", " return has_key(_key);", " bool has_key(double key) const {", " object _key = key;", " return has_key(_key);", " bool has_key(const std::complex& key) const {", " object _key = key;", " return has_key(_key);", "", " //-------------------------------------------------------------------------", " // has_key -- string versions", " //-------------------------------------------------------------------------", " bool has_key(const std::string& key) const {", " return has_key(key.c_str());", " };", "", " //-------------------------------------------------------------------------", " // len and length methods", " //-------------------------------------------------------------------------", " return PyDict_Size(_obj);", " return PyDict_Size(_obj);", "", " //-------------------------------------------------------------------------", " // set_item", " //-------------------------------------------------------------------------", " virtual void set_item(const char* key, object& val) {", " int rslt = PyDict_SetItemString(_obj, (char*) key, val);", " fail(PyExc_RuntimeError, \"Cannot add key / value\");", "", " virtual void set_item(object& key, object& val) const {", " fail(PyExc_KeyError, \"Key must be hashable\");", "", " //-------------------------------------------------------------------------", " // clear", " //-------------------------------------------------------------------------", "", " //-------------------------------------------------------------------------", " // update", " //-------------------------------------------------------------------------", " void update(dict& other) {", " PyDict_Merge(_obj,other,1);", " };", "", " //-------------------------------------------------------------------------", " // del -- remove key from dictionary", " // overloaded to take all common weave types", " //-------------------------------------------------------------------------", " void del(object& key) {", " int rslt = PyDict_DelItem(_obj, key);", " fail(PyExc_KeyError, \"Key not found\");", " };", " void del(int key) {", " object _key = key;", " del(_key);", " };", " void del(double key) {", " object _key = key;", " del(_key);", " };", " void del(const std::complex& key) {", " object _key = key;", " del(_key);", " fail(PyExc_KeyError, \"Key not found\");", " void del(const std::string key) {", " del(key.c_str());", " };", "", " //-------------------------------------------------------------------------", " // items, keys, and values", " //-------------------------------------------------------------------------", " PyObject* rslt = PyDict_Items(_obj);", " fail(PyExc_RuntimeError, \"failed to get items\");", " return lose_ref(rslt);", "", " PyObject* rslt = PyDict_Keys(_obj);", " fail(PyExc_RuntimeError, \"failed to get keys\");", " return lose_ref(rslt);", "", " PyObject* rslt = PyDict_Values(_obj);", " fail(PyExc_RuntimeError, \"failed to get values\");", " return lose_ref(rslt);" ], "deleted": [ "", "#include \"number.h\"", "#include \"str.h\"", "#include ", "class dict;", "", "class dict_member : public object", "{", " dict& _parent;", " PyObject* _key;", "public:", " dict_member(PyObject* obj, dict& parent, PyObject* key)", " : object(obj), _parent(parent), _key(key)", " {", " Py_XINCREF(_key);", " };", " virtual ~dict_member() {", " Py_XDECREF(_key);", " };", " dict_member& operator=(const object& other);", " dict_member& operator=(int other);", " dict_member& operator=(double other);", " dict_member& operator=(const char* other);", " dict_member& operator=(std::string other);", "};", " dict() : object (PyDict_New()) { LoseRef(_obj); }", " GrabRef(other);", " GrabRef(other);", " if (!PyMapping_Check(_obj)) {", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a mapping\");", "", " //PyMapping_GetItemString", " //PyDict_GetItemString", " dict_member operator [] (const char* key) {", " PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key);", " if (rslt==0)", " PyErr_Clear();", " // ?? why do I need py:: here?", " str _key(key);", " return dict_member(rslt, *this, _key);", "", " dict_member operator [] (std::string key) {", " PyObject* rslt = PyMapping_GetItemString(_obj, (char*) key.c_str());", " if (rslt==0)", " PyErr_Clear();", " str _key(key.c_str());", " return dict_member(rslt, *this, _key);", " //PyDict_GetItem", " dict_member operator [] (PyObject* key) {", " PyObject* rslt = PyDict_GetItem(_obj, key);", " //if (rslt==0)", " // Fail(PyExc_KeyError, \"Key not found\");", " return dict_member(rslt, *this, key);", "", " //PyDict_GetItem", " dict_member operator [] (int key) {", " number _key = number(key);", " PyObject* rslt = PyDict_GetItem(_obj, _key);", " //if (rslt==0)", " // Fail(PyExc_KeyError, \"Key not found\");", " return dict_member(rslt, *this, _key);", "", " dict_member operator [] (double key) {", " number _key = number(key);", " PyObject* rslt = PyDict_GetItem(_obj, _key);", " //if (rslt==0)", " // Fail(PyExc_KeyError, \"Key not found\");", " return dict_member(rslt, *this, _key);", "", " //PyMapping_HasKey", " bool has_key(PyObject* key) const {", " return PyMapping_HasKey(_obj, key)==1;", " //PyMapping_HasKeyString", " //PyMapping_Length", " //PyDict_Size", " return PyMapping_Length(_obj);", " return PyMapping_Length(_obj);", " //PyMapping_SetItemString", " //PyDict_SetItemString", " void set_item(const char* key, PyObject* val) {", " int rslt = PyMapping_SetItemString(_obj, (char*) key, val);", " Fail(PyExc_RuntimeError, \"Cannot add key / value\");", " //PyDict_SetItem", " void set_item(PyObject* key, PyObject* val) const {", " Fail(PyExc_KeyError, \"Key must be hashable\");", " //PyDict_Clear", " //PyDict_DelItem", " void del(PyObject* key) {", " int rslt = PyMapping_DelItem(_obj, key);", " Fail(PyExc_KeyError, \"Key not found\");", " //PyDict_DelItemString", " Fail(PyExc_KeyError, \"Key not found\");", " //PyDict_Items", " PyObject* rslt = PyMapping_Items(_obj);", " Fail(PyExc_RuntimeError, \"Failed to get items\");", " return LoseRef(rslt);", " //PyDict_Keys", " PyObject* rslt = PyMapping_Keys(_obj);", " Fail(PyExc_RuntimeError, \"Failed to get keys\");", " return LoseRef(rslt);", " //PyDict_New - default constructor", " //PyDict_Next", " //PyDict_Values", " PyObject* rslt = PyMapping_Values(_obj);", " Fail(PyExc_RuntimeError, \"Failed to get values\");", " return LoseRef(rslt);" ] } }, { "old_path": "weave/scxx/list.h", "new_path": "weave/scxx/list.h", "filename": "list.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -1,4 +1,4 @@\n-/******************************************** \n+/********************************************\n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n@@ -15,209 +15,194 @@\n #include \"object.h\"\n #include \"sequence.h\"\n #include \n+#include \n \n namespace py {\n- \n-class list_member : public object\n-{\n- list& _parent;\n- int _ndx;\n-public:\n- list_member(PyObject* obj, list& parent, int ndx);\n- virtual ~list_member() {};\n- list_member& operator=(const object& other);\n- list_member& operator=(const list_member& other);\n- list_member& operator=(int other);\n- list_member& operator=(double other);\n- list_member& operator=(const char* other);\n- list_member& operator=(std::string other);\n-};\n \n class list : public sequence\n {\n+ \n public:\n- list(int size=0) : sequence (PyList_New(size)) { LoseRef(_obj); }\n+ //-------------------------------------------------------------------------\n+ // constructors\n+ //-------------------------------------------------------------------------\n+ list(int size=0) : sequence (PyList_New(size)) { lose_ref(_obj); }\n list(const list& other) : sequence(other) {};\n list(PyObject* obj) : sequence(obj) {\n _violentTypeCheck();\n };\n+ \n+ //-------------------------------------------------------------------------\n+ // descructor\n+ //-------------------------------------------------------------------------\n virtual ~list() {};\n \n+ //-------------------------------------------------------------------------\n+ // operator=\n+ //-------------------------------------------------------------------------\n virtual list& operator=(const list& other) {\n- GrabRef(other);\n+ grab_ref(other);\n return *this;\n };\n list& operator=(const object& other) {\n- GrabRef(other);\n+ grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n+ \n+ //-------------------------------------------------------------------------\n+ // type checking\n+ //-------------------------------------------------------------------------\n virtual void _violentTypeCheck() {\n- if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a mutable sequence\");\n+ if (!PyList_Check(_obj)) { \n+ //should probably check the sequence methods for non-0 setitem\n+ grab_ref(0);\n+ fail(PyExc_TypeError, \"Not a mutable sequence\");\n }\n };\n- //PySequence_DelItem ##lists\n+ \n+ //-------------------------------------------------------------------------\n+ // del -- remove the item at a given index from the list.\n+ // also a two valued version for removing slices from a list.\n+ //-------------------------------------------------------------------------\n bool del(int i) {\n int rslt = PySequence_DelItem(_obj, i);\n if (rslt == -1)\n- Fail(PyExc_RuntimeError, \"cannot delete item\");\n+ fail(PyExc_RuntimeError, \"cannot delete item\");\n return true;\n };\n- //PySequence_DelSlice ##lists\n bool del(int lo, int hi) {\n int rslt = PySequence_DelSlice(_obj, lo, hi);\n if (rslt == -1)\n- Fail(PyExc_RuntimeError, \"cannot delete slice\");\n+ fail(PyExc_RuntimeError, \"cannot delete slice\");\n return true;\n };\n- //PySequence_GetItem ##lists - return list_member (mutable) otherwise just a object\n- list_member operator [] (int i) { // can't be virtual\n- //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n+\n+ //-------------------------------------------------------------------------\n+ // operator[] -- access/set elements in a list\n+ //-------------------------------------------------------------------------\n+ indexed_ref operator [] (int i) {\n PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n- //Py_XINCREF(o);\n- //if (o == 0)\n- // Fail(PyExc_IndexError, \"index out of range\");\n- return list_member(o, *this, i); // this increfs\n+ // don't throw error for when [] fails because it might be on left hand \n+ // side (a[0] = 1). If the list was just created, it will be filled \n+ // with NULL values, and setting the values should be ok. However, we\n+ // do want to catch index errors that might occur on the right hand side\n+ // (obj = a[4] when a has len==3).\n+ if (!o) {\n+ if (PyErr_ExceptionMatches(PyExc_IndexError))\n+ throw 1;\n+ }\n+ return indexed_ref(o, *this, i); // this increfs\n };\n- //PySequence_SetItem ##Lists\n- void set_item(int ndx, object& val) {\n+\n+ //-------------------------------------------------------------------------\n+ // set_item -- set list entry at a given index to a new value.\n+ //-------------------------------------------------------------------------\n+ virtual void set_item(int ndx, object& val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, val);\n val.disown(); //when using PyList_SetItem, he steals my reference\n if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void set_item(int ndx, int val) {\n- int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n- \n- void set_item(int ndx, double val) {\n- int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void set_item(int ndx, char* val) {\n- int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void set_item(int ndx, std::string val) {\n- int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n+ fail(PyExc_IndexError, \"Index out of range\");\n };\n \n- //PySequence_SetSlice ##Lists\n- void setSlice(int lo, int hi, const sequence& slice) {\n+ //-------------------------------------------------------------------------\n+ // set_slice -- set slice to a new sequence of values\n+ //\n+ // !! NOT TESTED\n+ //-------------------------------------------------------------------------\n+ void set_slice(int lo, int hi, const sequence& slice) {\n int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n if (rslt==-1)\n- Fail(PyExc_RuntimeError, \"Error setting slice\");\n+ fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n \n- //PyList_Append\n+ //-------------------------------------------------------------------------\n+ // append -- add new item to end of list\n+ // overloaded to accept all of the common weave types.\n+ //-------------------------------------------------------------------------\n list& append(const object& other) {\n int rslt = PyList_Append(_obj, other);\n if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error appending\");\n+ PyErr_Clear(); //Python sets one\n+ fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n-\n list& append(int other) {\n- PyObject* oth = PyInt_FromLong(other);\n- int rslt = PyList_Append(_obj, oth); \n- Py_XDECREF(oth);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error appending\");\n- }\n- return *this;\n+ object oth = other;\n+ return append(oth);\n };\n-\n list& append(double other) {\n- PyObject* oth = PyFloat_FromDouble(other);\n- int rslt = PyList_Append(_obj, oth); \n- Py_XDECREF(oth);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error appending\");\n- }\n- return *this;\n+ object oth = other;\n+ return append(oth);\n };\n-\n- list& append(char* other) {\n- PyObject* oth = PyString_FromString(other);\n- int rslt = PyList_Append(_obj, oth); \n- Py_XDECREF(oth);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error appending\");\n- }\n- return *this;\n+ list& append(const std::complex& other) {\n+ object oth = other;\n+ return append(oth);\n };\n-\n- list& append(std::string other) {\n- PyObject* oth = PyString_FromString(other.c_str());\n- int rslt = PyList_Append(_obj, oth); \n- Py_XDECREF(oth);\n- if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error appending\");\n- }\n- return *this;\n+ list& append(const char* other) {\n+ object oth = other;\n+ return append(oth);\n };\n-\n- //PyList_AsTuple\n- // problem with this is it's created on the heap\n- //virtual PWOTuple& asTuple() const {\n- // PyObject* rslt = PyList_AsTuple(_obj);\n- // PWOTuple rtrn = new PWOTuple(rslt);\n- // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed\n- // return *rtrn;\n- //};\n- //PyList_GetItem - inherited OK\n- //PyList_GetSlice - inherited OK\n- //PyList_Insert\n+ list& append(const std::string& other) {\n+ object oth = other;\n+ return append(oth);\n+ };\n+ \n+ //-------------------------------------------------------------------------\n+ // insert -- insert a new item before the given index.\n+ // overloaded to accept all of the common weave types.\n+ //-------------------------------------------------------------------------\n list& insert(int ndx, object& other) {\n int rslt = PyList_Insert(_obj, ndx, other);\n if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error inserting\");\n+ PyErr_Clear(); //Python sets one\n+ fail(PyExc_RuntimeError, \"Error inserting\");\n };\n return *this;\n };\n- list& insert(int ndx, int other);\n- list& insert(int ndx, double other);\n- list& insert(int ndx, char* other); \n- list& insert(int ndx, std::string other);\n+ list& list::insert(int ndx, int other) {\n+ object oth = other;\n+ return insert(ndx, oth);\n+ };\n+ list& list::insert(int ndx, double other) {\n+ object oth = other;\n+ return insert(ndx, oth);\n+ };\n+ list& list::insert(int ndx, std::complex& other) {\n+ object oth = other;\n+ return insert(ndx, oth);\n+ }; \n+ list& list::insert(int ndx, const char* other) {\n+ object oth = other;\n+ return insert(ndx, oth);\n+ };\n+ list& list::insert(int ndx, const std::string& other) {\n+ object oth = other;\n+ return insert(ndx, oth);\n+ };\n \n- //PyList_New\n- //PyList_Reverse\n+ //-------------------------------------------------------------------------\n+ // reverse -- reverse the order of items in the list.\n+ //-------------------------------------------------------------------------\n list& reverse() {\n int rslt = PyList_Reverse(_obj);\n if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error reversing\");\n+ PyErr_Clear(); //Python sets one\n+ fail(PyExc_RuntimeError, \"Error reversing\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n- //PyList_SetItem - using abstract\n- //PyList_SetSlice - using abstract\n- //PyList_Size - inherited OK\n- //PyList_Sort\n+\n+ //-------------------------------------------------------------------------\n+ // sort -- sort the items in the list.\n+ //-------------------------------------------------------------------------\n list& sort() {\n int rslt = PyList_Sort(_obj);\n if (rslt==-1) {\n- PyErr_Clear(); //Python sets one \n- Fail(PyExc_RuntimeError, \"Error sorting\");\n+ PyErr_Clear(); //Python sets one\n+ fail(PyExc_RuntimeError, \"Error sorting\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n", "added_lines": 117, "deleted_lines": 132, "source_code": "/********************************************\n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones\n*********************************************/\n#if !defined(LIST_H_INCLUDED_)\n#define LIST_H_INCLUDED_\n\n// ej: not sure what this is about, but we'll leave it.\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#include \"object.h\"\n#include \"sequence.h\"\n#include \n#include \n\nnamespace py {\n\nclass list : public sequence\n{\n \npublic:\n //-------------------------------------------------------------------------\n // constructors\n //-------------------------------------------------------------------------\n list(int size=0) : sequence (PyList_New(size)) { lose_ref(_obj); }\n list(const list& other) : sequence(other) {};\n list(PyObject* obj) : sequence(obj) {\n _violentTypeCheck();\n };\n \n //-------------------------------------------------------------------------\n // descructor\n //-------------------------------------------------------------------------\n virtual ~list() {};\n\n //-------------------------------------------------------------------------\n // operator=\n //-------------------------------------------------------------------------\n virtual list& operator=(const list& other) {\n grab_ref(other);\n return *this;\n };\n list& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // type checking\n //-------------------------------------------------------------------------\n virtual void _violentTypeCheck() {\n if (!PyList_Check(_obj)) { \n //should probably check the sequence methods for non-0 setitem\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a mutable sequence\");\n }\n };\n \n //-------------------------------------------------------------------------\n // del -- remove the item at a given index from the list.\n // also a two valued version for removing slices from a list.\n //-------------------------------------------------------------------------\n bool del(int i) {\n int rslt = PySequence_DelItem(_obj, i);\n if (rslt == -1)\n fail(PyExc_RuntimeError, \"cannot delete item\");\n return true;\n };\n bool del(int lo, int hi) {\n int rslt = PySequence_DelSlice(_obj, lo, hi);\n if (rslt == -1)\n fail(PyExc_RuntimeError, \"cannot delete slice\");\n return true;\n };\n\n //-------------------------------------------------------------------------\n // operator[] -- access/set elements in a list\n //-------------------------------------------------------------------------\n indexed_ref operator [] (int i) {\n PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n // don't throw error for when [] fails because it might be on left hand \n // side (a[0] = 1). If the list was just created, it will be filled \n // with NULL values, and setting the values should be ok. However, we\n // do want to catch index errors that might occur on the right hand side\n // (obj = a[4] when a has len==3).\n if (!o) {\n if (PyErr_ExceptionMatches(PyExc_IndexError))\n throw 1;\n }\n return indexed_ref(o, *this, i); // this increfs\n };\n\n //-------------------------------------------------------------------------\n // set_item -- set list entry at a given index to a new value.\n //-------------------------------------------------------------------------\n virtual void set_item(int ndx, object& val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, val);\n val.disown(); //when using PyList_SetItem, he steals my reference\n if (rslt==-1)\n fail(PyExc_IndexError, \"Index out of range\");\n };\n\n //-------------------------------------------------------------------------\n // set_slice -- set slice to a new sequence of values\n //\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n void set_slice(int lo, int hi, const sequence& slice) {\n int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n if (rslt==-1)\n fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n\n //-------------------------------------------------------------------------\n // append -- add new item to end of list\n // overloaded to accept all of the common weave types.\n //-------------------------------------------------------------------------\n list& append(const object& other) {\n int rslt = PyList_Append(_obj, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one\n fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n list& append(int other) {\n object oth = other;\n return append(oth);\n };\n list& append(double other) {\n object oth = other;\n return append(oth);\n };\n list& append(const std::complex& other) {\n object oth = other;\n return append(oth);\n };\n list& append(const char* other) {\n object oth = other;\n return append(oth);\n };\n list& append(const std::string& other) {\n object oth = other;\n return append(oth);\n };\n \n //-------------------------------------------------------------------------\n // insert -- insert a new item before the given index.\n // overloaded to accept all of the common weave types.\n //-------------------------------------------------------------------------\n list& insert(int ndx, object& other) {\n int rslt = PyList_Insert(_obj, ndx, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one\n fail(PyExc_RuntimeError, \"Error inserting\");\n };\n return *this;\n };\n list& list::insert(int ndx, int other) {\n object oth = other;\n return insert(ndx, oth);\n };\n list& list::insert(int ndx, double other) {\n object oth = other;\n return insert(ndx, oth);\n };\n list& list::insert(int ndx, std::complex& other) {\n object oth = other;\n return insert(ndx, oth);\n }; \n list& list::insert(int ndx, const char* other) {\n object oth = other;\n return insert(ndx, oth);\n };\n list& list::insert(int ndx, const std::string& other) {\n object oth = other;\n return insert(ndx, oth);\n };\n\n //-------------------------------------------------------------------------\n // reverse -- reverse the order of items in the list.\n //-------------------------------------------------------------------------\n list& reverse() {\n int rslt = PyList_Reverse(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one\n fail(PyExc_RuntimeError, \"Error reversing\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n\n //-------------------------------------------------------------------------\n // sort -- sort the items in the list.\n //-------------------------------------------------------------------------\n list& sort() {\n int rslt = PyList_Sort(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one\n fail(PyExc_RuntimeError, \"Error sorting\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n}; // class list\n\n} // namespace py\n\n#endif // LIST_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones\n*********************************************/\n#if !defined(LIST_H_INCLUDED_)\n#define LIST_H_INCLUDED_\n\n// ej: not sure what this is about, but we'll leave it.\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#include \"object.h\"\n#include \"sequence.h\"\n#include \n\nnamespace py {\n \nclass list_member : public object\n{\n list& _parent;\n int _ndx;\npublic:\n list_member(PyObject* obj, list& parent, int ndx);\n virtual ~list_member() {};\n list_member& operator=(const object& other);\n list_member& operator=(const list_member& other);\n list_member& operator=(int other);\n list_member& operator=(double other);\n list_member& operator=(const char* other);\n list_member& operator=(std::string other);\n};\n\nclass list : public sequence\n{\npublic:\n list(int size=0) : sequence (PyList_New(size)) { LoseRef(_obj); }\n list(const list& other) : sequence(other) {};\n list(PyObject* obj) : sequence(obj) {\n _violentTypeCheck();\n };\n virtual ~list() {};\n\n virtual list& operator=(const list& other) {\n GrabRef(other);\n return *this;\n };\n list& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a mutable sequence\");\n }\n };\n //PySequence_DelItem ##lists\n bool del(int i) {\n int rslt = PySequence_DelItem(_obj, i);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete item\");\n return true;\n };\n //PySequence_DelSlice ##lists\n bool del(int lo, int hi) {\n int rslt = PySequence_DelSlice(_obj, lo, hi);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"cannot delete slice\");\n return true;\n };\n //PySequence_GetItem ##lists - return list_member (mutable) otherwise just a object\n list_member operator [] (int i) { // can't be virtual\n //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n PyObject* o = PyList_GetItem(_obj, i); // get a \"borrowed\" refcount\n //Py_XINCREF(o);\n //if (o == 0)\n // Fail(PyExc_IndexError, \"index out of range\");\n return list_member(o, *this, i); // this increfs\n };\n //PySequence_SetItem ##Lists\n void set_item(int ndx, object& val) {\n //int rslt = PySequence_SetItem(_obj, ndx, val); - assumes old item is valid\n int rslt = PyList_SetItem(_obj, ndx, val);\n val.disown(); //when using PyList_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, int val) {\n int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n void set_item(int ndx, double val) {\n int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, char* val) {\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, std::string val) {\n int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n //PySequence_SetSlice ##Lists\n void setSlice(int lo, int hi, const sequence& slice) {\n int rslt = PySequence_SetSlice(_obj, lo, hi, slice);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"Error setting slice\");\n };\n\n //PyList_Append\n list& append(const object& other) {\n int rslt = PyList_Append(_obj, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n list& append(int other) {\n PyObject* oth = PyInt_FromLong(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n list& append(double other) {\n PyObject* oth = PyFloat_FromDouble(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n list& append(char* other) {\n PyObject* oth = PyString_FromString(other);\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n list& append(std::string other) {\n PyObject* oth = PyString_FromString(other.c_str());\n int rslt = PyList_Append(_obj, oth); \n Py_XDECREF(oth);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error appending\");\n }\n return *this;\n };\n\n //PyList_AsTuple\n // problem with this is it's created on the heap\n //virtual PWOTuple& asTuple() const {\n // PyObject* rslt = PyList_AsTuple(_obj);\n // PWOTuple rtrn = new PWOTuple(rslt);\n // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed\n // return *rtrn;\n //};\n //PyList_GetItem - inherited OK\n //PyList_GetSlice - inherited OK\n //PyList_Insert\n list& insert(int ndx, object& other) {\n int rslt = PyList_Insert(_obj, ndx, other);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error inserting\");\n };\n return *this;\n };\n list& insert(int ndx, int other);\n list& insert(int ndx, double other);\n list& insert(int ndx, char* other); \n list& insert(int ndx, std::string other);\n\n //PyList_New\n //PyList_Reverse\n list& reverse() {\n int rslt = PyList_Reverse(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error reversing\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n //PyList_SetItem - using abstract\n //PyList_SetSlice - using abstract\n //PyList_Size - inherited OK\n //PyList_Sort\n list& sort() {\n int rslt = PyList_Sort(_obj);\n if (rslt==-1) {\n PyErr_Clear(); //Python sets one \n Fail(PyExc_RuntimeError, \"Error sorting\");\n };\n return *this; //HA HA - Guido can't stop me!!!\n };\n}; // class list\n\n} // namespace py\n\n#endif // LIST_H_INCLUDED_\n", "methods": [ { "name": "py::list::list", "long_name": "py::list::list( int size = 0)", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 29, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( const list & other)", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 30, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( PyObject * obj)", "filename": "list.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 31, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::list::~list", "long_name": "py::list::~list()", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 38, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::operator =", "long_name": "py::list::operator =( const list & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 43, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::operator =", "long_name": "py::list::operator =( const object & other)", "filename": "list.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 47, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::_violentTypeCheck", "long_name": "py::list::_violentTypeCheck()", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 56, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::list::del", "long_name": "py::list::del( int i)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 68, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::del", "long_name": "py::list::del( int lo , int hi)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::operator [ ]", "long_name": "py::list::operator [ ]( int i)", "filename": "list.h", "nloc": 8, "complexity": 3, "token_count": 48, "parameters": [ "i" ], "start_line": 84, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , object & val)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 101, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::list::set_slice", "long_name": "py::list::set_slice( int lo , int hi , const sequence & slice)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 114, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const object & other)", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "other" ], "start_line": 124, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( int other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 132, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( double other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 136, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const std :: complex & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 140, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const char * other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "other" ], "start_line": 144, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const std :: string & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 148, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::insert", "long_name": "py::list::insert( int ndx , object & other)", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 157, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::list::insert", "long_name": "py::list::list::insert( int ndx , int other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "ndx", "other" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::list::insert", "long_name": "py::list::list::insert( int ndx , double other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "ndx", "other" ], "start_line": 169, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::list::insert", "long_name": "py::list::list::insert( int ndx , std :: complex & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "ndx", "std" ], "start_line": 173, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::list::insert", "long_name": "py::list::list::insert( int ndx , const char * other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "ndx", "other" ], "start_line": 177, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::list::insert", "long_name": "py::list::list::insert( int ndx , const std :: string & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "std" ], "start_line": 181, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::reverse", "long_name": "py::list::reverse()", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 189, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::sort", "long_name": "py::list::sort()", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 201, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::list_member::~list_member", "long_name": "py::list_member::~list_member()", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 27, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( int size = 0)", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 39, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( const list & other)", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 40, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( PyObject * obj)", "filename": "list.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::list::~list", "long_name": "py::list::~list()", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 44, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::operator =", "long_name": "py::list::operator =( const list & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::operator =", "long_name": "py::list::operator =( const object & other)", "filename": "list.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::_violentTypeCheck", "long_name": "py::list::_violentTypeCheck()", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::del", "long_name": "py::list::del( int i)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 62, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::del", "long_name": "py::list::del( int lo , int hi)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 69, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::operator [ ]", "long_name": "py::list::operator [ ]( int i)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 76, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , object & val)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 85, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , int val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 93, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , double val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 99, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , char * val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 105, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , std :: string val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 111, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::setSlice", "long_name": "py::list::setSlice( int lo , int hi , const sequence & slice)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 118, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const object & other)", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "other" ], "start_line": 125, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( int other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 134, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( double other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 55, "parameters": [ "other" ], "start_line": 145, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( char * other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 56, "parameters": [ "other" ], "start_line": 156, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( std :: string other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 167, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::insert", "long_name": "py::list::insert( int ndx , object & other)", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 189, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::reverse", "long_name": "py::list::reverse()", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 204, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::sort", "long_name": "py::list::sort()", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 216, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , double val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 99, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::del", "long_name": "py::list::del( int i)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "i" ], "start_line": 68, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::list", "long_name": "py::list::list( int size = 0)", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "size" ], "start_line": 29, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::list::insert", "long_name": "py::list::list::insert( int ndx , std :: complex & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "ndx", "std" ], "start_line": 173, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::insert", "long_name": "py::list::insert( int ndx , object & other)", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 48, "parameters": [ "ndx", "other" ], "start_line": 157, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const object & other)", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "other" ], "start_line": 124, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::list::insert", "long_name": "py::list::list::insert( int ndx , const char * other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "ndx", "other" ], "start_line": 177, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( int other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 132, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const std :: complex & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 140, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , std :: string val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 111, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( double other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 136, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::operator =", "long_name": "py::list::operator =( const object & other)", "filename": "list.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 47, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , int val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 93, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const char * other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "other" ], "start_line": 144, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::operator [ ]", "long_name": "py::list::operator [ ]( int i)", "filename": "list.h", "nloc": 8, "complexity": 3, "token_count": 48, "parameters": [ "i" ], "start_line": 84, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 2 }, { "name": "py::list::del", "long_name": "py::list::del( int lo , int hi)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "lo", "hi" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::list::list::insert", "long_name": "py::list::list::insert( int ndx , double other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "ndx", "other" ], "start_line": 169, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list_member::~list_member", "long_name": "py::list_member::~list_member()", "filename": "list.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 27, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , char * val)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 105, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::operator =", "long_name": "py::list::operator =( const list & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 43, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::set_item", "long_name": "py::list::set_item( int ndx , object & val)", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 101, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( const std :: string & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 148, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::reverse", "long_name": "py::list::reverse()", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 189, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::_violentTypeCheck", "long_name": "py::list::_violentTypeCheck()", "filename": "list.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 56, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( char * other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 56, "parameters": [ "other" ], "start_line": 156, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "py::list::setSlice", "long_name": "py::list::setSlice( int lo , int hi , const sequence & slice)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 118, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::sort", "long_name": "py::list::sort()", "filename": "list.h", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 201, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::list::list::insert", "long_name": "py::list::list::insert( int ndx , int other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "ndx", "other" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::list::insert", "long_name": "py::list::list::insert( int ndx , const std :: string & other)", "filename": "list.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "std" ], "start_line": 181, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::list::set_slice", "long_name": "py::list::set_slice( int lo , int hi , const sequence & slice)", "filename": "list.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi", "slice" ], "start_line": 114, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::list::append", "long_name": "py::list::append( std :: string other)", "filename": "list.h", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "std" ], "start_line": 167, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 } ], "nloc": 134, "complexity": 37, "token_count": 830, "diff_parsed": { "added": [ "/********************************************", "#include ", "", " //-------------------------------------------------------------------------", " // constructors", " //-------------------------------------------------------------------------", " list(int size=0) : sequence (PyList_New(size)) { lose_ref(_obj); }", "", " //-------------------------------------------------------------------------", " // descructor", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // operator=", " //-------------------------------------------------------------------------", " grab_ref(other);", " grab_ref(other);", "", " //-------------------------------------------------------------------------", " // type checking", " //-------------------------------------------------------------------------", " if (!PyList_Check(_obj)) {", " //should probably check the sequence methods for non-0 setitem", " grab_ref(0);", " fail(PyExc_TypeError, \"Not a mutable sequence\");", "", " //-------------------------------------------------------------------------", " // del -- remove the item at a given index from the list.", " // also a two valued version for removing slices from a list.", " //-------------------------------------------------------------------------", " fail(PyExc_RuntimeError, \"cannot delete item\");", " fail(PyExc_RuntimeError, \"cannot delete slice\");", "", " //-------------------------------------------------------------------------", " // operator[] -- access/set elements in a list", " //-------------------------------------------------------------------------", " indexed_ref operator [] (int i) {", " // don't throw error for when [] fails because it might be on left hand", " // side (a[0] = 1). If the list was just created, it will be filled", " // with NULL values, and setting the values should be ok. However, we", " // do want to catch index errors that might occur on the right hand side", " // (obj = a[4] when a has len==3).", " if (!o) {", " if (PyErr_ExceptionMatches(PyExc_IndexError))", " throw 1;", " }", " return indexed_ref(o, *this, i); // this increfs", "", " //-------------------------------------------------------------------------", " // set_item -- set list entry at a given index to a new value.", " //-------------------------------------------------------------------------", " virtual void set_item(int ndx, object& val) {", " fail(PyExc_IndexError, \"Index out of range\");", " //-------------------------------------------------------------------------", " // set_slice -- set slice to a new sequence of values", " //", " // !! NOT TESTED", " //-------------------------------------------------------------------------", " void set_slice(int lo, int hi, const sequence& slice) {", " fail(PyExc_RuntimeError, \"Error setting slice\");", " //-------------------------------------------------------------------------", " // append -- add new item to end of list", " // overloaded to accept all of the common weave types.", " //-------------------------------------------------------------------------", " PyErr_Clear(); //Python sets one", " fail(PyExc_RuntimeError, \"Error appending\");", " object oth = other;", " return append(oth);", " object oth = other;", " return append(oth);", " list& append(const std::complex& other) {", " object oth = other;", " return append(oth);", " list& append(const char* other) {", " object oth = other;", " return append(oth);", " list& append(const std::string& other) {", " object oth = other;", " return append(oth);", " };", "", " //-------------------------------------------------------------------------", " // insert -- insert a new item before the given index.", " // overloaded to accept all of the common weave types.", " //-------------------------------------------------------------------------", " PyErr_Clear(); //Python sets one", " fail(PyExc_RuntimeError, \"Error inserting\");", " list& list::insert(int ndx, int other) {", " object oth = other;", " return insert(ndx, oth);", " };", " list& list::insert(int ndx, double other) {", " object oth = other;", " return insert(ndx, oth);", " };", " list& list::insert(int ndx, std::complex& other) {", " object oth = other;", " return insert(ndx, oth);", " };", " list& list::insert(int ndx, const char* other) {", " object oth = other;", " return insert(ndx, oth);", " };", " list& list::insert(int ndx, const std::string& other) {", " object oth = other;", " return insert(ndx, oth);", " };", " //-------------------------------------------------------------------------", " // reverse -- reverse the order of items in the list.", " //-------------------------------------------------------------------------", " PyErr_Clear(); //Python sets one", " fail(PyExc_RuntimeError, \"Error reversing\");", "", " //-------------------------------------------------------------------------", " // sort -- sort the items in the list.", " //-------------------------------------------------------------------------", " PyErr_Clear(); //Python sets one", " fail(PyExc_RuntimeError, \"Error sorting\");" ], "deleted": [ "/********************************************", "", "class list_member : public object", "{", " list& _parent;", " int _ndx;", "public:", " list_member(PyObject* obj, list& parent, int ndx);", " virtual ~list_member() {};", " list_member& operator=(const object& other);", " list_member& operator=(const list_member& other);", " list_member& operator=(int other);", " list_member& operator=(double other);", " list_member& operator=(const char* other);", " list_member& operator=(std::string other);", "};", " list(int size=0) : sequence (PyList_New(size)) { LoseRef(_obj); }", " GrabRef(other);", " GrabRef(other);", " if (!PyList_Check(_obj)) { //should probably check the sequence methods for non-0 setitem", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a mutable sequence\");", " //PySequence_DelItem ##lists", " Fail(PyExc_RuntimeError, \"cannot delete item\");", " //PySequence_DelSlice ##lists", " Fail(PyExc_RuntimeError, \"cannot delete slice\");", " //PySequence_GetItem ##lists - return list_member (mutable) otherwise just a object", " list_member operator [] (int i) { // can't be virtual", " //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid", " //Py_XINCREF(o);", " //if (o == 0)", " // Fail(PyExc_IndexError, \"index out of range\");", " return list_member(o, *this, i); // this increfs", " //PySequence_SetItem ##Lists", " void set_item(int ndx, object& val) {", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, int val) {", " int rslt = PyList_SetItem(_obj, ndx, PyInt_FromLong(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, double val) {", " int rslt = PyList_SetItem(_obj, ndx, PyFloat_FromDouble(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, char* val) {", " int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, std::string val) {", " int rslt = PyList_SetItem(_obj, ndx, PyString_FromString(val.c_str()));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " //PySequence_SetSlice ##Lists", " void setSlice(int lo, int hi, const sequence& slice) {", " Fail(PyExc_RuntimeError, \"Error setting slice\");", " //PyList_Append", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", "", " PyObject* oth = PyInt_FromLong(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", "", " PyObject* oth = PyFloat_FromDouble(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", "", " list& append(char* other) {", " PyObject* oth = PyString_FromString(other);", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", "", " list& append(std::string other) {", " PyObject* oth = PyString_FromString(other.c_str());", " int rslt = PyList_Append(_obj, oth);", " Py_XDECREF(oth);", " if (rslt==-1) {", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error appending\");", " }", " return *this;", "", " //PyList_AsTuple", " // problem with this is it's created on the heap", " //virtual PWOTuple& asTuple() const {", " // PyObject* rslt = PyList_AsTuple(_obj);", " // PWOTuple rtrn = new PWOTuple(rslt);", " // Py_XDECREF(rslt); //AsTuple set refcnt to 1, PWOTuple(rslt) increffed", " // return *rtrn;", " //};", " //PyList_GetItem - inherited OK", " //PyList_GetSlice - inherited OK", " //PyList_Insert", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error inserting\");", " list& insert(int ndx, int other);", " list& insert(int ndx, double other);", " list& insert(int ndx, char* other);", " list& insert(int ndx, std::string other);", " //PyList_New", " //PyList_Reverse", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error reversing\");", " //PyList_SetItem - using abstract", " //PyList_SetSlice - using abstract", " //PyList_Size - inherited OK", " //PyList_Sort", " PyErr_Clear(); //Python sets one", " Fail(PyExc_RuntimeError, \"Error sorting\");" ] } }, { "old_path": "weave/scxx/notes.txt", "new_path": "weave/scxx/notes.txt", "filename": "notes.txt", "extension": "txt", "change_type": "MODIFY", "diff": "@@ -1,18 +1,56 @@\n+Questions:\n+\n+ 1. sequences (tuples and lists) are empty (full of NULL values)\n+ on creation. On return to Python, nothing is done to check\n+ whether a sequence has NULL values in it. NULL values in \n+ Python will cause problems. An alternative is to fill created\n+ sequences with PyNone. This is slower, but maybe safer. I\n+ believe this is what CXX does. I need to ask others what they\n+ think about this.\n+ 2. operator[] presents the biggest problems for C++ Python library\n+ as far as I can tell. The problem is we need a different function\n+ called in the following two cases:\n+ \n+ dict_obj[\"a\"] = 1;\n+ obj = dict_obj[\"a\"];\n+ \n+ In the first case, no KeyError should be thrown. In the 2nd,\n+ the KeyError should be thrown. Unfortunately, this is not \n+ possible with simple C++. It may be possible with template\n+ expressions, but we aren't using those. So, for now, we will\n+ have to deal with KeyErrors not occuring on the RHS of equations.\n+ A secondary option here is to have a second argument have a \n+ special function for RHS access to values. This is likely \n+ what we will do in auto generated code. \n+ \n+ In the case that IndexErrors occur, these should always be\n+ thrown.\n+ \n For release:\n 1. Change return_val to be an py::object. This will get rid of \n of the need to handle incref/decref on your own most of the time.\n DONE\n 2. Flesh out object to handle all types of values in a generic way:\n a. sequence access.\n+ DONE\n b. casting from/to standard types\n int, float, double, std::complex, char*, std::string.\n DONE\n c. attr should return a reference? Not sure about this.\n I DONT THINK SO\n- 3. Tests that always through exceptions aren't getting cataloged.\n+ 3. Tests that always thrown exceptions aren't getting cataloged.\n This isn't a big deal in practice, but it needs to be cleaned up.\n 4. Test file conversion for ref counts\n 5. Examine all examples and make sure they make sense (and work). \n+ 6. Add iter() and next() to objects.\n+ 7. check comparisons\n+ DONE.\n+ 8. clean up dict objects.\n+ DONE.\n+ 9. test dict object.\n+ DONE \n+ 9. test get_item_operator for object, list, tuples, dicts.\n+ DONE -- but I don't really like the operator[] behavior.\n \n base package\n scipy_base\n@@ -191,4 +229,3 @@ EVERYTHING BELOW HERE IS DONE.\n \n py::list items() const\n py::list keys() const\n- py::list values() const\n\\ No newline at end of file\n", "added_lines": 39, "deleted_lines": 2, "source_code": "Questions:\n\n 1. sequences (tuples and lists) are empty (full of NULL values)\n on creation. On return to Python, nothing is done to check\n whether a sequence has NULL values in it. NULL values in \n Python will cause problems. An alternative is to fill created\n sequences with PyNone. This is slower, but maybe safer. I\n believe this is what CXX does. I need to ask others what they\n think about this.\n 2. operator[] presents the biggest problems for C++ Python library\n as far as I can tell. The problem is we need a different function\n called in the following two cases:\n \n dict_obj[\"a\"] = 1;\n obj = dict_obj[\"a\"];\n \n In the first case, no KeyError should be thrown. In the 2nd,\n the KeyError should be thrown. Unfortunately, this is not \n possible with simple C++. It may be possible with template\n expressions, but we aren't using those. So, for now, we will\n have to deal with KeyErrors not occuring on the RHS of equations.\n A secondary option here is to have a second argument have a \n special function for RHS access to values. This is likely \n what we will do in auto generated code. \n \n In the case that IndexErrors occur, these should always be\n thrown.\n \nFor release:\n 1. Change return_val to be an py::object. This will get rid of \n of the need to handle incref/decref on your own most of the time.\n DONE\n 2. Flesh out object to handle all types of values in a generic way:\n a. sequence access.\n DONE\n b. casting from/to standard types\n int, float, double, std::complex, char*, std::string.\n DONE\n c. attr should return a reference? Not sure about this.\n I DONT THINK SO\n 3. Tests that always thrown exceptions aren't getting cataloged.\n This isn't a big deal in practice, but it needs to be cleaned up.\n 4. Test file conversion for ref counts\n 5. Examine all examples and make sure they make sense (and work). \n 6. Add iter() and next() to objects.\n 7. check comparisons\n DONE.\n 8. clean up dict objects.\n DONE.\n 9. test dict object.\n DONE \n 9. test get_item_operator for object, list, tuples, dicts.\n DONE -- but I don't really like the operator[] behavior.\n \nbase package\n scipy_base\n scipy_distutils\n scipy_test\n gui_thread\n\nscipy\nweave\nchaco\n \nweave\n\nNote on ref counts:\nThere is some ref count strangness in inline() *if it is called from\na function*. When called from the command line, the ref counts behave\ncorrectly. When called from a function, the first call to a\ninline() causes the ref count goes up an extra count. However,\nsubsequent calls don't cause any further refcount increases. Checks\nput in py::object creation and destruction look like the C++ code is\nnot loosing a ref count. I'm thinking that some of the stack frame\nlimbo played in inline() might be to blame??? Anyway, this needs\nfurther investigation. I'm not sure if the issue is leading to leaks\nor not.\n\nProposed changes to weave:\n\n* change return_val to a py::object\n This could remove almost all of the need of handling PyObject*.\n* document changes. \n* review directory structure.\n* outline method of aggregating functions into a single file.\n\nEVERYTHING BELOW HERE IS DONE.\n* all classes moved to py:: namespace\n* made tuples mutable with indexing notation. (handy in weave)\n* converted camel case names (setItem -> set_item)\n* change class names to reflect boost like names and put each \n exposed class in its own header file.\n PWOBase -> py::object -- object.h \n PWOList -> py::list -- list.h \n PWOTuple -> py::tuple -- tuple.h \n PWOMapping -> py::dict -- dict.h \n PWOCallable -> py::callable -- callable.h \n PWOString -> py::str -- str.h \n PWONumber -> py::number -- number.h \n \n py::object public methods:\n int print(FILE *f, int flags) const DONE\n\n bool hasattr(const char* nm) const DONE\n\n py::object_attr attr(const char* nm) const\n py::object_attr attr(const py::object& nm) const\n\n ??\n int set_attr(const char* nm, py::object& val)\n int set_attr(PyObject* nm, py::object& val)\n\n int del(const char* nm)\n int del(const py::object& nm)\n \n int cmp(const py::object& other) const\n\n bool operator == (const py::object& other) const \n bool operator != (const py::object& other) const \n bool operator > (const py::object& other) const \n bool operator < (const py::object& other) const\n bool operator >= (const py::object& other) const\n bool operator <= (const py::object& other) const \n \n PyObject* repr() const\n /*PyObject* str() const*/ // conflicts with class named str\n PyObject* type() const\n \n int hash() const\n bool is_true() const\n bool is_callable() const\n \n PyObject* disown() \n\n\n py::sequence public methods:\n PWOSequence operator+(const PWOSequence& rhs) const\n //count\n int count(const py::object& value) const\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n py::object operator [] (int i) const\n py::sequence get_slice(int lo, int hi) const\n \n bool in(const py::object& value) const\n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n int index(const py::object& value) const\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n int len() const\n int length() const // compatible with std::string\n\n py::sequence operator * (int count) const //repeat\n\n class py::tuple\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n \n // make tuples mutable like lists\n // much easier to set up call lists, etc.\n py::tuple_member operator [] (int i)\n \n class py::list\n\n bool del(int i)\n bool del(int lo, int hi)\n\n py::list_member operator [] (int i)\n\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n\n void set_slice(int lo, int hi, const py::sequence& slice)\n\n py::list& append(const py::object& other)\n py::list& append(int other)\n py::list& append(double other)\n py::list& append(char* other)\n py::list& append(std::string other)\n \n py::list& insert(int ndx, py::object& other)\n py::list& insert(int ndx, int other);\n py::list& insert(int ndx, double other);\n py::list& insert(int ndx, char* other); \n py::list& insert(int ndx, std::string other);\n\n py::list& reverse()\n py::list& sort()\n\n class py::dict\n py::dict_member operator [] (const char* key)\n py::dict_member operator [] (std::string key)\n \n py::dict_member operator [] (PyObject* key)\n py::dict_member operator [] (int key) \n py::dict_member operator [] (double key)\n \n bool has_key(PyObject* key) const\n bool has_key(const char* key) const\n // needs int, std::string, and double versions\n \n int len() const\n int length() const\n\n void set_item(const char* key, PyObject* val)\n void set_item(PyObject* key, PyObject* val) const\n // need int, std::string and double versions\n void clear()\n \n void del(PyObject* key)\n void del(const char* key)\n // need int, std::string, and double versions\n \n py::list items() const\n py::list keys() const\n", "source_code_before": "For release:\n 1. Change return_val to be an py::object. This will get rid of \n of the need to handle incref/decref on your own most of the time.\n DONE\n 2. Flesh out object to handle all types of values in a generic way:\n a. sequence access.\n b. casting from/to standard types\n int, float, double, std::complex, char*, std::string.\n DONE\n c. attr should return a reference? Not sure about this.\n I DONT THINK SO\n 3. Tests that always through exceptions aren't getting cataloged.\n This isn't a big deal in practice, but it needs to be cleaned up.\n 4. Test file conversion for ref counts\n 5. Examine all examples and make sure they make sense (and work). \n \nbase package\n scipy_base\n scipy_distutils\n scipy_test\n gui_thread\n\nscipy\nweave\nchaco\n \nweave\n\nNote on ref counts:\nThere is some ref count strangness in inline() *if it is called from\na function*. When called from the command line, the ref counts behave\ncorrectly. When called from a function, the first call to a\ninline() causes the ref count goes up an extra count. However,\nsubsequent calls don't cause any further refcount increases. Checks\nput in py::object creation and destruction look like the C++ code is\nnot loosing a ref count. I'm thinking that some of the stack frame\nlimbo played in inline() might be to blame??? Anyway, this needs\nfurther investigation. I'm not sure if the issue is leading to leaks\nor not.\n\nProposed changes to weave:\n\n* change return_val to a py::object\n This could remove almost all of the need of handling PyObject*.\n* document changes. \n* review directory structure.\n* outline method of aggregating functions into a single file.\n\nEVERYTHING BELOW HERE IS DONE.\n* all classes moved to py:: namespace\n* made tuples mutable with indexing notation. (handy in weave)\n* converted camel case names (setItem -> set_item)\n* change class names to reflect boost like names and put each \n exposed class in its own header file.\n PWOBase -> py::object -- object.h \n PWOList -> py::list -- list.h \n PWOTuple -> py::tuple -- tuple.h \n PWOMapping -> py::dict -- dict.h \n PWOCallable -> py::callable -- callable.h \n PWOString -> py::str -- str.h \n PWONumber -> py::number -- number.h \n \n py::object public methods:\n int print(FILE *f, int flags) const DONE\n\n bool hasattr(const char* nm) const DONE\n\n py::object_attr attr(const char* nm) const\n py::object_attr attr(const py::object& nm) const\n\n ??\n int set_attr(const char* nm, py::object& val)\n int set_attr(PyObject* nm, py::object& val)\n\n int del(const char* nm)\n int del(const py::object& nm)\n \n int cmp(const py::object& other) const\n\n bool operator == (const py::object& other) const \n bool operator != (const py::object& other) const \n bool operator > (const py::object& other) const \n bool operator < (const py::object& other) const\n bool operator >= (const py::object& other) const\n bool operator <= (const py::object& other) const \n \n PyObject* repr() const\n /*PyObject* str() const*/ // conflicts with class named str\n PyObject* type() const\n \n int hash() const\n bool is_true() const\n bool is_callable() const\n \n PyObject* disown() \n\n\n py::sequence public methods:\n PWOSequence operator+(const PWOSequence& rhs) const\n //count\n int count(const py::object& value) const\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n py::object operator [] (int i) const\n py::sequence get_slice(int lo, int hi) const\n \n bool in(const py::object& value) const\n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n int index(const py::object& value) const\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n int len() const\n int length() const // compatible with std::string\n\n py::sequence operator * (int count) const //repeat\n\n class py::tuple\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n \n // make tuples mutable like lists\n // much easier to set up call lists, etc.\n py::tuple_member operator [] (int i)\n \n class py::list\n\n bool del(int i)\n bool del(int lo, int hi)\n\n py::list_member operator [] (int i)\n\n void set_item(int ndx, py::object& val)\n void set_item(int ndx, int val)\n void set_item(int ndx, double val)\n void set_item(int ndx, char* val)\n void set_item(int ndx, std::string val)\n\n void set_slice(int lo, int hi, const py::sequence& slice)\n\n py::list& append(const py::object& other)\n py::list& append(int other)\n py::list& append(double other)\n py::list& append(char* other)\n py::list& append(std::string other)\n \n py::list& insert(int ndx, py::object& other)\n py::list& insert(int ndx, int other);\n py::list& insert(int ndx, double other);\n py::list& insert(int ndx, char* other); \n py::list& insert(int ndx, std::string other);\n\n py::list& reverse()\n py::list& sort()\n\n class py::dict\n py::dict_member operator [] (const char* key)\n py::dict_member operator [] (std::string key)\n \n py::dict_member operator [] (PyObject* key)\n py::dict_member operator [] (int key) \n py::dict_member operator [] (double key)\n \n bool has_key(PyObject* key) const\n bool has_key(const char* key) const\n // needs int, std::string, and double versions\n \n int len() const\n int length() const\n\n void set_item(const char* key, PyObject* val)\n void set_item(PyObject* key, PyObject* val) const\n // need int, std::string and double versions\n void clear()\n \n void del(PyObject* key)\n void del(const char* key)\n // need int, std::string, and double versions\n \n py::list items() const\n py::list keys() const\n py::list values() const", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "Questions:", "", " 1. sequences (tuples and lists) are empty (full of NULL values)", " on creation. On return to Python, nothing is done to check", " whether a sequence has NULL values in it. NULL values in", " Python will cause problems. An alternative is to fill created", " sequences with PyNone. This is slower, but maybe safer. I", " believe this is what CXX does. I need to ask others what they", " think about this.", " 2. operator[] presents the biggest problems for C++ Python library", " as far as I can tell. The problem is we need a different function", " called in the following two cases:", "", " dict_obj[\"a\"] = 1;", " obj = dict_obj[\"a\"];", "", " In the first case, no KeyError should be thrown. In the 2nd,", " the KeyError should be thrown. Unfortunately, this is not", " possible with simple C++. It may be possible with template", " expressions, but we aren't using those. So, for now, we will", " have to deal with KeyErrors not occuring on the RHS of equations.", " A secondary option here is to have a second argument have a", " special function for RHS access to values. This is likely", " what we will do in auto generated code.", "", " In the case that IndexErrors occur, these should always be", " thrown.", "", " DONE", " 3. Tests that always thrown exceptions aren't getting cataloged.", " 6. Add iter() and next() to objects.", " 7. check comparisons", " DONE.", " 8. clean up dict objects.", " DONE.", " 9. test dict object.", " DONE", " 9. test get_item_operator for object, list, tuples, dicts.", " DONE -- but I don't really like the operator[] behavior." ], "deleted": [ " 3. Tests that always through exceptions aren't getting cataloged.", " py::list values() const" ] } }, { "old_path": "weave/scxx/number.h", "new_path": "weave/scxx/number.h", "filename": "number.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -16,10 +16,11 @@ class number : public object\n {\n public:\n number() : object() {};\n- number(int i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }\n- number(long i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }\n- number(unsigned long i) : object (PyLong_FromUnsignedLong(i)) { LoseRef(_obj); }\n- number(double d) : object (PyFloat_FromDouble(d)) { LoseRef(_obj); }\n+ number(int i) : object(i) {};\n+ number(long i) : object(i) {};\n+ number(unsigned long i) : object(i) {};\n+ number(double d) : object(d) {}\n+ number(std::complex& d) : object(d) {};\n \n number(const number& other) : object(other) {};\n number(PyObject* obj) : object(obj) {\n@@ -28,61 +29,61 @@ public:\n virtual ~number() {};\n \n virtual number& operator=(const number& other) {\n- GrabRef(other);\n+ grab_ref(other);\n return *this;\n };\n /*virtual*/ number& operator=(const object& other) {\n- GrabRef(other);\n+ grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyNumber_Check(_obj)) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a number\");\n+ grab_ref(0);\n+ fail(PyExc_TypeError, \"Not a number\");\n }\n };\n //PyNumber_Absolute\n number abs() const {\n PyObject* rslt = PyNumber_Absolute(_obj);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Failed to get absolute value\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"failed to get absolute value\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Add\n number operator+(const number& rhs) const {\n PyObject* rslt = PyNumber_Add(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for +\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for +\");\n+ return lose_ref(rslt);\n };\n //PyNumber_And\n number operator&(const number& rhs) const {\n PyObject* rslt = PyNumber_And(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for &\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for &\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Coerce\n //PyNumber_Divide\n number operator/(const number& rhs) const {\n PyObject* rslt = PyNumber_Divide(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for /\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for /\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Divmod\n sequence divmod(const number& rhs) const {\n PyObject* rslt = PyNumber_Divmod(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for divmod\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for divmod\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Float\n operator double () const {\n PyObject* F = PyNumber_Float(_obj);\n if (F==0)\n- Fail(PyExc_TypeError, \"Cannot convert to double\");\n+ fail(PyExc_TypeError, \"Cannot convert to double\");\n double r = PyFloat_AS_DOUBLE(F);\n Py_DECREF(F);\n return r;\n@@ -90,14 +91,14 @@ public:\n operator float () const {\n double rslt = (double) *this;\n //if (rslt > INT_MAX)\n- // Fail(PyExc_TypeError, \"Cannot convert to a float\");\n+ // fail(PyExc_TypeError, \"Cannot convert to a float\");\n return (float) rslt;\n };\n //PyNumber_Int\n operator long () const {\n PyObject* Int = PyNumber_Int(_obj);\n if (Int==0)\n- Fail(PyExc_TypeError, \"Cannot convert to long\");\n+ fail(PyExc_TypeError, \"Cannot convert to long\");\n long r = PyInt_AS_LONG(Int);\n Py_DECREF(Int);\n return r;\n@@ -105,79 +106,79 @@ public:\n operator int () const {\n long rslt = (long) *this;\n if (rslt > INT_MAX)\n- Fail(PyExc_TypeError, \"Cannot convert to an int\");\n+ fail(PyExc_TypeError, \"Cannot convert to an int\");\n return (int) rslt;\n };\n //PyNumber_Invert\n number operator~ () const {\n PyObject* rslt = PyNumber_Invert(_obj);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper type for ~\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper type for ~\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Long\n //PyNumber_Lshift\n number operator<<(const number& rhs) const {\n PyObject* rslt = PyNumber_Lshift(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for <<\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for <<\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Multiply\n number operator*(const number& rhs) const {\n PyObject* rslt = PyNumber_Multiply(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for *\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for *\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Negative\n number operator- () const {\n PyObject* rslt = PyNumber_Negative(_obj);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper type for unary -\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper type for unary -\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Or\n number operator|(const number& rhs) const {\n PyObject* rslt = PyNumber_Or(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for |\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for |\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Positive\n number operator+ () const {\n PyObject* rslt = PyNumber_Positive(_obj);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper type for unary +\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper type for unary +\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Remainder\n number operator%(const number& rhs) const {\n PyObject* rslt = PyNumber_Remainder(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for %\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for %\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Rshift\n number operator>>(const number& rhs) const {\n PyObject* rslt = PyNumber_Rshift(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for >>\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for >>\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Subtract\n number operator-(const number& rhs) const {\n PyObject* rslt = PyNumber_Subtract(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for -\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for -\");\n+ return lose_ref(rslt);\n };\n //PyNumber_Xor\n number operator^(const number& rhs) const {\n PyObject* rslt = PyNumber_Xor(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for ^\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for ^\");\n+ return lose_ref(rslt);\n };\n };\n \n", "added_lines": 43, "deleted_lines": 42, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones\n*********************************************/\n#if !defined(NUMBER_H_INCLUDED_)\n#define NUMBER_H_INCLUDED_\n\n#include \"object.h\"\n#include \"sequence.h\"\n\nnamespace py {\n \nclass number : public object\n{\npublic:\n number() : object() {};\n number(int i) : object(i) {};\n number(long i) : object(i) {};\n number(unsigned long i) : object(i) {};\n number(double d) : object(d) {}\n number(std::complex& d) : object(d) {};\n\n number(const number& other) : object(other) {};\n number(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n virtual ~number() {};\n\n virtual number& operator=(const number& other) {\n grab_ref(other);\n return *this;\n };\n /*virtual*/ number& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyNumber_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a number\");\n }\n };\n //PyNumber_Absolute\n number abs() const {\n PyObject* rslt = PyNumber_Absolute(_obj);\n if (rslt==0)\n fail(PyExc_TypeError, \"failed to get absolute value\");\n return lose_ref(rslt);\n };\n //PyNumber_Add\n number operator+(const number& rhs) const {\n PyObject* rslt = PyNumber_Add(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for +\");\n return lose_ref(rslt);\n };\n //PyNumber_And\n number operator&(const number& rhs) const {\n PyObject* rslt = PyNumber_And(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for &\");\n return lose_ref(rslt);\n };\n //PyNumber_Coerce\n //PyNumber_Divide\n number operator/(const number& rhs) const {\n PyObject* rslt = PyNumber_Divide(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for /\");\n return lose_ref(rslt);\n };\n //PyNumber_Divmod\n sequence divmod(const number& rhs) const {\n PyObject* rslt = PyNumber_Divmod(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for divmod\");\n return lose_ref(rslt);\n };\n //PyNumber_Float\n operator double () const {\n PyObject* F = PyNumber_Float(_obj);\n if (F==0)\n fail(PyExc_TypeError, \"Cannot convert to double\");\n double r = PyFloat_AS_DOUBLE(F);\n Py_DECREF(F);\n return r;\n };\n operator float () const {\n double rslt = (double) *this;\n //if (rslt > INT_MAX)\n // fail(PyExc_TypeError, \"Cannot convert to a float\");\n return (float) rslt;\n };\n //PyNumber_Int\n operator long () const {\n PyObject* Int = PyNumber_Int(_obj);\n if (Int==0)\n fail(PyExc_TypeError, \"Cannot convert to long\");\n long r = PyInt_AS_LONG(Int);\n Py_DECREF(Int);\n return r;\n };\n operator int () const {\n long rslt = (long) *this;\n if (rslt > INT_MAX)\n fail(PyExc_TypeError, \"Cannot convert to an int\");\n return (int) rslt;\n };\n //PyNumber_Invert\n number operator~ () const {\n PyObject* rslt = PyNumber_Invert(_obj);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper type for ~\");\n return lose_ref(rslt);\n };\n //PyNumber_Long\n //PyNumber_Lshift\n number operator<<(const number& rhs) const {\n PyObject* rslt = PyNumber_Lshift(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for <<\");\n return lose_ref(rslt);\n };\n //PyNumber_Multiply\n number operator*(const number& rhs) const {\n PyObject* rslt = PyNumber_Multiply(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for *\");\n return lose_ref(rslt);\n };\n //PyNumber_Negative\n number operator- () const {\n PyObject* rslt = PyNumber_Negative(_obj);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper type for unary -\");\n return lose_ref(rslt);\n };\n //PyNumber_Or\n number operator|(const number& rhs) const {\n PyObject* rslt = PyNumber_Or(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for |\");\n return lose_ref(rslt);\n };\n //PyNumber_Positive\n number operator+ () const {\n PyObject* rslt = PyNumber_Positive(_obj);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper type for unary +\");\n return lose_ref(rslt);\n };\n //PyNumber_Remainder\n number operator%(const number& rhs) const {\n PyObject* rslt = PyNumber_Remainder(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for %\");\n return lose_ref(rslt);\n };\n //PyNumber_Rshift\n number operator>>(const number& rhs) const {\n PyObject* rslt = PyNumber_Rshift(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for >>\");\n return lose_ref(rslt);\n };\n //PyNumber_Subtract\n number operator-(const number& rhs) const {\n PyObject* rslt = PyNumber_Subtract(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for -\");\n return lose_ref(rslt);\n };\n //PyNumber_Xor\n number operator^(const number& rhs) const {\n PyObject* rslt = PyNumber_Xor(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for ^\");\n return lose_ref(rslt);\n };\n};\n\n} // namespace py\n\n#endif //NUMBER_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones\n*********************************************/\n#if !defined(NUMBER_H_INCLUDED_)\n#define NUMBER_H_INCLUDED_\n\n#include \"object.h\"\n#include \"sequence.h\"\n\nnamespace py {\n \nclass number : public object\n{\npublic:\n number() : object() {};\n number(int i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }\n number(long i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }\n number(unsigned long i) : object (PyLong_FromUnsignedLong(i)) { LoseRef(_obj); }\n number(double d) : object (PyFloat_FromDouble(d)) { LoseRef(_obj); }\n\n number(const number& other) : object(other) {};\n number(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n virtual ~number() {};\n\n virtual number& operator=(const number& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ number& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyNumber_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a number\");\n }\n };\n //PyNumber_Absolute\n number abs() const {\n PyObject* rslt = PyNumber_Absolute(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Failed to get absolute value\");\n return LoseRef(rslt);\n };\n //PyNumber_Add\n number operator+(const number& rhs) const {\n PyObject* rslt = PyNumber_Add(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for +\");\n return LoseRef(rslt);\n };\n //PyNumber_And\n number operator&(const number& rhs) const {\n PyObject* rslt = PyNumber_And(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for &\");\n return LoseRef(rslt);\n };\n //PyNumber_Coerce\n //PyNumber_Divide\n number operator/(const number& rhs) const {\n PyObject* rslt = PyNumber_Divide(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for /\");\n return LoseRef(rslt);\n };\n //PyNumber_Divmod\n sequence divmod(const number& rhs) const {\n PyObject* rslt = PyNumber_Divmod(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for divmod\");\n return LoseRef(rslt);\n };\n //PyNumber_Float\n operator double () const {\n PyObject* F = PyNumber_Float(_obj);\n if (F==0)\n Fail(PyExc_TypeError, \"Cannot convert to double\");\n double r = PyFloat_AS_DOUBLE(F);\n Py_DECREF(F);\n return r;\n };\n operator float () const {\n double rslt = (double) *this;\n //if (rslt > INT_MAX)\n // Fail(PyExc_TypeError, \"Cannot convert to a float\");\n return (float) rslt;\n };\n //PyNumber_Int\n operator long () const {\n PyObject* Int = PyNumber_Int(_obj);\n if (Int==0)\n Fail(PyExc_TypeError, \"Cannot convert to long\");\n long r = PyInt_AS_LONG(Int);\n Py_DECREF(Int);\n return r;\n };\n operator int () const {\n long rslt = (long) *this;\n if (rslt > INT_MAX)\n Fail(PyExc_TypeError, \"Cannot convert to an int\");\n return (int) rslt;\n };\n //PyNumber_Invert\n number operator~ () const {\n PyObject* rslt = PyNumber_Invert(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper type for ~\");\n return LoseRef(rslt);\n };\n //PyNumber_Long\n //PyNumber_Lshift\n number operator<<(const number& rhs) const {\n PyObject* rslt = PyNumber_Lshift(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for <<\");\n return LoseRef(rslt);\n };\n //PyNumber_Multiply\n number operator*(const number& rhs) const {\n PyObject* rslt = PyNumber_Multiply(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for *\");\n return LoseRef(rslt);\n };\n //PyNumber_Negative\n number operator- () const {\n PyObject* rslt = PyNumber_Negative(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper type for unary -\");\n return LoseRef(rslt);\n };\n //PyNumber_Or\n number operator|(const number& rhs) const {\n PyObject* rslt = PyNumber_Or(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for |\");\n return LoseRef(rslt);\n };\n //PyNumber_Positive\n number operator+ () const {\n PyObject* rslt = PyNumber_Positive(_obj);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper type for unary +\");\n return LoseRef(rslt);\n };\n //PyNumber_Remainder\n number operator%(const number& rhs) const {\n PyObject* rslt = PyNumber_Remainder(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for %\");\n return LoseRef(rslt);\n };\n //PyNumber_Rshift\n number operator>>(const number& rhs) const {\n PyObject* rslt = PyNumber_Rshift(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for >>\");\n return LoseRef(rslt);\n };\n //PyNumber_Subtract\n number operator-(const number& rhs) const {\n PyObject* rslt = PyNumber_Subtract(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for -\");\n return LoseRef(rslt);\n };\n //PyNumber_Xor\n number operator^(const number& rhs) const {\n PyObject* rslt = PyNumber_Xor(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for ^\");\n return LoseRef(rslt);\n };\n};\n\n} // namespace py\n\n#endif //NUMBER_H_INCLUDED_\n", "methods": [ { "name": "py::number::number", "long_name": "py::number::number()", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 18, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( int i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 12, "parameters": [ "i" ], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( long i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 12, "parameters": [ "i" ], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( unsigned long i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 13, "parameters": [ "i" ], "start_line": 21, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( double d)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 12, "parameters": [ "d" ], "start_line": 22, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( std :: complex & d)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 18, "parameters": [ "std" ], "start_line": 23, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( const number & other)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( PyObject * obj)", "filename": "number.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 26, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::number::~number", "long_name": "py::number::~number()", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 29, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator =", "long_name": "py::number::operator =( const number & other)", "filename": "number.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 31, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::number::operator =", "long_name": "py::number::operator =( const object & other)", "filename": "number.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 35, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::number::_violentTypeCheck", "long_name": "py::number::_violentTypeCheck()", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 40, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::abs", "long_name": "py::number::abs() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 47, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator +", "long_name": "py::number::operator +( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 54, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator &", "long_name": "py::number::operator &( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator /", "long_name": "py::number::operator /( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 69, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::divmod", "long_name": "py::number::divmod( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "rhs" ], "start_line": 76, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator double", "long_name": "py::number::operator double() const", "filename": "number.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 83, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::number::operator float", "long_name": "py::number::operator float() const", "filename": "number.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator long", "long_name": "py::number::operator long() const", "filename": "number.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 98, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::number::operator int", "long_name": "py::number::operator int() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 106, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator ~ ", "long_name": "py::number::operator ~ () const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 113, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator < <", "long_name": "py::number::operator < <( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 121, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator *", "long_name": "py::number::operator *( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 128, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator -", "long_name": "py::number::operator -() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 135, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator |", "long_name": "py::number::operator |( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 142, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator +", "long_name": "py::number::operator +() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 149, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator %", "long_name": "py::number::operator %( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 156, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator > >", "long_name": "py::number::operator > >( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 163, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator -", "long_name": "py::number::operator -( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 170, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator ^", "long_name": "py::number::operator ^( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 177, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::number::number", "long_name": "py::number::number()", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 18, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( int i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "i" ], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( long i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "i" ], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( unsigned long i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 21, "parameters": [ "i" ], "start_line": 21, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( double d)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 20, "parameters": [ "d" ], "start_line": 22, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( const number & other)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( PyObject * obj)", "filename": "number.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 25, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::number::~number", "long_name": "py::number::~number()", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 28, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator =", "long_name": "py::number::operator =( const number & other)", "filename": "number.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::number::operator =", "long_name": "py::number::operator =( const object & other)", "filename": "number.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 34, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::number::_violentTypeCheck", "long_name": "py::number::_violentTypeCheck()", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 39, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::abs", "long_name": "py::number::abs() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 46, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator +", "long_name": "py::number::operator +( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 53, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator &", "long_name": "py::number::operator &( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 60, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator /", "long_name": "py::number::operator /( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 68, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::divmod", "long_name": "py::number::divmod( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "rhs" ], "start_line": 75, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator double", "long_name": "py::number::operator double() const", "filename": "number.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 82, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::number::operator float", "long_name": "py::number::operator float() const", "filename": "number.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 90, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator long", "long_name": "py::number::operator long() const", "filename": "number.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 97, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::number::operator int", "long_name": "py::number::operator int() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 105, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator ~ ", "long_name": "py::number::operator ~ () const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator < <", "long_name": "py::number::operator < <( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 120, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator *", "long_name": "py::number::operator *( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 127, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator -", "long_name": "py::number::operator -() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 134, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator |", "long_name": "py::number::operator |( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 141, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator +", "long_name": "py::number::operator +() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 148, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator %", "long_name": "py::number::operator %( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 155, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator > >", "long_name": "py::number::operator > >( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 162, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator -", "long_name": "py::number::operator -( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 169, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator ^", "long_name": "py::number::operator ^( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 176, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::number::number", "long_name": "py::number::number( int i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 12, "parameters": [ "i" ], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator ~ ", "long_name": "py::number::operator ~ () const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 113, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator int", "long_name": "py::number::operator int() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 106, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator ^", "long_name": "py::number::operator ^( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 177, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( long i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 12, "parameters": [ "i" ], "start_line": 20, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator =", "long_name": "py::number::operator =( const number & other)", "filename": "number.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 31, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( double d)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 12, "parameters": [ "d" ], "start_line": 22, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator +", "long_name": "py::number::operator +() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 149, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator > >", "long_name": "py::number::operator > >( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 163, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator +", "long_name": "py::number::operator +( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 54, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator *", "long_name": "py::number::operator *( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 128, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::divmod", "long_name": "py::number::divmod( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "rhs" ], "start_line": 76, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator /", "long_name": "py::number::operator /( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 69, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator float", "long_name": "py::number::operator float() const", "filename": "number.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator %", "long_name": "py::number::operator %( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 156, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator &", "long_name": "py::number::operator &( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator |", "long_name": "py::number::operator |( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 142, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator -", "long_name": "py::number::operator -() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 135, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::_violentTypeCheck", "long_name": "py::number::_violentTypeCheck()", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 40, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator double", "long_name": "py::number::operator double() const", "filename": "number.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 83, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::number::operator -", "long_name": "py::number::operator -( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 170, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( std :: complex & d)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 18, "parameters": [ "std" ], "start_line": 23, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::number", "long_name": "py::number::number( unsigned long i)", "filename": "number.h", "nloc": 1, "complexity": 1, "token_count": 13, "parameters": [ "i" ], "start_line": 21, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::number::operator =", "long_name": "py::number::operator =( const object & other)", "filename": "number.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 35, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::number::operator < <", "long_name": "py::number::operator < <( const number & rhs) const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "rhs" ], "start_line": 121, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::abs", "long_name": "py::number::abs() const", "filename": "number.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 47, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::number::operator long", "long_name": "py::number::operator long() const", "filename": "number.h", "nloc": 8, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 98, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 } ], "nloc": 150, "complexity": 50, "token_count": 990, "diff_parsed": { "added": [ " number(int i) : object(i) {};", " number(long i) : object(i) {};", " number(unsigned long i) : object(i) {};", " number(double d) : object(d) {}", " number(std::complex& d) : object(d) {};", " grab_ref(other);", " grab_ref(other);", " grab_ref(0);", " fail(PyExc_TypeError, \"Not a number\");", " fail(PyExc_TypeError, \"failed to get absolute value\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for +\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for &\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for /\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for divmod\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Cannot convert to double\");", " // fail(PyExc_TypeError, \"Cannot convert to a float\");", " fail(PyExc_TypeError, \"Cannot convert to long\");", " fail(PyExc_TypeError, \"Cannot convert to an int\");", " fail(PyExc_TypeError, \"Improper type for ~\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for <<\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for *\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper type for unary -\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for |\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper type for unary +\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for %\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for >>\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for -\");", " return lose_ref(rslt);", " fail(PyExc_TypeError, \"Improper rhs for ^\");", " return lose_ref(rslt);" ], "deleted": [ " number(int i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }", " number(long i) : object (PyInt_FromLong(i)) { LoseRef(_obj); }", " number(unsigned long i) : object (PyLong_FromUnsignedLong(i)) { LoseRef(_obj); }", " number(double d) : object (PyFloat_FromDouble(d)) { LoseRef(_obj); }", " GrabRef(other);", " GrabRef(other);", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a number\");", " Fail(PyExc_TypeError, \"Failed to get absolute value\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for +\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for &\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for /\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for divmod\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Cannot convert to double\");", " // Fail(PyExc_TypeError, \"Cannot convert to a float\");", " Fail(PyExc_TypeError, \"Cannot convert to long\");", " Fail(PyExc_TypeError, \"Cannot convert to an int\");", " Fail(PyExc_TypeError, \"Improper type for ~\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for <<\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for *\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper type for unary -\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for |\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper type for unary +\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for %\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for >>\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for -\");", " return LoseRef(rslt);", " Fail(PyExc_TypeError, \"Improper rhs for ^\");", " return LoseRef(rslt);" ] } }, { "old_path": "weave/scxx/object.h", "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -2,7 +2,7 @@\n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n- modified heavily for weave by eric jones.\n+ modified for weave by eric jones.\n *********************************************/\n \n #if !defined(OBJECT_H_INCLUDED_)\n@@ -18,89 +18,102 @@\n \n namespace py {\n \n-void Fail(PyObject*, const char* msg);\n+void fail(PyObject*, const char* msg);\n \n-// used in method call specification.\n-class tuple;\n-class dict;\n+//---------------------------------------------------------------------------\n+// py::object -- A simple C++ interface to Python objects.\n+//\n+// This is the basic type from which all others are derived from. It is \n+// also quite useful on its own. The class is very light weight as far as\n+// data contents, carrying around only two python pointers.\n+//---------------------------------------------------------------------------\n \n class object \n {\n protected:\n+\n+ //-------------------------------------------------------------------------\n+ // _obj is the underlying pointer to the real python object.\n+ //-------------------------------------------------------------------------\n PyObject* _obj;\n \n- // incref new owner, decref old owner, and adjust to new owner\n- void GrabRef(PyObject* newObj);\n- // decrease reference count without destroying the object\n- static PyObject* LoseRef(PyObject* o)\n+ //-------------------------------------------------------------------------\n+ // grab_ref (rename to grab_ref)\n+ //\n+ // incref new owner, decref old owner, and adjust to new owner\n+ //-------------------------------------------------------------------------\n+ void grab_ref(PyObject* newObj) {\n+ // be careful to incref before decref if old is same as new\n+ Py_XINCREF(newObj);\n+ Py_XDECREF(_own);\n+ _own = _obj = newObj;\n+ };\n+\n+ //-------------------------------------------------------------------------\n+ // lose_ref (rename to lose_ref)\n+ //\n+ // decrease reference count without destroying the object.\n+ //-------------------------------------------------------------------------\n+ static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n \n private:\n- PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n+ //-------------------------------------------------------------------------\n+ // _own is set to _obj if we \"own\" a reference to _obj, else zero\n+ //-------------------------------------------------------------------------\n+ PyObject* _own; \n \n public:\n+ //-------------------------------------------------------------------------\n+ // forward declaration of reference obj returned when [] used as an lvalue.\n+ //-------------------------------------------------------------------------\n+ class keyed_ref; \n+\n object()\n- : _obj (0), _own (0) { }\n+ : _obj (0), _own (0) { };\n object(const object& other)\n- : _obj (0), _own (0) { GrabRef(other); }\n+ : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n- : _obj (0), _own (0) { \n- //std::cout << \"construct before: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;\n- GrabRef(obj); \n- //std::cout << \"construct after: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;\n- }\n+ : _obj (0), _own (0) { grab_ref(obj); };\n \n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n- /*\n- object(bool val) : _obj (0), _own (0) { \n- GrabRef(PyInt_FromLong((int)val)); \n- LoseRef(_obj); \n+ object(bool val) { \n+ _obj = _own = PyInt_FromLong((int)val); \n };\n- */\n- object(int val) : _obj (0), _own (0) { \n- GrabRef(PyInt_FromLong(val)); \n- LoseRef(_obj); \n+ object(int val) { \n+ _obj = _own = PyInt_FromLong((int)val); \n };\n- object(long val) : _obj (0), _own (0) { \n- GrabRef(PyInt_FromLong(val)); \n- LoseRef(_obj); \n+ object(long val) { \n+ _obj = _own = PyInt_FromLong((int)val); \n }; \n- object(unsigned long val) : _obj (0), _own (0) { \n- GrabRef(PyLong_FromUnsignedLong(val)); \n- LoseRef(_obj); \n+ object(unsigned long val) { \n+ _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n- object(double val) : _obj (0), _own (0) { \n- GrabRef(PyFloat_FromDouble(val)); \n- LoseRef(_obj); \n+ object(double val) {\n+ _obj = _own = PyFloat_FromDouble(val); \n };\n- object(std::complex& val) : _obj (0), _own (0) { \n- GrabRef(PyComplex_FromDoubles(val.real(),val.imag())); \n- LoseRef(_obj); \n+ object(const std::complex& val) { \n+ _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n- object(char* val) : _obj (0), _own (0) { \n- GrabRef(PyString_FromString(val)); \n- LoseRef(_obj); \n+ object(const char* val) {\n+ _obj = _own = PyString_FromString((char*) val); \n };\n- object(std::string& val) : _obj (0), _own (0) { \n- GrabRef(PyString_FromString((char*)val.c_str())); \n- LoseRef(_obj); \n+ object(const std::string& val) : _obj (0), _own (0) { \n+ _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n- virtual ~object()\n- { \n- //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;\n- Py_XDECREF(_own); \n- //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;\n- } \n+ virtual ~object() { \n+ Py_XDECREF(_own); \n+ };\n \n //-------------------------------------------------------------------------\n // casting operators\n@@ -111,33 +124,33 @@ public:\n \n operator int () const {\n if (!PyInt_Check(_obj))\n- Fail(PyExc_TypeError, \"cannot convert value to integer\");\n+ fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n- Fail(PyExc_TypeError, \"cannot convert value to float\");\n+ fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n- Fail(PyExc_TypeError, \"cannot convert value to double\");\n+ fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n- Fail(PyExc_TypeError, \"cannot convert value to complex\");\n+ fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n- Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n+ fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n- Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n+ fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n@@ -145,17 +158,26 @@ public:\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n- GrabRef(other);\n+ grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n- // !! UNTESTED\n+ // This needs to become more sophisticated and handle objects that \n+ // implement the file protocol.\n //-------------------------------------------------------------------------\n- int print(FILE *f, int flags) const {\n- return PyObject_Print(_obj, f, flags);\n+ void print(FILE* f, int flags=0) const {\n+ int res = PyObject_Print(_obj, f, flags);\n+ if (res == -1)\n+ throw 1;\n+ };\n+\n+ void print(object f, int flags=0) const {\n+ int res = PyFile_WriteObject(_obj, f, flags);\n+ if (res == -1)\n+ throw 1;\n };\n \n //-------------------------------------------------------------------------\n@@ -164,23 +186,25 @@ public:\n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n- int hasattr(std::string nm) const {\n+ int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n+ int hasattr(object& nm) const {\n+ return PyObject_HasAttr(_obj, nm) == 1;\n+ };\n+ \n \n //-------------------------------------------------------------------------\n- // attribute access\n- //\n- // should this return a reference? Need to think about this.\n+ // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n- return object(LoseRef(val)); \n+ return object(lose_ref(val)); \n };\n \n- object attr(std::string nm) const {\n+ object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n \n@@ -188,18 +212,26 @@ public:\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n- return object(LoseRef(val)); \n+ return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n- // !! NOT TESTED\n+ //\n+ // There is a combinatorial explosion here of function combinations.\n+ // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n+\n+ void set_attr(const std::string& nm, object& val) {\n+ int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n+ if (res == -1)\n+ throw 1;\n+ };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n@@ -207,52 +239,158 @@ public:\n throw 1;\n };\n \n- //-------------------------------------------------------------------------\n- // calling methods\n- //-------------------------------------------------------------------------\n- object mcall(const char* nm);\n- object mcall(const char* nm, tuple& args);\n- object mcall(const char* nm, tuple& args, dict& kwargs);\n+ ////////////// int //////////////\n+ void set_attr(const char* nm, int val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n \n- object mcall(std::string nm) {\n- return mcall(nm.c_str());\n- }\n- object mcall(std::string nm, tuple& args) {\n- return mcall(nm.c_str(),args);\n- }\n- object mcall(std::string nm, tuple& args, dict& kwargs) {\n- return mcall(nm.c_str(),args,kwargs);\n- }\n+ void set_attr(const std::string& nm, int val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+ \n+ void set_attr(const object& nm, int val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttr(_obj, nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+ \n+ ////////////// unsigned long //////////////\n+ void set_attr(const char* nm, unsigned long val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n \n- //-------------------------------------------------------------------------\n- // calling callable objects\n- //-------------------------------------------------------------------------\n- object call() const;\n- object call(tuple& args) const;\n- object call(tuple& args, dict& kws) const;\n+ void set_attr(const std::string& nm, unsigned long val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+ \n+ void set_attr(const object& nm, unsigned long val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttr(_obj, nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n \n- //-------------------------------------------------------------------------\n- // sequence methods\n- // !! NOT TESTED\n- //-------------------------------------------------------------------------\n+ ////////////// double //////////////\n+ void set_attr(const char* nm, double val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n \n- //-------------------------------------------------------------------------\n- // iter methods\n- // !! NOT TESTED\n- //-------------------------------------------------------------------------\n+ void set_attr(const std::string& nm, double val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+ \n+ void set_attr(const object& nm, double val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttr(_obj, nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+\n+ ////////////// complex //////////////\n+ void set_attr(const char* nm, const std::complex& val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n \n+ void set_attr(const std::string& nm, const std::complex& val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+ \n+ void set_attr(const object& nm, const std::complex& val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttr(_obj, nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+ \n+ ////////////// char* //////////////\n+ void set_attr(const char* nm, const char* val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+\n+ void set_attr(const std::string& nm, const char* val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+ \n+ void set_attr(const object& nm, const char* val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttr(_obj, nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+\n+ ////////////// std::string //////////////\n+ void set_attr(const char* nm, const std::string& val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+\n+ void set_attr(const std::string& nm, const std::string& val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+ \n+ void set_attr(const object& nm, const std::string& val) {\n+ py::object _val = py::object(val);\n+ int res = PyObject_SetAttr(_obj, nm, _val);\n+ if (res == -1)\n+ throw 1;\n+ };\n+ \n //-------------------------------------------------------------------------\n- // del objects\n- // !! NOT TESTED\n+ // del attributes/methods from object\n //-------------------------------------------------------------------------\n- int del(const char* nm) {\n- return PyObject_DelAttrString(_obj, (char*) nm);\n+ void del(const char* nm) {\n+ int result = PyObject_DelAttrString(_obj, (char*) nm);\n+ if (result == -1)\n+ throw 1;\n+ };\n+ void del(const std::string& nm) {\n+ int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n+ if (result == -1)\n+ throw 1;\n };\n- int del(const object& nm) {\n- return PyObject_DelAttr(_obj, nm);\n+ void del(const object& nm) {\n+ int result = PyObject_DelAttr(_obj, nm);\n+ if (result ==-1)\n+ throw 1;\n };\n \n- //-------------------------------------------------------------------------\n+ //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n@@ -260,54 +398,407 @@ public:\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n- Fail(PyExc_TypeError, \"cannot make the comparison\");\n+ fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n+ int cmp(int other) const {\n+ object _other = object(other);\n+ return cmp(_other);\n+ }; \n+ int cmp(unsigned long other) const {\n+ object _other = object(other);\n+ return cmp(_other);\n+ };\n+ int cmp(double other) const {\n+ object _other = object(other);\n+ return cmp(_other);\n+ };\n+ int cmp(const std::complex& other) const {\n+ object _other = object(other);\n+ return cmp(_other);\n+ };\n+ \n+ int cmp(const char* other) const {\n+ object _other = object((char*)other);\n+ return cmp(_other);\n+ };\n+ \n+ int cmp(const std::string& other) const {\n+ object _other = object(other);\n+ return cmp(_other);\n+ };\n+ \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n+ bool operator == (int other) const {\n+ return cmp(other) == 0;\n+ };\n+ bool operator == (unsigned long other) const {\n+ return cmp(other) == 0;\n+ };\n+ bool operator == (double other) const {\n+ return cmp(other) == 0;\n+ };\n+ bool operator == (const std::complex& other) const {\n+ return cmp(other) == 0;\n+ };\n+ bool operator == (const std::string& other) const {\n+ return cmp(other) == 0;\n+ };\n+ bool operator == (const char* other) const {\n+ return cmp(other) == 0;\n+ };\n+\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n- bool operator > (const object& other) const {\n- return cmp(other) > 0;\n+ bool operator != (int other) const {\n+ return cmp(other) != 0;\n };\n+ bool operator != (unsigned long other) const {\n+ return cmp(other) != 0;\n+ };\n+ bool operator != (double other) const {\n+ return cmp(other) != 0;\n+ };\n+ bool operator != (const std::complex& other) const {\n+ return cmp(other) != 0;\n+ };\n+ bool operator != (const std::string& other) const {\n+ return cmp(other) != 0;\n+ };\n+ bool operator != (const char* other) const {\n+ return cmp(other) != 0;\n+ };\n+ \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n+ bool operator < (int other) const {\n+ return cmp(other) < 0;\n+ };\n+ bool operator < (unsigned long other) const {\n+ return cmp(other) < 0;\n+ };\n+ bool operator < (double other) const {\n+ return cmp(other) < 0;\n+ };\n+ bool operator < (const std::complex& other) const {\n+ return cmp(other) < 0;\n+ };\n+ bool operator < (const std::string& other) const {\n+ return cmp(other) < 0;\n+ };\n+ bool operator < (const char* other) const {\n+ return cmp(other) < 0;\n+ };\n+ \n+ bool operator > (const object& other) const {\n+ return cmp(other) > 0;\n+ };\n+ bool operator > (int other) const {\n+ return cmp(other) > 0;\n+ };\n+ bool operator > (unsigned long other) const {\n+ return cmp(other) > 0;\n+ };\n+ bool operator > (double other) const {\n+ return cmp(other) > 0;\n+ };\n+ bool operator > (const std::complex& other) const {\n+ return cmp(other) > 0;\n+ };\n+ bool operator > (const std::string& other) const {\n+ return cmp(other) > 0;\n+ };\n+ bool operator > (const char* other) const {\n+ return cmp(other) > 0;\n+ };\n+\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n+ bool operator >= (int other) const {\n+ return cmp(other) >= 0;\n+ };\n+ bool operator >= (unsigned long other) const {\n+ return cmp(other) >= 0;\n+ };\n+ bool operator >= (double other) const {\n+ return cmp(other) >= 0;\n+ };\n+ bool operator >= (const std::complex& other) const {\n+ return cmp(other) >= 0;\n+ };\n+ bool operator >= (const std::string& other) const {\n+ return cmp(other) >= 0;\n+ };\n+ bool operator >= (const char* other) const {\n+ return cmp(other) >= 0;\n+ };\n+ \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n- \n- PyObject* repr() const {\n- return LoseRef(PyObject_Repr(_obj));\n+ bool operator <= (int other) const {\n+ return cmp(other) <= 0;\n+ };\n+ bool operator <= (unsigned long other) const {\n+ return cmp(other) <= 0;\n+ };\n+ bool operator <= (double other) const {\n+ return cmp(other) <= 0;\n+ };\n+ bool operator <= (const std::complex& other) const {\n+ return cmp(other) <= 0;\n+ };\n+ bool operator <= (const std::string& other) const {\n+ return cmp(other) <= 0;\n+ };\n+ bool operator <= (const char* other) const {\n+ return cmp(other) <= 0;\n };\n- /*\n- PyObject* str() const {\n- return LoseRef(PyObject_Str(_obj));\n+\n+ //-------------------------------------------------------------------------\n+ // string representations\n+ //-------------------------------------------------------------------------\n+ object repr() const { \n+ object result = PyObject_Repr(_obj);\n+ if (!(PyObject*)result)\n+ throw 1;\n+ lose_ref(result); \n+ return result;\n+ };\n+ \n+ object str() const {\n+ object result = PyObject_Str(_obj);\n+ if (!(PyObject*)result)\n+ throw 1;\n+ lose_ref(result); \n+ return result;\n+ };\n+\n+ // !! Not Tested \n+ object unicode() const {\n+ object result = PyObject_Unicode(_obj);\n+ if (!(PyObject*)result)\n+ throw 1;\n+ lose_ref(result); \n+ return result;\n };\n- */\n+ \n+ //-------------------------------------------------------------------------\n+ // calling methods on object\n+ //\n+ // Note: I changed args_tup from a tuple& to a object& so that it could\n+ // be inlined instead of implemented i weave_imp.cpp. This \n+ // provides less automatic type checking, but is potentially faster.\n+ //-------------------------------------------------------------------------\n+ object object::mcall(const char* nm) {\n+ object method = attr(nm);\n+ PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n+ if (!result)\n+ throw 1; // signal exception has occured.\n+ return object(lose_ref(result));\n+ }\n+ \n+ object object::mcall(const char* nm, object& args_tup) {\n+ object method = attr(nm);\n+ PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n+ if (!result)\n+ throw 1; // signal exception has occured.\n+ return object(lose_ref(result));\n+ }\n+ \n+ object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n+ object method = attr(nm);\n+ PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n+ if (!result)\n+ throw 1; // signal exception has occured.\n+ return object(lose_ref(result));\n+ }\n+\n+ object mcall(const std::string& nm) {\n+ return mcall(nm.c_str());\n+ }\n+ object mcall(const std::string& nm, object& args_tup) {\n+ return mcall(nm.c_str(),args_tup);\n+ }\n+ object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n+ return mcall(nm.c_str(),args_tup,kw_dict);\n+ }\n+\n+ //-------------------------------------------------------------------------\n+ // calling callable objects\n+ //\n+ // Note: see not on mcall()\n+ //-------------------------------------------------------------------------\n+ object object::call() const {\n+ PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n+ if (rslt == 0)\n+ throw 1;\n+ return object(lose_ref(rslt));\n+ }\n+ object object::call(object& args_tup) const {\n+ PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n+ if (rslt == 0)\n+ throw 1;\n+ return object(lose_ref(rslt));\n+ }\n+ object object::call(object& args_tup, object& kw_dict) const {\n+ PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n+ if (rslt == 0)\n+ throw 1;\n+ return object(lose_ref(rslt));\n+ }\n+\n+ //-------------------------------------------------------------------------\n+ // check if object is callable\n+ //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n+\n+ //-------------------------------------------------------------------------\n+ // retreive the objects hash value\n+ //-------------------------------------------------------------------------\n int hash() const {\n- return PyObject_Hash(_obj);\n+ int result = PyObject_Hash(_obj);\n+ if (result == -1 && PyErr_Occurred())\n+ throw 1;\n+ return result; \n };\n+ \n+ //-------------------------------------------------------------------------\n+ // test whether object is true\n+ //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n+ \n+ //-------------------------------------------------------------------------\n+ // test whether object is not true\n+ //-------------------------------------------------------------------------\n+ bool not() const {\n+ return PyObject_Not(_obj) == 1;\n+ };\n+ \n+ //-------------------------------------------------------------------------\n+ // return the variable type for the object\n+ //-------------------------------------------------------------------------\n PyObject* type() const {\n- return LoseRef(PyObject_Type(_obj));\n+ PyObject* result = PyObject_Type(_obj);\n+ if (!result)\n+ throw 1;\n+ return lose_ref(result);\n+ };\n+\n+ //-------------------------------------------------------------------------\n+ // size, len, and length are all synonyms.\n+ // \n+ // length() is useful because it allows the same code to work with STL \n+ // strings as works with py::objects.\n+ //-------------------------------------------------------------------------\n+ int size() const {\n+ int result = PyObject_Size(_obj);\n+ if (result == -1)\n+ throw 1;\n+ return result;\n };\n+ int len() const {\n+ return size();\n+ };\n+ int length() const {\n+ return size();\n+ };\n+\n+ //-------------------------------------------------------------------------\n+ // set_item \n+ //\n+ // To prevent a combonatorial explosion, only objects are allowed for keys.\n+ // Users are encouraged to use the [] interface for setting values.\n+ //------------------------------------------------------------------------- \n+ virtual void set_item(const object& key, const object& val) {\n+ int rslt = PyObject_SetItem(_obj, key, val);\n+ if (rslt==-1)\n+ throw 1;\n+ };\n+\n+ //-------------------------------------------------------------------------\n+ // operator[] \n+ //-------------------------------------------------------------------------\n+ // !! defined in weave_imp.cpp\n+ // !! I'd like to refactor things so that they can be defined here.\n+ keyed_ref operator [] (object& key);\n+ keyed_ref operator [] (const char* key);\n+ keyed_ref operator [] (const std::string& key);\n+ keyed_ref operator [] (int key);\n+ keyed_ref operator [] (double key);\n+ keyed_ref operator [] (const std::complex& key);\n+ \n+ //-------------------------------------------------------------------------\n+ // iter methods\n+ // !! NOT TESTED\n+ //-------------------------------------------------------------------------\n+ \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n+ \n+ int refcount() {\n+ return _obj->ob_refcnt;\n+ }\n };\n \n+//---------------------------------------------------------------------------\n+// keyed_ref\n+//\n+// Provides a reference value when operator[] returns an lvalue. The \n+// reference has to keep track of its parent object and its key in the parent\n+// object so that it can insert a new value into the parent at the \n+// appropriate place when a new value is assigned to the keyed_ref object.\n+//\n+// The keyed_ref class is also used by the py::dict class derived from \n+// py::object\n+// !! Note: Need to check ref counting on key and parent here.\n+//---------------------------------------------------------------------------\n+class object::keyed_ref : public object\n+{\n+ object& _parent;\n+ object _key;\n+public:\n+ keyed_ref(object obj, object& parent, object& key)\n+ : object(obj), _parent(parent), _key(key) {}; \n+ virtual ~keyed_ref() {};\n+\n+ keyed_ref& operator=(const object& other) {\n+ grab_ref(other);\n+ _parent.set_item(_key, other);\n+ return *this;\n+ }\n+ keyed_ref& operator=(int other) {\n+ object _other = object(other);\n+ return operator=(_other);\n+ } \n+ keyed_ref& operator=(double other) {\n+ object _other = object(other);\n+ return operator=(_other);\n+ }\n+ keyed_ref& operator=(const std::complex& other) {\n+ object _other = object(other);\n+ return operator=(_other);\n+ }\n+ keyed_ref& operator=(const char* other) {\n+ object _other = object(other);\n+ return operator=(_other);\n+ }\n+ keyed_ref& operator=(const std::string& other) {\n+ object _other = object(other);\n+ return operator=(_other);\n+ }\n+};\n } // namespace\n \n #endif // !defined(OBJECT_H_INCLUDED_)\n", "added_lines": 606, "deleted_lines": 115, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //-------------------------------------------------------------------------\n object repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n object str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n bool not() const {\n return PyObject_Not(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n PyObject* type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified heavily for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid Fail(PyObject*, const char* msg);\n\n// used in method call specification.\nclass tuple;\nclass dict;\n \nclass object \n{\nprotected:\n PyObject* _obj;\n\n // incref new owner, decref old owner, and adjust to new owner\n void GrabRef(PyObject* newObj);\n // decrease reference count without destroying the object\n static PyObject* LoseRef(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero\n\npublic:\n object()\n : _obj (0), _own (0) { }\n object(const object& other)\n : _obj (0), _own (0) { GrabRef(other); }\n object(PyObject* obj)\n : _obj (0), _own (0) { \n //std::cout << \"construct before: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;\n GrabRef(obj); \n //std::cout << \"construct after: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;\n }\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n /*\n object(bool val) : _obj (0), _own (0) { \n GrabRef(PyInt_FromLong((int)val)); \n LoseRef(_obj); \n };\n */\n object(int val) : _obj (0), _own (0) { \n GrabRef(PyInt_FromLong(val)); \n LoseRef(_obj); \n };\n object(long val) : _obj (0), _own (0) { \n GrabRef(PyInt_FromLong(val)); \n LoseRef(_obj); \n }; \n object(unsigned long val) : _obj (0), _own (0) { \n GrabRef(PyLong_FromUnsignedLong(val)); \n LoseRef(_obj); \n }; \n object(double val) : _obj (0), _own (0) { \n GrabRef(PyFloat_FromDouble(val)); \n LoseRef(_obj); \n };\n object(std::complex& val) : _obj (0), _own (0) { \n GrabRef(PyComplex_FromDoubles(val.real(),val.imag())); \n LoseRef(_obj); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(char* val) : _obj (0), _own (0) { \n GrabRef(PyString_FromString(val)); \n LoseRef(_obj); \n };\n object(std::string& val) : _obj (0), _own (0) { \n GrabRef(PyString_FromString((char*)val.c_str())); \n LoseRef(_obj); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object()\n { \n //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;\n Py_XDECREF(_own); \n //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;\n } \n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n Fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n GrabRef(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // !! UNTESTED\n //-------------------------------------------------------------------------\n int print(FILE *f, int flags) const {\n return PyObject_Print(_obj, f, flags);\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(std::string nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n\n //-------------------------------------------------------------------------\n // attribute access\n //\n // should this return a reference? Need to think about this.\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n };\n\n object attr(std::string nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(LoseRef(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // calling methods\n //-------------------------------------------------------------------------\n object mcall(const char* nm);\n object mcall(const char* nm, tuple& args);\n object mcall(const char* nm, tuple& args, dict& kwargs);\n\n object mcall(std::string nm) {\n return mcall(nm.c_str());\n }\n object mcall(std::string nm, tuple& args) {\n return mcall(nm.c_str(),args);\n }\n object mcall(std::string nm, tuple& args, dict& kwargs) {\n return mcall(nm.c_str(),args,kwargs);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //-------------------------------------------------------------------------\n object call() const;\n object call(tuple& args) const;\n object call(tuple& args, dict& kws) const;\n\n //-------------------------------------------------------------------------\n // sequence methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n\n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n\n //-------------------------------------------------------------------------\n // del objects\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int del(const char* nm) {\n return PyObject_DelAttrString(_obj, (char*) nm);\n };\n int del(const object& nm) {\n return PyObject_DelAttr(_obj, nm);\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n Fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n \n PyObject* repr() const {\n return LoseRef(PyObject_Repr(_obj));\n };\n /*\n PyObject* str() const {\n return LoseRef(PyObject_Str(_obj));\n };\n */\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n int hash() const {\n return PyObject_Hash(_obj);\n };\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n PyObject* type() const {\n return LoseRef(PyObject_Type(_obj));\n };\n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n};\n\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "methods": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 140, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 146, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 160, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 186, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 207, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 224, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 243, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 250, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 265, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 272, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 279, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 287, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 301, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 309, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 316, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 323, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 353, "end_line": 358, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 360, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 367, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 377, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 382, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 387, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 397, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 408, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 412, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 416, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 421, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 453, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 475, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 497, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 519, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 566, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 574, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 583, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 598, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 606, "end_line": 612, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 614, "end_line": 620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 622, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 625, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 628, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 637, "end_line": 642, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 649, "end_line": 654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 659, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 666, "end_line": 671, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 676, "end_line": 678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::not", "long_name": "py::object::not() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 683, "end_line": 685, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 690, "end_line": 695, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 703, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 722, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 745, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 750, "end_line": 752, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 772, "end_line": 773, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 774, "end_line": 774, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 776, "end_line": 780, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 781, "end_line": 784, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 785, "end_line": 788, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 789, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 793, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 797, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 35, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 42, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 44, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 46, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "val" ], "start_line": 62, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "val" ], "start_line": 66, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "val" ], "start_line": 70, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "val" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( std :: complex & val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "std" ], "start_line": 78, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( char * val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "val" ], "start_line": 86, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( std :: string & val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "std" ], "start_line": 90, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 98, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 108, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 112, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 117, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 122, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 127, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 133, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 147, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 157, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 176, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "std" ], "start_line": 183, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 187, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 198, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 204, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std", "args" ], "start_line": 220, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args , dict & kwargs)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "std", "args", "kwargs" ], "start_line": 223, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "nm" ], "start_line": 248, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "nm" ], "start_line": 251, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 259, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 272, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 275, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 278, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 281, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 285, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 293, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 296, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 299, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 302, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 305, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 625, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 382, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 649, "end_line": 654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( char * val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "val" ], "start_line": 86, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 789, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 606, "end_line": 612, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 703, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 140, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 690, "end_line": 695, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 785, "end_line": 788, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 781, "end_line": 784, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 574, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 360, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 207, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 146, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( std :: string & val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "std" ], "start_line": 90, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 387, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( std :: complex & val)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "std" ], "start_line": 78, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 628, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 408, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 397, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 598, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 265, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 377, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args , dict & kwargs)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "std", "args", "kwargs" ], "start_line": 223, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 250, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::LoseRef", "long_name": "py::object::LoseRef( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 35, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 793, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 797, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 583, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 323, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 614, "end_line": 620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 774, "end_line": 774, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 412, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::not", "long_name": "py::object::not() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 683, "end_line": 685, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( std :: string nm , tuple & args)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std", "args" ], "start_line": 220, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 353, "end_line": 358, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 421, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 637, "end_line": 642, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 722, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 772, "end_line": 773, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 160, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 566, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 279, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 416, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 309, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( std :: string nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "std" ], "start_line": 183, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 287, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 666, "end_line": 671, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 622, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "f", "flags" ], "start_line": 157, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 301, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 243, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 316, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 750, "end_line": 752, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 367, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 497, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 776, "end_line": 780, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 272, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 } ], "nloc": 578, "complexity": 184, "token_count": 4206, "diff_parsed": { "added": [ " modified for weave by eric jones.", "void fail(PyObject*, const char* msg);", "//---------------------------------------------------------------------------", "// py::object -- A simple C++ interface to Python objects.", "//", "// This is the basic type from which all others are derived from. It is", "// also quite useful on its own. The class is very light weight as far as", "// data contents, carrying around only two python pointers.", "//---------------------------------------------------------------------------", "", " //-------------------------------------------------------------------------", " // _obj is the underlying pointer to the real python object.", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // grab_ref (rename to grab_ref)", " //", " // incref new owner, decref old owner, and adjust to new owner", " //-------------------------------------------------------------------------", " void grab_ref(PyObject* newObj) {", " // be careful to incref before decref if old is same as new", " Py_XINCREF(newObj);", " Py_XDECREF(_own);", " _own = _obj = newObj;", " };", "", " //-------------------------------------------------------------------------", " // lose_ref (rename to lose_ref)", " //", " // decrease reference count without destroying the object.", " //-------------------------------------------------------------------------", " static PyObject* lose_ref(PyObject* o)", " //-------------------------------------------------------------------------", " // _own is set to _obj if we \"own\" a reference to _obj, else zero", " //-------------------------------------------------------------------------", " PyObject* _own;", " //-------------------------------------------------------------------------", " // forward declaration of reference obj returned when [] used as an lvalue.", " //-------------------------------------------------------------------------", " class keyed_ref;", "", " : _obj (0), _own (0) { };", " : _obj (0), _own (0) { grab_ref(other); };", " : _obj (0), _own (0) { grab_ref(obj); };", " object(bool val) {", " _obj = _own = PyInt_FromLong((int)val);", " object(int val) {", " _obj = _own = PyInt_FromLong((int)val);", " object(long val) {", " _obj = _own = PyInt_FromLong((int)val);", " object(unsigned long val) {", " _obj = _own = PyLong_FromUnsignedLong(val);", " object(double val) {", " _obj = _own = PyFloat_FromDouble(val);", " object(const std::complex& val) {", " _obj = _own = PyComplex_FromDoubles(val.real(),val.imag());", " object(const char* val) {", " _obj = _own = PyString_FromString((char*) val);", " object(const std::string& val) : _obj (0), _own (0) {", " _obj = _own = PyString_FromString((char*)val.c_str());", " virtual ~object() {", " Py_XDECREF(_own);", " };", " fail(PyExc_TypeError, \"cannot convert value to integer\");", " fail(PyExc_TypeError, \"cannot convert value to float\");", " fail(PyExc_TypeError, \"cannot convert value to double\");", " fail(PyExc_TypeError, \"cannot convert value to complex\");", " fail(PyExc_TypeError, \"cannot convert value to std::string\");", " fail(PyExc_TypeError, \"cannot convert value to char*\");", " grab_ref(other);", " // This needs to become more sophisticated and handle objects that", " // implement the file protocol.", " void print(FILE* f, int flags=0) const {", " int res = PyObject_Print(_obj, f, flags);", " if (res == -1)", " throw 1;", " };", "", " void print(object f, int flags=0) const {", " int res = PyFile_WriteObject(_obj, f, flags);", " if (res == -1)", " throw 1;", " int hasattr(const std::string& nm) const {", " int hasattr(object& nm) const {", " return PyObject_HasAttr(_obj, nm) == 1;", " };", "", " // attr -- retreive attribute/method from object", " return object(lose_ref(val));", " object attr(const std::string& nm) const {", " return object(lose_ref(val));", " //", " // There is a combinatorial explosion here of function combinations.", " // perhaps there is a casting fix someone can suggest.", "", " void set_attr(const std::string& nm, object& val) {", " int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);", " if (res == -1)", " throw 1;", " };", " ////////////// int //////////////", " void set_attr(const char* nm, int val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm, _val);", " if (res == -1)", " throw 1;", " };", " void set_attr(const std::string& nm, int val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);", " if (res == -1)", " throw 1;", " };", "", " void set_attr(const object& nm, int val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttr(_obj, nm, _val);", " if (res == -1)", " throw 1;", " };", "", " ////////////// unsigned long //////////////", " void set_attr(const char* nm, unsigned long val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm, _val);", " if (res == -1)", " throw 1;", " };", " void set_attr(const std::string& nm, unsigned long val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);", " if (res == -1)", " throw 1;", " };", "", " void set_attr(const object& nm, unsigned long val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttr(_obj, nm, _val);", " if (res == -1)", " throw 1;", " };", " ////////////// double //////////////", " void set_attr(const char* nm, double val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm, _val);", " if (res == -1)", " throw 1;", " };", " void set_attr(const std::string& nm, double val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);", " if (res == -1)", " throw 1;", " };", "", " void set_attr(const object& nm, double val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttr(_obj, nm, _val);", " if (res == -1)", " throw 1;", " };", "", " ////////////// complex //////////////", " void set_attr(const char* nm, const std::complex& val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm, _val);", " if (res == -1)", " throw 1;", " };", " void set_attr(const std::string& nm, const std::complex& val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);", " if (res == -1)", " throw 1;", " };", "", " void set_attr(const object& nm, const std::complex& val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttr(_obj, nm, _val);", " if (res == -1)", " throw 1;", " };", "", " ////////////// char* //////////////", " void set_attr(const char* nm, const char* val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm, _val);", " if (res == -1)", " throw 1;", " };", "", " void set_attr(const std::string& nm, const char* val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);", " if (res == -1)", " throw 1;", " };", "", " void set_attr(const object& nm, const char* val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttr(_obj, nm, _val);", " if (res == -1)", " throw 1;", " };", "", " ////////////// std::string //////////////", " void set_attr(const char* nm, const std::string& val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm, _val);", " if (res == -1)", " throw 1;", " };", "", " void set_attr(const std::string& nm, const std::string& val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);", " if (res == -1)", " throw 1;", " };", "", " void set_attr(const object& nm, const std::string& val) {", " py::object _val = py::object(val);", " int res = PyObject_SetAttr(_obj, nm, _val);", " if (res == -1)", " throw 1;", " };", "", " // del attributes/methods from object", " void del(const char* nm) {", " int result = PyObject_DelAttrString(_obj, (char*) nm);", " if (result == -1)", " throw 1;", " };", " void del(const std::string& nm) {", " int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());", " if (result == -1)", " throw 1;", " void del(const object& nm) {", " int result = PyObject_DelAttr(_obj, nm);", " if (result ==-1)", " throw 1;", " //-------------------------------------------------------------------------", " fail(PyExc_TypeError, \"cannot make the comparison\");", " int cmp(int other) const {", " object _other = object(other);", " return cmp(_other);", " };", " int cmp(unsigned long other) const {", " object _other = object(other);", " return cmp(_other);", " };", " int cmp(double other) const {", " object _other = object(other);", " return cmp(_other);", " };", " int cmp(const std::complex& other) const {", " object _other = object(other);", " return cmp(_other);", " };", "", " int cmp(const char* other) const {", " object _other = object((char*)other);", " return cmp(_other);", " };", "", " int cmp(const std::string& other) const {", " object _other = object(other);", " return cmp(_other);", " };", "", " bool operator == (int other) const {", " return cmp(other) == 0;", " };", " bool operator == (unsigned long other) const {", " return cmp(other) == 0;", " };", " bool operator == (double other) const {", " return cmp(other) == 0;", " };", " bool operator == (const std::complex& other) const {", " return cmp(other) == 0;", " };", " bool operator == (const std::string& other) const {", " return cmp(other) == 0;", " };", " bool operator == (const char* other) const {", " return cmp(other) == 0;", " };", "", " bool operator != (int other) const {", " return cmp(other) != 0;", " bool operator != (unsigned long other) const {", " return cmp(other) != 0;", " };", " bool operator != (double other) const {", " return cmp(other) != 0;", " };", " bool operator != (const std::complex& other) const {", " return cmp(other) != 0;", " };", " bool operator != (const std::string& other) const {", " return cmp(other) != 0;", " };", " bool operator != (const char* other) const {", " return cmp(other) != 0;", " };", "", " bool operator < (int other) const {", " return cmp(other) < 0;", " };", " bool operator < (unsigned long other) const {", " return cmp(other) < 0;", " };", " bool operator < (double other) const {", " return cmp(other) < 0;", " };", " bool operator < (const std::complex& other) const {", " return cmp(other) < 0;", " };", " bool operator < (const std::string& other) const {", " return cmp(other) < 0;", " };", " bool operator < (const char* other) const {", " return cmp(other) < 0;", " };", "", " bool operator > (const object& other) const {", " return cmp(other) > 0;", " };", " bool operator > (int other) const {", " return cmp(other) > 0;", " };", " bool operator > (unsigned long other) const {", " return cmp(other) > 0;", " };", " bool operator > (double other) const {", " return cmp(other) > 0;", " };", " bool operator > (const std::complex& other) const {", " return cmp(other) > 0;", " };", " bool operator > (const std::string& other) const {", " return cmp(other) > 0;", " };", " bool operator > (const char* other) const {", " return cmp(other) > 0;", " };", "", " bool operator >= (int other) const {", " return cmp(other) >= 0;", " };", " bool operator >= (unsigned long other) const {", " return cmp(other) >= 0;", " };", " bool operator >= (double other) const {", " return cmp(other) >= 0;", " };", " bool operator >= (const std::complex& other) const {", " return cmp(other) >= 0;", " };", " bool operator >= (const std::string& other) const {", " return cmp(other) >= 0;", " };", " bool operator >= (const char* other) const {", " return cmp(other) >= 0;", " };", "", " bool operator <= (int other) const {", " return cmp(other) <= 0;", " };", " bool operator <= (unsigned long other) const {", " return cmp(other) <= 0;", " };", " bool operator <= (double other) const {", " return cmp(other) <= 0;", " };", " bool operator <= (const std::complex& other) const {", " return cmp(other) <= 0;", " };", " bool operator <= (const std::string& other) const {", " return cmp(other) <= 0;", " };", " bool operator <= (const char* other) const {", " return cmp(other) <= 0;", "", " //-------------------------------------------------------------------------", " // string representations", " //-------------------------------------------------------------------------", " object repr() const {", " object result = PyObject_Repr(_obj);", " if (!(PyObject*)result)", " throw 1;", " lose_ref(result);", " return result;", " };", "", " object str() const {", " object result = PyObject_Str(_obj);", " if (!(PyObject*)result)", " throw 1;", " lose_ref(result);", " return result;", " };", "", " // !! Not Tested", " object unicode() const {", " object result = PyObject_Unicode(_obj);", " if (!(PyObject*)result)", " throw 1;", " lose_ref(result);", " return result;", "", " //-------------------------------------------------------------------------", " // calling methods on object", " //", " // Note: I changed args_tup from a tuple& to a object& so that it could", " // be inlined instead of implemented i weave_imp.cpp. This", " // provides less automatic type checking, but is potentially faster.", " //-------------------------------------------------------------------------", " object object::mcall(const char* nm) {", " object method = attr(nm);", " PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);", " if (!result)", " throw 1; // signal exception has occured.", " return object(lose_ref(result));", " }", "", " object object::mcall(const char* nm, object& args_tup) {", " object method = attr(nm);", " PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);", " if (!result)", " throw 1; // signal exception has occured.", " return object(lose_ref(result));", " }", "", " object object::mcall(const char* nm, object& args_tup, object& kw_dict) {", " object method = attr(nm);", " PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);", " if (!result)", " throw 1; // signal exception has occured.", " return object(lose_ref(result));", " }", "", " object mcall(const std::string& nm) {", " return mcall(nm.c_str());", " }", " object mcall(const std::string& nm, object& args_tup) {", " return mcall(nm.c_str(),args_tup);", " }", " object mcall(const std::string& nm, object& args_tup, object& kw_dict) {", " return mcall(nm.c_str(),args_tup,kw_dict);", " }", "", " //-------------------------------------------------------------------------", " // calling callable objects", " //", " // Note: see not on mcall()", " //-------------------------------------------------------------------------", " object object::call() const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);", " if (rslt == 0)", " throw 1;", " return object(lose_ref(rslt));", " }", " object object::call(object& args_tup) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);", " if (rslt == 0)", " throw 1;", " return object(lose_ref(rslt));", " }", " object object::call(object& args_tup, object& kw_dict) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);", " if (rslt == 0)", " throw 1;", " return object(lose_ref(rslt));", " }", "", " //-------------------------------------------------------------------------", " // check if object is callable", " //-------------------------------------------------------------------------", "", " //-------------------------------------------------------------------------", " // retreive the objects hash value", " //-------------------------------------------------------------------------", " int result = PyObject_Hash(_obj);", " if (result == -1 && PyErr_Occurred())", " throw 1;", " return result;", "", " //-------------------------------------------------------------------------", " // test whether object is true", " //-------------------------------------------------------------------------", "", " //-------------------------------------------------------------------------", " // test whether object is not true", " //-------------------------------------------------------------------------", " bool not() const {", " return PyObject_Not(_obj) == 1;", " };", "", " //-------------------------------------------------------------------------", " // return the variable type for the object", " //-------------------------------------------------------------------------", " PyObject* result = PyObject_Type(_obj);", " if (!result)", " throw 1;", " return lose_ref(result);", " };", "", " //-------------------------------------------------------------------------", " // size, len, and length are all synonyms.", " //", " // length() is useful because it allows the same code to work with STL", " // strings as works with py::objects.", " //-------------------------------------------------------------------------", " int size() const {", " int result = PyObject_Size(_obj);", " if (result == -1)", " throw 1;", " return result;", " int len() const {", " return size();", " };", " int length() const {", " return size();", " };", "", " //-------------------------------------------------------------------------", " // set_item", " //", " // To prevent a combonatorial explosion, only objects are allowed for keys.", " // Users are encouraged to use the [] interface for setting values.", " //-------------------------------------------------------------------------", " virtual void set_item(const object& key, const object& val) {", " int rslt = PyObject_SetItem(_obj, key, val);", " if (rslt==-1)", " throw 1;", " };", "", " //-------------------------------------------------------------------------", " // operator[]", " //-------------------------------------------------------------------------", " // !! defined in weave_imp.cpp", " // !! I'd like to refactor things so that they can be defined here.", " keyed_ref operator [] (object& key);", " keyed_ref operator [] (const char* key);", " keyed_ref operator [] (const std::string& key);", " keyed_ref operator [] (int key);", " keyed_ref operator [] (double key);", " keyed_ref operator [] (const std::complex& key);", "", " //-------------------------------------------------------------------------", " // iter methods", " // !! NOT TESTED", " //-------------------------------------------------------------------------", "", "", " int refcount() {", " return _obj->ob_refcnt;", " }", "//---------------------------------------------------------------------------", "// keyed_ref", "//", "// Provides a reference value when operator[] returns an lvalue. The", "// reference has to keep track of its parent object and its key in the parent", "// object so that it can insert a new value into the parent at the", "// appropriate place when a new value is assigned to the keyed_ref object.", "//", "// The keyed_ref class is also used by the py::dict class derived from", "// py::object", "// !! Note: Need to check ref counting on key and parent here.", "//---------------------------------------------------------------------------", "class object::keyed_ref : public object", "{", " object& _parent;", " object _key;", "public:", " keyed_ref(object obj, object& parent, object& key)", " : object(obj), _parent(parent), _key(key) {};", " virtual ~keyed_ref() {};", "", " keyed_ref& operator=(const object& other) {", " grab_ref(other);", " _parent.set_item(_key, other);", " return *this;", " }", " keyed_ref& operator=(int other) {", " object _other = object(other);", " return operator=(_other);", " }", " keyed_ref& operator=(double other) {", " object _other = object(other);", " return operator=(_other);", " }", " keyed_ref& operator=(const std::complex& other) {", " object _other = object(other);", " return operator=(_other);", " }", " keyed_ref& operator=(const char* other) {", " object _other = object(other);", " return operator=(_other);", " }", " keyed_ref& operator=(const std::string& other) {", " object _other = object(other);", " return operator=(_other);", " }", "};" ], "deleted": [ " modified heavily for weave by eric jones.", "void Fail(PyObject*, const char* msg);", "// used in method call specification.", "class tuple;", "class dict;", " // incref new owner, decref old owner, and adjust to new owner", " void GrabRef(PyObject* newObj);", " // decrease reference count without destroying the object", " static PyObject* LoseRef(PyObject* o)", " PyObject* _own; // set to _obj if we \"own\" a reference to _obj, else zero", " : _obj (0), _own (0) { }", " : _obj (0), _own (0) { GrabRef(other); }", " : _obj (0), _own (0) {", " //std::cout << \"construct before: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;", " GrabRef(obj);", " //std::cout << \"construct after: (own,ref)\" << (int)_own << \" \" << obj->ob_refcnt << std::endl;", " }", " /*", " object(bool val) : _obj (0), _own (0) {", " GrabRef(PyInt_FromLong((int)val));", " LoseRef(_obj);", " */", " object(int val) : _obj (0), _own (0) {", " GrabRef(PyInt_FromLong(val));", " LoseRef(_obj);", " object(long val) : _obj (0), _own (0) {", " GrabRef(PyInt_FromLong(val));", " LoseRef(_obj);", " object(unsigned long val) : _obj (0), _own (0) {", " GrabRef(PyLong_FromUnsignedLong(val));", " LoseRef(_obj);", " object(double val) : _obj (0), _own (0) {", " GrabRef(PyFloat_FromDouble(val));", " LoseRef(_obj);", " object(std::complex& val) : _obj (0), _own (0) {", " GrabRef(PyComplex_FromDoubles(val.real(),val.imag()));", " LoseRef(_obj);", " object(char* val) : _obj (0), _own (0) {", " GrabRef(PyString_FromString(val));", " LoseRef(_obj);", " object(std::string& val) : _obj (0), _own (0) {", " GrabRef(PyString_FromString((char*)val.c_str()));", " LoseRef(_obj);", " virtual ~object()", " {", " //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;", " Py_XDECREF(_own);", " //std::cout << \"destruct: (own,ref)\" << (int)_own << \" \" << _obj->ob_refcnt << std::endl;", " }", " Fail(PyExc_TypeError, \"cannot convert value to integer\");", " Fail(PyExc_TypeError, \"cannot convert value to float\");", " Fail(PyExc_TypeError, \"cannot convert value to double\");", " Fail(PyExc_TypeError, \"cannot convert value to complex\");", " Fail(PyExc_TypeError, \"cannot convert value to std::string\");", " Fail(PyExc_TypeError, \"cannot convert value to std::string\");", " GrabRef(other);", " // !! UNTESTED", " int print(FILE *f, int flags) const {", " return PyObject_Print(_obj, f, flags);", " int hasattr(std::string nm) const {", " // attribute access", " //", " // should this return a reference? Need to think about this.", " return object(LoseRef(val));", " object attr(std::string nm) const {", " return object(LoseRef(val));", " // !! NOT TESTED", " //-------------------------------------------------------------------------", " // calling methods", " //-------------------------------------------------------------------------", " object mcall(const char* nm);", " object mcall(const char* nm, tuple& args);", " object mcall(const char* nm, tuple& args, dict& kwargs);", " object mcall(std::string nm) {", " return mcall(nm.c_str());", " }", " object mcall(std::string nm, tuple& args) {", " return mcall(nm.c_str(),args);", " }", " object mcall(std::string nm, tuple& args, dict& kwargs) {", " return mcall(nm.c_str(),args,kwargs);", " }", " //-------------------------------------------------------------------------", " // calling callable objects", " //-------------------------------------------------------------------------", " object call() const;", " object call(tuple& args) const;", " object call(tuple& args, dict& kws) const;", " //-------------------------------------------------------------------------", " // sequence methods", " // !! NOT TESTED", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // iter methods", " // !! NOT TESTED", " //-------------------------------------------------------------------------", " // del objects", " // !! NOT TESTED", " int del(const char* nm) {", " return PyObject_DelAttrString(_obj, (char*) nm);", " int del(const object& nm) {", " return PyObject_DelAttr(_obj, nm);", " //-------------------------------------------------------------------------", " Fail(PyExc_TypeError, \"cannot make the comparison\");", " bool operator > (const object& other) const {", " return cmp(other) > 0;", "", " PyObject* repr() const {", " return LoseRef(PyObject_Repr(_obj));", " /*", " PyObject* str() const {", " return LoseRef(PyObject_Str(_obj));", " */", " return PyObject_Hash(_obj);", " return LoseRef(PyObject_Type(_obj));" ] } }, { "old_path": "weave/scxx/sequence.h", "new_path": "weave/scxx/sequence.h", "filename": "sequence.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -2,132 +2,260 @@\n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n- modified heavily for weave by eric jones\n+ modified for weave by eric jones\n *********************************************/\n #if !defined(SEQUENCE_H_INCLUDED_)\n #define SEQUENCE_H_INCLUDED_\n \n #include \n+#include \n+\n #include \"object.h\"\n \n namespace py {\n \n-// This isn't being picked up out of object.h for some reason\n-void Fail(PyObject*, const char* msg);\n-\n-// pre-declared. needed by other include files\n-class str;\n-class tuple;\n-class list;\n+//---------------------------------------------------------------------------\n+// !! This isn't being picked up out of object.h for some reason, so I'll \n+// !! redeclare it.\n+//---------------------------------------------------------------------------\n+void fail(PyObject*, const char* msg);\n \n+//---------------------------------------------------------------------------\n+// base class for list and tuple objects.\n+//---------------------------------------------------------------------------\n class sequence : public object\n {\n public:\n+ //-------------------------------------------------------------------------\n+ // constructors\n+ //-------------------------------------------------------------------------\n sequence() : object() {};\n sequence(const sequence& other) : object(other) {};\n sequence(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n+\n+ //-------------------------------------------------------------------------\n+ // destructors\n+ //------------------------------------------------------------------------- \n virtual ~sequence() {}\n \n+ //-------------------------------------------------------------------------\n+ // operator=\n+ //-------------------------------------------------------------------------\n virtual sequence& operator=(const sequence& other) {\n- GrabRef(other);\n+ grab_ref(other);\n return *this;\n };\n /*virtual*/ sequence& operator=(const object& other) {\n- GrabRef(other);\n+ grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n+ \n+ //-------------------------------------------------------------------------\n+ // type checking.\n+ //------------------------------------------------------------------------- \n virtual void _violentTypeCheck() {\n if (!PySequence_Check(_obj)) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a sequence\");\n+ grab_ref(0);\n+ fail(PyExc_TypeError, \"Not a sequence\");\n }\n };\n- //PySequence_Concat\n+ \n+ //-------------------------------------------------------------------------\n+ // operator+ -- concatenation\n+ //-------------------------------------------------------------------------\n sequence operator+(const sequence& rhs) const {\n PyObject* rslt = PySequence_Concat(_obj, rhs);\n if (rslt==0)\n- Fail(PyExc_TypeError, \"Improper rhs for +\");\n- return LoseRef(rslt);\n+ fail(PyExc_TypeError, \"Improper rhs for +\");\n+ return lose_ref(rslt);\n };\n \n- //PySequence_Count\n+ //-------------------------------------------------------------------------\n+ // count -- count the number of objects in a sequence.\n+ //-------------------------------------------------------------------------\n int count(const object& value) const {\n int rslt = PySequence_Count(_obj, value);\n if (rslt == -1)\n- Fail(PyExc_RuntimeError, \"failure in count\");\n+ fail(PyExc_RuntimeError, \"failure in count\");\n return rslt;\n };\n+ int count(int value) const {\n+ object val = value;\n+ return count(val);\n+ };\n+ int count(double value) const {\n+ object val = value;\n+ return count(val);\n+ };\n+ int count(char* value) const {\n+ object val = value;\n+ return count(val);\n+ };\n+ int count(std::string& value) const {\n+ object val = value.c_str();\n+ return count(val);\n+ };\n \n- int count(int value) const;\n- int count(double value) const; \n- int count(char* value) const;\n- int count(std::string value) const;\n- \n- //PySequence_GetItem \n- // ## lists - return list_member (mutable) \n- // ## tuples - return tuple_member (mutable)\n- // ## otherwise just a object\n- object operator [] (int i) const { //can't be virtual\n+ //-------------------------------------------------------------------------\n+ // set_item -- virtual so that set_item for tuple and list use \n+ // type specific xxx_SetItem function calls.\n+ //-------------------------------------------------------------------------\n+ virtual void set_item(int ndx, object& val) {\n+ int rslt = PySequence_SetItem(_obj, ndx, val);\n+ if (rslt==-1)\n+ fail(PyExc_IndexError, \"Index out of range\");\n+ };\n+\n+\n+ //-------------------------------------------------------------------------\n+ // operator[] -- non-const version defined in list and tuple sub-types.\n+ //-------------------------------------------------------------------------\n+ object operator [] (int i) {\n PyObject* o = PySequence_GetItem(_obj, i);\n- if (o == 0)\n- Fail(PyExc_IndexError, \"index out of range\");\n- return LoseRef(o);\n+ // don't throw error for when [] fails because it might be on left hand \n+ // side (a[0] = 1). If the sequence was just created, it will be filled \n+ // with NULL values, and setting the values should be ok. However, we\n+ // do want to catch index errors that might occur on the right hand side\n+ // (obj = a[4] when a has len==3).\n+ if (!o) {\n+ if (PyErr_ExceptionMatches(PyExc_IndexError))\n+ throw 1;\n+ }\n+ return lose_ref(o);\n };\n- //PySequence_GetSlice\n- //virtual sequence& operator [] (PWSlice& x) {...};\n+ \n+ //-------------------------------------------------------------------------\n+ // slice -- handles slice operations.\n+ // !! NOT TESTED\n+ //-------------------------------------------------------------------------\n sequence slice(int lo, int hi) const {\n PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n if (o == 0)\n- Fail(PyExc_IndexError, \"could not obtain slice\");\n- return LoseRef(o);\n+ fail(PyExc_IndexError, \"could not obtain slice\");\n+ return lose_ref(o);\n };\n \n- //PySequence_In\n+ //-------------------------------------------------------------------------\n+ // in -- find whether a value is in the given sequence.\n+ // overloaded to handle the standard types used in weave.\n+ //-------------------------------------------------------------------------\n bool in(const object& value) const {\n int rslt = PySequence_In(_obj, value);\n if (rslt==-1)\n- Fail(PyExc_RuntimeError, \"problem in in\");\n+ fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n+ }; \n+ bool sequence::in(int value) {\n+ object val = value;\n+ return in(val);\n+ };\n+ bool sequence::in(double value) {\n+ object val = value;\n+ return in(val);\n+ };\n+ bool sequence::in(const char* value) {\n+ object val = value;\n+ return in(val);\n+ };\n+ bool sequence::in(std::string& value) {\n+ object val = value.c_str();\n+ return in(val);\n };\n \n- bool in(int value); \n- bool in(double value);\n- bool in(char* value);\n- bool in(std::string value);\n- \n- //PySequence_Index\n+ //-------------------------------------------------------------------------\n+ // index -- find whether a value is in the given sequence.\n+ // overloaded to handle the standard types used in weave.\n+ //-------------------------------------------------------------------------\n int index(const object& value) const {\n int rslt = PySequence_Index(_obj, value);\n if (rslt==-1)\n- Fail(PyExc_IndexError, \"value not found\");\n+ fail(PyExc_IndexError, \"value not found\");\n return rslt;\n };\n- int index(int value) const;\n- int index(double value) const;\n- int index(char* value) const;\n- int index(std::string value) const; \n- \n- //PySequence_Length\n- int len() const {\n- return PySequence_Length(_obj);\n+ int sequence::index(int value) const {\n+ object val = value;\n+ return index(val);\n+ }; \n+ int sequence::index(double value) const {\n+ object val = value;\n+ return index(val);\n };\n- // added length for compatibility with std::string.\n- int length() const {\n- return PySequence_Length(_obj);\n+ int sequence::index(const std::complex& value) const {\n+ object val = value;\n+ return index(val);\n };\n- //PySequence_Repeat\n+ int sequence::index(const char* value) const {\n+ object val = value;\n+ return index(val);\n+ }; \n+ int sequence::index(const std::string& value) const {\n+ object val = value;\n+ return index(val);\n+ };\n+\n+ //-------------------------------------------------------------------------\n+ // len, length, size -- find the length of the sequence. \n+ // version inherited from py::object ok.\n+ //-------------------------------------------------------------------------\n+ \n+ //-------------------------------------------------------------------------\n+ // operator* -- repeat a list multiple times.\n+ //-------------------------------------------------------------------------\n sequence operator * (int count) const {\n PyObject* rslt = PySequence_Repeat(_obj, count);\n if (rslt==0)\n- Fail(PyExc_RuntimeError, \"sequence repeat failed\");\n- return LoseRef(rslt);\n+ fail(PyExc_RuntimeError, \"sequence repeat failed\");\n+ return lose_ref(rslt);\n };\n- //PySequence_Tuple\n };\n \n+//---------------------------------------------------------------------------\n+// indexed_ref -- return reference obj when operator[] is used as an lvalue.\n+//\n+// list and tuple objects return this for non-const calls to operator[].\n+// It is similar to object::keyed_ref, except that it stores an integer\n+// index instead of py::object key.\n+//---------------------------------------------------------------------------\n+class indexed_ref : public object\n+{\n+ sequence& _parent;\n+ int _ndx;\n+public:\n+ indexed_ref::indexed_ref(PyObject* obj, sequence& parent, int ndx)\n+ : object(obj), _parent(parent), _ndx(ndx) { };\n+ virtual ~indexed_ref() {};\n+ \n+ indexed_ref& indexed_ref::operator=(const object& other) {\n+ grab_ref(other);\n+ _parent.set_item(_ndx, *this);\n+ return *this;\n+ };\n+ indexed_ref& indexed_ref::operator=(int other) {\n+ object oth = other;\n+ return operator=(oth);\n+ }; \n+ indexed_ref& indexed_ref::operator=(double other) {\n+ object oth = other;\n+ return operator=(oth);\n+ }; \n+ indexed_ref& indexed_ref::operator=(const std::complex& other) {\n+ object oth = other;\n+ return operator=(oth);\n+ }; \n+ indexed_ref& indexed_ref::operator=(const char* other) {\n+ object oth = other;\n+ return operator=(oth);\n+ }; \n+ indexed_ref& indexed_ref::operator=(const std::string& other) {\n+ object oth = other;\n+ return operator=(oth);\n+ };\n+};\n+\n+\n } // namespace py\n \n #endif // PWOSEQUENCE_H_INCLUDED_\n", "added_lines": 186, "deleted_lines": 58, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n#if !defined(SEQUENCE_H_INCLUDED_)\n#define SEQUENCE_H_INCLUDED_\n\n#include \n#include \n\n#include \"object.h\"\n\nnamespace py {\n \n//---------------------------------------------------------------------------\n// !! This isn't being picked up out of object.h for some reason, so I'll \n// !! redeclare it.\n//---------------------------------------------------------------------------\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// base class for list and tuple objects.\n//---------------------------------------------------------------------------\nclass sequence : public object\n{\npublic:\n //-------------------------------------------------------------------------\n // constructors\n //-------------------------------------------------------------------------\n sequence() : object() {};\n sequence(const sequence& other) : object(other) {};\n sequence(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n\n //-------------------------------------------------------------------------\n // destructors\n //------------------------------------------------------------------------- \n virtual ~sequence() {}\n\n //-------------------------------------------------------------------------\n // operator=\n //-------------------------------------------------------------------------\n virtual sequence& operator=(const sequence& other) {\n grab_ref(other);\n return *this;\n };\n /*virtual*/ sequence& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // type checking.\n //------------------------------------------------------------------------- \n virtual void _violentTypeCheck() {\n if (!PySequence_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a sequence\");\n }\n };\n \n //-------------------------------------------------------------------------\n // operator+ -- concatenation\n //-------------------------------------------------------------------------\n sequence operator+(const sequence& rhs) const {\n PyObject* rslt = PySequence_Concat(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for +\");\n return lose_ref(rslt);\n };\n\n //-------------------------------------------------------------------------\n // count -- count the number of objects in a sequence.\n //-------------------------------------------------------------------------\n int count(const object& value) const {\n int rslt = PySequence_Count(_obj, value);\n if (rslt == -1)\n fail(PyExc_RuntimeError, \"failure in count\");\n return rslt;\n };\n int count(int value) const {\n object val = value;\n return count(val);\n };\n int count(double value) const {\n object val = value;\n return count(val);\n };\n int count(char* value) const {\n object val = value;\n return count(val);\n };\n int count(std::string& value) const {\n object val = value.c_str();\n return count(val);\n };\n\n //-------------------------------------------------------------------------\n // set_item -- virtual so that set_item for tuple and list use \n // type specific xxx_SetItem function calls.\n //-------------------------------------------------------------------------\n virtual void set_item(int ndx, object& val) {\n int rslt = PySequence_SetItem(_obj, ndx, val);\n if (rslt==-1)\n fail(PyExc_IndexError, \"Index out of range\");\n };\n\n\n //-------------------------------------------------------------------------\n // operator[] -- non-const version defined in list and tuple sub-types.\n //-------------------------------------------------------------------------\n object operator [] (int i) {\n PyObject* o = PySequence_GetItem(_obj, i);\n // don't throw error for when [] fails because it might be on left hand \n // side (a[0] = 1). If the sequence was just created, it will be filled \n // with NULL values, and setting the values should be ok. However, we\n // do want to catch index errors that might occur on the right hand side\n // (obj = a[4] when a has len==3).\n if (!o) {\n if (PyErr_ExceptionMatches(PyExc_IndexError))\n throw 1;\n }\n return lose_ref(o);\n };\n \n //-------------------------------------------------------------------------\n // slice -- handles slice operations.\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n sequence slice(int lo, int hi) const {\n PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n if (o == 0)\n fail(PyExc_IndexError, \"could not obtain slice\");\n return lose_ref(o);\n };\n \n //-------------------------------------------------------------------------\n // in -- find whether a value is in the given sequence.\n // overloaded to handle the standard types used in weave.\n //-------------------------------------------------------------------------\n bool in(const object& value) const {\n int rslt = PySequence_In(_obj, value);\n if (rslt==-1)\n fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n }; \n bool sequence::in(int value) {\n object val = value;\n return in(val);\n };\n bool sequence::in(double value) {\n object val = value;\n return in(val);\n };\n bool sequence::in(const char* value) {\n object val = value;\n return in(val);\n };\n bool sequence::in(std::string& value) {\n object val = value.c_str();\n return in(val);\n };\n \n //-------------------------------------------------------------------------\n // index -- find whether a value is in the given sequence.\n // overloaded to handle the standard types used in weave.\n //-------------------------------------------------------------------------\n int index(const object& value) const {\n int rslt = PySequence_Index(_obj, value);\n if (rslt==-1)\n fail(PyExc_IndexError, \"value not found\");\n return rslt;\n };\n int sequence::index(int value) const {\n object val = value;\n return index(val);\n }; \n int sequence::index(double value) const {\n object val = value;\n return index(val);\n };\n int sequence::index(const std::complex& value) const {\n object val = value;\n return index(val);\n };\n int sequence::index(const char* value) const {\n object val = value;\n return index(val);\n }; \n int sequence::index(const std::string& value) const {\n object val = value;\n return index(val);\n };\n\n //-------------------------------------------------------------------------\n // len, length, size -- find the length of the sequence. \n // version inherited from py::object ok.\n //-------------------------------------------------------------------------\n \n //-------------------------------------------------------------------------\n // operator* -- repeat a list multiple times.\n //-------------------------------------------------------------------------\n sequence operator * (int count) const {\n PyObject* rslt = PySequence_Repeat(_obj, count);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"sequence repeat failed\");\n return lose_ref(rslt);\n };\n};\n\n//---------------------------------------------------------------------------\n// indexed_ref -- return reference obj when operator[] is used as an lvalue.\n//\n// list and tuple objects return this for non-const calls to operator[].\n// It is similar to object::keyed_ref, except that it stores an integer\n// index instead of py::object key.\n//---------------------------------------------------------------------------\nclass indexed_ref : public object\n{\n sequence& _parent;\n int _ndx;\npublic:\n indexed_ref::indexed_ref(PyObject* obj, sequence& parent, int ndx)\n : object(obj), _parent(parent), _ndx(ndx) { };\n virtual ~indexed_ref() {};\n \n indexed_ref& indexed_ref::operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_ndx, *this);\n return *this;\n };\n indexed_ref& indexed_ref::operator=(int other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(double other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(const std::complex& other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(const char* other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(const std::string& other) {\n object oth = other;\n return operator=(oth);\n };\n};\n\n\n} // namespace py\n\n#endif // PWOSEQUENCE_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified heavily for weave by eric jones\n*********************************************/\n#if !defined(SEQUENCE_H_INCLUDED_)\n#define SEQUENCE_H_INCLUDED_\n\n#include \n#include \"object.h\"\n\nnamespace py {\n \n// This isn't being picked up out of object.h for some reason\nvoid Fail(PyObject*, const char* msg);\n\n// pre-declared. needed by other include files\nclass str;\nclass tuple;\nclass list;\n\nclass sequence : public object\n{\npublic:\n sequence() : object() {};\n sequence(const sequence& other) : object(other) {};\n sequence(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n virtual ~sequence() {}\n\n virtual sequence& operator=(const sequence& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ sequence& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PySequence_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a sequence\");\n }\n };\n //PySequence_Concat\n sequence operator+(const sequence& rhs) const {\n PyObject* rslt = PySequence_Concat(_obj, rhs);\n if (rslt==0)\n Fail(PyExc_TypeError, \"Improper rhs for +\");\n return LoseRef(rslt);\n };\n\n //PySequence_Count\n int count(const object& value) const {\n int rslt = PySequence_Count(_obj, value);\n if (rslt == -1)\n Fail(PyExc_RuntimeError, \"failure in count\");\n return rslt;\n };\n\n int count(int value) const;\n int count(double value) const; \n int count(char* value) const;\n int count(std::string value) const;\n \n //PySequence_GetItem \n // ## lists - return list_member (mutable) \n // ## tuples - return tuple_member (mutable)\n // ## otherwise just a object\n object operator [] (int i) const { //can't be virtual\n PyObject* o = PySequence_GetItem(_obj, i);\n if (o == 0)\n Fail(PyExc_IndexError, \"index out of range\");\n return LoseRef(o);\n };\n //PySequence_GetSlice\n //virtual sequence& operator [] (PWSlice& x) {...};\n sequence slice(int lo, int hi) const {\n PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n if (o == 0)\n Fail(PyExc_IndexError, \"could not obtain slice\");\n return LoseRef(o);\n };\n \n //PySequence_In\n bool in(const object& value) const {\n int rslt = PySequence_In(_obj, value);\n if (rslt==-1)\n Fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n };\n \n bool in(int value); \n bool in(double value);\n bool in(char* value);\n bool in(std::string value);\n \n //PySequence_Index\n int index(const object& value) const {\n int rslt = PySequence_Index(_obj, value);\n if (rslt==-1)\n Fail(PyExc_IndexError, \"value not found\");\n return rslt;\n };\n int index(int value) const;\n int index(double value) const;\n int index(char* value) const;\n int index(std::string value) const; \n \n //PySequence_Length\n int len() const {\n return PySequence_Length(_obj);\n };\n // added length for compatibility with std::string.\n int length() const {\n return PySequence_Length(_obj);\n };\n //PySequence_Repeat\n sequence operator * (int count) const {\n PyObject* rslt = PySequence_Repeat(_obj, count);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"sequence repeat failed\");\n return LoseRef(rslt);\n };\n //PySequence_Tuple\n};\n\n} // namespace py\n\n#endif // PWOSEQUENCE_H_INCLUDED_\n", "methods": [ { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 32, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( const sequence & other)", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( PyObject * obj)", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 34, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::~sequence", "long_name": "py::sequence::~sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 41, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const sequence & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::_violentTypeCheck", "long_name": "py::sequence::_violentTypeCheck()", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 59, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator +", "long_name": "py::sequence::operator +( const sequence & rhs) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 69, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 79, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( int value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "value" ], "start_line": 85, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( double value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "value" ], "start_line": 89, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( char * value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 93, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( std :: string & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::set_item", "long_name": "py::sequence::set_item( int ndx , object & val)", "filename": "sequence.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "ndx", "val" ], "start_line": 106, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::operator [ ]", "long_name": "py::sequence::operator [ ]( int i)", "filename": "sequence.h", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "i" ], "start_line": 116, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 2 }, { "name": "py::sequence::slice", "long_name": "py::sequence::slice( int lo , int hi) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 134, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::in", "long_name": "py::sequence::in( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 145, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( int value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 151, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( double value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 155, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( const char * value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "value" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( std :: string & value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::index", "long_name": "py::sequence::index( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( int value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 178, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( double value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 182, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const std :: complex & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 186, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const char * value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 190, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const std :: string & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 194, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::operator *", "long_name": "py::sequence::operator *( int count) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 207, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::indexed_ref", "long_name": "py::indexed_ref::indexed_ref::indexed_ref( PyObject * obj , sequence & parent , int ndx)", "filename": "sequence.h", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 227, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::indexed_ref::~indexed_ref", "long_name": "py::indexed_ref::~indexed_ref()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 229, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( int other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 236, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( double other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 240, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const std :: complex & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 244, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const char * other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 248, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const std :: string & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 252, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 26, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( const sequence & other)", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 27, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( PyObject * obj)", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 28, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::~sequence", "long_name": "py::sequence::~sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 31, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const sequence & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 33, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 37, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::_violentTypeCheck", "long_name": "py::sequence::_violentTypeCheck()", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 42, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator +", "long_name": "py::sequence::operator +( const sequence & rhs) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 57, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator [ ]", "long_name": "py::sequence::operator [ ]( int i) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "i" ], "start_line": 73, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::slice", "long_name": "py::sequence::slice( int lo , int hi) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 81, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::in", "long_name": "py::sequence::in( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::index", "long_name": "py::sequence::index( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 102, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::len", "long_name": "py::sequence::len() const", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::length", "long_name": "py::sequence::length() const", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::operator *", "long_name": "py::sequence::operator *( int count) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 122, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const char * value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 190, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::index", "long_name": "py::sequence::index( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::indexed_ref::~indexed_ref", "long_name": "py::indexed_ref::~indexed_ref()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 229, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( double value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 155, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( std :: string & value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( int value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 151, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( double value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 182, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::_violentTypeCheck", "long_name": "py::sequence::_violentTypeCheck()", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 59, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const std :: string & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 194, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( std :: string & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::len", "long_name": "py::sequence::len() const", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( double other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 240, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const std :: complex & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 244, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( int value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "value" ], "start_line": 85, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const char * other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 248, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::indexed_ref", "long_name": "py::indexed_ref::indexed_ref::indexed_ref( PyObject * obj , sequence & parent , int ndx)", "filename": "sequence.h", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 227, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( int other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 236, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const std :: string & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 252, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const std :: complex & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 186, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::length", "long_name": "py::sequence::length() const", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( const char * value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "value" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::operator *", "long_name": "py::sequence::operator *( int count) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 207, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( double value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "value" ], "start_line": 89, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::set_item", "long_name": "py::sequence::set_item( int ndx , object & val)", "filename": "sequence.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "ndx", "val" ], "start_line": 106, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 79, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const sequence & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( int value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 178, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::operator [ ]", "long_name": "py::sequence::operator [ ]( int i) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "i" ], "start_line": 73, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( char * value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 93, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::slice", "long_name": "py::sequence::slice( int lo , int hi) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 134, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::in", "long_name": "py::sequence::in( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 145, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator +", "long_name": "py::sequence::operator +( const sequence & rhs) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 69, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator [ ]", "long_name": "py::sequence::operator [ ]( int i)", "filename": "sequence.h", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "i" ], "start_line": 116, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 2 } ], "nloc": 166, "complexity": 46, "token_count": 1041, "diff_parsed": { "added": [ " modified for weave by eric jones", "#include ", "", "//---------------------------------------------------------------------------", "// !! This isn't being picked up out of object.h for some reason, so I'll", "// !! redeclare it.", "//---------------------------------------------------------------------------", "void fail(PyObject*, const char* msg);", "//---------------------------------------------------------------------------", "// base class for list and tuple objects.", "//---------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // constructors", " //-------------------------------------------------------------------------", "", " //-------------------------------------------------------------------------", " // destructors", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // operator=", " //-------------------------------------------------------------------------", " grab_ref(other);", " grab_ref(other);", "", " //-------------------------------------------------------------------------", " // type checking.", " //-------------------------------------------------------------------------", " grab_ref(0);", " fail(PyExc_TypeError, \"Not a sequence\");", "", " //-------------------------------------------------------------------------", " // operator+ -- concatenation", " //-------------------------------------------------------------------------", " fail(PyExc_TypeError, \"Improper rhs for +\");", " return lose_ref(rslt);", " //-------------------------------------------------------------------------", " // count -- count the number of objects in a sequence.", " //-------------------------------------------------------------------------", " fail(PyExc_RuntimeError, \"failure in count\");", " int count(int value) const {", " object val = value;", " return count(val);", " };", " int count(double value) const {", " object val = value;", " return count(val);", " };", " int count(char* value) const {", " object val = value;", " return count(val);", " };", " int count(std::string& value) const {", " object val = value.c_str();", " return count(val);", " };", " //-------------------------------------------------------------------------", " // set_item -- virtual so that set_item for tuple and list use", " // type specific xxx_SetItem function calls.", " //-------------------------------------------------------------------------", " virtual void set_item(int ndx, object& val) {", " int rslt = PySequence_SetItem(_obj, ndx, val);", " if (rslt==-1)", " fail(PyExc_IndexError, \"Index out of range\");", " };", "", "", " //-------------------------------------------------------------------------", " // operator[] -- non-const version defined in list and tuple sub-types.", " //-------------------------------------------------------------------------", " object operator [] (int i) {", " // don't throw error for when [] fails because it might be on left hand", " // side (a[0] = 1). If the sequence was just created, it will be filled", " // with NULL values, and setting the values should be ok. However, we", " // do want to catch index errors that might occur on the right hand side", " // (obj = a[4] when a has len==3).", " if (!o) {", " if (PyErr_ExceptionMatches(PyExc_IndexError))", " throw 1;", " }", " return lose_ref(o);", "", " //-------------------------------------------------------------------------", " // slice -- handles slice operations.", " // !! NOT TESTED", " //-------------------------------------------------------------------------", " fail(PyExc_IndexError, \"could not obtain slice\");", " return lose_ref(o);", " //-------------------------------------------------------------------------", " // in -- find whether a value is in the given sequence.", " // overloaded to handle the standard types used in weave.", " //-------------------------------------------------------------------------", " fail(PyExc_RuntimeError, \"problem in in\");", " };", " bool sequence::in(int value) {", " object val = value;", " return in(val);", " };", " bool sequence::in(double value) {", " object val = value;", " return in(val);", " };", " bool sequence::in(const char* value) {", " object val = value;", " return in(val);", " };", " bool sequence::in(std::string& value) {", " object val = value.c_str();", " return in(val);", " //-------------------------------------------------------------------------", " // index -- find whether a value is in the given sequence.", " // overloaded to handle the standard types used in weave.", " //-------------------------------------------------------------------------", " fail(PyExc_IndexError, \"value not found\");", " int sequence::index(int value) const {", " object val = value;", " return index(val);", " };", " int sequence::index(double value) const {", " object val = value;", " return index(val);", " int sequence::index(const std::complex& value) const {", " object val = value;", " return index(val);", " int sequence::index(const char* value) const {", " object val = value;", " return index(val);", " };", " int sequence::index(const std::string& value) const {", " object val = value;", " return index(val);", " };", "", " //-------------------------------------------------------------------------", " // len, length, size -- find the length of the sequence.", " // version inherited from py::object ok.", " //-------------------------------------------------------------------------", "", " //-------------------------------------------------------------------------", " // operator* -- repeat a list multiple times.", " //-------------------------------------------------------------------------", " fail(PyExc_RuntimeError, \"sequence repeat failed\");", " return lose_ref(rslt);", "//---------------------------------------------------------------------------", "// indexed_ref -- return reference obj when operator[] is used as an lvalue.", "//", "// list and tuple objects return this for non-const calls to operator[].", "// It is similar to object::keyed_ref, except that it stores an integer", "// index instead of py::object key.", "//---------------------------------------------------------------------------", "class indexed_ref : public object", "{", " sequence& _parent;", " int _ndx;", "public:", " indexed_ref::indexed_ref(PyObject* obj, sequence& parent, int ndx)", " : object(obj), _parent(parent), _ndx(ndx) { };", " virtual ~indexed_ref() {};", "", " indexed_ref& indexed_ref::operator=(const object& other) {", " grab_ref(other);", " _parent.set_item(_ndx, *this);", " return *this;", " };", " indexed_ref& indexed_ref::operator=(int other) {", " object oth = other;", " return operator=(oth);", " };", " indexed_ref& indexed_ref::operator=(double other) {", " object oth = other;", " return operator=(oth);", " };", " indexed_ref& indexed_ref::operator=(const std::complex& other) {", " object oth = other;", " return operator=(oth);", " };", " indexed_ref& indexed_ref::operator=(const char* other) {", " object oth = other;", " return operator=(oth);", " };", " indexed_ref& indexed_ref::operator=(const std::string& other) {", " object oth = other;", " return operator=(oth);", " };", "};", "", "" ], "deleted": [ " modified heavily for weave by eric jones", "// This isn't being picked up out of object.h for some reason", "void Fail(PyObject*, const char* msg);", "", "// pre-declared. needed by other include files", "class str;", "class tuple;", "class list;", " GrabRef(other);", " GrabRef(other);", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a sequence\");", " //PySequence_Concat", " Fail(PyExc_TypeError, \"Improper rhs for +\");", " return LoseRef(rslt);", " //PySequence_Count", " Fail(PyExc_RuntimeError, \"failure in count\");", " int count(int value) const;", " int count(double value) const;", " int count(char* value) const;", " int count(std::string value) const;", "", " //PySequence_GetItem", " // ## lists - return list_member (mutable)", " // ## tuples - return tuple_member (mutable)", " // ## otherwise just a object", " object operator [] (int i) const { //can't be virtual", " if (o == 0)", " Fail(PyExc_IndexError, \"index out of range\");", " return LoseRef(o);", " //PySequence_GetSlice", " //virtual sequence& operator [] (PWSlice& x) {...};", " Fail(PyExc_IndexError, \"could not obtain slice\");", " return LoseRef(o);", " //PySequence_In", " Fail(PyExc_RuntimeError, \"problem in in\");", " bool in(int value);", " bool in(double value);", " bool in(char* value);", " bool in(std::string value);", "", " //PySequence_Index", " Fail(PyExc_IndexError, \"value not found\");", " int index(int value) const;", " int index(double value) const;", " int index(char* value) const;", " int index(std::string value) const;", "", " //PySequence_Length", " int len() const {", " return PySequence_Length(_obj);", " // added length for compatibility with std::string.", " int length() const {", " return PySequence_Length(_obj);", " //PySequence_Repeat", " Fail(PyExc_RuntimeError, \"sequence repeat failed\");", " return LoseRef(rslt);", " //PySequence_Tuple" ] } }, { "old_path": "weave/scxx/str.h", "new_path": "weave/scxx/str.h", "filename": "str.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -18,9 +18,9 @@ class str : public sequence\n public:\n str() : sequence() {};\n str(const char* s)\n- : sequence(PyString_FromString((char* )s)) { LoseRef(_obj); }\n+ : sequence(PyString_FromString((char* )s)) { lose_ref(_obj); }\n str(const char* s, int sz)\n- : sequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }\n+ : sequence(PyString_FromStringAndSize((char* )s, sz)) { lose_ref(_obj); }\n str(const str& other)\n : sequence(other) {};\n str(PyObject* obj)\n@@ -30,18 +30,18 @@ public:\n virtual ~str() {};\n \n virtual str& operator=(const str& other) {\n- GrabRef(other);\n+ grab_ref(other);\n return *this;\n };\n str& operator=(const object& other) {\n- GrabRef(other);\n+ grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyString_Check(_obj)) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a Python String\");\n+ grab_ref(0);\n+ fail(PyExc_TypeError, \"Not a Python String\");\n }\n };\n operator const char* () const {\n@@ -51,8 +51,8 @@ public:\n static str format(const str& fmt, tuple& args){\n PyObject * rslt =PyString_Format(fmt, args);\n if (rslt==0)\n- Fail(PyExc_RuntimeError, \"string format failed\");\n- return LoseRef(rslt);\n+ fail(PyExc_RuntimeError, \"string format failed\");\n+ return lose_ref(rslt);\n };\n */\n }; // class str\n", "added_lines": 8, "deleted_lines": 8, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified heavily for weave by eric jones\n*********************************************/\n#if !defined(STR_H_INCLUDED_)\n#define STR_H_INCLUDED_\n\n#include \n#include \"object.h\"\n#include \"sequence.h\"\n\nnamespace py {\n\nclass str : public sequence\n{\npublic:\n str() : sequence() {};\n str(const char* s)\n : sequence(PyString_FromString((char* )s)) { lose_ref(_obj); }\n str(const char* s, int sz)\n : sequence(PyString_FromStringAndSize((char* )s, sz)) { lose_ref(_obj); }\n str(const str& other)\n : sequence(other) {};\n str(PyObject* obj)\n : sequence(obj) { _violentTypeCheck(); };\n str(const object& other)\n : sequence(other) { _violentTypeCheck(); };\n virtual ~str() {};\n\n virtual str& operator=(const str& other) {\n grab_ref(other);\n return *this;\n };\n str& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyString_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a Python String\");\n }\n };\n operator const char* () const {\n return PyString_AsString(_obj);\n };\n /*\n static str format(const str& fmt, tuple& args){\n PyObject * rslt =PyString_Format(fmt, args);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"string format failed\");\n return lose_ref(rslt);\n };\n */\n}; // class str\n\n} // namespace\n\n#endif // STR_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified heavily for weave by eric jones\n*********************************************/\n#if !defined(STR_H_INCLUDED_)\n#define STR_H_INCLUDED_\n\n#include \n#include \"object.h\"\n#include \"sequence.h\"\n\nnamespace py {\n\nclass str : public sequence\n{\npublic:\n str() : sequence() {};\n str(const char* s)\n : sequence(PyString_FromString((char* )s)) { LoseRef(_obj); }\n str(const char* s, int sz)\n : sequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }\n str(const str& other)\n : sequence(other) {};\n str(PyObject* obj)\n : sequence(obj) { _violentTypeCheck(); };\n str(const object& other)\n : sequence(other) { _violentTypeCheck(); };\n virtual ~str() {};\n\n virtual str& operator=(const str& other) {\n GrabRef(other);\n return *this;\n };\n str& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyString_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a Python String\");\n }\n };\n operator const char* () const {\n return PyString_AsString(_obj);\n };\n /*\n static str format(const str& fmt, tuple& args){\n PyObject * rslt =PyString_Format(fmt, args);\n if (rslt==0)\n Fail(PyExc_RuntimeError, \"string format failed\");\n return LoseRef(rslt);\n };\n */\n}; // class str\n\n} // namespace\n\n#endif // STR_H_INCLUDED_\n", "methods": [ { "name": "py::str::str", "long_name": "py::str::str()", "filename": "str.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const char * s)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "s" ], "start_line": 20, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const char * s , int sz)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "s", "sz" ], "start_line": 22, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const str & other)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 24, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( PyObject * obj)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 26, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const object & other)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 28, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::~str", "long_name": "py::str::~str()", "filename": "str.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 30, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::str::operator =", "long_name": "py::str::operator =( const str & other)", "filename": "str.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 32, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::str::operator =", "long_name": "py::str::operator =( const object & other)", "filename": "str.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 36, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::str::_violentTypeCheck", "long_name": "py::str::_violentTypeCheck()", "filename": "str.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 41, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::str::operator const char *", "long_name": "py::str::operator const char *() const", "filename": "str.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::str::str", "long_name": "py::str::str()", "filename": "str.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 19, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const char * s)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "s" ], "start_line": 20, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const char * s , int sz)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "s", "sz" ], "start_line": 22, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const str & other)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 24, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( PyObject * obj)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 26, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const object & other)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 28, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::~str", "long_name": "py::str::~str()", "filename": "str.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 30, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::str::operator =", "long_name": "py::str::operator =( const str & other)", "filename": "str.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 32, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::str::operator =", "long_name": "py::str::operator =( const object & other)", "filename": "str.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 36, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::str::_violentTypeCheck", "long_name": "py::str::_violentTypeCheck()", "filename": "str.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 41, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::str::operator const char *", "long_name": "py::str::operator const char *() const", "filename": "str.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::str::operator =", "long_name": "py::str::operator =( const object & other)", "filename": "str.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 36, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::str::operator =", "long_name": "py::str::operator =( const str & other)", "filename": "str.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 32, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const char * s , int sz)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "s", "sz" ], "start_line": 22, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::str", "long_name": "py::str::str( const char * s)", "filename": "str.h", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "s" ], "start_line": 20, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::str::_violentTypeCheck", "long_name": "py::str::_violentTypeCheck()", "filename": "str.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 41, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "nloc": 39, "complexity": 12, "token_count": 241, "diff_parsed": { "added": [ " : sequence(PyString_FromString((char* )s)) { lose_ref(_obj); }", " : sequence(PyString_FromStringAndSize((char* )s, sz)) { lose_ref(_obj); }", " grab_ref(other);", " grab_ref(other);", " grab_ref(0);", " fail(PyExc_TypeError, \"Not a Python String\");", " fail(PyExc_RuntimeError, \"string format failed\");", " return lose_ref(rslt);" ], "deleted": [ " : sequence(PyString_FromString((char* )s)) { LoseRef(_obj); }", " : sequence(PyString_FromStringAndSize((char* )s, sz)) { LoseRef(_obj); }", " GrabRef(other);", " GrabRef(other);", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a Python String\");", " Fail(PyExc_RuntimeError, \"string format failed\");", " return LoseRef(rslt);" ] } }, { "old_path": "weave/scxx/tuple.h", "new_path": "weave/scxx/tuple.h", "filename": "tuple.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -6,89 +6,79 @@\n \n namespace py {\n \n-\n-// added to make tuples mutable.\n-class tuple_member : public object\n-{\n- tuple& _parent;\n- int _ndx;\n-public:\n- tuple_member(PyObject* obj, tuple& parent, int ndx);\n- virtual ~tuple_member() {};\n- tuple_member& operator=(const object& other);\n- tuple_member& operator=(const tuple_member& other);\n- tuple_member& operator=(int other);\n- tuple_member& operator=(double other);\n- tuple_member& operator=(const char* other);\n- tuple_member& operator=(std::string other);\n-};\n- \n class tuple : public sequence\n-{\n+{ \n public:\n- tuple(int sz=0) : sequence (PyTuple_New(sz)) { LoseRef(_obj); }\n+\n+ //-------------------------------------------------------------------------\n+ // constructors\n+ //-------------------------------------------------------------------------\n+ tuple(int sz=0) : sequence (PyTuple_New(sz)) { lose_ref(_obj); }\n tuple(const tuple& other) : sequence(other) { }\n tuple(PyObject* obj) : sequence(obj) { _violentTypeCheck(); }\n- tuple(const list& list);\n+ tuple::tuple(const list& lst)\n+ : sequence (PyList_AsTuple(lst)) { lose_ref(_obj); }\n+ \n+ //-------------------------------------------------------------------------\n+ // destructor\n+ //------------------------------------------------------------------------- \n virtual ~tuple() {};\n \n+ //-------------------------------------------------------------------------\n+ // operator=\n+ //-------------------------------------------------------------------------\n virtual tuple& operator=(const tuple& other) {\n- GrabRef(other);\n+ grab_ref(other);\n return *this;\n };\n /*virtual*/ tuple& operator=(const object& other) {\n- GrabRef(other);\n+ grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n+\n+ //-------------------------------------------------------------------------\n+ // type checking\n+ //------------------------------------------------------------------------- \n virtual void _violentTypeCheck() {\n if (!PyTuple_Check(_obj)) {\n- GrabRef(0);\n- Fail(PyExc_TypeError, \"Not a Python Tuple\");\n+ grab_ref(0);\n+ fail(PyExc_TypeError, \"Not a Python Tuple\");\n }\n };\n- void set_item(int ndx, object& val) {\n+\n+ //-------------------------------------------------------------------------\n+ // set_item\n+ //\n+ // We have to do a little extra checking here, because tuples can only\n+ // be assigned to if there is only a single reference to them.\n+ //------------------------------------------------------------------------- \n+ virtual void set_item(int ndx, object& val) {\n+ if (_obj->ob_refcnt != 1)\n+ fail(PyExc_TypeError,\"Tuples values can't be set if ref count > 1\\n\"); \n int rslt = PyTuple_SetItem(_obj, ndx, val);\n val.disown(); //when using PyTuple_SetItem, he steals my reference\n if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n+ throw 1;\n };\n \n- // ej: additions\n- void set_item(int ndx, int val) {\n- int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void set_item(int ndx, double val) {\n- int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void set_item(int ndx, char* val) {\n- int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- void set_item(int ndx, std::string val) {\n- int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n- if (rslt==-1)\n- Fail(PyExc_IndexError, \"Index out of range\");\n- };\n-\n- tuple_member operator [] (int i) { // can't be virtual\n- //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n- PyObject* o = PyTuple_GetItem(_obj, i); // get a \"borrowed\" refcount\n- //Py_XINCREF(o);\n- //if (o == 0)\n- // Fail(PyExc_IndexError, \"index out of range\");\n- return tuple_member(o, *this, i); // this increfs\n+ //-------------------------------------------------------------------------\n+ // operator[] -- const and non-const versions of element access.\n+ //------------------------------------------------------------------------- \n+ indexed_ref tuple::operator [] (int i) { \n+ // get a \"borrowed\" refcount \n+ PyObject* o = PyTuple_GetItem(_obj, i); \n+ // don't throw error for when [] fails because it might be on left hand \n+ // side (a[0] = 1). If the tuple was just created, it will be filled \n+ // with NULL values, and setting the values should be ok. However, we\n+ // do want to catch index errors that might occur on the right hand side\n+ // (obj = a[4] when a has len==3).\n+ if (!o) {\n+ if (PyErr_ExceptionMatches(PyExc_IndexError))\n+ throw 1;\n+ }\n+ return indexed_ref(o, *this, i); // this increfs\n };\n- // ej: end additions\n- \n };// class tuple\n \n } // namespace\n", "added_lines": 50, "deleted_lines": 60, "source_code": "#if !defined(TUPLE_H_INCLUDED_)\n#define TUPLE_H_INCLUDED_\n\n#include \"sequence.h\"\n#include \n\nnamespace py {\n\nclass tuple : public sequence\n{ \npublic:\n\n //-------------------------------------------------------------------------\n // constructors\n //-------------------------------------------------------------------------\n tuple(int sz=0) : sequence (PyTuple_New(sz)) { lose_ref(_obj); }\n tuple(const tuple& other) : sequence(other) { }\n tuple(PyObject* obj) : sequence(obj) { _violentTypeCheck(); }\n tuple::tuple(const list& lst)\n : sequence (PyList_AsTuple(lst)) { lose_ref(_obj); }\n \n //-------------------------------------------------------------------------\n // destructor\n //------------------------------------------------------------------------- \n virtual ~tuple() {};\n\n //-------------------------------------------------------------------------\n // operator=\n //-------------------------------------------------------------------------\n virtual tuple& operator=(const tuple& other) {\n grab_ref(other);\n return *this;\n };\n /*virtual*/ tuple& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n\n //-------------------------------------------------------------------------\n // type checking\n //------------------------------------------------------------------------- \n virtual void _violentTypeCheck() {\n if (!PyTuple_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a Python Tuple\");\n }\n };\n\n //-------------------------------------------------------------------------\n // set_item\n //\n // We have to do a little extra checking here, because tuples can only\n // be assigned to if there is only a single reference to them.\n //------------------------------------------------------------------------- \n virtual void set_item(int ndx, object& val) {\n if (_obj->ob_refcnt != 1)\n fail(PyExc_TypeError,\"Tuples values can't be set if ref count > 1\\n\"); \n int rslt = PyTuple_SetItem(_obj, ndx, val);\n val.disown(); //when using PyTuple_SetItem, he steals my reference\n if (rslt==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // operator[] -- const and non-const versions of element access.\n //------------------------------------------------------------------------- \n indexed_ref tuple::operator [] (int i) { \n // get a \"borrowed\" refcount \n PyObject* o = PyTuple_GetItem(_obj, i); \n // don't throw error for when [] fails because it might be on left hand \n // side (a[0] = 1). If the tuple was just created, it will be filled \n // with NULL values, and setting the values should be ok. However, we\n // do want to catch index errors that might occur on the right hand side\n // (obj = a[4] when a has len==3).\n if (!o) {\n if (PyErr_ExceptionMatches(PyExc_IndexError))\n throw 1;\n }\n return indexed_ref(o, *this, i); // this increfs\n };\n};// class tuple\n\n} // namespace\n\n#endif // TUPLE_H_INCLUDED_\n", "source_code_before": "#if !defined(TUPLE_H_INCLUDED_)\n#define TUPLE_H_INCLUDED_\n\n#include \"sequence.h\"\n#include \n\nnamespace py {\n\n\n// added to make tuples mutable.\nclass tuple_member : public object\n{\n tuple& _parent;\n int _ndx;\npublic:\n tuple_member(PyObject* obj, tuple& parent, int ndx);\n virtual ~tuple_member() {};\n tuple_member& operator=(const object& other);\n tuple_member& operator=(const tuple_member& other);\n tuple_member& operator=(int other);\n tuple_member& operator=(double other);\n tuple_member& operator=(const char* other);\n tuple_member& operator=(std::string other);\n};\n \nclass tuple : public sequence\n{\npublic:\n tuple(int sz=0) : sequence (PyTuple_New(sz)) { LoseRef(_obj); }\n tuple(const tuple& other) : sequence(other) { }\n tuple(PyObject* obj) : sequence(obj) { _violentTypeCheck(); }\n tuple(const list& list);\n virtual ~tuple() {};\n\n virtual tuple& operator=(const tuple& other) {\n GrabRef(other);\n return *this;\n };\n /*virtual*/ tuple& operator=(const object& other) {\n GrabRef(other);\n _violentTypeCheck();\n return *this;\n };\n virtual void _violentTypeCheck() {\n if (!PyTuple_Check(_obj)) {\n GrabRef(0);\n Fail(PyExc_TypeError, \"Not a Python Tuple\");\n }\n };\n void set_item(int ndx, object& val) {\n int rslt = PyTuple_SetItem(_obj, ndx, val);\n val.disown(); //when using PyTuple_SetItem, he steals my reference\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n \n // ej: additions\n void set_item(int ndx, int val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, double val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, char* val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n void set_item(int ndx, std::string val) {\n int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));\n if (rslt==-1)\n Fail(PyExc_IndexError, \"Index out of range\");\n };\n\n tuple_member operator [] (int i) { // can't be virtual\n //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid\n PyObject* o = PyTuple_GetItem(_obj, i); // get a \"borrowed\" refcount\n //Py_XINCREF(o);\n //if (o == 0)\n // Fail(PyExc_IndexError, \"index out of range\");\n return tuple_member(o, *this, i); // this increfs\n };\n // ej: end additions\n \n};// class tuple\n\n} // namespace\n\n#endif // TUPLE_H_INCLUDED_\n", "methods": [ { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( int sz = 0)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "sz" ], "start_line": 16, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( const tuple & other)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 17, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( PyObject * obj)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 18, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::tuple::tuple", "long_name": "py::tuple::tuple::tuple( const list & lst)", "filename": "tuple.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "lst" ], "start_line": 19, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::tuple::~tuple", "long_name": "py::tuple::~tuple()", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::operator =", "long_name": "py::tuple::operator =( const tuple & other)", "filename": "tuple.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::tuple::operator =", "long_name": "py::tuple::operator =( const object & other)", "filename": "tuple.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 34, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::_violentTypeCheck", "long_name": "py::tuple::_violentTypeCheck()", "filename": "tuple.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 43, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , object & val)", "filename": "tuple.h", "nloc": 8, "complexity": 3, "token_count": 54, "parameters": [ "ndx", "val" ], "start_line": 56, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::tuple::tuple::operator [ ]", "long_name": "py::tuple::tuple::operator [ ]( int i)", "filename": "tuple.h", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "i" ], "start_line": 68, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::tuple_member::~tuple_member", "long_name": "py::tuple_member::~tuple_member()", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 17, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( int sz = 0)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "sz" ], "start_line": 29, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( const tuple & other)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 30, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( PyObject * obj)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 31, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::~tuple", "long_name": "py::tuple::~tuple()", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::operator =", "long_name": "py::tuple::operator =( const tuple & other)", "filename": "tuple.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 35, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::tuple::operator =", "long_name": "py::tuple::operator =( const object & other)", "filename": "tuple.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 39, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::_violentTypeCheck", "long_name": "py::tuple::_violentTypeCheck()", "filename": "tuple.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 44, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , object & val)", "filename": "tuple.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "ndx", "val" ], "start_line": 50, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , int val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 58, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , double val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 64, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , char * val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 70, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , std :: string val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 76, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::operator [ ]", "long_name": "py::tuple::operator [ ]( int i)", "filename": "tuple.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 82, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::tuple::tuple::operator [ ]", "long_name": "py::tuple::tuple::operator [ ]( int i)", "filename": "tuple.h", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "i" ], "start_line": 68, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 2 }, { "name": "py::tuple::operator [ ]", "long_name": "py::tuple::operator [ ]( int i)", "filename": "tuple.h", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "i" ], "start_line": 82, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::tuple::tuple::tuple", "long_name": "py::tuple::tuple::tuple( const list & lst)", "filename": "tuple.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "lst" ], "start_line": 19, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::tuple::operator =", "long_name": "py::tuple::operator =( const object & other)", "filename": "tuple.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 34, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , char * val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "ndx", "val" ], "start_line": 70, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::tuple", "long_name": "py::tuple::tuple( int sz = 0)", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 22, "parameters": [ "sz" ], "start_line": 16, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , object & val)", "filename": "tuple.h", "nloc": 8, "complexity": 3, "token_count": 54, "parameters": [ "ndx", "val" ], "start_line": 56, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "py::tuple::_violentTypeCheck", "long_name": "py::tuple::_violentTypeCheck()", "filename": "tuple.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 43, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , std :: string val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "ndx", "std" ], "start_line": 76, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple_member::~tuple_member", "long_name": "py::tuple_member::~tuple_member()", "filename": "tuple.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 17, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , double val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 64, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::tuple::operator =", "long_name": "py::tuple::operator =( const tuple & other)", "filename": "tuple.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 30, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::tuple::set_item", "long_name": "py::tuple::set_item( int ndx , int val)", "filename": "tuple.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "ndx", "val" ], "start_line": 58, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 } ], "nloc": 45, "complexity": 15, "token_count": 290, "diff_parsed": { "added": [ "{", "", " //-------------------------------------------------------------------------", " // constructors", " //-------------------------------------------------------------------------", " tuple(int sz=0) : sequence (PyTuple_New(sz)) { lose_ref(_obj); }", " tuple::tuple(const list& lst)", " : sequence (PyList_AsTuple(lst)) { lose_ref(_obj); }", "", " //-------------------------------------------------------------------------", " // destructor", " //-------------------------------------------------------------------------", " //-------------------------------------------------------------------------", " // operator=", " //-------------------------------------------------------------------------", " grab_ref(other);", " grab_ref(other);", "", " //-------------------------------------------------------------------------", " // type checking", " //-------------------------------------------------------------------------", " grab_ref(0);", " fail(PyExc_TypeError, \"Not a Python Tuple\");", "", " //-------------------------------------------------------------------------", " // set_item", " //", " // We have to do a little extra checking here, because tuples can only", " // be assigned to if there is only a single reference to them.", " //-------------------------------------------------------------------------", " virtual void set_item(int ndx, object& val) {", " if (_obj->ob_refcnt != 1)", " fail(PyExc_TypeError,\"Tuples values can't be set if ref count > 1\\n\");", " throw 1;", " //-------------------------------------------------------------------------", " // operator[] -- const and non-const versions of element access.", " //-------------------------------------------------------------------------", " indexed_ref tuple::operator [] (int i) {", " // get a \"borrowed\" refcount", " PyObject* o = PyTuple_GetItem(_obj, i);", " // don't throw error for when [] fails because it might be on left hand", " // side (a[0] = 1). If the tuple was just created, it will be filled", " // with NULL values, and setting the values should be ok. However, we", " // do want to catch index errors that might occur on the right hand side", " // (obj = a[4] when a has len==3).", " if (!o) {", " if (PyErr_ExceptionMatches(PyExc_IndexError))", " throw 1;", " }", " return indexed_ref(o, *this, i); // this increfs" ], "deleted": [ "", "// added to make tuples mutable.", "class tuple_member : public object", "{", " tuple& _parent;", " int _ndx;", "public:", " tuple_member(PyObject* obj, tuple& parent, int ndx);", " virtual ~tuple_member() {};", " tuple_member& operator=(const object& other);", " tuple_member& operator=(const tuple_member& other);", " tuple_member& operator=(int other);", " tuple_member& operator=(double other);", " tuple_member& operator=(const char* other);", " tuple_member& operator=(std::string other);", "};", "", "{", " tuple(int sz=0) : sequence (PyTuple_New(sz)) { LoseRef(_obj); }", " tuple(const list& list);", " GrabRef(other);", " GrabRef(other);", " GrabRef(0);", " Fail(PyExc_TypeError, \"Not a Python Tuple\");", " void set_item(int ndx, object& val) {", " Fail(PyExc_IndexError, \"Index out of range\");", " // ej: additions", " void set_item(int ndx, int val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyInt_FromLong(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, double val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyFloat_FromDouble(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, char* val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " void set_item(int ndx, std::string val) {", " int rslt = PyTuple_SetItem(_obj, ndx, PyString_FromString(val.c_str()));", " if (rslt==-1)", " Fail(PyExc_IndexError, \"Index out of range\");", " };", "", " tuple_member operator [] (int i) { // can't be virtual", " //PyObject* o = PySequence_GetItem(_obj, i); assumes item is valid", " PyObject* o = PyTuple_GetItem(_obj, i); // get a \"borrowed\" refcount", " //Py_XINCREF(o);", " //if (o == 0)", " // Fail(PyExc_IndexError, \"index out of range\");", " return tuple_member(o, *this, i); // this increfs", " // ej: end additions", "" ] } }, { "old_path": "weave/scxx/weave_imp.cpp", "new_path": "weave/scxx/weave_imp.cpp", "filename": "weave_imp.cpp", "extension": "cpp", "change_type": "MODIFY", "diff": "@@ -1,319 +1,63 @@\n /******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n+\n+ modified for weave by eric jones.\n *********************************************/\n-#include \"sequence.h\"\n-#include \"list.h\"\n-#include \"tuple.h\"\n-#include \"str.h\"\n-#include \"dict.h\"\n-#include \"callable.h\"\n-#include \"number.h\"\n+#include \"object.h\"\n \n using namespace py;\n- \n-//---------------------------------------------------------------------------\n-// object\n-//---------------------------------------------------------------------------\n-\n-// incref new owner, and decref old owner, and adjust to new owner\n-void object::GrabRef(PyObject* newObj)\n-{\n- // be careful to incref before decref if old is same as new\n- Py_XINCREF(newObj);\n- Py_XDECREF(_own);\n- _own = _obj = newObj;\n-}\n-\n-object object::mcall(const char* nm)\n-{\n- object method = attr(nm);\n- PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n- if (!result)\n- throw 1; // signal exception has occured.\n- return object(LoseRef(result));\n-}\n-\n-object object::mcall(const char* nm, tuple& args)\n-{\n- object method = attr(nm);\n- PyObject* result = PyEval_CallObjectWithKeywords(method,args,NULL);\n- if (!result)\n- throw 1; // signal exception has occured.\n- return object(LoseRef(result));\n-}\n-\n-object object::mcall(const char* nm, tuple& args, dict& kwargs)\n-{\n- object method = attr(nm);\n- PyObject* result = PyEval_CallObjectWithKeywords(method,args,kwargs);\n- if (!result)\n- throw 1; // signal exception has occured.\n- return object(LoseRef(result));\n-}\n-\n-object object::call() const {\n- PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n- if (rslt == 0)\n- throw 1;\n- return object(LoseRef(rslt));\n-}\n-object object::call(tuple& args) const {\n- PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n- if (rslt == 0)\n- throw 1;\n- return object(LoseRef(rslt));\n-}\n-object object::call(tuple& args, dict& kws) const {\n- PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n- if (rslt == 0)\n- throw 1;\n- return object(LoseRef(rslt));\n-}\n \n //---------------------------------------------------------------------------\n-// sequence\n+// object\n+//\n+// !! Wish I knew how to get these defined inline in object.h...\n //---------------------------------------------------------------------------\n \n-bool sequence::in(int value) {\n- object val = number(value);\n- return in(val);\n-};\n- \n-bool sequence::in(double value) {\n- object val = number(value);\n- return in(val);\n-};\n-\n-bool sequence::in(char* value) {\n- object val = str(value);\n- return in(val);\n+object::keyed_ref object::operator [] (object& key) {\n+ object rslt = PyObject_GetItem(_obj, key);\n+ lose_ref(rslt);\n+ if (!(PyObject*)rslt)\n+ {\n+ // don't throw error for when [] fails because it might be on left hand \n+ // side (a[0] = 1). If the obj was just created, it will be filled \n+ // with NULL values, and setting the values should be ok. However, we\n+ // do want to catch index errors that might occur on the right hand side\n+ // (obj = a[4] when a has len==3).\n+ if (PyErr_ExceptionMatches(PyExc_KeyError))\n+ PyErr_Clear(); // Ignore key errors\n+ else if (PyErr_ExceptionMatches(PyExc_IndexError))\n+ throw 1;\n+ }\n+ return object::keyed_ref(rslt, *this, key);\n };\n-\n-bool sequence::in(std::string value) {\n- object val = str(value.c_str());\n- return in(val);\n+object::keyed_ref object::operator [] (const char* key) {\n+ object _key = object(key);\n+ return operator[](_key);\n };\n- \n-int sequence::count(int value) const {\n- number val = number(value);\n- return count(val);\n-};\n-\n-int sequence::count(double value) const {\n- number val = number(value);\n- return count(val);\n-};\n-\n-int sequence::count(char* value) const {\n- str val = str(value);\n- return count(val);\n-};\n-\n-int sequence::count(std::string value) const {\n- str val = str(value.c_str());\n- return count(val);\n-};\n-\n-int sequence::index(int value) const {\n- number val = number(value);\n- return index(val);\n-};\n-\n-int sequence::index(double value) const {\n- number val = number(value);\n- return index(val);\n-};\n-int sequence::index(char* value) const {\n- str val = str(value);\n- return index(val);\n-};\n-\n-int sequence::index(std::string value) const {\n- str val = str(value.c_str());\n- return index(val);\n-};\n-\n-//---------------------------------------------------------------------------\n-// tuple\n-//---------------------------------------------------------------------------\n-\n-tuple::tuple(const list& lst)\n- : sequence (PyList_AsTuple(lst)) { LoseRef(_obj); }\n-\n-//---------------------------------------------------------------------------\n-// tuple_member\n-//---------------------------------------------------------------------------\n-\n-tuple_member::tuple_member(PyObject* obj, tuple& parent, int ndx) \n- : object(obj), _parent(parent), _ndx(ndx) { }\n-\n-tuple_member& tuple_member::operator=(const object& other) {\n- GrabRef(other);\n- //Py_XINCREF(_obj); // this one is for set_item to steal\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-tuple_member& tuple_member::operator=(const tuple_member& other) {\n- GrabRef(other);\n- //Py_XINCREF(_obj); // this one is for set_item to steal\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-tuple_member& tuple_member::operator=(int other) {\n- GrabRef(number(other));\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-tuple_member& tuple_member::operator=(double other) {\n- GrabRef(number(other));\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-tuple_member& tuple_member::operator=(const char* other) {\n- GrabRef(str(other));\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-tuple_member& tuple_member::operator=(std::string other) {\n- GrabRef(str(other.c_str()));\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-//---------------------------------------------------------------------------\n-// list\n-//---------------------------------------------------------------------------\n- \n-list& list::insert(int ndx, int other) {\n- number oth = number(other);\n- return insert(ndx, oth);\n+object::keyed_ref object::operator [] (const std::string& key) {\n+ object _key = object(key);\n+ return operator [](_key);\n };\n-\n-list& list::insert(int ndx, double other) {\n- number oth = number(other);\n- return insert(ndx, oth);\n+object::keyed_ref object::operator [] (int key) {\n+ object _key = object(key);\n+ return operator [](_key);\n };\n-\n-list& list::insert(int ndx, char* other) {\n- str oth = str(other);\n- return insert(ndx, oth);\n+object::keyed_ref object::operator [] (double key) {\n+ object _key = object(key);\n+ return operator [](_key);\n };\n-\n-list& list::insert(int ndx, std::string other) {\n- str oth = str(other.c_str());\n- return insert(ndx, oth);\n+object::keyed_ref object::operator [] (const std::complex& key) {\n+ object _key = object(key);\n+ return operator [](_key);\n };\n \n //---------------------------------------------------------------------------\n-// list_member\n+// Fail method for throwing exceptions with a given message.\n //---------------------------------------------------------------------------\n \n-list_member::list_member(PyObject* obj, list& parent, int ndx) \n- : object(obj), _parent(parent), _ndx(ndx) { }\n-\n-list_member& list_member::operator=(const object& other) {\n- GrabRef(other);\n- //Py_XINCREF(_obj); // this one is for set_item to steal\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-list_member& list_member::operator=(const list_member& other) {\n- GrabRef(other);\n- //Py_XINCREF(_obj); // this one is for set_item to steal\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-list_member& list_member::operator=(int other) {\n- GrabRef(number(other));\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-list_member& list_member::operator=(double other) {\n- GrabRef(number(other));\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-list_member& list_member::operator=(const char* other) {\n- GrabRef(str(other));\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-list_member& list_member::operator=(std::string other) {\n- GrabRef(str(other.c_str()));\n- _parent.set_item(_ndx, *this);\n- return *this;\n-}\n-\n-//---------------------------------------------------------------------------\n-// dict_member\n-//---------------------------------------------------------------------------\n-\n-dict_member& dict_member::operator=(const object& other) {\n- GrabRef(other);\n- _parent.set_item(_key, *this);\n- return *this;\n-}\n-\n-dict_member& dict_member::operator=(int other) {\n- GrabRef(number(other));\n- _parent.set_item(_key, *this);\n- return *this;\n-}\n-\n-dict_member& dict_member::operator=(double other) {\n- GrabRef(number(other));\n- _parent.set_item(_key, *this);\n- return *this;\n-}\n-\n-dict_member& dict_member::operator=(const char* other) {\n- GrabRef(str(other));\n- _parent.set_item(_key, *this);\n- return *this;\n-}\n-\n-dict_member& dict_member::operator=(std::string other) {\n- GrabRef(str(other.c_str()));\n- _parent.set_item(_key, *this);\n- return *this;\n-}\n-\n-//---------------------------------------------------------------------------\n-// callable\n-//---------------------------------------------------------------------------\n-\n-object callable::call() const {\n- static tuple _empty;\n- PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n- if (rslt == 0)\n- throw 1;\n- return rslt;\n-}\n-object callable::call(tuple& args) const {\n- PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n- if (rslt == 0)\n- throw 1;\n- return rslt;\n-}\n-object callable::call(tuple& args, dict& kws) const {\n- PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n- if (rslt == 0)\n- throw 1;\n- return rslt;\n-}\n-\n-void py::Fail(PyObject* exc, const char* msg)\n+void py::fail(PyObject* exc, const char* msg)\n {\n PyErr_SetString(exc, msg);\n throw 1;\n-}\n\\ No newline at end of file\n+}\n", "added_lines": 40, "deleted_lines": 296, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n#include \"object.h\"\n\nusing namespace py;\n\n//---------------------------------------------------------------------------\n// object\n//\n// !! Wish I knew how to get these defined inline in object.h...\n//---------------------------------------------------------------------------\n\nobject::keyed_ref object::operator [] (object& key) {\n object rslt = PyObject_GetItem(_obj, key);\n lose_ref(rslt);\n if (!(PyObject*)rslt)\n {\n // don't throw error for when [] fails because it might be on left hand \n // side (a[0] = 1). If the obj was just created, it will be filled \n // with NULL values, and setting the values should be ok. However, we\n // do want to catch index errors that might occur on the right hand side\n // (obj = a[4] when a has len==3).\n if (PyErr_ExceptionMatches(PyExc_KeyError))\n PyErr_Clear(); // Ignore key errors\n else if (PyErr_ExceptionMatches(PyExc_IndexError))\n throw 1;\n }\n return object::keyed_ref(rslt, *this, key);\n};\nobject::keyed_ref object::operator [] (const char* key) {\n object _key = object(key);\n return operator[](_key);\n};\nobject::keyed_ref object::operator [] (const std::string& key) {\n object _key = object(key);\n return operator [](_key);\n};\nobject::keyed_ref object::operator [] (int key) {\n object _key = object(key);\n return operator [](_key);\n};\nobject::keyed_ref object::operator [] (double key) {\n object _key = object(key);\n return operator [](_key);\n};\nobject::keyed_ref object::operator [] (const std::complex& key) {\n object _key = object(key);\n return operator [](_key);\n};\n\n//---------------------------------------------------------------------------\n// Fail method for throwing exceptions with a given message.\n//---------------------------------------------------------------------------\n\nvoid py::fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n*********************************************/\n#include \"sequence.h\"\n#include \"list.h\"\n#include \"tuple.h\"\n#include \"str.h\"\n#include \"dict.h\"\n#include \"callable.h\"\n#include \"number.h\"\n\nusing namespace py;\n \n//---------------------------------------------------------------------------\n// object\n//---------------------------------------------------------------------------\n\n// incref new owner, and decref old owner, and adjust to new owner\nvoid object::GrabRef(PyObject* newObj)\n{\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n}\n\nobject object::mcall(const char* nm)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(LoseRef(result));\n}\n\nobject object::mcall(const char* nm, tuple& args)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(LoseRef(result));\n}\n\nobject object::mcall(const char* nm, tuple& args, dict& kwargs)\n{\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args,kwargs);\n if (!result)\n throw 1; // signal exception has occured.\n return object(LoseRef(result));\n}\n\nobject object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(LoseRef(rslt));\n}\nobject object::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return object(LoseRef(rslt));\n}\nobject object::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return object(LoseRef(rslt));\n}\n\n//---------------------------------------------------------------------------\n// sequence\n//---------------------------------------------------------------------------\n\nbool sequence::in(int value) {\n object val = number(value);\n return in(val);\n};\n \nbool sequence::in(double value) {\n object val = number(value);\n return in(val);\n};\n\nbool sequence::in(char* value) {\n object val = str(value);\n return in(val);\n};\n\nbool sequence::in(std::string value) {\n object val = str(value.c_str());\n return in(val);\n};\n \nint sequence::count(int value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(double value) const {\n number val = number(value);\n return count(val);\n};\n\nint sequence::count(char* value) const {\n str val = str(value);\n return count(val);\n};\n\nint sequence::count(std::string value) const {\n str val = str(value.c_str());\n return count(val);\n};\n\nint sequence::index(int value) const {\n number val = number(value);\n return index(val);\n};\n\nint sequence::index(double value) const {\n number val = number(value);\n return index(val);\n};\nint sequence::index(char* value) const {\n str val = str(value);\n return index(val);\n};\n\nint sequence::index(std::string value) const {\n str val = str(value.c_str());\n return index(val);\n};\n\n//---------------------------------------------------------------------------\n// tuple\n//---------------------------------------------------------------------------\n\ntuple::tuple(const list& lst)\n : sequence (PyList_AsTuple(lst)) { LoseRef(_obj); }\n\n//---------------------------------------------------------------------------\n// tuple_member\n//---------------------------------------------------------------------------\n\ntuple_member::tuple_member(PyObject* obj, tuple& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\ntuple_member& tuple_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const tuple_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\ntuple_member& tuple_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n//---------------------------------------------------------------------------\n// list\n//---------------------------------------------------------------------------\n \nlist& list::insert(int ndx, int other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, double other) {\n number oth = number(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, char* other) {\n str oth = str(other);\n return insert(ndx, oth);\n};\n\nlist& list::insert(int ndx, std::string other) {\n str oth = str(other.c_str());\n return insert(ndx, oth);\n};\n\n//---------------------------------------------------------------------------\n// list_member\n//---------------------------------------------------------------------------\n\nlist_member::list_member(PyObject* obj, list& parent, int ndx) \n : object(obj), _parent(parent), _ndx(ndx) { }\n\nlist_member& list_member::operator=(const object& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const list_member& other) {\n GrabRef(other);\n //Py_XINCREF(_obj); // this one is for set_item to steal\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\nlist_member& list_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_ndx, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// dict_member\n//---------------------------------------------------------------------------\n\ndict_member& dict_member::operator=(const object& other) {\n GrabRef(other);\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(int other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(double other) {\n GrabRef(number(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(const char* other) {\n GrabRef(str(other));\n _parent.set_item(_key, *this);\n return *this;\n}\n\ndict_member& dict_member::operator=(std::string other) {\n GrabRef(str(other.c_str()));\n _parent.set_item(_key, *this);\n return *this;\n}\n\n//---------------------------------------------------------------------------\n// callable\n//---------------------------------------------------------------------------\n\nobject callable::call() const {\n static tuple _empty;\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\nobject callable::call(tuple& args, dict& kws) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);\n if (rslt == 0)\n throw 1;\n return rslt;\n}\n\nvoid py::Fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}", "methods": [ { "name": "object::operator [ ]", "long_name": "object::operator [ ]( object & key)", "filename": "weave_imp.cpp", "nloc": 12, "complexity": 4, "token_count": 73, "parameters": [ "key" ], "start_line": 17, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const char * key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "key" ], "start_line": 34, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const std :: string & key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "std" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( int key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "key" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( double key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "key" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const std :: complex & key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "std" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "py::fail", "long_name": "py::fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 59, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "object::GrabRef", "long_name": "object::GrabRef( PyObject * newObj)", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 20, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 28, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args" ], "start_line": 37, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args , dict & kwargs)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args", "kwargs" ], "start_line": 46, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call() const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args", "kws" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( int value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 78, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( double value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 83, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( char * value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 88, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( std :: string value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 93, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 103, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 113, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 118, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 123, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 127, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 132, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "tuple::tuple", "long_name": "tuple::tuple( const list & lst)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "lst" ], "start_line": 141, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::tuple_member", "long_name": "tuple_member::tuple_member( PyObject * obj , tuple & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 151, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const tuple_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 158, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 165, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 183, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , int other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , double other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 197, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , char * other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 202, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , std :: string other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 207, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::list_member", "long_name": "list_member::list_member( PyObject * obj , list & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 216, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 219, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const list_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 226, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 245, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 251, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 261, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 267, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 273, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 279, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 285, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call() const", "filename": "weave_imp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 295, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 302, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 308, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "py::Fail", "long_name": "py::Fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 315, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 183, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "py::Fail", "long_name": "py::Fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 315, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const std :: string & key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "std" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const tuple_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 158, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( char * value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 88, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 132, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( double value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 83, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "args" ], "start_line": 302, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const std :: complex & key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "std" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "args", "kws" ], "start_line": 308, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( double key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "key" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args , dict & kws) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args", "kws" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , double other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 197, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( int value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 78, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "py::fail", "long_name": "py::fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 59, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( int value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 118, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 251, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 267, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args , dict & kwargs)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args", "kwargs" ], "start_line": 46, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 151, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const list_member & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 226, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 103, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 261, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( char * value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "value" ], "start_line": 127, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( std :: string other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 285, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , std :: string other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "ndx", "std" ], "start_line": 207, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::in", "long_name": "sequence::in( std :: string value)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 93, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call( tuple & args) const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "object::GrabRef", "long_name": "object::GrabRef( PyObject * newObj)", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 1, "token_count": 26, "parameters": [ "newObj" ], "start_line": 20, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( int key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "key" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 245, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 279, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "tuple_member::tuple_member", "long_name": "tuple_member::tuple_member( PyObject * obj , tuple & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const char * key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "key" ], "start_line": 34, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 28, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , char * other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "ndx", "other" ], "start_line": 202, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "tuple::tuple", "long_name": "tuple::tuple( const list & lst)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "lst" ], "start_line": 141, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "object::call", "long_name": "object::call() const", "filename": "weave_imp.cpp", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dict_member::operator =", "long_name": "dict_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 273, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list_member::list_member", "long_name": "list_member::list_member( PyObject * obj , list & parent , int ndx)", "filename": "weave_imp.cpp", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 216, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( int other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 165, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sequence::index", "long_name": "sequence::index( double value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "value" ], "start_line": 123, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sequence::count", "long_name": "sequence::count( std :: string value) const", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 113, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( double other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "other" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "list::insert", "long_name": "list::insert( int ndx , int other)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "ndx", "other" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::mcall", "long_name": "object::mcall( const char * nm , tuple & args)", "filename": "weave_imp.cpp", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args" ], "start_line": 37, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "callable::call", "long_name": "callable::call() const", "filename": "weave_imp.cpp", "nloc": 7, "complexity": 2, "token_count": 38, "parameters": [], "start_line": 295, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "tuple_member::operator =", "long_name": "tuple_member::operator =( const char * other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "other" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( object & key)", "filename": "weave_imp.cpp", "nloc": 12, "complexity": 4, "token_count": 73, "parameters": [ "key" ], "start_line": 17, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "list_member::operator =", "long_name": "list_member::operator =( const object & other)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 219, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "nloc": 39, "complexity": 10, "token_count": 277, "diff_parsed": { "added": [ "", " modified for weave by eric jones.", "#include \"object.h\"", "// object", "//", "// !! Wish I knew how to get these defined inline in object.h...", "object::keyed_ref object::operator [] (object& key) {", " object rslt = PyObject_GetItem(_obj, key);", " lose_ref(rslt);", " if (!(PyObject*)rslt)", " {", " // don't throw error for when [] fails because it might be on left hand", " // side (a[0] = 1). If the obj was just created, it will be filled", " // with NULL values, and setting the values should be ok. However, we", " // do want to catch index errors that might occur on the right hand side", " // (obj = a[4] when a has len==3).", " if (PyErr_ExceptionMatches(PyExc_KeyError))", " PyErr_Clear(); // Ignore key errors", " else if (PyErr_ExceptionMatches(PyExc_IndexError))", " throw 1;", " }", " return object::keyed_ref(rslt, *this, key);", "object::keyed_ref object::operator [] (const char* key) {", " object _key = object(key);", " return operator[](_key);", "object::keyed_ref object::operator [] (const std::string& key) {", " object _key = object(key);", " return operator [](_key);", "object::keyed_ref object::operator [] (int key) {", " object _key = object(key);", " return operator [](_key);", "object::keyed_ref object::operator [] (double key) {", " object _key = object(key);", " return operator [](_key);", "object::keyed_ref object::operator [] (const std::complex& key) {", " object _key = object(key);", " return operator [](_key);", "// Fail method for throwing exceptions with a given message.", "void py::fail(PyObject* exc, const char* msg)", "}" ], "deleted": [ "#include \"sequence.h\"", "#include \"list.h\"", "#include \"tuple.h\"", "#include \"str.h\"", "#include \"dict.h\"", "#include \"callable.h\"", "#include \"number.h\"", "", "//---------------------------------------------------------------------------", "// object", "//---------------------------------------------------------------------------", "", "// incref new owner, and decref old owner, and adjust to new owner", "void object::GrabRef(PyObject* newObj)", "{", " // be careful to incref before decref if old is same as new", " Py_XINCREF(newObj);", " Py_XDECREF(_own);", " _own = _obj = newObj;", "}", "", "object object::mcall(const char* nm)", "{", " object method = attr(nm);", " PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);", " if (!result)", " throw 1; // signal exception has occured.", " return object(LoseRef(result));", "}", "", "object object::mcall(const char* nm, tuple& args)", "{", " object method = attr(nm);", " PyObject* result = PyEval_CallObjectWithKeywords(method,args,NULL);", " if (!result)", " throw 1; // signal exception has occured.", " return object(LoseRef(result));", "}", "", "object object::mcall(const char* nm, tuple& args, dict& kwargs)", "{", " object method = attr(nm);", " PyObject* result = PyEval_CallObjectWithKeywords(method,args,kwargs);", " if (!result)", " throw 1; // signal exception has occured.", " return object(LoseRef(result));", "}", "", "object object::call() const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);", " if (rslt == 0)", " throw 1;", " return object(LoseRef(rslt));", "}", "object object::call(tuple& args) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);", " if (rslt == 0)", " throw 1;", " return object(LoseRef(rslt));", "}", "object object::call(tuple& args, dict& kws) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);", " if (rslt == 0)", " throw 1;", " return object(LoseRef(rslt));", "}", "// sequence", "bool sequence::in(int value) {", " object val = number(value);", " return in(val);", "};", "", "bool sequence::in(double value) {", " object val = number(value);", " return in(val);", "};", "", "bool sequence::in(char* value) {", " object val = str(value);", " return in(val);", "", "bool sequence::in(std::string value) {", " object val = str(value.c_str());", " return in(val);", "", "int sequence::count(int value) const {", " number val = number(value);", " return count(val);", "};", "", "int sequence::count(double value) const {", " number val = number(value);", " return count(val);", "};", "", "int sequence::count(char* value) const {", " str val = str(value);", " return count(val);", "};", "", "int sequence::count(std::string value) const {", " str val = str(value.c_str());", " return count(val);", "};", "", "int sequence::index(int value) const {", " number val = number(value);", " return index(val);", "};", "", "int sequence::index(double value) const {", " number val = number(value);", " return index(val);", "};", "int sequence::index(char* value) const {", " str val = str(value);", " return index(val);", "};", "", "int sequence::index(std::string value) const {", " str val = str(value.c_str());", " return index(val);", "};", "", "//---------------------------------------------------------------------------", "// tuple", "//---------------------------------------------------------------------------", "", "tuple::tuple(const list& lst)", " : sequence (PyList_AsTuple(lst)) { LoseRef(_obj); }", "", "//---------------------------------------------------------------------------", "// tuple_member", "//---------------------------------------------------------------------------", "", "tuple_member::tuple_member(PyObject* obj, tuple& parent, int ndx)", " : object(obj), _parent(parent), _ndx(ndx) { }", "", "tuple_member& tuple_member::operator=(const object& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for set_item to steal", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "tuple_member& tuple_member::operator=(const tuple_member& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for set_item to steal", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "tuple_member& tuple_member::operator=(int other) {", " GrabRef(number(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "tuple_member& tuple_member::operator=(double other) {", " GrabRef(number(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "tuple_member& tuple_member::operator=(const char* other) {", " GrabRef(str(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "tuple_member& tuple_member::operator=(std::string other) {", " GrabRef(str(other.c_str()));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "//---------------------------------------------------------------------------", "// list", "//---------------------------------------------------------------------------", "", "list& list::insert(int ndx, int other) {", " number oth = number(other);", " return insert(ndx, oth);", "", "list& list::insert(int ndx, double other) {", " number oth = number(other);", " return insert(ndx, oth);", "", "list& list::insert(int ndx, char* other) {", " str oth = str(other);", " return insert(ndx, oth);", "", "list& list::insert(int ndx, std::string other) {", " str oth = str(other.c_str());", " return insert(ndx, oth);", "// list_member", "list_member::list_member(PyObject* obj, list& parent, int ndx)", " : object(obj), _parent(parent), _ndx(ndx) { }", "", "list_member& list_member::operator=(const object& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for set_item to steal", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "list_member& list_member::operator=(const list_member& other) {", " GrabRef(other);", " //Py_XINCREF(_obj); // this one is for set_item to steal", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "list_member& list_member::operator=(int other) {", " GrabRef(number(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "list_member& list_member::operator=(double other) {", " GrabRef(number(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "list_member& list_member::operator=(const char* other) {", " GrabRef(str(other));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "list_member& list_member::operator=(std::string other) {", " GrabRef(str(other.c_str()));", " _parent.set_item(_ndx, *this);", " return *this;", "}", "", "//---------------------------------------------------------------------------", "// dict_member", "//---------------------------------------------------------------------------", "", "dict_member& dict_member::operator=(const object& other) {", " GrabRef(other);", " _parent.set_item(_key, *this);", " return *this;", "}", "", "dict_member& dict_member::operator=(int other) {", " GrabRef(number(other));", " _parent.set_item(_key, *this);", " return *this;", "}", "", "dict_member& dict_member::operator=(double other) {", " GrabRef(number(other));", " _parent.set_item(_key, *this);", " return *this;", "}", "", "dict_member& dict_member::operator=(const char* other) {", " GrabRef(str(other));", " _parent.set_item(_key, *this);", " return *this;", "}", "", "dict_member& dict_member::operator=(std::string other) {", " GrabRef(str(other.c_str()));", " _parent.set_item(_key, *this);", " return *this;", "}", "", "//---------------------------------------------------------------------------", "// callable", "//---------------------------------------------------------------------------", "", "object callable::call() const {", " static tuple _empty;", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, _empty, NULL);", " if (rslt == 0)", " throw 1;", " return rslt;", "}", "object callable::call(tuple& args) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, NULL);", " if (rslt == 0)", " throw 1;", " return rslt;", "}", "object callable::call(tuple& args, dict& kws) const {", " PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args, kws);", " if (rslt == 0)", " throw 1;", " return rslt;", "}", "", "void py::Fail(PyObject* exc, const char* msg)", "}" ] } }, { "old_path": null, "new_path": "weave/tests/scxx_timings.py", "filename": "scxx_timings.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,129 @@\n+import weave\n+import time\n+\n+force = 0\n+N = 1000000\n+\n+def list_append_scxx(a,Na):\n+ code = \"\"\"\n+ for(int i = 0; i < Na;i++)\n+ a.append(i); \n+ \"\"\"\n+ weave.inline(code,['a','Na'],force=force,verbose=2,compiler='gcc')\n+\n+def list_append_c(a,Na):\n+ code = \"\"\"\n+ for(int i = 0; i < Na;i++)\n+ {\n+ PyObject* oth = PyInt_FromLong(i);\n+ int res = PyList_Append(py_a,oth);\n+ Py_DECREF(oth);\n+ if(res == -1)\n+ {\n+ PyErr_Clear(); //Python sets one \n+ throw_error(PyExc_RuntimeError, \"append failed\");\n+ } \n+ }\n+ \"\"\"\n+ weave.inline(code,['a','Na'],force=force,compiler='gcc')\n+\n+def list_append_py(a,Na):\n+ for i in xrange(Na):\n+ a.append(i)\n+\n+def time_list_append(Na):\n+ \"\"\" Compare the list append method from scxx to using the Python API\n+ directly.\n+ \"\"\"\n+ print 'list appending times:', \n+\n+ a = []\n+ t1 = time.time()\n+ list_append_c(a,Na)\n+ t2 = time.time()\n+ print 'py api: ', t2 - t1, ''\n+ \n+ a = []\n+ t1 = time.time()\n+ list_append_c(a,Na)\n+ t2 = time.time()\n+ print 'py api: ', t2 - t1\n+ \n+ a = []\n+ t1 = time.time()\n+ list_append_scxx(a,Na)\n+ t2 = time.time()\n+ print 'scxx: ', t2 - t1 \n+ \n+ a = []\n+ t1 = time.time()\n+ list_append_c(a,Na)\n+ t2 = time.time()\n+ print 'python: ', t2 - t1\n+\n+#----------------------------------------------------------------------------\n+#\n+#----------------------------------------------------------------------------\n+\n+def list_copy_scxx(a,b):\n+ code = \"\"\"\n+ for(int i = 0; i < a.length();i++)\n+ b[i] = a[i]; \n+ \"\"\"\n+ weave.inline(code,['a','b'],force=force,verbose=2,compiler='gcc')\n+\n+def list_copy_c(a,b):\n+ code = \"\"\"\n+ for(int i = 0; i < a.length();i++)\n+ {\n+ int res = PySequence_SetItem(py_b,i,PyList_GET_ITEM(py_a,i));\n+ if(res == -1)\n+ {\n+ PyErr_Clear(); //Python sets one \n+ throw_error(PyExc_RuntimeError, \"append failed\");\n+ } \n+ }\n+ \"\"\"\n+ weave.inline(code,['a','b'],force=force,compiler='gcc')\n+\n+def list_copy_py(a,b):\n+ for item in a:\n+ b[i] = item\n+\n+def time_list_copy(N):\n+ \"\"\" Compare the list append method from scxx to using the Python API\n+ directly.\n+ \"\"\"\n+ print 'list copy times:', \n+\n+ a = [0] * N\n+ b = [1] * N\n+ t1 = time.time()\n+ list_copy_c(a,b)\n+ t2 = time.time()\n+ print 'py api: ', t2 - t1, ''\n+ \n+ a = [0] * N\n+ b = [1] * N\n+ t1 = time.time()\n+ list_copy_c(a,b)\n+ t2 = time.time()\n+ print 'py api: ', t2 - t1\n+ \n+ a = [0] * N\n+ b = [1] * N\n+ t1 = time.time()\n+ list_copy_scxx(a,b)\n+ t2 = time.time()\n+ print 'scxx: ', t2 - t1 \n+ \n+ a = [0] * N\n+ b = [1] * N\n+ t1 = time.time()\n+ list_copy_c(a,b)\n+ t2 = time.time()\n+ print 'python: ', t2 - t1\n+ \n+if __name__ == \"__main__\":\n+ #time_list_append(N)\n+ time_list_copy(N)\n\\ No newline at end of file\n", "added_lines": 129, "deleted_lines": 0, "source_code": "import weave\nimport time\n\nforce = 0\nN = 1000000\n\ndef list_append_scxx(a,Na):\n code = \"\"\"\n for(int i = 0; i < Na;i++)\n a.append(i); \n \"\"\"\n weave.inline(code,['a','Na'],force=force,verbose=2,compiler='gcc')\n\ndef list_append_c(a,Na):\n code = \"\"\"\n for(int i = 0; i < Na;i++)\n {\n PyObject* oth = PyInt_FromLong(i);\n int res = PyList_Append(py_a,oth);\n Py_DECREF(oth);\n if(res == -1)\n {\n PyErr_Clear(); //Python sets one \n throw_error(PyExc_RuntimeError, \"append failed\");\n } \n }\n \"\"\"\n weave.inline(code,['a','Na'],force=force,compiler='gcc')\n\ndef list_append_py(a,Na):\n for i in xrange(Na):\n a.append(i)\n\ndef time_list_append(Na):\n \"\"\" Compare the list append method from scxx to using the Python API\n directly.\n \"\"\"\n print 'list appending times:', \n\n a = []\n t1 = time.time()\n list_append_c(a,Na)\n t2 = time.time()\n print 'py api: ', t2 - t1, ''\n \n a = []\n t1 = time.time()\n list_append_c(a,Na)\n t2 = time.time()\n print 'py api: ', t2 - t1\n \n a = []\n t1 = time.time()\n list_append_scxx(a,Na)\n t2 = time.time()\n print 'scxx: ', t2 - t1 \n \n a = []\n t1 = time.time()\n list_append_c(a,Na)\n t2 = time.time()\n print 'python: ', t2 - t1\n\n#----------------------------------------------------------------------------\n#\n#----------------------------------------------------------------------------\n\ndef list_copy_scxx(a,b):\n code = \"\"\"\n for(int i = 0; i < a.length();i++)\n b[i] = a[i]; \n \"\"\"\n weave.inline(code,['a','b'],force=force,verbose=2,compiler='gcc')\n\ndef list_copy_c(a,b):\n code = \"\"\"\n for(int i = 0; i < a.length();i++)\n {\n int res = PySequence_SetItem(py_b,i,PyList_GET_ITEM(py_a,i));\n if(res == -1)\n {\n PyErr_Clear(); //Python sets one \n throw_error(PyExc_RuntimeError, \"append failed\");\n } \n }\n \"\"\"\n weave.inline(code,['a','b'],force=force,compiler='gcc')\n\ndef list_copy_py(a,b):\n for item in a:\n b[i] = item\n\ndef time_list_copy(N):\n \"\"\" Compare the list append method from scxx to using the Python API\n directly.\n \"\"\"\n print 'list copy times:', \n\n a = [0] * N\n b = [1] * N\n t1 = time.time()\n list_copy_c(a,b)\n t2 = time.time()\n print 'py api: ', t2 - t1, ''\n \n a = [0] * N\n b = [1] * N\n t1 = time.time()\n list_copy_c(a,b)\n t2 = time.time()\n print 'py api: ', t2 - t1\n \n a = [0] * N\n b = [1] * N\n t1 = time.time()\n list_copy_scxx(a,b)\n t2 = time.time()\n print 'scxx: ', t2 - t1 \n \n a = [0] * N\n b = [1] * N\n t1 = time.time()\n list_copy_c(a,b)\n t2 = time.time()\n print 'python: ', t2 - t1\n \nif __name__ == \"__main__\":\n #time_list_append(N)\n time_list_copy(N)", "source_code_before": null, "methods": [ { "name": "list_append_scxx", "long_name": "list_append_scxx( a , Na )", "filename": "scxx_timings.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "a", "Na" ], "start_line": 7, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_append_c", "long_name": "list_append_c( a , Na )", "filename": "scxx_timings.py", "nloc": 15, "complexity": 1, "token_count": 30, "parameters": [ "a", "Na" ], "start_line": 14, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "list_append_py", "long_name": "list_append_py( a , Na )", "filename": "scxx_timings.py", "nloc": 3, "complexity": 2, "token_count": 21, "parameters": [ "a", "Na" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "time_list_append", "long_name": "time_list_append( Na )", "filename": "scxx_timings.py", "nloc": 22, "complexity": 1, "token_count": 131, "parameters": [ "Na" ], "start_line": 34, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "list_copy_scxx", "long_name": "list_copy_scxx( a , b )", "filename": "scxx_timings.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "a", "b" ], "start_line": 68, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "list_copy_c", "long_name": "list_copy_c( a , b )", "filename": "scxx_timings.py", "nloc": 13, "complexity": 1, "token_count": 30, "parameters": [ "a", "b" ], "start_line": 75, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "list_copy_py", "long_name": "list_copy_py( a , b )", "filename": "scxx_timings.py", "nloc": 3, "complexity": 2, "token_count": 18, "parameters": [ "a", "b" ], "start_line": 89, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "time_list_copy", "long_name": "time_list_copy( N )", "filename": "scxx_timings.py", "nloc": 26, "complexity": 1, "token_count": 171, "parameters": [ "N" ], "start_line": 93, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "list_copy_py", "long_name": "list_copy_py( a , b )", "filename": "scxx_timings.py", "nloc": 3, "complexity": 2, "token_count": 18, "parameters": [ "a", "b" ], "start_line": 89, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "time_list_copy", "long_name": "time_list_copy( N )", "filename": "scxx_timings.py", "nloc": 26, "complexity": 1, "token_count": 171, "parameters": [ "N" ], "start_line": 93, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "list_copy_scxx", "long_name": "list_copy_scxx( a , b )", "filename": "scxx_timings.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "a", "b" ], "start_line": 68, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "time_list_append", "long_name": "time_list_append( Na )", "filename": "scxx_timings.py", "nloc": 22, "complexity": 1, "token_count": 131, "parameters": [ "Na" ], "start_line": 34, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "list_copy_c", "long_name": "list_copy_c( a , b )", "filename": "scxx_timings.py", "nloc": 13, "complexity": 1, "token_count": 30, "parameters": [ "a", "b" ], "start_line": 75, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "list_append_c", "long_name": "list_append_c( a , Na )", "filename": "scxx_timings.py", "nloc": 15, "complexity": 1, "token_count": 30, "parameters": [ "a", "Na" ], "start_line": 14, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "list_append_py", "long_name": "list_append_py( a , Na )", "filename": "scxx_timings.py", "nloc": 3, "complexity": 2, "token_count": 21, "parameters": [ "a", "Na" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "list_append_scxx", "long_name": "list_append_scxx( a , Na )", "filename": "scxx_timings.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "a", "Na" ], "start_line": 7, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "nloc": 100, "complexity": 10, "token_count": 496, "diff_parsed": { "added": [ "import weave", "import time", "", "force = 0", "N = 1000000", "", "def list_append_scxx(a,Na):", " code = \"\"\"", " for(int i = 0; i < Na;i++)", " a.append(i);", " \"\"\"", " weave.inline(code,['a','Na'],force=force,verbose=2,compiler='gcc')", "", "def list_append_c(a,Na):", " code = \"\"\"", " for(int i = 0; i < Na;i++)", " {", " PyObject* oth = PyInt_FromLong(i);", " int res = PyList_Append(py_a,oth);", " Py_DECREF(oth);", " if(res == -1)", " {", " PyErr_Clear(); //Python sets one", " throw_error(PyExc_RuntimeError, \"append failed\");", " }", " }", " \"\"\"", " weave.inline(code,['a','Na'],force=force,compiler='gcc')", "", "def list_append_py(a,Na):", " for i in xrange(Na):", " a.append(i)", "", "def time_list_append(Na):", " \"\"\" Compare the list append method from scxx to using the Python API", " directly.", " \"\"\"", " print 'list appending times:',", "", " a = []", " t1 = time.time()", " list_append_c(a,Na)", " t2 = time.time()", " print 'py api: ', t2 - t1, ''", "", " a = []", " t1 = time.time()", " list_append_c(a,Na)", " t2 = time.time()", " print 'py api: ', t2 - t1", "", " a = []", " t1 = time.time()", " list_append_scxx(a,Na)", " t2 = time.time()", " print 'scxx: ', t2 - t1", "", " a = []", " t1 = time.time()", " list_append_c(a,Na)", " t2 = time.time()", " print 'python: ', t2 - t1", "", "#----------------------------------------------------------------------------", "#", "#----------------------------------------------------------------------------", "", "def list_copy_scxx(a,b):", " code = \"\"\"", " for(int i = 0; i < a.length();i++)", " b[i] = a[i];", " \"\"\"", " weave.inline(code,['a','b'],force=force,verbose=2,compiler='gcc')", "", "def list_copy_c(a,b):", " code = \"\"\"", " for(int i = 0; i < a.length();i++)", " {", " int res = PySequence_SetItem(py_b,i,PyList_GET_ITEM(py_a,i));", " if(res == -1)", " {", " PyErr_Clear(); //Python sets one", " throw_error(PyExc_RuntimeError, \"append failed\");", " }", " }", " \"\"\"", " weave.inline(code,['a','b'],force=force,compiler='gcc')", "", "def list_copy_py(a,b):", " for item in a:", " b[i] = item", "", "def time_list_copy(N):", " \"\"\" Compare the list append method from scxx to using the Python API", " directly.", " \"\"\"", " print 'list copy times:',", "", " a = [0] * N", " b = [1] * N", " t1 = time.time()", " list_copy_c(a,b)", " t2 = time.time()", " print 'py api: ', t2 - t1, ''", "", " a = [0] * N", " b = [1] * N", " t1 = time.time()", " list_copy_c(a,b)", " t2 = time.time()", " print 'py api: ', t2 - t1", "", " a = [0] * N", " b = [1] * N", " t1 = time.time()", " list_copy_scxx(a,b)", " t2 = time.time()", " print 'scxx: ', t2 - t1", "", " a = [0] * N", " b = [1] * N", " t1 = time.time()", " list_copy_c(a,b)", " t2 = time.time()", " print 'python: ', t2 - t1", "", "if __name__ == \"__main__\":", " #time_list_append(N)", " time_list_copy(N)" ], "deleted": [] } }, { "old_path": "weave/tests/test_scxx.py", "new_path": "weave/tests/test_scxx.py", "filename": "test_scxx.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -9,736 +9,22 @@\n import inline_tools\n restore_path()\n \n-# Test:\n-# append DONE\n-# insert DONE\n-# in DONE\n-# count DONE\n-# setItem DONE\n-# operator[] (get)\n-# operator[] (set) DONE\n-\n-class test_list(unittest.TestCase):\n- def check_conversion(self):\n- a = []\n- before = sys.getrefcount(a)\n- import weave\n- weave.inline(\"\",['a'])\n- print 'first:',before\n- # first call is goofing up refcount.\n- before = sys.getrefcount(a) \n- weave.inline(\"\",['a'])\n- after = sys.getrefcount(a) \n- print '2nd,3rd:', before, after\n- assert(after == before)\n-\n- def check_append_passed_item(self):\n- a = []\n- item = 1\n- \n- # temporary refcount fix until I understand why it incs by one.\n- inline_tools.inline(\"a.append(item);\",['a','item'])\n- del a[0] \n- \n- before1 = sys.getrefcount(a)\n- before2 = sys.getrefcount(item)\n- inline_tools.inline(\"a.append(item);\",['a','item'])\n- assert a[0] is item\n- del a[0] \n- after1 = sys.getrefcount(a)\n- after2 = sys.getrefcount(item)\n- assert after1 == before1\n- assert after2 == before2\n-\n- \n- def check_append(self):\n- a = []\n-\n- # temporary refcount fix until I understand why it incs by one.\n- inline_tools.inline(\"a.append(1);\",['a'])\n- del a[0] \n- \n- before1 = sys.getrefcount(a)\n- \n- # check overloaded append(int val) method\n- inline_tools.inline(\"a.append(1234);\",['a']) \n- assert sys.getrefcount(a[0]) == 2 \n- assert a[0] == 1234\n- del a[0] \n-\n- # check overloaded append(double val) method\n- inline_tools.inline(\"a.append(123.0);\",['a'])\n- assert sys.getrefcount(a[0]) == 2 \n- assert a[0] == 123.0\n- del a[0] \n- \n- # check overloaded append(char* val) method \n- inline_tools.inline('a.append(\"bubba\");',['a'])\n- assert sys.getrefcount(a[0]) == 2 \n- assert a[0] == 'bubba'\n- del a[0] \n- \n- # check overloaded append(std::string val) method\n- inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n- assert sys.getrefcount(a[0]) == 2 \n- assert a[0] == 'sissy'\n- del a[0] \n- \n- after1 = sys.getrefcount(a)\n- assert after1 == before1\n-\n- def check_insert(self):\n- a = [1,2,3]\n- \n- a.insert(1,234)\n- del a[1]\n- \n- # temporary refcount fix until I understand why it incs by one.\n- inline_tools.inline(\"a.insert(1,1234);\",['a'])\n- del a[1] \n- \n- before1 = sys.getrefcount(a)\n- \n- # check overloaded insert(int ndx, int val) method\n- inline_tools.inline(\"a.insert(1,1234);\",['a']) \n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 1234\n- del a[1] \n-\n- # check overloaded insert(int ndx, double val) method\n- inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 123.0\n- del a[1] \n- \n- # check overloaded insert(int ndx, char* val) method \n- inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 'bubba'\n- del a[1] \n- \n- # check overloaded insert(int ndx, std::string val) method\n- inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 'sissy'\n- del a[0] \n- \n- after1 = sys.getrefcount(a)\n- assert after1 == before1\n-\n- def check_set_item(self):\n- a = [1,2,3]\n- \n- # temporary refcount fix until I understand why it incs by one.\n- inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n- \n- before1 = sys.getrefcount(a)\n- \n- # check overloaded insert(int ndx, int val) method\n- inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 1234\n-\n- # check overloaded insert(int ndx, double val) method\n- inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 123.0\n- \n- # check overloaded insert(int ndx, char* val) method \n- inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 'bubba'\n- \n- # check overloaded insert(int ndx, std::string val) method\n- inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 'sissy'\n- \n- after1 = sys.getrefcount(a)\n- assert after1 == before1\n-\n- def check_set_item_operator_equal(self):\n- a = [1,2,3]\n- \n- # temporary refcount fix until I understand why it incs by one.\n- inline_tools.inline(\"a[1] = 1234;\",['a'])\n- \n- before1 = sys.getrefcount(a)\n- \n- # check overloaded insert(int ndx, int val) method\n- inline_tools.inline(\"a[1] = 1234;\",['a']) \n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 1234\n-\n- # check overloaded insert(int ndx, double val) method\n- inline_tools.inline(\"a[1] = 123.0;\",['a'])\n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 123.0\n- \n- # check overloaded insert(int ndx, char* val) method \n- inline_tools.inline('a[1] = \"bubba\";',['a'])\n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 'bubba'\n- \n- # check overloaded insert(int ndx, std::string val) method\n- inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n- assert sys.getrefcount(a[1]) == 2 \n- assert a[1] == 'sissy'\n- \n- after1 = sys.getrefcount(a)\n- assert after1 == before1\n-\n- def check_in(self):\n- \"\"\" Test the \"in\" method for lists. We'll assume\n- it works for sequences if it works here.\n- \"\"\"\n- a = [1,2,'alpha',3.1416]\n-\n- item = 1\n- code = \"return_val = PyInt_FromLong(a.in(item));\"\n- res = inline_tools.inline(code,['a','item'])\n- assert res == 1\n- item = 0\n- res = inline_tools.inline(code,['a','item'])\n- assert res == 0\n- \n- # check overloaded in(int val) method\n- code = \"return_val = PyInt_FromLong(a.in(1));\"\n- res = inline_tools.inline(code,['a'])\n- assert res == 1\n- code = \"return_val = PyInt_FromLong(a.in(0));\"\n- res = inline_tools.inline(code,['a'])\n- assert res == 0\n- \n- # check overloaded in(double val) method\n- code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n- res = inline_tools.inline(code,['a'])\n- assert res == 1\n- code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n- res = inline_tools.inline(code,['a'])\n- assert res == 0\n- \n- # check overloaded in(char* val) method \n- code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n- res = inline_tools.inline(code,['a'])\n- assert res == 1\n- code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n- res = inline_tools.inline(code,['a'])\n- assert res == 0\n- \n- # check overloaded in(std::string val) method\n- code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n- res = inline_tools.inline(code,['a'])\n- assert res == 1\n- code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n- res = inline_tools.inline(code,['a'])\n- assert res == 0\n-\n- def check_count(self):\n- \"\"\" Test the \"count\" method for lists. We'll assume\n- it works for sequences if it works hre.\n- \"\"\"\n- a = [1,2,'alpha',3.1416]\n-\n- item = 1\n- code = \"return_val = PyInt_FromLong(a.count(item));\"\n- res = inline_tools.inline(code,['a','item'])\n- assert res == 1\n- \n- # check overloaded count(int val) method\n- code = \"return_val = PyInt_FromLong(a.count(1));\"\n- res = inline_tools.inline(code,['a'])\n- assert res == 1\n- \n- # check overloaded count(double val) method\n- code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n- res = inline_tools.inline(code,['a'])\n- assert res == 1\n- \n- # check overloaded count(char* val) method \n- code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n- res = inline_tools.inline(code,['a'])\n- assert res == 1\n- \n- # check overloaded count(std::string val) method\n- code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n- res = inline_tools.inline(code,['a'])\n- assert res == 1\n-\n- def check_access_speed(self):\n- N = 1000000\n- print 'list access -- val = a[i] for N =', N\n- a = [0] * N\n- val = 0\n- t1 = time.time()\n- for i in xrange(N):\n- val = a[i]\n- t2 = time.time()\n- print 'python1:', t2 - t1\n- t1 = time.time()\n- for i in a:\n- val = i\n- t2 = time.time()\n- print 'python2:', t2 - t1\n- \n- code = \"\"\"\n- const int N = a.length();\n- py::object val;\n- for(int i=0; i < N; i++)\n- val = a[i];\n- \"\"\"\n- # compile not included in timing \n- inline_tools.inline(code,['a']) \n- t1 = time.time()\n- inline_tools.inline(code,['a']) \n- t2 = time.time()\n- print 'weave:', t2 - t1\n-\n- def check_access_set_speed(self):\n- N = 1000000\n- print 'list access/set -- b[i] = a[i] for N =', N \n- a = [0] * N\n- b = [1] * N\n- t1 = time.time()\n- for i in xrange(N):\n- b[i] = a[i]\n- t2 = time.time()\n- print 'python:', t2 - t1\n- \n- a = [0] * N\n- b = [1] * N \n- code = \"\"\"\n- const int N = a.length();\n- for(int i=0; i < N; i++)\n- b[i] = a[i]; \n- \"\"\"\n- # compile not included in timing\n- inline_tools.inline(code,['a','b']) \n- t1 = time.time()\n- inline_tools.inline(code,['a','b']) \n- t2 = time.time()\n- print 'weave:', t2 - t1\n- assert b == a \n-\n- def check_string_add_speed(self):\n- N = 1000000\n- print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n- a = [\"blah\"] * N\n- desired = [1] * N\n- t1 = time.time()\n- for i in xrange(N):\n- desired[i] = a[i] + 'blah'\n- t2 = time.time()\n- print 'python:', t2 - t1\n- \n- a = [\"blah\"] * N\n- b = [1] * N \n- code = \"\"\"\n- const int N = a.length();\n- std::string blah = std::string(\"blah\");\n- for(int i=0; i < N; i++)\n- b[i] = (std::string)a[i] + blah; \n- \"\"\"\n- # compile not included in timing\n- inline_tools.inline(code,['a','b']) \n- t1 = time.time()\n- inline_tools.inline(code,['a','b']) \n- t2 = time.time()\n- print 'weave:', t2 - t1\n- assert b == desired \n-\n- def check_int_add_speed(self):\n- N = 1000000\n- print 'int add -- b[i] = a[i] + 1 for N =', N \n- a = [0] * N\n- desired = [1] * N\n- t1 = time.time()\n- for i in xrange(N):\n- desired[i] = a[i] + 1\n- t2 = time.time()\n- print 'python:', t2 - t1\n- \n- a = [0] * N\n- b = [0] * N \n- code = \"\"\"\n- const int N = a.length();\n- for(int i=0; i < N; i++)\n- b[i] = (int)a[i] + 1; \n- \"\"\"\n- # compile not included in timing\n- inline_tools.inline(code,['a','b']) \n- t1 = time.time()\n- inline_tools.inline(code,['a','b']) \n- t2 = time.time()\n- print 'weave:', t2 - t1\n- assert b == desired \n-\n-class test_object_construct(unittest.TestCase):\n- #------------------------------------------------------------------------\n- # Check that construction from basic types is allowed and have correct\n- # reference counts\n- #------------------------------------------------------------------------\n- def check_int(self):\n- # strange int value used to try and make sure refcount is 2.\n- code = \"\"\"\n- py::object val = 1001;\n- return_val = val;\n- \"\"\"\n- res = inline_tools.inline(code)\n- assert sys.getrefcount(res) == 2\n- assert res == 1001\n- def check_float(self):\n- code = \"\"\"\n- py::object val = (float)1.0;\n- return_val = val;\n- \"\"\"\n- res = inline_tools.inline(code)\n- assert sys.getrefcount(res) == 2\n- assert res == 1.0\n- def check_double(self):\n- code = \"\"\"\n- py::object val = 1.0;\n- return_val = val;\n- \"\"\"\n- res = inline_tools.inline(code)\n- assert sys.getrefcount(res) == 2\n- assert res == 1.0\n- def check_complex(self):\n- code = \"\"\"\n- std::complex num = std::complex(1.0,1.0);\n- py::object val = num;\n- return_val = val;\n- \"\"\"\n- res = inline_tools.inline(code)\n- assert sys.getrefcount(res) == 2\n- assert res == 1.0+1.0j\n- def check_string(self):\n- code = \"\"\"\n- py::object val = \"hello\";\n- return_val = val;\n- \"\"\"\n- res = inline_tools.inline(code)\n- assert sys.getrefcount(res) == 2\n- assert res == \"hello\"\n-\n- def check_std_string(self):\n- code = \"\"\"\n- std::string s = std::string(\"hello\");\n- py::object val = s;\n- return_val = val;\n- \"\"\"\n- res = inline_tools.inline(code)\n- assert sys.getrefcount(res) == 2\n- assert res == \"hello\"\n- \n- \n-class test_object_cast(unittest.TestCase):\n- def check_int_cast(self):\n- code = \"\"\"\n- py::object val = 1;\n- int raw_val = val;\n- \"\"\"\n- inline_tools.inline(code)\n- def check_double_cast(self):\n- code = \"\"\"\n- py::object val = 1.0;\n- double raw_val = val;\n- \"\"\"\n- inline_tools.inline(code)\n- def check_float_cast(self):\n- code = \"\"\"\n- py::object val = 1.0;\n- float raw_val = val;\n- \"\"\"\n- inline_tools.inline(code)\n- def check_complex_cast(self):\n- code = \"\"\"\n- std::complex num = std::complex(1.0,1.0);\n- py::object val = num;\n- std::complex raw_val = val;\n- \"\"\"\n- inline_tools.inline(code)\n- def check_string_cast(self):\n- code = \"\"\"\n- py::object val = \"hello\";\n- std::string raw_val = val;\n- \"\"\"\n- inline_tools.inline(code)\n- \n-# test class used for testing python class access from C++.\n-class foo:\n- def bar(self):\n- return \"bar results\"\n- def bar2(self,val1,val2):\n- return val1, val2\n- def bar3(self,val1,val2,val3=1):\n- return val1, val2, val3\n-\n-class str_obj:\n- def __str__(self):\n- return \"b\"\n-\n-class test_object_hasattr(unittest.TestCase):\n- def check_string(self):\n- a = foo()\n- a.b = 12345\n- code = \"\"\"\n- return_val = a.hasattr(\"b\"); \n- \"\"\"\n- res = inline_tools.inline(code,['a'])\n- assert res\n- def check_std_string(self):\n- a = foo()\n- a.b = 12345\n- attr_name = \"b\"\n- code = \"\"\"\n- return_val = a.hasattr(attr_name); \n- \"\"\"\n- res = inline_tools.inline(code,['a','attr_name'])\n- assert res \n- def check_string_fail(self):\n- a = foo()\n- a.b = 12345\n- code = \"\"\"\n- return_val = a.hasattr(\"c\"); \n- \"\"\"\n- res = inline_tools.inline(code,['a'])\n- assert not res\n- def check_inline(self):\n- \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n- \"\"\"\n- a = foo()\n- a.b = 12345\n- code = \"\"\"\n- throw_error(PyExc_AttributeError,\"bummer\"); \n- \"\"\"\n- try:\n- before = sys.getrefcount(a)\n- res = inline_tools.inline(code,['a'])\n- except AttributeError:\n- after = sys.getrefcount(a)\n- try: \n- res = inline_tools.inline(code,['a'])\n- except:\n- after2 = sys.getrefcount(a)\n- print \"after and after2 should be equal in the following\" \n- print 'before, after, after2:', before, after, after2\n- pass \n-\n- def check_func(self):\n- a = foo()\n- a.b = 12345\n- code = \"\"\"\n- return_val = a.hasattr(\"bar\"); \n- \"\"\"\n- res = inline_tools.inline(code,['a'])\n- assert res\n-\n-class test_object_attr(unittest.TestCase):\n-\n- def generic_attr(self,code,args=['a']):\n- a = foo()\n- a.b = 12345\n- \n- before = sys.getrefcount(a.b)\n- res = inline_tools.inline(code,args)\n- assert res == a.b\n- del res\n- after = sys.getrefcount(a.b)\n- assert after == before\n-\n- def check_char(self):\n- self.generic_attr('return_val = a.attr(\"b\");')\n-\n- def check_string(self):\n- self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n-\n- def check_obj(self):\n- code = \"\"\"\n- py::str name = py::str(\"b\");\n- return_val = a.attr(name);\n- \"\"\" \n- self.generic_attr(code,['a'])\n- def check_attr_call(self):\n- a = foo()\n- res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n- first = sys.getrefcount(res)\n- del res\n- res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n- second = sys.getrefcount(res)\n- assert res == \"bar results\"\n- assert first == second\n-\n-class test_object_mcall(unittest.TestCase):\n- def check_noargs(self):\n- a = foo()\n- res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n- assert res == \"bar results\"\n- first = sys.getrefcount(res)\n- del res\n- res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n- assert res == \"bar results\"\n- second = sys.getrefcount(res)\n- assert first == second\n- def check_args(self):\n- a = foo()\n- code = \"\"\"\n- py::tuple args(2);\n- args[0] = 1;\n- args[1] = \"hello\";\n- return_val = a.mcall(\"bar2\",args);\n- \"\"\"\n- res = inline_tools.inline(code,['a'])\n- assert res == (1,\"hello\")\n- assert sys.getrefcount(res) == 2\n- def check_args_kw(self):\n- a = foo()\n- code = \"\"\"\n- py::tuple args(2);\n- args[0] = 1;\n- args[1] = \"hello\";\n- py::dict kw;\n- kw[\"val3\"] = 3;\n- return_val = a.mcall(\"bar3\",args,kw);\n- \"\"\"\n- res = inline_tools.inline(code,['a'])\n- assert res == (1,\"hello\",3)\n- assert sys.getrefcount(res) == 2\n- def check_std_noargs(self):\n- a = foo()\n- method = \"bar\"\n- res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n- assert res == \"bar results\"\n- first = sys.getrefcount(res)\n- del res\n- res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n- assert res == \"bar results\"\n- second = sys.getrefcount(res)\n- assert first == second\n- def check_std_args(self):\n- a = foo()\n- method = \"bar2\"\n- code = \"\"\"\n- py::tuple args(2);\n- args[0] = 1;\n- args[1] = \"hello\";\n- return_val = a.mcall(method,args);\n- \"\"\"\n- res = inline_tools.inline(code,['a','method'])\n- assert res == (1,\"hello\")\n- assert sys.getrefcount(res) == 2\n- def check_std_args_kw(self):\n- a = foo()\n- method = \"bar3\"\n- code = \"\"\"\n- py::tuple args(2);\n- args[0] = 1;\n- args[1] = \"hello\";\n- py::dict kw;\n- kw[\"val3\"] = 3;\n- return_val = a.mcall(method,args,kw);\n- \"\"\"\n- res = inline_tools.inline(code,['a','method'])\n- assert res == (1,\"hello\",3)\n- assert sys.getrefcount(res) == 2\n- def check_noargs_with_args(self):\n- # calling a function that does take args with args \n- # should fail.\n- a = foo()\n- code = \"\"\"\n- py::tuple args(2);\n- args[0] = 1;\n- args[1] = \"hello\";\n- return_val = a.mcall(\"bar\",args);\n- \"\"\"\n- try:\n- first = sys.getrefcount(a)\n- res = inline_tools.inline(code,['a'])\n- except TypeError:\n- second = sys.getrefcount(a) \n- try:\n- res = inline_tools.inline(code,['a'])\n- except TypeError:\n- third = sys.getrefcount(a) \n- # first should == second, but the weird refcount error \n- assert second == third\n-\n-class test_object_call(unittest.TestCase):\n- def check_noargs(self):\n- def foo():\n- return (1,2,3)\n- res = inline_tools.inline('return_val = foo.call();',['foo'])\n- assert res == (1,2,3)\n- assert sys.getrefcount(res) == 2\n- def check_args(self):\n- def foo(val1,val2):\n- return (val1,val2)\n- code = \"\"\"\n- py::tuple args(2);\n- args[0] = 1;\n- args[1] = \"hello\";\n- return_val = foo.call(args);\n- \"\"\"\n- res = inline_tools.inline(code,['foo'])\n- assert res == (1,\"hello\")\n- assert sys.getrefcount(res) == 2\n- def check_args_kw(self):\n- def foo(val1,val2,val3=1):\n- return (val1,val2,val3)\n- code = \"\"\"\n- py::tuple args(2);\n- args[0] = 1;\n- args[1] = \"hello\";\n- py::dict kw;\n- kw[\"val3\"] = 3; \n- return_val = foo.call(args,kw);\n- \"\"\"\n- res = inline_tools.inline(code,['foo'])\n- assert res == (1,\"hello\",3)\n- assert sys.getrefcount(res) == 2\n- def check_noargs_with_args(self):\n- # calling a function that does take args with args \n- # should fail.\n- def foo():\n- return \"blah\"\n- code = \"\"\"\n- py::tuple args(2);\n- args[0] = 1;\n- args[1] = \"hello\";\n- return_val = foo.call(args);\n- \"\"\"\n- try:\n- first = sys.getrefcount(foo)\n- res = inline_tools.inline(code,['foo'])\n- except TypeError:\n- second = sys.getrefcount(foo) \n- try:\n- res = inline_tools.inline(code,['foo'])\n- except TypeError:\n- third = sys.getrefcount(foo) \n- # first should == second, but the weird refcount error \n- assert second == third\n- \n def test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n- #suites.append( makeSuite(test_list,'check_'))\n- \n- #suites.append( makeSuite(test_object_construct,'check_'))\n- #suites.append( makeSuite(test_object_cast,'check_'))\n- #suites.append( makeSuite(test_object_hasattr,'check_')) \n- #suites.append( makeSuite(test_object_attr,'check_'))\n- suites.append( makeSuite(test_object_mcall,'check_'))\n- suites.append( makeSuite(test_object_call,'check_'))\n- \n-\n+ import test_scxx_object\n+ suites.append( test_scxx_object.test_suite(level))\n+ import test_scxx_sequence\n+ suites.append( test_scxx_sequence.test_suite(level))\n+ import test_scxx_dict\n+ suites.append( test_scxx_dict.test_suite(level))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n \n-def test(level=10):\n+def test(level=10,verbose=2):\n all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n+ runner = unittest.TextTestRunner(verbosity=verbose)\n runner.run(all_tests)\n return runner\n \n", "added_lines": 8, "deleted_lines": 722, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n import test_scxx_object\n suites.append( test_scxx_object.test_suite(level))\n import test_scxx_sequence\n suites.append( test_scxx_sequence.test_suite(level))\n import test_scxx_dict\n suites.append( test_scxx_dict.test_suite(level))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbose=2):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner(verbosity=verbose)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nclass test_list(unittest.TestCase):\n def check_conversion(self):\n a = []\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n print 'first:',before\n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n print '2nd,3rd:', before, after\n assert(after == before)\n\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2\n\n \n def check_append(self):\n a = []\n\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.set_item(1,1234);\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.set_item(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.set_item(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.set_item(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = [1,2,3]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n item = 1\n code = \"return_val = PyInt_FromLong(a.in(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = PyInt_FromLong(a.in(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(0));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = PyInt_FromLong(a.in(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = PyInt_FromLong(a.in(3.1417));\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = [1,2,'alpha',3.1416]\n\n item = 1\n code = \"return_val = PyInt_FromLong(a.count(item));\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = PyInt_FromLong(a.count(1));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = PyInt_FromLong(a.count(3.1416));\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n\n def check_access_speed(self):\n N = 1000000\n print 'list access -- val = a[i] for N =', N\n a = [0] * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self):\n N = 1000000\n print 'list access/set -- b[i] = a[i] for N =', N \n a = [0] * N\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == a \n\n def check_string_add_speed(self):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 'blah'\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [\"blah\"] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n std::string blah = std::string(\"blah\");\n for(int i=0; i < N; i++)\n b[i] = (std::string)a[i] + blah; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\n def check_int_add_speed(self):\n N = 1000000\n print 'int add -- b[i] = a[i] + 1 for N =', N \n a = [0] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 1\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [0] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = (int)a[i] + 1; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\nclass test_object_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_int(self):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::object val = 1001;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1001\n def check_float(self):\n code = \"\"\"\n py::object val = (float)1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_double(self):\n code = \"\"\"\n py::object val = 1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_complex(self):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0+1.0j\n def check_string(self):\n code = \"\"\"\n py::object val = \"hello\";\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n\n def check_std_string(self):\n code = \"\"\"\n std::string s = std::string(\"hello\");\n py::object val = s;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n \n \nclass test_object_cast(unittest.TestCase):\n def check_int_cast(self):\n code = \"\"\"\n py::object val = 1;\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self):\n code = \"\"\"\n py::object val = 1.0;\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self):\n code = \"\"\"\n py::object val = 1.0;\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_complex_cast(self):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n std::complex raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self):\n code = \"\"\"\n py::object val = \"hello\";\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n def bar2(self,val1,val2):\n return val1, val2\n def bar3(self,val1,val2,val3=1):\n return val1, val2, val3\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_hasattr(unittest.TestCase):\n def check_string(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self):\n a = foo()\n a.b = 12345\n attr_name = \"b\"\n code = \"\"\"\n return_val = a.hasattr(attr_name); \n \"\"\"\n res = inline_tools.inline(code,['a','attr_name'])\n assert res \n def check_string_fail(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n def check_inline(self):\n \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n \"\"\"\n a = foo()\n a.b = 12345\n code = \"\"\"\n throw_error(PyExc_AttributeError,\"bummer\"); \n \"\"\"\n try:\n before = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except AttributeError:\n after = sys.getrefcount(a)\n try: \n res = inline_tools.inline(code,['a'])\n except:\n after2 = sys.getrefcount(a)\n print \"after and after2 should be equal in the following\" \n print 'before, after, after2:', before, after, after2\n pass \n\n def check_func(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"bar\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self):\n self.generic_attr('return_val = a.attr(\"b\");')\n\n def check_string(self):\n self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n\n def check_obj(self):\n code = \"\"\"\n py::str name = py::str(\"b\");\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n def check_attr_call(self):\n a = foo()\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n second = sys.getrefcount(res)\n assert res == \"bar results\"\n assert first == second\n\nclass test_object_mcall(unittest.TestCase):\n def check_noargs(self):\n a = foo()\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_args(self):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar2\",args);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(\"bar3\",args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_std_noargs(self):\n a = foo()\n method = \"bar\"\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_std_args(self):\n a = foo()\n method = \"bar2\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(method,args);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_std_args_kw(self):\n a = foo()\n method = \"bar3\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(method,args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self):\n # calling a function that does take args with args \n # should fail.\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar\",args);\n \"\"\"\n try:\n first = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except TypeError:\n second = sys.getrefcount(a) \n try:\n res = inline_tools.inline(code,['a'])\n except TypeError:\n third = sys.getrefcount(a) \n # first should == second, but the weird refcount error \n assert second == third\n\nclass test_object_call(unittest.TestCase):\n def check_noargs(self):\n def foo():\n return (1,2,3)\n res = inline_tools.inline('return_val = foo.call();',['foo'])\n assert res == (1,2,3)\n assert sys.getrefcount(res) == 2\n def check_args(self):\n def foo(val1,val2):\n return (val1,val2)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self):\n def foo(val1,val2,val3=1):\n return (val1,val2,val3)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3; \n return_val = foo.call(args,kw);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self):\n # calling a function that does take args with args \n # should fail.\n def foo():\n return \"blah\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n try:\n first = sys.getrefcount(foo)\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n second = sys.getrefcount(foo) \n try:\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n third = sys.getrefcount(foo) \n # first should == second, but the weird refcount error \n assert second == third\n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n #suites.append( makeSuite(test_list,'check_'))\n \n #suites.append( makeSuite(test_object_construct,'check_'))\n #suites.append( makeSuite(test_object_cast,'check_'))\n #suites.append( makeSuite(test_object_hasattr,'check_')) \n #suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_object_mcall,'check_'))\n suites.append( makeSuite(test_object_call,'check_'))\n \n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "level" ], "start_line": 12, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 22, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 35, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 54, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 90, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 129, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 160, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 191, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx.py", "nloc": 26, "complexity": 3, "token_count": 127, "parameters": [ "self" ], "start_line": 268, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 128, "parameters": [ "self" ], "start_line": 297, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_string_add_speed", "long_name": "check_string_add_speed( self )", "filename": "test_scxx.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 323, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 350, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 381, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_float", "long_name": "check_float( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 390, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 398, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 406, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 415, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 424, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 436, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 442, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 448, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_cast", "long_name": "check_complex_cast( self )", "filename": "test_scxx.py", "nloc": 7, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 454, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 461, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 470, "end_line": 471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar2", "long_name": "bar2( self , val1 , val2 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "val1", "val2" ], "start_line": 472, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar3", "long_name": "bar3( self , val1 , val2 , val3 = 1 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val1", "val2", "val3" ], "start_line": 474, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 478, "end_line": 479, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 482, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 490, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 499, "end_line": 506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_inline", "long_name": "check_inline( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 507, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_func", "long_name": "check_func( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 528, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 539, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 550, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 553, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 556, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_attr_call", "long_name": "check_attr_call( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 562, "end_line": 570, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx.py", "nloc": 10, "complexity": 1, "token_count": 64, "parameters": [ "self" ], "start_line": 573, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 583, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx.py", "nloc": 13, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 594, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_std_noargs", "long_name": "check_std_noargs( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 607, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_std_args", "long_name": "check_std_args( self )", "filename": "test_scxx.py", "nloc": 12, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 618, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_std_args_kw", "long_name": "check_std_args_kw( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 630, "end_line": 643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 3, "token_count": 75, "parameters": [ "self" ], "start_line": 644, "end_line": 664, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "check_noargs.foo", "long_name": "check_noargs.foo( )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 667, "end_line": 672, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_args.foo", "long_name": "check_args.foo( val1 , val2 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "val1", "val2" ], "start_line": 674, "end_line": 675, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 673, "end_line": 684, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_args_kw.foo", "long_name": "check_args_kw.foo( val1 , val2 , val3 = 1 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "val1", "val2", "val3" ], "start_line": 686, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx.py", "nloc": 13, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 685, "end_line": 698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_noargs_with_args.foo", "long_name": "check_noargs_with_args.foo( )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 702, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 699, "end_line": 720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 8, "complexity": 2, "token_count": 52, "parameters": [ "level" ], "start_line": 722, "end_line": 737, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 739, "end_line": 743, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_attr_call", "long_name": "check_attr_call( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 562, "end_line": 570, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 22, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 128, "parameters": [ "self" ], "start_line": 297, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_noargs_with_args.foo", "long_name": "check_noargs_with_args.foo( )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 702, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 381, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 556, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 739, "end_line": 743, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_set_item", "long_name": "check_set_item( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 129, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_inline", "long_name": "check_inline( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 507, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx.py", "nloc": 33, "complexity": 1, "token_count": 216, "parameters": [ "self" ], "start_line": 191, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "check_std_noargs", "long_name": "check_std_noargs( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 607, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_std_args", "long_name": "check_std_args( self )", "filename": "test_scxx.py", "nloc": 12, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 618, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 539, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 478, "end_line": 479, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 90, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 470, "end_line": 471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 162, "parameters": [ "self" ], "start_line": 160, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 1, "token_count": 119, "parameters": [ "self" ], "start_line": 237, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx.py", "nloc": 13, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 594, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_func", "long_name": "check_func( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 528, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_args_kw", "long_name": "check_std_args_kw( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 630, "end_line": 643, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 499, "end_line": 506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_string_add_speed", "long_name": "check_string_add_speed( self )", "filename": "test_scxx.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 323, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 424, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx.py", "nloc": 9, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 406, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_noargs.foo", "long_name": "check_noargs.foo( )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 415, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "level" ], "start_line": 12, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "bar3", "long_name": "bar3( self , val1 , val2 , val3 = 1 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val1", "val2", "val3" ], "start_line": 474, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 54, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 550, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 436, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx.py", "nloc": 26, "complexity": 3, "token_count": 127, "parameters": [ "self" ], "start_line": 268, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx.py", "nloc": 10, "complexity": 1, "token_count": 64, "parameters": [ "self" ], "start_line": 573, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 398, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx.py", "nloc": 11, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 583, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 442, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 448, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar2", "long_name": "bar2( self , val1 , val2 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "val1", "val2" ], "start_line": 472, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_args.foo", "long_name": "check_args.foo( val1 , val2 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "val1", "val2" ], "start_line": 674, "end_line": 675, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args_kw.foo", "long_name": "check_args_kw.foo( val1 , val2 , val3 = 1 )", "filename": "test_scxx.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "val1", "val2", "val3" ], "start_line": 686, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx.py", "nloc": 18, "complexity": 3, "token_count": 75, "parameters": [ "self" ], "start_line": 644, "end_line": 664, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "check_float", "long_name": "check_float( self )", "filename": "test_scxx.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 390, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex_cast", "long_name": "check_complex_cast( self )", "filename": "test_scxx.py", "nloc": 7, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 454, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 461, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 35, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self )", "filename": "test_scxx.py", "nloc": 23, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 350, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 } ], "nloc": 28, "complexity": 3, "token_count": 140, "diff_parsed": { "added": [ " import test_scxx_object", " suites.append( test_scxx_object.test_suite(level))", " import test_scxx_sequence", " suites.append( test_scxx_sequence.test_suite(level))", " import test_scxx_dict", " suites.append( test_scxx_dict.test_suite(level))", "def test(level=10,verbose=2):", " runner = unittest.TextTestRunner(verbosity=verbose)" ], "deleted": [ "# Test:", "# append DONE", "# insert DONE", "# in DONE", "# count DONE", "# setItem DONE", "# operator[] (get)", "# operator[] (set) DONE", "", "class test_list(unittest.TestCase):", " def check_conversion(self):", " a = []", " before = sys.getrefcount(a)", " import weave", " weave.inline(\"\",['a'])", " print 'first:',before", " # first call is goofing up refcount.", " before = sys.getrefcount(a)", " weave.inline(\"\",['a'])", " after = sys.getrefcount(a)", " print '2nd,3rd:', before, after", " assert(after == before)", "", " def check_append_passed_item(self):", " a = []", " item = 1", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.append(item);\",['a','item'])", " del a[0]", "", " before1 = sys.getrefcount(a)", " before2 = sys.getrefcount(item)", " inline_tools.inline(\"a.append(item);\",['a','item'])", " assert a[0] is item", " del a[0]", " after1 = sys.getrefcount(a)", " after2 = sys.getrefcount(item)", " assert after1 == before1", " assert after2 == before2", "", "", " def check_append(self):", " a = []", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.append(1);\",['a'])", " del a[0]", "", " before1 = sys.getrefcount(a)", "", " # check overloaded append(int val) method", " inline_tools.inline(\"a.append(1234);\",['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 1234", " del a[0]", "", " # check overloaded append(double val) method", " inline_tools.inline(\"a.append(123.0);\",['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 123.0", " del a[0]", "", " # check overloaded append(char* val) method", " inline_tools.inline('a.append(\"bubba\");',['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 'bubba'", " del a[0]", "", " # check overloaded append(std::string val) method", " inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 'sissy'", " del a[0]", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", "", " def check_insert(self):", " a = [1,2,3]", "", " a.insert(1,234)", " del a[1]", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.insert(1,1234);\",['a'])", " del a[1]", "", " before1 = sys.getrefcount(a)", "", " # check overloaded insert(int ndx, int val) method", " inline_tools.inline(\"a.insert(1,1234);\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 1234", " del a[1]", "", " # check overloaded insert(int ndx, double val) method", " inline_tools.inline(\"a.insert(1,123.0);\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 123.0", " del a[1]", "", " # check overloaded insert(int ndx, char* val) method", " inline_tools.inline('a.insert(1,\"bubba\");',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'bubba'", " del a[1]", "", " # check overloaded insert(int ndx, std::string val) method", " inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'sissy'", " del a[0]", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", "", " def check_set_item(self):", " a = [1,2,3]", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.set_item(1,1234);\",['a'])", "", " before1 = sys.getrefcount(a)", "", " # check overloaded insert(int ndx, int val) method", " inline_tools.inline(\"a.set_item(1,1234);\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 1234", "", " # check overloaded insert(int ndx, double val) method", " inline_tools.inline(\"a.set_item(1,123.0);\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 123.0", "", " # check overloaded insert(int ndx, char* val) method", " inline_tools.inline('a.set_item(1,\"bubba\");',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'bubba'", "", " # check overloaded insert(int ndx, std::string val) method", " inline_tools.inline('a.set_item(1,std::string(\"sissy\"));',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'sissy'", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", "", " def check_set_item_operator_equal(self):", " a = [1,2,3]", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a[1] = 1234;\",['a'])", "", " before1 = sys.getrefcount(a)", "", " # check overloaded insert(int ndx, int val) method", " inline_tools.inline(\"a[1] = 1234;\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 1234", "", " # check overloaded insert(int ndx, double val) method", " inline_tools.inline(\"a[1] = 123.0;\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 123.0", "", " # check overloaded insert(int ndx, char* val) method", " inline_tools.inline('a[1] = \"bubba\";',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'bubba'", "", " # check overloaded insert(int ndx, std::string val) method", " inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'sissy'", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", "", " def check_in(self):", " \"\"\" Test the \"in\" method for lists. We'll assume", " it works for sequences if it works here.", " \"\"\"", " a = [1,2,'alpha',3.1416]", "", " item = 1", " code = \"return_val = PyInt_FromLong(a.in(item));\"", " res = inline_tools.inline(code,['a','item'])", " assert res == 1", " item = 0", " res = inline_tools.inline(code,['a','item'])", " assert res == 0", "", " # check overloaded in(int val) method", " code = \"return_val = PyInt_FromLong(a.in(1));\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = \"return_val = PyInt_FromLong(a.in(0));\"", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " # check overloaded in(double val) method", " code = \"return_val = PyInt_FromLong(a.in(3.1416));\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = \"return_val = PyInt_FromLong(a.in(3.1417));\"", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " # check overloaded in(char* val) method", " code = 'return_val = PyInt_FromLong(a.in(\"alpha\"));'", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = 'return_val = PyInt_FromLong(a.in(\"beta\"));'", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " # check overloaded in(std::string val) method", " code = 'return_val = PyInt_FromLong(a.in(std::string(\"alpha\")));'", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = 'return_val = PyInt_FromLong(a.in(std::string(\"beta\")));'", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " def check_count(self):", " \"\"\" Test the \"count\" method for lists. We'll assume", " it works for sequences if it works hre.", " \"\"\"", " a = [1,2,'alpha',3.1416]", "", " item = 1", " code = \"return_val = PyInt_FromLong(a.count(item));\"", " res = inline_tools.inline(code,['a','item'])", " assert res == 1", "", " # check overloaded count(int val) method", " code = \"return_val = PyInt_FromLong(a.count(1));\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " # check overloaded count(double val) method", " code = \"return_val = PyInt_FromLong(a.count(3.1416));\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " # check overloaded count(char* val) method", " code = 'return_val = PyInt_FromLong(a.count(\"alpha\"));'", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " # check overloaded count(std::string val) method", " code = 'return_val = PyInt_FromLong(a.count(std::string(\"alpha\")));'", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " def check_access_speed(self):", " N = 1000000", " print 'list access -- val = a[i] for N =', N", " a = [0] * N", " val = 0", " t1 = time.time()", " for i in xrange(N):", " val = a[i]", " t2 = time.time()", " print 'python1:', t2 - t1", " t1 = time.time()", " for i in a:", " val = i", " t2 = time.time()", " print 'python2:', t2 - t1", "", " code = \"\"\"", " const int N = a.length();", " py::object val;", " for(int i=0; i < N; i++)", " val = a[i];", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a'])", " t1 = time.time()", " inline_tools.inline(code,['a'])", " t2 = time.time()", " print 'weave:', t2 - t1", "", " def check_access_set_speed(self):", " N = 1000000", " print 'list access/set -- b[i] = a[i] for N =', N", " a = [0] * N", " b = [1] * N", " t1 = time.time()", " for i in xrange(N):", " b[i] = a[i]", " t2 = time.time()", " print 'python:', t2 - t1", "", " a = [0] * N", " b = [1] * N", " code = \"\"\"", " const int N = a.length();", " for(int i=0; i < N; i++)", " b[i] = a[i];", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a','b'])", " t1 = time.time()", " inline_tools.inline(code,['a','b'])", " t2 = time.time()", " print 'weave:', t2 - t1", " assert b == a", "", " def check_string_add_speed(self):", " N = 1000000", " print 'string add -- b[i] = a[i] + \"blah\" for N =', N", " a = [\"blah\"] * N", " desired = [1] * N", " t1 = time.time()", " for i in xrange(N):", " desired[i] = a[i] + 'blah'", " t2 = time.time()", " print 'python:', t2 - t1", "", " a = [\"blah\"] * N", " b = [1] * N", " code = \"\"\"", " const int N = a.length();", " std::string blah = std::string(\"blah\");", " for(int i=0; i < N; i++)", " b[i] = (std::string)a[i] + blah;", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a','b'])", " t1 = time.time()", " inline_tools.inline(code,['a','b'])", " t2 = time.time()", " print 'weave:', t2 - t1", " assert b == desired", "", " def check_int_add_speed(self):", " N = 1000000", " print 'int add -- b[i] = a[i] + 1 for N =', N", " a = [0] * N", " desired = [1] * N", " t1 = time.time()", " for i in xrange(N):", " desired[i] = a[i] + 1", " t2 = time.time()", " print 'python:', t2 - t1", "", " a = [0] * N", " b = [0] * N", " code = \"\"\"", " const int N = a.length();", " for(int i=0; i < N; i++)", " b[i] = (int)a[i] + 1;", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a','b'])", " t1 = time.time()", " inline_tools.inline(code,['a','b'])", " t2 = time.time()", " print 'weave:', t2 - t1", " assert b == desired", "", "class test_object_construct(unittest.TestCase):", " #------------------------------------------------------------------------", " # Check that construction from basic types is allowed and have correct", " # reference counts", " #------------------------------------------------------------------------", " def check_int(self):", " # strange int value used to try and make sure refcount is 2.", " code = \"\"\"", " py::object val = 1001;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1001", " def check_float(self):", " code = \"\"\"", " py::object val = (float)1.0;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1.0", " def check_double(self):", " code = \"\"\"", " py::object val = 1.0;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1.0", " def check_complex(self):", " code = \"\"\"", " std::complex num = std::complex(1.0,1.0);", " py::object val = num;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1.0+1.0j", " def check_string(self):", " code = \"\"\"", " py::object val = \"hello\";", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == \"hello\"", "", " def check_std_string(self):", " code = \"\"\"", " std::string s = std::string(\"hello\");", " py::object val = s;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == \"hello\"", "", "", "class test_object_cast(unittest.TestCase):", " def check_int_cast(self):", " code = \"\"\"", " py::object val = 1;", " int raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_double_cast(self):", " code = \"\"\"", " py::object val = 1.0;", " double raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_float_cast(self):", " code = \"\"\"", " py::object val = 1.0;", " float raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_complex_cast(self):", " code = \"\"\"", " std::complex num = std::complex(1.0,1.0);", " py::object val = num;", " std::complex raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_string_cast(self):", " code = \"\"\"", " py::object val = \"hello\";", " std::string raw_val = val;", " \"\"\"", " inline_tools.inline(code)", "", "# test class used for testing python class access from C++.", "class foo:", " def bar(self):", " return \"bar results\"", " def bar2(self,val1,val2):", " return val1, val2", " def bar3(self,val1,val2,val3=1):", " return val1, val2, val3", "", "class str_obj:", " def __str__(self):", " return \"b\"", "", "class test_object_hasattr(unittest.TestCase):", " def check_string(self):", " a = foo()", " a.b = 12345", " code = \"\"\"", " return_val = a.hasattr(\"b\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res", " def check_std_string(self):", " a = foo()", " a.b = 12345", " attr_name = \"b\"", " code = \"\"\"", " return_val = a.hasattr(attr_name);", " \"\"\"", " res = inline_tools.inline(code,['a','attr_name'])", " assert res", " def check_string_fail(self):", " a = foo()", " a.b = 12345", " code = \"\"\"", " return_val = a.hasattr(\"c\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert not res", " def check_inline(self):", " \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE", " \"\"\"", " a = foo()", " a.b = 12345", " code = \"\"\"", " throw_error(PyExc_AttributeError,\"bummer\");", " \"\"\"", " try:", " before = sys.getrefcount(a)", " res = inline_tools.inline(code,['a'])", " except AttributeError:", " after = sys.getrefcount(a)", " try:", " res = inline_tools.inline(code,['a'])", " except:", " after2 = sys.getrefcount(a)", " print \"after and after2 should be equal in the following\"", " print 'before, after, after2:', before, after, after2", " pass", "", " def check_func(self):", " a = foo()", " a.b = 12345", " code = \"\"\"", " return_val = a.hasattr(\"bar\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res", "", "class test_object_attr(unittest.TestCase):", "", " def generic_attr(self,code,args=['a']):", " a = foo()", " a.b = 12345", "", " before = sys.getrefcount(a.b)", " res = inline_tools.inline(code,args)", " assert res == a.b", " del res", " after = sys.getrefcount(a.b)", " assert after == before", "", " def check_char(self):", " self.generic_attr('return_val = a.attr(\"b\");')", "", " def check_string(self):", " self.generic_attr('return_val = a.attr(std::string(\"b\"));')", "", " def check_obj(self):", " code = \"\"\"", " py::str name = py::str(\"b\");", " return_val = a.attr(name);", " \"\"\"", " self.generic_attr(code,['a'])", " def check_attr_call(self):", " a = foo()", " res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])", " second = sys.getrefcount(res)", " assert res == \"bar results\"", " assert first == second", "", "class test_object_mcall(unittest.TestCase):", " def check_noargs(self):", " a = foo()", " res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])", " assert res == \"bar results\"", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])", " assert res == \"bar results\"", " second = sys.getrefcount(res)", " assert first == second", " def check_args(self):", " a = foo()", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = a.mcall(\"bar2\",args);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res == (1,\"hello\")", " assert sys.getrefcount(res) == 2", " def check_args_kw(self):", " a = foo()", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " py::dict kw;", " kw[\"val3\"] = 3;", " return_val = a.mcall(\"bar3\",args,kw);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res == (1,\"hello\",3)", " assert sys.getrefcount(res) == 2", " def check_std_noargs(self):", " a = foo()", " method = \"bar\"", " res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])", " assert res == \"bar results\"", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])", " assert res == \"bar results\"", " second = sys.getrefcount(res)", " assert first == second", " def check_std_args(self):", " a = foo()", " method = \"bar2\"", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = a.mcall(method,args);", " \"\"\"", " res = inline_tools.inline(code,['a','method'])", " assert res == (1,\"hello\")", " assert sys.getrefcount(res) == 2", " def check_std_args_kw(self):", " a = foo()", " method = \"bar3\"", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " py::dict kw;", " kw[\"val3\"] = 3;", " return_val = a.mcall(method,args,kw);", " \"\"\"", " res = inline_tools.inline(code,['a','method'])", " assert res == (1,\"hello\",3)", " assert sys.getrefcount(res) == 2", " def check_noargs_with_args(self):", " # calling a function that does take args with args", " # should fail.", " a = foo()", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = a.mcall(\"bar\",args);", " \"\"\"", " try:", " first = sys.getrefcount(a)", " res = inline_tools.inline(code,['a'])", " except TypeError:", " second = sys.getrefcount(a)", " try:", " res = inline_tools.inline(code,['a'])", " except TypeError:", " third = sys.getrefcount(a)", " # first should == second, but the weird refcount error", " assert second == third", "", "class test_object_call(unittest.TestCase):", " def check_noargs(self):", " def foo():", " return (1,2,3)", " res = inline_tools.inline('return_val = foo.call();',['foo'])", " assert res == (1,2,3)", " assert sys.getrefcount(res) == 2", " def check_args(self):", " def foo(val1,val2):", " return (val1,val2)", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = foo.call(args);", " \"\"\"", " res = inline_tools.inline(code,['foo'])", " assert res == (1,\"hello\")", " assert sys.getrefcount(res) == 2", " def check_args_kw(self):", " def foo(val1,val2,val3=1):", " return (val1,val2,val3)", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " py::dict kw;", " kw[\"val3\"] = 3;", " return_val = foo.call(args,kw);", " \"\"\"", " res = inline_tools.inline(code,['foo'])", " assert res == (1,\"hello\",3)", " assert sys.getrefcount(res) == 2", " def check_noargs_with_args(self):", " # calling a function that does take args with args", " # should fail.", " def foo():", " return \"blah\"", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = foo.call(args);", " \"\"\"", " try:", " first = sys.getrefcount(foo)", " res = inline_tools.inline(code,['foo'])", " except TypeError:", " second = sys.getrefcount(foo)", " try:", " res = inline_tools.inline(code,['foo'])", " except TypeError:", " third = sys.getrefcount(foo)", " # first should == second, but the weird refcount error", " assert second == third", "", " #suites.append( makeSuite(test_list,'check_'))", "", " #suites.append( makeSuite(test_object_construct,'check_'))", " #suites.append( makeSuite(test_object_cast,'check_'))", " #suites.append( makeSuite(test_object_hasattr,'check_'))", " #suites.append( makeSuite(test_object_attr,'check_'))", " suites.append( makeSuite(test_object_mcall,'check_'))", " suites.append( makeSuite(test_object_call,'check_'))", "", "", "def test(level=10):", " runner = unittest.TextTestRunner()" ] } }, { "old_path": null, "new_path": "weave/tests/test_scxx_dict.py", "filename": "test_scxx_dict.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,285 @@\n+\"\"\" Test refcounting and behavior of SCXX.\n+\"\"\"\n+import unittest\n+import time\n+import os,sys\n+from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n+\n+add_grandparent_to_path(__name__)\n+import inline_tools\n+restore_path()\n+\n+class test_dict_construct(unittest.TestCase):\n+ #------------------------------------------------------------------------\n+ # Check that construction from basic types is allowed and have correct\n+ # reference counts\n+ #------------------------------------------------------------------------\n+ def check_empty(self):\n+ # strange int value used to try and make sure refcount is 2.\n+ code = \"\"\"\n+ py::dict val;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == {}\n+ \n+ \n+class test_dict_has_key(unittest.TestCase):\n+ def check_obj(self):\n+ class foo:\n+ pass\n+ key = foo()\n+ a = {}\n+ a[key] = 12345\n+ code = \"\"\"\n+ return_val = a.has_key(key); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a','key'])\n+ assert res\n+ def check_int(self):\n+ a = {}\n+ a[1234] = 12345\n+ code = \"\"\"\n+ return_val = a.has_key(1234); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res\n+ def check_double(self):\n+ a = {}\n+ a[1234.] = 12345\n+ code = \"\"\"\n+ return_val = a.has_key(1234.); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res\n+ def check_complex(self):\n+ a = {}\n+ a[1+1j] = 12345\n+ key = 1+1j\n+ code = \"\"\"\n+ return_val = a.has_key(key); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a','key'])\n+ assert res\n+ \n+ def check_string(self):\n+ a = {}\n+ a[\"b\"] = 12345\n+ code = \"\"\"\n+ return_val = a.has_key(\"b\"); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res\n+ def check_std_string(self):\n+ a = {}\n+ a[\"b\"] = 12345\n+ key_name = \"b\"\n+ code = \"\"\"\n+ return_val = a.has_key(key_name); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a','key_name'])\n+ assert res \n+ def check_string_fail(self):\n+ a = {}\n+ a[\"b\"] = 12345\n+ code = \"\"\"\n+ return_val = a.has_key(\"c\"); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert not res\n+\n+class test_dict_get_item_op(unittest.TestCase):\n+\n+ def generic_get(self,code,args=['a']):\n+ a = {}\n+ a['b'] = 12345\n+ \n+ res = inline_tools.inline(code,args)\n+ assert res == a['b']\n+\n+ def check_char(self):\n+ self.generic_get('return_val = a[\"b\"];')\n+\n+ def DOESNT_WORK_check_char_fail(self):\n+ # We can't through a KeyError for dicts on RHS of\n+ # = but not on LHS. Not sure how to deal with this.\n+ try:\n+ self.generic_get('return_val = a[\"c\"];')\n+ except KeyError:\n+ pass\n+ \n+ def check_string(self):\n+ self.generic_get('return_val = a[std::string(\"b\")];')\n+\n+\n+ def check_obj(self):\n+ code = \"\"\"\n+ py::object name = \"b\";\n+ return_val = a[name];\n+ \"\"\" \n+ self.generic_get(code,['a'])\n+\n+ def DOESNT_WORK_check_obj_fail(self):\n+ # We can't through a KeyError for dicts on RHS of\n+ # = but not on LHS. Not sure how to deal with this.\n+ try:\n+ code = \"\"\"\n+ py::object name = \"c\";\n+ return_val = a[name];\n+ \"\"\" \n+ self.generic_get(code,['a'])\n+ except KeyError:\n+ pass \n+ \n+class test_dict_set_operator(unittest.TestCase):\n+ def generic_new(self,key,val):\n+ # test that value is set correctly and that reference counts\n+ # on dict, key, and val are being handled correctly.\n+ a = {}\n+ # call once to handle mysterious addition of one ref count\n+ # on first call to inline.\n+ inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n+ assert a[key] == val\n+ before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n+ inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n+ assert a[key] == val\n+ after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n+ assert before == after\n+ def generic_overwrite(self,key,val):\n+ a = {}\n+ overwritten = 1\n+ a[key] = overwritten # put an item in the dict to be overwritten\n+ # call once to handle mysterious addition of one ref count\n+ # on first call to inline.\n+ before_overwritten = sys.getrefcount(overwritten)\n+ inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n+ assert a[key] == val\n+ before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n+ inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n+ assert a[key] == val\n+ after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n+ after_overwritten = sys.getrefcount(overwritten)\n+ assert before == after\n+ assert before_overwritten == after_overwritten\n+ \n+ def check_new_int_int(self):\n+ key,val = 1234,12345\n+ self.generic_new(key,val)\n+ def check_new_double_int(self):\n+ key,val = 1234.,12345\n+ self.generic_new(key,val)\n+ def check_new_std_string_int(self):\n+ key,val = \"hello\",12345\n+ self.generic_new(key,val)\n+ def check_new_complex_int(self):\n+ key,val = 1+1j,12345\n+ self.generic_new(key,val)\n+ def check_new_obj_int(self):\n+ class foo:\n+ pass\n+ key,val = foo(),12345\n+ self.generic_new(key,val)\n+\n+ def check_overwrite_int_int(self):\n+ key,val = 1234,12345\n+ self.generic_overwrite(key,val)\n+ def check_overwrite_double_int(self):\n+ key,val = 1234.,12345\n+ self.generic_overwrite(key,val)\n+ def check_overwrite_std_string_int(self):\n+ key,val = \"hello\",12345\n+ self.generic_overwrite(key,val)\n+ def check_overwrite_complex_int(self):\n+ key,val = 1+1j,12345\n+ self.generic_overwrite(key,val)\n+ def check_overwrite_obj_int(self):\n+ class foo:\n+ pass\n+ key,val = foo(),12345\n+ self.generic_overwrite(key,val)\n+ \n+class test_dict_del(unittest.TestCase):\n+ def generic(self,key):\n+ # test that value is set correctly and that reference counts\n+ # on dict, key, are being handled correctly. after deletion,\n+ # the keys refcount should be one less than before.\n+ a = {}\n+ a[key] = 1\n+ inline_tools.inline(\"a.del(key);\",['a','key'])\n+ assert not a.has_key(key)\n+ a[key] = 1\n+ before = sys.getrefcount(a), sys.getrefcount(key)\n+ inline_tools.inline(\"a.del(key);\",['a','key'])\n+ assert not a.has_key(key)\n+ after = sys.getrefcount(a), sys.getrefcount(key)\n+ assert before[0] == after[0]\n+ assert before[1] == after[1] + 1\n+ def check_int(self):\n+ key = 1234\n+ self.generic(key)\n+ def check_double(self):\n+ key = 1234.\n+ self.generic(key)\n+ def check_std_string(self):\n+ key = \"hello\"\n+ self.generic(key)\n+ def check_complex(self):\n+ key = 1+1j\n+ self.generic(key)\n+ def check_obj(self):\n+ class foo:\n+ pass\n+ key = foo()\n+ self.generic(key)\n+\n+class test_dict_others(unittest.TestCase):\n+ def check_clear(self):\n+ a = {}\n+ a[\"hello\"] = 1\n+ inline_tools.inline(\"a.clear();\",['a'])\n+ assert not a\n+ def check_items(self):\n+ a = {}\n+ a[\"hello\"] = 1\n+ items = inline_tools.inline(\"return_val = a.items();\",['a'])\n+ assert items == a.items()\n+ def check_values(self):\n+ a = {}\n+ a[\"hello\"] = 1\n+ values = inline_tools.inline(\"return_val = a.values();\",['a'])\n+ assert values == a.values()\n+ def check_keys(self):\n+ a = {}\n+ a[\"hello\"] = 1\n+ keys = inline_tools.inline(\"return_val = a.keys();\",['a'])\n+ assert keys == a.keys()\n+ def check_update(self):\n+ a,b = {},{}\n+ a[\"hello\"] = 1\n+ b[\"hello\"] = 2\n+ inline_tools.inline(\"a.update(b);\",['a','b'])\n+ assert a == b\n+ \n+def test_suite(level=1):\n+ from unittest import makeSuite\n+ suites = [] \n+ if level >= 5: \n+ suites.append( makeSuite(test_dict_construct,'check_'))\n+ suites.append( makeSuite(test_dict_has_key,'check_')) \n+ suites.append( makeSuite(test_dict_get_item_op,'check_'))\n+ suites.append( makeSuite(test_dict_set_operator,'check_'))\n+ suites.append( makeSuite(test_dict_del,'check_'))\n+ suites.append( makeSuite(test_dict_others,'check_'))\n+\n+ total_suite = unittest.TestSuite(suites)\n+ return total_suite\n+\n+def test(level=10,verbose=2):\n+ all_tests = test_suite(level)\n+ runner = unittest.TextTestRunner(verbosity=verbose)\n+ runner.run(all_tests)\n+ return runner\n+\n+if __name__ == \"__main__\":\n+ test()\n", "added_lines": 285, "deleted_lines": 0, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\nclass test_dict_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_empty(self):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::dict val;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == {}\n \n \nclass test_dict_has_key(unittest.TestCase):\n def check_obj(self):\n class foo:\n pass\n key = foo()\n a = {}\n a[key] = 12345\n code = \"\"\"\n return_val = a.has_key(key); \n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n def check_int(self):\n a = {}\n a[1234] = 12345\n code = \"\"\"\n return_val = a.has_key(1234); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_double(self):\n a = {}\n a[1234.] = 12345\n code = \"\"\"\n return_val = a.has_key(1234.); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_complex(self):\n a = {}\n a[1+1j] = 12345\n key = 1+1j\n code = \"\"\"\n return_val = a.has_key(key); \n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n \n def check_string(self):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n return_val = a.has_key(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self):\n a = {}\n a[\"b\"] = 12345\n key_name = \"b\"\n code = \"\"\"\n return_val = a.has_key(key_name); \n \"\"\"\n res = inline_tools.inline(code,['a','key_name'])\n assert res \n def check_string_fail(self):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n return_val = a.has_key(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n\nclass test_dict_get_item_op(unittest.TestCase):\n\n def generic_get(self,code,args=['a']):\n a = {}\n a['b'] = 12345\n \n res = inline_tools.inline(code,args)\n assert res == a['b']\n\n def check_char(self):\n self.generic_get('return_val = a[\"b\"];')\n\n def DOESNT_WORK_check_char_fail(self):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n self.generic_get('return_val = a[\"c\"];')\n except KeyError:\n pass\n \n def check_string(self):\n self.generic_get('return_val = a[std::string(\"b\")];')\n\n\n def check_obj(self):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n\n def DOESNT_WORK_check_obj_fail(self):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n code = \"\"\"\n py::object name = \"c\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n except KeyError:\n pass \n \nclass test_dict_set_operator(unittest.TestCase):\n def generic_new(self,key,val):\n # test that value is set correctly and that reference counts\n # on dict, key, and val are being handled correctly.\n a = {}\n # call once to handle mysterious addition of one ref count\n # on first call to inline.\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n assert before == after\n def generic_overwrite(self,key,val):\n a = {}\n overwritten = 1\n a[key] = overwritten # put an item in the dict to be overwritten\n # call once to handle mysterious addition of one ref count\n # on first call to inline.\n before_overwritten = sys.getrefcount(overwritten)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n after_overwritten = sys.getrefcount(overwritten)\n assert before == after\n assert before_overwritten == after_overwritten\n \n def check_new_int_int(self):\n key,val = 1234,12345\n self.generic_new(key,val)\n def check_new_double_int(self):\n key,val = 1234.,12345\n self.generic_new(key,val)\n def check_new_std_string_int(self):\n key,val = \"hello\",12345\n self.generic_new(key,val)\n def check_new_complex_int(self):\n key,val = 1+1j,12345\n self.generic_new(key,val)\n def check_new_obj_int(self):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_new(key,val)\n\n def check_overwrite_int_int(self):\n key,val = 1234,12345\n self.generic_overwrite(key,val)\n def check_overwrite_double_int(self):\n key,val = 1234.,12345\n self.generic_overwrite(key,val)\n def check_overwrite_std_string_int(self):\n key,val = \"hello\",12345\n self.generic_overwrite(key,val)\n def check_overwrite_complex_int(self):\n key,val = 1+1j,12345\n self.generic_overwrite(key,val)\n def check_overwrite_obj_int(self):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_overwrite(key,val)\n \nclass test_dict_del(unittest.TestCase):\n def generic(self,key):\n # test that value is set correctly and that reference counts\n # on dict, key, are being handled correctly. after deletion,\n # the keys refcount should be one less than before.\n a = {}\n a[key] = 1\n inline_tools.inline(\"a.del(key);\",['a','key'])\n assert not a.has_key(key)\n a[key] = 1\n before = sys.getrefcount(a), sys.getrefcount(key)\n inline_tools.inline(\"a.del(key);\",['a','key'])\n assert not a.has_key(key)\n after = sys.getrefcount(a), sys.getrefcount(key)\n assert before[0] == after[0]\n assert before[1] == after[1] + 1\n def check_int(self):\n key = 1234\n self.generic(key)\n def check_double(self):\n key = 1234.\n self.generic(key)\n def check_std_string(self):\n key = \"hello\"\n self.generic(key)\n def check_complex(self):\n key = 1+1j\n self.generic(key)\n def check_obj(self):\n class foo:\n pass\n key = foo()\n self.generic(key)\n\nclass test_dict_others(unittest.TestCase):\n def check_clear(self):\n a = {}\n a[\"hello\"] = 1\n inline_tools.inline(\"a.clear();\",['a'])\n assert not a\n def check_items(self):\n a = {}\n a[\"hello\"] = 1\n items = inline_tools.inline(\"return_val = a.items();\",['a'])\n assert items == a.items()\n def check_values(self):\n a = {}\n a[\"hello\"] = 1\n values = inline_tools.inline(\"return_val = a.values();\",['a'])\n assert values == a.values()\n def check_keys(self):\n a = {}\n a[\"hello\"] = 1\n keys = inline_tools.inline(\"return_val = a.keys();\",['a'])\n assert keys == a.keys()\n def check_update(self):\n a,b = {},{}\n a[\"hello\"] = 1\n b[\"hello\"] = 2\n inline_tools.inline(\"a.update(b);\",['a','b'])\n assert a == b\n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5: \n suites.append( makeSuite(test_dict_construct,'check_'))\n suites.append( makeSuite(test_dict_has_key,'check_')) \n suites.append( makeSuite(test_dict_get_item_op,'check_'))\n suites.append( makeSuite(test_dict_set_operator,'check_'))\n suites.append( makeSuite(test_dict_del,'check_'))\n suites.append( makeSuite(test_dict_others,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbose=2):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner(verbosity=verbose)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": null, "methods": [ { "name": "check_empty", "long_name": "check_empty( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 17, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_dict.py", "nloc": 11, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 29, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 40, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 48, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 56, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 66, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 74, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 83, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generic_get", "long_name": "generic_get( self , code , args = [ 'a' ] )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [ "self", "code", "args" ], "start_line": 94, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_dict.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 101, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_char_fail", "long_name": "DOESNT_WORK_check_char_fail( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 104, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_dict.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 112, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_dict.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 116, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_obj_fail", "long_name": "DOESNT_WORK_check_obj_fail( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 123, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "generic_new", "long_name": "generic_new( self , key , val )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 103, "parameters": [ "self", "key", "val" ], "start_line": 136, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "generic_overwrite", "long_name": "generic_overwrite( self , key , val )", "filename": "test_scxx_dict.py", "nloc": 14, "complexity": 1, "token_count": 132, "parameters": [ "self", "key", "val" ], "start_line": 149, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_new_int_int", "long_name": "check_new_int_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 166, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_double_int", "long_name": "check_new_double_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 169, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_std_string_int", "long_name": "check_new_std_string_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_complex_int", "long_name": "check_new_complex_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 175, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_obj_int", "long_name": "check_new_obj_int( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 178, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_overwrite_int_int", "long_name": "check_overwrite_int_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_double_int", "long_name": "check_overwrite_double_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 187, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_std_string_int", "long_name": "check_overwrite_std_string_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 190, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_complex_int", "long_name": "check_overwrite_complex_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 193, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_obj_int", "long_name": "check_overwrite_obj_int( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 196, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic", "long_name": "generic( self , key )", "filename": "test_scxx_dict.py", "nloc": 12, "complexity": 1, "token_count": 115, "parameters": [ "self", "key" ], "start_line": 203, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 218, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 221, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 224, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 227, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear", "long_name": "check_clear( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 237, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_items", "long_name": "check_items( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 242, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_values", "long_name": "check_values( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 247, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_keys", "long_name": "check_keys( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 252, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_update", "long_name": "check_update( self )", "filename": "test_scxx_dict.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_dict.py", "nloc": 12, "complexity": 2, "token_count": 96, "parameters": [ "level" ], "start_line": 264, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 278, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 40, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_dict.py", "nloc": 11, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 29, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_obj_fail", "long_name": "DOESNT_WORK_check_obj_fail( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 123, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_new_double_int", "long_name": "check_new_double_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 169, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_std_string_int", "long_name": "check_new_std_string_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_std_string_int", "long_name": "check_overwrite_std_string_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 190, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_empty", "long_name": "check_empty( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 17, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_overwrite_double_int", "long_name": "check_overwrite_double_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 187, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_keys", "long_name": "check_keys( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 252, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_char_fail", "long_name": "DOESNT_WORK_check_char_fail( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 104, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "generic_new", "long_name": "generic_new( self , key , val )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 103, "parameters": [ "self", "key", "val" ], "start_line": 136, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_new_int_int", "long_name": "check_new_int_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 166, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic", "long_name": "generic( self , key )", "filename": "test_scxx_dict.py", "nloc": 12, "complexity": 1, "token_count": 115, "parameters": [ "self", "key" ], "start_line": 203, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_overwrite_obj_int", "long_name": "check_overwrite_obj_int( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 196, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 83, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 74, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_new_obj_int", "long_name": "check_new_obj_int( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 178, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 56, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generic_overwrite", "long_name": "generic_overwrite( self , key , val )", "filename": "test_scxx_dict.py", "nloc": 14, "complexity": 1, "token_count": 132, "parameters": [ "self", "key", "val" ], "start_line": 149, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 66, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_values", "long_name": "check_values( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 247, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_dict.py", "nloc": 12, "complexity": 2, "token_count": 96, "parameters": [ "level" ], "start_line": 264, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_dict.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 101, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_overwrite_complex_int", "long_name": "check_overwrite_complex_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 193, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_get", "long_name": "generic_get( self , code , args = [ 'a' ] )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [ "self", "code", "args" ], "start_line": 94, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 48, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_items", "long_name": "check_items( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 242, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_overwrite_int_int", "long_name": "check_overwrite_int_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_clear", "long_name": "check_clear( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 237, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_update", "long_name": "check_update( self )", "filename": "test_scxx_dict.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_new_complex_int", "long_name": "check_new_complex_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 175, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 278, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 244, "complexity": 42, "token_count": 1476, "diff_parsed": { "added": [ "\"\"\" Test refcounting and behavior of SCXX.", "\"\"\"", "import unittest", "import time", "import os,sys", "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "", "add_grandparent_to_path(__name__)", "import inline_tools", "restore_path()", "", "class test_dict_construct(unittest.TestCase):", " #------------------------------------------------------------------------", " # Check that construction from basic types is allowed and have correct", " # reference counts", " #------------------------------------------------------------------------", " def check_empty(self):", " # strange int value used to try and make sure refcount is 2.", " code = \"\"\"", " py::dict val;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == {}", "", "", "class test_dict_has_key(unittest.TestCase):", " def check_obj(self):", " class foo:", " pass", " key = foo()", " a = {}", " a[key] = 12345", " code = \"\"\"", " return_val = a.has_key(key);", " \"\"\"", " res = inline_tools.inline(code,['a','key'])", " assert res", " def check_int(self):", " a = {}", " a[1234] = 12345", " code = \"\"\"", " return_val = a.has_key(1234);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res", " def check_double(self):", " a = {}", " a[1234.] = 12345", " code = \"\"\"", " return_val = a.has_key(1234.);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res", " def check_complex(self):", " a = {}", " a[1+1j] = 12345", " key = 1+1j", " code = \"\"\"", " return_val = a.has_key(key);", " \"\"\"", " res = inline_tools.inline(code,['a','key'])", " assert res", "", " def check_string(self):", " a = {}", " a[\"b\"] = 12345", " code = \"\"\"", " return_val = a.has_key(\"b\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res", " def check_std_string(self):", " a = {}", " a[\"b\"] = 12345", " key_name = \"b\"", " code = \"\"\"", " return_val = a.has_key(key_name);", " \"\"\"", " res = inline_tools.inline(code,['a','key_name'])", " assert res", " def check_string_fail(self):", " a = {}", " a[\"b\"] = 12345", " code = \"\"\"", " return_val = a.has_key(\"c\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert not res", "", "class test_dict_get_item_op(unittest.TestCase):", "", " def generic_get(self,code,args=['a']):", " a = {}", " a['b'] = 12345", "", " res = inline_tools.inline(code,args)", " assert res == a['b']", "", " def check_char(self):", " self.generic_get('return_val = a[\"b\"];')", "", " def DOESNT_WORK_check_char_fail(self):", " # We can't through a KeyError for dicts on RHS of", " # = but not on LHS. Not sure how to deal with this.", " try:", " self.generic_get('return_val = a[\"c\"];')", " except KeyError:", " pass", "", " def check_string(self):", " self.generic_get('return_val = a[std::string(\"b\")];')", "", "", " def check_obj(self):", " code = \"\"\"", " py::object name = \"b\";", " return_val = a[name];", " \"\"\"", " self.generic_get(code,['a'])", "", " def DOESNT_WORK_check_obj_fail(self):", " # We can't through a KeyError for dicts on RHS of", " # = but not on LHS. Not sure how to deal with this.", " try:", " code = \"\"\"", " py::object name = \"c\";", " return_val = a[name];", " \"\"\"", " self.generic_get(code,['a'])", " except KeyError:", " pass", "", "class test_dict_set_operator(unittest.TestCase):", " def generic_new(self,key,val):", " # test that value is set correctly and that reference counts", " # on dict, key, and val are being handled correctly.", " a = {}", " # call once to handle mysterious addition of one ref count", " # on first call to inline.", " inline_tools.inline(\"a[key] = val;\",['a','key','val'])", " assert a[key] == val", " before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)", " inline_tools.inline(\"a[key] = val;\",['a','key','val'])", " assert a[key] == val", " after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)", " assert before == after", " def generic_overwrite(self,key,val):", " a = {}", " overwritten = 1", " a[key] = overwritten # put an item in the dict to be overwritten", " # call once to handle mysterious addition of one ref count", " # on first call to inline.", " before_overwritten = sys.getrefcount(overwritten)", " inline_tools.inline(\"a[key] = val;\",['a','key','val'])", " assert a[key] == val", " before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)", " inline_tools.inline(\"a[key] = val;\",['a','key','val'])", " assert a[key] == val", " after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)", " after_overwritten = sys.getrefcount(overwritten)", " assert before == after", " assert before_overwritten == after_overwritten", "", " def check_new_int_int(self):", " key,val = 1234,12345", " self.generic_new(key,val)", " def check_new_double_int(self):", " key,val = 1234.,12345", " self.generic_new(key,val)", " def check_new_std_string_int(self):", " key,val = \"hello\",12345", " self.generic_new(key,val)", " def check_new_complex_int(self):", " key,val = 1+1j,12345", " self.generic_new(key,val)", " def check_new_obj_int(self):", " class foo:", " pass", " key,val = foo(),12345", " self.generic_new(key,val)", "", " def check_overwrite_int_int(self):", " key,val = 1234,12345", " self.generic_overwrite(key,val)", " def check_overwrite_double_int(self):", " key,val = 1234.,12345", " self.generic_overwrite(key,val)", " def check_overwrite_std_string_int(self):", " key,val = \"hello\",12345", " self.generic_overwrite(key,val)", " def check_overwrite_complex_int(self):", " key,val = 1+1j,12345", " self.generic_overwrite(key,val)", " def check_overwrite_obj_int(self):", " class foo:", " pass", " key,val = foo(),12345", " self.generic_overwrite(key,val)", "", "class test_dict_del(unittest.TestCase):", " def generic(self,key):", " # test that value is set correctly and that reference counts", " # on dict, key, are being handled correctly. after deletion,", " # the keys refcount should be one less than before.", " a = {}", " a[key] = 1", " inline_tools.inline(\"a.del(key);\",['a','key'])", " assert not a.has_key(key)", " a[key] = 1", " before = sys.getrefcount(a), sys.getrefcount(key)", " inline_tools.inline(\"a.del(key);\",['a','key'])", " assert not a.has_key(key)", " after = sys.getrefcount(a), sys.getrefcount(key)", " assert before[0] == after[0]", " assert before[1] == after[1] + 1", " def check_int(self):", " key = 1234", " self.generic(key)", " def check_double(self):", " key = 1234.", " self.generic(key)", " def check_std_string(self):", " key = \"hello\"", " self.generic(key)", " def check_complex(self):", " key = 1+1j", " self.generic(key)", " def check_obj(self):", " class foo:", " pass", " key = foo()", " self.generic(key)", "", "class test_dict_others(unittest.TestCase):", " def check_clear(self):", " a = {}", " a[\"hello\"] = 1", " inline_tools.inline(\"a.clear();\",['a'])", " assert not a", " def check_items(self):", " a = {}", " a[\"hello\"] = 1", " items = inline_tools.inline(\"return_val = a.items();\",['a'])", " assert items == a.items()", " def check_values(self):", " a = {}", " a[\"hello\"] = 1", " values = inline_tools.inline(\"return_val = a.values();\",['a'])", " assert values == a.values()", " def check_keys(self):", " a = {}", " a[\"hello\"] = 1", " keys = inline_tools.inline(\"return_val = a.keys();\",['a'])", " assert keys == a.keys()", " def check_update(self):", " a,b = {},{}", " a[\"hello\"] = 1", " b[\"hello\"] = 2", " inline_tools.inline(\"a.update(b);\",['a','b'])", " assert a == b", "", "def test_suite(level=1):", " from unittest import makeSuite", " suites = []", " if level >= 5:", " suites.append( makeSuite(test_dict_construct,'check_'))", " suites.append( makeSuite(test_dict_has_key,'check_'))", " suites.append( makeSuite(test_dict_get_item_op,'check_'))", " suites.append( makeSuite(test_dict_set_operator,'check_'))", " suites.append( makeSuite(test_dict_del,'check_'))", " suites.append( makeSuite(test_dict_others,'check_'))", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10,verbose=2):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner(verbosity=verbose)", " runner.run(all_tests)", " return runner", "", "if __name__ == \"__main__\":", " test()" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/tests/test_scxx_object.py", "filename": "test_scxx_object.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,856 @@\n+\"\"\" Test refcounting and behavior of SCXX.\n+\"\"\"\n+import unittest\n+import time\n+import os,sys\n+from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n+\n+add_grandparent_to_path(__name__)\n+import inline_tools\n+restore_path()\n+\n+class test_object_construct(unittest.TestCase):\n+ #------------------------------------------------------------------------\n+ # Check that construction from basic types is allowed and have correct\n+ # reference counts\n+ #------------------------------------------------------------------------\n+ def check_int(self):\n+ # strange int value used to try and make sure refcount is 2.\n+ code = \"\"\"\n+ py::object val = 1001;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == 1001\n+ def check_float(self):\n+ code = \"\"\"\n+ py::object val = (float)1.0;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == 1.0\n+ def check_double(self):\n+ code = \"\"\"\n+ py::object val = 1.0;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == 1.0\n+ def check_complex(self):\n+ code = \"\"\"\n+ std::complex num = std::complex(1.0,1.0);\n+ py::object val = num;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == 1.0+1.0j\n+ def check_string(self):\n+ code = \"\"\"\n+ py::object val = \"hello\";\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == \"hello\"\n+\n+ def check_std_string(self):\n+ code = \"\"\"\n+ std::string s = std::string(\"hello\");\n+ py::object val = s;\n+ return_val = val;\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ assert sys.getrefcount(res) == 2\n+ assert res == \"hello\"\n+ \n+class test_object_print(unittest.TestCase):\n+ #------------------------------------------------------------------------\n+ # Check the object print protocol. \n+ #------------------------------------------------------------------------\n+ def check_stdout(self):\n+ code = \"\"\"\n+ py::object val = \"how now brown cow\";\n+ val.print(stdout);\n+ \"\"\"\n+ res = inline_tools.inline(code)\n+ # visual check on this one.\n+ def check_stringio(self):\n+ import cStringIO\n+ file_imposter = cStringIO.StringIO()\n+ code = \"\"\"\n+ py::object val = \"how now brown cow\";\n+ val.print(file_imposter);\n+ \"\"\"\n+ res = inline_tools.inline(code,['file_imposter'])\n+ print file_imposter.getvalue()\n+ assert file_imposter.getvalue() == \"'how now brown cow'\"\n+\n+ def check_failure(self):\n+ code = \"\"\"\n+ FILE* file = 0;\n+ py::object val = \"how now brown cow\";\n+ val.print(file);\n+ \"\"\"\n+ try: \n+ res = inline_tools.inline(code)\n+ except:\n+ # error was supposed to occur.\n+ pass \n+\n+ \n+class test_object_cast(unittest.TestCase):\n+ def check_int_cast(self):\n+ code = \"\"\"\n+ py::object val = 1;\n+ int raw_val = val;\n+ \"\"\"\n+ inline_tools.inline(code)\n+ def check_double_cast(self):\n+ code = \"\"\"\n+ py::object val = 1.0;\n+ double raw_val = val;\n+ \"\"\"\n+ inline_tools.inline(code)\n+ def check_float_cast(self):\n+ code = \"\"\"\n+ py::object val = 1.0;\n+ float raw_val = val;\n+ \"\"\"\n+ inline_tools.inline(code)\n+ def check_complex_cast(self):\n+ code = \"\"\"\n+ std::complex num = std::complex(1.0,1.0);\n+ py::object val = num;\n+ std::complex raw_val = val;\n+ \"\"\"\n+ inline_tools.inline(code)\n+ def check_string_cast(self):\n+ code = \"\"\"\n+ py::object val = \"hello\";\n+ std::string raw_val = val;\n+ \"\"\"\n+ inline_tools.inline(code)\n+ \n+# test class used for testing python class access from C++.\n+class foo:\n+ def bar(self):\n+ return \"bar results\"\n+ def bar2(self,val1,val2):\n+ return val1, val2\n+ def bar3(self,val1,val2,val3=1):\n+ return val1, val2, val3\n+\n+class str_obj:\n+ def __str__(self):\n+ return \"b\"\n+\n+class test_object_hasattr(unittest.TestCase):\n+ def check_string(self):\n+ a = foo()\n+ a.b = 12345\n+ code = \"\"\"\n+ return_val = a.hasattr(\"b\"); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res\n+ def check_std_string(self):\n+ a = foo()\n+ a.b = 12345\n+ attr_name = \"b\"\n+ code = \"\"\"\n+ return_val = a.hasattr(attr_name); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a','attr_name'])\n+ assert res \n+ def check_string_fail(self):\n+ a = foo()\n+ a.b = 12345\n+ code = \"\"\"\n+ return_val = a.hasattr(\"c\"); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert not res\n+ def check_inline(self):\n+ \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n+ \"\"\"\n+ a = foo()\n+ a.b = 12345\n+ code = \"\"\"\n+ throw_error(PyExc_AttributeError,\"bummer\"); \n+ \"\"\"\n+ try:\n+ before = sys.getrefcount(a)\n+ res = inline_tools.inline(code,['a'])\n+ except AttributeError:\n+ after = sys.getrefcount(a)\n+ try: \n+ res = inline_tools.inline(code,['a'])\n+ except:\n+ after2 = sys.getrefcount(a)\n+ print \"after and after2 should be equal in the following\" \n+ print 'before, after, after2:', before, after, after2\n+ pass \n+\n+ def check_func(self):\n+ a = foo()\n+ a.b = 12345\n+ code = \"\"\"\n+ return_val = a.hasattr(\"bar\"); \n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res\n+\n+class test_object_attr(unittest.TestCase):\n+\n+ def generic_attr(self,code,args=['a']):\n+ a = foo()\n+ a.b = 12345\n+ \n+ before = sys.getrefcount(a.b)\n+ res = inline_tools.inline(code,args)\n+ assert res == a.b\n+ del res\n+ after = sys.getrefcount(a.b)\n+ assert after == before\n+\n+ def check_char(self):\n+ self.generic_attr('return_val = a.attr(\"b\");')\n+\n+ def check_char_fail(self):\n+ try:\n+ self.generic_attr('return_val = a.attr(\"c\");')\n+ except AttributeError:\n+ pass\n+ \n+ def check_string(self):\n+ self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n+\n+ def check_string_fail(self):\n+ try:\n+ self.generic_attr('return_val = a.attr(std::string(\"c\"));')\n+ except AttributeError:\n+ pass \n+\n+ def check_obj(self):\n+ code = \"\"\"\n+ py::object name = \"b\";\n+ return_val = a.attr(name);\n+ \"\"\" \n+ self.generic_attr(code,['a'])\n+\n+ def check_obj_fail(self):\n+ try:\n+ code = \"\"\"\n+ py::object name = \"c\";\n+ return_val = a.attr(name);\n+ \"\"\" \n+ self.generic_attr(code,['a'])\n+ except AttributeError:\n+ pass \n+ \n+ def check_attr_call(self):\n+ a = foo()\n+ res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n+ first = sys.getrefcount(res)\n+ del res\n+ res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n+ second = sys.getrefcount(res)\n+ assert res == \"bar results\"\n+ assert first == second\n+\n+class test_object_set_attr(unittest.TestCase):\n+\n+ def generic_existing(self, code, desired):\n+ args = ['a']\n+ a = foo()\n+ a.b = 12345 \n+ res = inline_tools.inline(code,args)\n+ assert a.b == desired\n+\n+ def generic_new(self, code, desired):\n+ args = ['a']\n+ a = foo()\n+ res = inline_tools.inline(code,args)\n+ assert a.b == desired\n+\n+ def check_existing_char(self):\n+ self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\")\n+ def check_new_char(self):\n+ self.generic_new('a.set_attr(\"b\",\"hello\");',\"hello\")\n+ def check_existing_string(self):\n+ self.generic_existing('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n+ def check_new_string(self):\n+ self.generic_new('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n+ def check_existing_object(self):\n+ code = \"\"\"\n+ py::object obj = \"hello\";\n+ a.set_attr(\"b\",obj);\n+ \"\"\"\n+ self.generic_existing(code,\"hello\")\n+ def check_new_object(self):\n+ code = \"\"\"\n+ py::object obj = \"hello\";\n+ a.set_attr(\"b\",obj);\n+ \"\"\"\n+ self.generic_new(code,\"hello\")\n+ def check_new_fail(self):\n+ try:\n+ code = \"\"\"\n+ py::object obj = 1;\n+ a.set_attr(obj,\"hello\");\n+ \"\"\"\n+ self.generic_new(code,\"hello\")\n+ except:\n+ pass \n+\n+ def check_existing_int(self):\n+ self.generic_existing('a.set_attr(\"b\",1);',1)\n+ def check_existing_double(self):\n+ self.generic_existing('a.set_attr(\"b\",1.0);',1.0)\n+ def check_existing_complex(self):\n+ code = \"\"\"\n+ std::complex obj = std::complex(1,1);\n+ a.set_attr(\"b\",obj);\n+ \"\"\"\n+ self.generic_existing(code,1+1j)\n+ def check_existing_char1(self):\n+ self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\") \n+ def check_existing_string1(self):\n+ code = \"\"\"\n+ std::string obj = std::string(\"hello\");\n+ a.set_attr(\"b\",obj);\n+ \"\"\"\n+ self.generic_existing(code,\"hello\")\n+\n+class test_object_del(unittest.TestCase):\n+ def generic(self, code):\n+ args = ['a']\n+ a = foo()\n+ a.b = 12345 \n+ res = inline_tools.inline(code,args)\n+ assert not hasattr(a,\"b\")\n+\n+ def check_char(self):\n+ self.generic('a.del(\"b\");')\n+ def check_string(self):\n+ code = \"\"\"\n+ std::string name = std::string(\"b\");\n+ a.del(name);\n+ \"\"\"\n+ self.generic(code)\n+ def check_object(self):\n+ code = \"\"\"\n+ py::object name = py::object(\"b\");\n+ a.del(name);\n+ \"\"\"\n+ self.generic(code)\n+\n+class test_object_cmp(unittest.TestCase):\n+ def check_equal(self):\n+ a,b = 1,1\n+ res = inline_tools.inline('return_val = (a == b);',['a','b'])\n+ assert res == (a == b)\n+ def check_equal_objects(self):\n+ class foo:\n+ def __init__(self,x):\n+ self.x = x\n+ def __cmp__(self,other):\n+ return cmp(self.x,other.x)\n+ a,b = foo(1),foo(2)\n+ res = inline_tools.inline('return_val = (a == b);',['a','b'])\n+ assert res == (a == b)\n+ def check_lt(self):\n+ a,b = 1,2\n+ res = inline_tools.inline('return_val = (a < b);',['a','b'])\n+ assert res == (a < b)\n+ def check_gt(self):\n+ a,b = 1,2\n+ res = inline_tools.inline('return_val = (a > b);',['a','b'])\n+ assert res == (a > b)\n+ def check_gte(self):\n+ a,b = 1,2\n+ res = inline_tools.inline('return_val = (a >= b);',['a','b'])\n+ assert res == (a >= b)\n+ def check_lte(self):\n+ a,b = 1,2\n+ res = inline_tools.inline('return_val = (a <= b);',['a','b'])\n+ assert res == (a <= b)\n+ def check_not_equal(self):\n+ a,b = 1,2\n+ res = inline_tools.inline('return_val = (a != b);',['a','b'])\n+ assert res == (a != b)\n+ def check_int(self):\n+ a = 1\n+ res = inline_tools.inline('return_val = (a == 1);',['a'])\n+ assert res == (a == 1)\n+ def check_int2(self):\n+ a = 1\n+ res = inline_tools.inline('return_val = (1 == a);',['a'])\n+ assert res == (a == 1)\n+ def check_unsigned_long(self):\n+ a = 1\n+ res = inline_tools.inline('return_val = (a == (unsigned long)1);',['a'])\n+ assert res == (a == 1)\n+ def check_double(self):\n+ a = 1\n+ res = inline_tools.inline('return_val = (a == 1.0);',['a'])\n+ assert res == (a == 1.0)\n+ def check_char(self):\n+ a = \"hello\"\n+ res = inline_tools.inline('return_val = (a == \"hello\");',['a'])\n+ assert res == (a == \"hello\")\n+ def check_std_string(self):\n+ a = \"hello\"\n+ code = \"\"\"\n+ std::string hello = std::string(\"hello\");\n+ return_val = (a == hello);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == (a == \"hello\")\n+\n+class test_object_repr(unittest.TestCase):\n+ def check_repr(self):\n+ class foo:\n+ def __str__(self):\n+ return \"str return\"\n+ def __repr__(self):\n+ return \"repr return\"\n+ a = foo() \n+ res = inline_tools.inline('return_val = a.repr();',['a'])\n+ first = sys.getrefcount(res)\n+ del res\n+ res = inline_tools.inline('return_val = a.repr();',['a'])\n+ second = sys.getrefcount(res)\n+ assert first == second\n+ assert res == \"repr return\"\n+\n+class test_object_str(unittest.TestCase):\n+ def check_str(self):\n+ class foo:\n+ def __str__(self):\n+ return \"str return\"\n+ def __repr__(self):\n+ return \"repr return\"\n+ a = foo() \n+ res = inline_tools.inline('return_val = a.str();',['a'])\n+ first = sys.getrefcount(res)\n+ del res\n+ res = inline_tools.inline('return_val = a.str();',['a'])\n+ second = sys.getrefcount(res)\n+ assert first == second\n+ print res\n+ assert res == \"str return\"\n+\n+class test_object_unicode(unittest.TestCase):\n+ # This ain't going to win awards for test of the year...\n+ def check_unicode(self):\n+ class foo:\n+ def __repr__(self):\n+ return \"repr return\"\n+ def __str__(self):\n+ return \"unicode\"\n+ a= foo() \n+ res = inline_tools.inline('return_val = a.unicode();',['a'])\n+ first = sys.getrefcount(res)\n+ del res\n+ res = inline_tools.inline('return_val = a.unicode();',['a'])\n+ second = sys.getrefcount(res)\n+ assert first == second\n+ assert res == \"unicode\"\n+\n+class test_object_is_callable(unittest.TestCase):\n+ def check_true(self):\n+ class foo:\n+ def __call__(self):\n+ return 0\n+ a= foo() \n+ res = inline_tools.inline('return_val = a.is_callable();',['a'])\n+ assert res\n+ def check_false(self):\n+ class foo:\n+ pass\n+ a= foo() \n+ res = inline_tools.inline('return_val = a.is_callable();',['a'])\n+ assert not res\n+\n+class test_object_call(unittest.TestCase):\n+ def check_noargs(self):\n+ def foo():\n+ return (1,2,3)\n+ res = inline_tools.inline('return_val = foo.call();',['foo'])\n+ assert res == (1,2,3)\n+ assert sys.getrefcount(res) == 2\n+ def check_args(self):\n+ def foo(val1,val2):\n+ return (val1,val2)\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ return_val = foo.call(args);\n+ \"\"\"\n+ res = inline_tools.inline(code,['foo'])\n+ assert res == (1,\"hello\")\n+ assert sys.getrefcount(res) == 2\n+ def check_args_kw(self):\n+ def foo(val1,val2,val3=1):\n+ return (val1,val2,val3)\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ py::dict kw;\n+ kw[\"val3\"] = 3; \n+ return_val = foo.call(args,kw);\n+ \"\"\"\n+ res = inline_tools.inline(code,['foo'])\n+ assert res == (1,\"hello\",3)\n+ assert sys.getrefcount(res) == 2\n+ def check_noargs_with_args(self):\n+ # calling a function that does take args with args \n+ # should fail.\n+ def foo():\n+ return \"blah\"\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ return_val = foo.call(args);\n+ \"\"\"\n+ try:\n+ first = sys.getrefcount(foo)\n+ res = inline_tools.inline(code,['foo'])\n+ except TypeError:\n+ second = sys.getrefcount(foo) \n+ try:\n+ res = inline_tools.inline(code,['foo'])\n+ except TypeError:\n+ third = sys.getrefcount(foo) \n+ # first should == second, but the weird refcount error \n+ assert second == third\n+ \n+class test_object_mcall(unittest.TestCase):\n+ def check_noargs(self):\n+ a = foo()\n+ res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n+ assert res == \"bar results\"\n+ first = sys.getrefcount(res)\n+ del res\n+ res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n+ assert res == \"bar results\"\n+ second = sys.getrefcount(res)\n+ assert first == second\n+ def check_args(self):\n+ a = foo()\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ return_val = a.mcall(\"bar2\",args);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == (1,\"hello\")\n+ assert sys.getrefcount(res) == 2\n+ def check_args_kw(self):\n+ a = foo()\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ py::dict kw;\n+ kw[\"val3\"] = 3;\n+ return_val = a.mcall(\"bar3\",args,kw);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == (1,\"hello\",3)\n+ assert sys.getrefcount(res) == 2\n+ def check_std_noargs(self):\n+ a = foo()\n+ method = \"bar\"\n+ res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n+ assert res == \"bar results\"\n+ first = sys.getrefcount(res)\n+ del res\n+ res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n+ assert res == \"bar results\"\n+ second = sys.getrefcount(res)\n+ assert first == second\n+ def check_std_args(self):\n+ a = foo()\n+ method = \"bar2\"\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ return_val = a.mcall(method,args);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a','method'])\n+ assert res == (1,\"hello\")\n+ assert sys.getrefcount(res) == 2\n+ def check_std_args_kw(self):\n+ a = foo()\n+ method = \"bar3\"\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ py::dict kw;\n+ kw[\"val3\"] = 3;\n+ return_val = a.mcall(method,args,kw);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a','method'])\n+ assert res == (1,\"hello\",3)\n+ assert sys.getrefcount(res) == 2\n+ def check_noargs_with_args(self):\n+ # calling a function that does take args with args \n+ # should fail.\n+ a = foo()\n+ code = \"\"\"\n+ py::tuple args(2);\n+ args[0] = 1;\n+ args[1] = \"hello\";\n+ return_val = a.mcall(\"bar\",args);\n+ \"\"\"\n+ try:\n+ first = sys.getrefcount(a)\n+ res = inline_tools.inline(code,['a'])\n+ except TypeError:\n+ second = sys.getrefcount(a) \n+ try:\n+ res = inline_tools.inline(code,['a'])\n+ except TypeError:\n+ third = sys.getrefcount(a) \n+ # first should == second, but the weird refcount error \n+ assert second == third\n+\n+class test_object_hash(unittest.TestCase):\n+ def check_hash(self):\n+ class foo:\n+ def __hash__(self):\n+ return 123\n+ a= foo() \n+ res = inline_tools.inline('return_val = a.hash(); ',['a'])\n+ print 'hash:', res\n+ assert res == 123\n+\n+class test_object_is_true(unittest.TestCase):\n+ def check_true(self):\n+ class foo:\n+ pass\n+ a= foo() \n+ res = inline_tools.inline('return_val = a.is_true();',['a'])\n+ assert res == 1\n+ def check_false(self):\n+ a= None \n+ res = inline_tools.inline('return_val = a.is_true();',['a'])\n+ assert res == 0\n+\n+class test_object_is_true(unittest.TestCase):\n+ def check_false(self):\n+ class foo:\n+ pass\n+ a= foo() \n+ res = inline_tools.inline('return_val = a.not();',['a'])\n+ assert res == 0\n+ def check_true(self):\n+ a= None \n+ res = inline_tools.inline('return_val = a.not();',['a'])\n+ assert res == 1 \n+\n+class test_object_type(unittest.TestCase):\n+ def check_type(self):\n+ class foo:\n+ pass\n+ a= foo() \n+ res = inline_tools.inline('return_val = a.type();',['a'])\n+ assert res == type(a)\n+\n+class test_object_size(unittest.TestCase):\n+ def check_size(self):\n+ class foo:\n+ def __len__(self):\n+ return 10\n+ a= foo() \n+ res = inline_tools.inline('return_val = a.size();',['a'])\n+ assert res == len(a)\n+ def check_len(self):\n+ class foo:\n+ def __len__(self):\n+ return 10\n+ a= foo() \n+ res = inline_tools.inline('return_val = a.len();',['a'])\n+ assert res == len(a)\n+ def check_length(self):\n+ class foo:\n+ def __len__(self):\n+ return 10\n+ a= foo() \n+ res = inline_tools.inline('return_val = a.length();',['a'])\n+ assert res == len(a) \n+\n+from UserList import UserList\n+class test_object_set_item_op_index(unittest.TestCase):\n+ def check_list_refcount(self):\n+ a = UserList([1,2,3]) \n+ # temporary refcount fix until I understand why it incs by one.\n+ inline_tools.inline(\"a[1] = 1234;\",['a']) \n+ before1 = sys.getrefcount(a)\n+ after1 = sys.getrefcount(a)\n+ assert after1 == before1\n+ def check_set_int(self):\n+ a = UserList([1,2,3]) \n+ inline_tools.inline(\"a[1] = 1234;\",['a']) \n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 1234\n+ def check_set_double(self):\n+ a = UserList([1,2,3]) \n+ inline_tools.inline(\"a[1] = 123.0;\",['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 123.0 \n+ def check_set_char(self):\n+ a = UserList([1,2,3]) \n+ inline_tools.inline('a[1] = \"bubba\";',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'bubba'\n+ def check_set_string(self):\n+ a = UserList([1,2,3]) \n+ inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'sissy'\n+ def check_set_string(self):\n+ a = UserList([1,2,3]) \n+ inline_tools.inline('a[1] = std::complex(1,1);',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 1+1j\n+\n+from UserDict import UserDict\n+class test_object_set_item_op_key(unittest.TestCase):\n+ def check_key_refcount(self):\n+ a = UserDict()\n+ code = \"\"\"\n+ py::object one = 1;\n+ py::object two = 2;\n+ py::tuple ref_counts(3);\n+ py::tuple obj_counts(3);\n+ py::tuple val_counts(3);\n+ py::tuple key_counts(3);\n+ obj_counts[0] = a.refcount();\n+ key_counts[0] = one.refcount();\n+ val_counts[0] = two.refcount();\n+ a[1] = 2;\n+ obj_counts[1] = a.refcount();\n+ key_counts[1] = one.refcount();\n+ val_counts[1] = two.refcount();\n+ a[1] = 2;\n+ obj_counts[2] = a.refcount();\n+ key_counts[2] = one.refcount();\n+ val_counts[2] = two.refcount();\n+ \n+ ref_counts[0] = obj_counts;\n+ ref_counts[1] = key_counts;\n+ ref_counts[2] = val_counts;\n+ return_val = ref_counts;\n+ \"\"\"\n+ obj,key,val = inline_tools.inline(code,['a'])\n+ assert obj[0] == obj[1] and obj[1] == obj[2]\n+ assert key[0] + 1 == key[1] and key[1] == key[2]\n+ assert val[0] + 1 == val[1] and val[1] == val[2]\n+ \n+ def check_set_double_exists(self):\n+ a = UserDict() \n+ key = 10.0 \n+ a[key] = 100.0\n+ inline_tools.inline('a[key] = 123.0;',['a','key'])\n+ first = sys.getrefcount(key)\n+ inline_tools.inline('a[key] = 123.0;',['a','key'])\n+ second = sys.getrefcount(key)\n+ assert first == second\n+ # !! I think the following should be 3\n+ assert sys.getrefcount(key) == 5\n+ assert sys.getrefcount(a[key]) == 2 \n+ assert a[key] == 123.0\n+ def check_set_double_new(self):\n+ a = UserDict() \n+ key = 1.0\n+ inline_tools.inline('a[key] = 123.0;',['a','key'])\n+ assert sys.getrefcount(key) == 4 # should be 3 \n+ assert sys.getrefcount(a[key]) == 2 \n+ assert a[key] == 123.0\n+ def check_set_complex(self):\n+ a = UserDict()\n+ key = 1+1j \n+ inline_tools.inline(\"a[key] = 1234;\",['a','key'])\n+ assert sys.getrefcount(key) == 3 \n+ assert sys.getrefcount(a[key]) == 2 \n+ assert a[key] == 1234\n+ def check_set_char(self):\n+ a = UserDict() \n+ inline_tools.inline('a[\"hello\"] = 123.0;',['a'])\n+ assert sys.getrefcount(a[\"hello\"]) == 2 \n+ assert a[\"hello\"] == 123.0\n+ \n+ def check_set_class(self):\n+ a = UserDict() \n+ class foo:\n+ def __init__(self,val):\n+ self.val = val\n+ def __hash__(self):\n+ return self.val\n+ key = foo(4)\n+ inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n+ first = sys.getrefcount(key) \n+ inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n+ second = sys.getrefcount(key) \n+ # I don't think we're leaking if this is true\n+ assert first == second \n+ # !! BUT -- I think this should be 3\n+ assert sys.getrefcount(key) == 4 \n+ assert sys.getrefcount(a[key]) == 2 \n+ assert a[key] == 'bubba'\n+ def check_set_from_member(self):\n+ a = UserDict() \n+ a['first'] = 1\n+ a['second'] = 2\n+ inline_tools.inline('a[\"first\"] = a[\"second\"];',['a'])\n+ assert a['first'] == a['second']\n+\n+def test_suite(level=1):\n+ from unittest import makeSuite\n+ suites = [] \n+ if level >= 5:\n+ suites.append( makeSuite(test_object_construct,'check_'))\n+ suites.append( makeSuite(test_object_print,'check_'))\n+ suites.append( makeSuite(test_object_cast,'check_'))\n+ suites.append( makeSuite(test_object_hasattr,'check_')) \n+ suites.append( makeSuite(test_object_attr,'check_'))\n+ suites.append( makeSuite(test_object_set_attr,'check_'))\n+ suites.append( makeSuite(test_object_del,'check_'))\n+ suites.append( makeSuite(test_object_cmp,'check_'))\n+ suites.append( makeSuite(test_object_repr,'check_'))\n+ suites.append( makeSuite(test_object_str,'check_'))\n+ suites.append( makeSuite(test_object_unicode,'check_'))\n+ suites.append( makeSuite(test_object_is_callable,'check_')) \n+ suites.append( makeSuite(test_object_call,'check_'))\n+ suites.append( makeSuite(test_object_mcall,'check_'))\n+ suites.append( makeSuite(test_object_hash,'check_'))\n+ suites.append( makeSuite(test_object_is_true,'check_'))\n+ suites.append( makeSuite(test_object_type,'check_'))\n+ suites.append( makeSuite(test_object_size,'check_'))\n+ suites.append( makeSuite(test_object_set_item_op_index,'check_'))\n+ suites.append( makeSuite(test_object_set_item_op_key,'check_'))\n+\n+ total_suite = unittest.TestSuite(suites)\n+ return total_suite\n+\n+def test(level=10,verbose=2):\n+ all_tests = test_suite(level)\n+ runner = unittest.TextTestRunner(verbosity=verbose)\n+ runner.run(all_tests)\n+ return runner\n+\n+if __name__ == \"__main__\":\n+ test()\n", "added_lines": 856, "deleted_lines": 0, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\nclass test_object_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_int(self):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::object val = 1001;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1001\n def check_float(self):\n code = \"\"\"\n py::object val = (float)1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_double(self):\n code = \"\"\"\n py::object val = 1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_complex(self):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0+1.0j\n def check_string(self):\n code = \"\"\"\n py::object val = \"hello\";\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n\n def check_std_string(self):\n code = \"\"\"\n std::string s = std::string(\"hello\");\n py::object val = s;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n \nclass test_object_print(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check the object print protocol. \n #------------------------------------------------------------------------\n def check_stdout(self):\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(stdout);\n \"\"\"\n res = inline_tools.inline(code)\n # visual check on this one.\n def check_stringio(self):\n import cStringIO\n file_imposter = cStringIO.StringIO()\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(file_imposter);\n \"\"\"\n res = inline_tools.inline(code,['file_imposter'])\n print file_imposter.getvalue()\n assert file_imposter.getvalue() == \"'how now brown cow'\"\n\n def check_failure(self):\n code = \"\"\"\n FILE* file = 0;\n py::object val = \"how now brown cow\";\n val.print(file);\n \"\"\"\n try: \n res = inline_tools.inline(code)\n except:\n # error was supposed to occur.\n pass \n\n \nclass test_object_cast(unittest.TestCase):\n def check_int_cast(self):\n code = \"\"\"\n py::object val = 1;\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self):\n code = \"\"\"\n py::object val = 1.0;\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self):\n code = \"\"\"\n py::object val = 1.0;\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_complex_cast(self):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n std::complex raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self):\n code = \"\"\"\n py::object val = \"hello\";\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n def bar2(self,val1,val2):\n return val1, val2\n def bar3(self,val1,val2,val3=1):\n return val1, val2, val3\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_hasattr(unittest.TestCase):\n def check_string(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self):\n a = foo()\n a.b = 12345\n attr_name = \"b\"\n code = \"\"\"\n return_val = a.hasattr(attr_name); \n \"\"\"\n res = inline_tools.inline(code,['a','attr_name'])\n assert res \n def check_string_fail(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n def check_inline(self):\n \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n \"\"\"\n a = foo()\n a.b = 12345\n code = \"\"\"\n throw_error(PyExc_AttributeError,\"bummer\"); \n \"\"\"\n try:\n before = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except AttributeError:\n after = sys.getrefcount(a)\n try: \n res = inline_tools.inline(code,['a'])\n except:\n after2 = sys.getrefcount(a)\n print \"after and after2 should be equal in the following\" \n print 'before, after, after2:', before, after, after2\n pass \n\n def check_func(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"bar\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self):\n self.generic_attr('return_val = a.attr(\"b\");')\n\n def check_char_fail(self):\n try:\n self.generic_attr('return_val = a.attr(\"c\");')\n except AttributeError:\n pass\n \n def check_string(self):\n self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n\n def check_string_fail(self):\n try:\n self.generic_attr('return_val = a.attr(std::string(\"c\"));')\n except AttributeError:\n pass \n\n def check_obj(self):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n\n def check_obj_fail(self):\n try:\n code = \"\"\"\n py::object name = \"c\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n except AttributeError:\n pass \n \n def check_attr_call(self):\n a = foo()\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n second = sys.getrefcount(res)\n assert res == \"bar results\"\n assert first == second\n\nclass test_object_set_attr(unittest.TestCase):\n\n def generic_existing(self, code, desired):\n args = ['a']\n a = foo()\n a.b = 12345 \n res = inline_tools.inline(code,args)\n assert a.b == desired\n\n def generic_new(self, code, desired):\n args = ['a']\n a = foo()\n res = inline_tools.inline(code,args)\n assert a.b == desired\n\n def check_existing_char(self):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\")\n def check_new_char(self):\n self.generic_new('a.set_attr(\"b\",\"hello\");',\"hello\")\n def check_existing_string(self):\n self.generic_existing('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n def check_new_string(self):\n self.generic_new('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n def check_existing_object(self):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n def check_new_object(self):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_new(code,\"hello\")\n def check_new_fail(self):\n try:\n code = \"\"\"\n py::object obj = 1;\n a.set_attr(obj,\"hello\");\n \"\"\"\n self.generic_new(code,\"hello\")\n except:\n pass \n\n def check_existing_int(self):\n self.generic_existing('a.set_attr(\"b\",1);',1)\n def check_existing_double(self):\n self.generic_existing('a.set_attr(\"b\",1.0);',1.0)\n def check_existing_complex(self):\n code = \"\"\"\n std::complex obj = std::complex(1,1);\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,1+1j)\n def check_existing_char1(self):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\") \n def check_existing_string1(self):\n code = \"\"\"\n std::string obj = std::string(\"hello\");\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n\nclass test_object_del(unittest.TestCase):\n def generic(self, code):\n args = ['a']\n a = foo()\n a.b = 12345 \n res = inline_tools.inline(code,args)\n assert not hasattr(a,\"b\")\n\n def check_char(self):\n self.generic('a.del(\"b\");')\n def check_string(self):\n code = \"\"\"\n std::string name = std::string(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n def check_object(self):\n code = \"\"\"\n py::object name = py::object(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n\nclass test_object_cmp(unittest.TestCase):\n def check_equal(self):\n a,b = 1,1\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n def check_equal_objects(self):\n class foo:\n def __init__(self,x):\n self.x = x\n def __cmp__(self,other):\n return cmp(self.x,other.x)\n a,b = foo(1),foo(2)\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n def check_lt(self):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a < b);',['a','b'])\n assert res == (a < b)\n def check_gt(self):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a > b);',['a','b'])\n assert res == (a > b)\n def check_gte(self):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a >= b);',['a','b'])\n assert res == (a >= b)\n def check_lte(self):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a <= b);',['a','b'])\n assert res == (a <= b)\n def check_not_equal(self):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a != b);',['a','b'])\n assert res == (a != b)\n def check_int(self):\n a = 1\n res = inline_tools.inline('return_val = (a == 1);',['a'])\n assert res == (a == 1)\n def check_int2(self):\n a = 1\n res = inline_tools.inline('return_val = (1 == a);',['a'])\n assert res == (a == 1)\n def check_unsigned_long(self):\n a = 1\n res = inline_tools.inline('return_val = (a == (unsigned long)1);',['a'])\n assert res == (a == 1)\n def check_double(self):\n a = 1\n res = inline_tools.inline('return_val = (a == 1.0);',['a'])\n assert res == (a == 1.0)\n def check_char(self):\n a = \"hello\"\n res = inline_tools.inline('return_val = (a == \"hello\");',['a'])\n assert res == (a == \"hello\")\n def check_std_string(self):\n a = \"hello\"\n code = \"\"\"\n std::string hello = std::string(\"hello\");\n return_val = (a == hello);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (a == \"hello\")\n\nclass test_object_repr(unittest.TestCase):\n def check_repr(self):\n class foo:\n def __str__(self):\n return \"str return\"\n def __repr__(self):\n return \"repr return\"\n a = foo() \n res = inline_tools.inline('return_val = a.repr();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.repr();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n assert res == \"repr return\"\n\nclass test_object_str(unittest.TestCase):\n def check_str(self):\n class foo:\n def __str__(self):\n return \"str return\"\n def __repr__(self):\n return \"repr return\"\n a = foo() \n res = inline_tools.inline('return_val = a.str();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.str();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n print res\n assert res == \"str return\"\n\nclass test_object_unicode(unittest.TestCase):\n # This ain't going to win awards for test of the year...\n def check_unicode(self):\n class foo:\n def __repr__(self):\n return \"repr return\"\n def __str__(self):\n return \"unicode\"\n a= foo() \n res = inline_tools.inline('return_val = a.unicode();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.unicode();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n assert res == \"unicode\"\n\nclass test_object_is_callable(unittest.TestCase):\n def check_true(self):\n class foo:\n def __call__(self):\n return 0\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert res\n def check_false(self):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert not res\n\nclass test_object_call(unittest.TestCase):\n def check_noargs(self):\n def foo():\n return (1,2,3)\n res = inline_tools.inline('return_val = foo.call();',['foo'])\n assert res == (1,2,3)\n assert sys.getrefcount(res) == 2\n def check_args(self):\n def foo(val1,val2):\n return (val1,val2)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self):\n def foo(val1,val2,val3=1):\n return (val1,val2,val3)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3; \n return_val = foo.call(args,kw);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self):\n # calling a function that does take args with args \n # should fail.\n def foo():\n return \"blah\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n try:\n first = sys.getrefcount(foo)\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n second = sys.getrefcount(foo) \n try:\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n third = sys.getrefcount(foo) \n # first should == second, but the weird refcount error \n assert second == third\n \nclass test_object_mcall(unittest.TestCase):\n def check_noargs(self):\n a = foo()\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_args(self):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar2\",args);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(\"bar3\",args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_std_noargs(self):\n a = foo()\n method = \"bar\"\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_std_args(self):\n a = foo()\n method = \"bar2\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(method,args);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_std_args_kw(self):\n a = foo()\n method = \"bar3\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(method,args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self):\n # calling a function that does take args with args \n # should fail.\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar\",args);\n \"\"\"\n try:\n first = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except TypeError:\n second = sys.getrefcount(a) \n try:\n res = inline_tools.inline(code,['a'])\n except TypeError:\n third = sys.getrefcount(a) \n # first should == second, but the weird refcount error \n assert second == third\n\nclass test_object_hash(unittest.TestCase):\n def check_hash(self):\n class foo:\n def __hash__(self):\n return 123\n a= foo() \n res = inline_tools.inline('return_val = a.hash(); ',['a'])\n print 'hash:', res\n assert res == 123\n\nclass test_object_is_true(unittest.TestCase):\n def check_true(self):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 1\n def check_false(self):\n a= None \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 0\n\nclass test_object_is_true(unittest.TestCase):\n def check_false(self):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 0\n def check_true(self):\n a= None \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 1 \n\nclass test_object_type(unittest.TestCase):\n def check_type(self):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.type();',['a'])\n assert res == type(a)\n\nclass test_object_size(unittest.TestCase):\n def check_size(self):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.size();',['a'])\n assert res == len(a)\n def check_len(self):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.len();',['a'])\n assert res == len(a)\n def check_length(self):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.length();',['a'])\n assert res == len(a) \n\nfrom UserList import UserList\nclass test_object_set_item_op_index(unittest.TestCase):\n def check_list_refcount(self):\n a = UserList([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n before1 = sys.getrefcount(a)\n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_set_int(self):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n def check_set_double(self):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0 \n def check_set_char(self):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n def check_set_string(self):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n def check_set_string(self):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::complex(1,1);',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1+1j\n\nfrom UserDict import UserDict\nclass test_object_set_item_op_key(unittest.TestCase):\n def check_key_refcount(self):\n a = UserDict()\n code = \"\"\"\n py::object one = 1;\n py::object two = 2;\n py::tuple ref_counts(3);\n py::tuple obj_counts(3);\n py::tuple val_counts(3);\n py::tuple key_counts(3);\n obj_counts[0] = a.refcount();\n key_counts[0] = one.refcount();\n val_counts[0] = two.refcount();\n a[1] = 2;\n obj_counts[1] = a.refcount();\n key_counts[1] = one.refcount();\n val_counts[1] = two.refcount();\n a[1] = 2;\n obj_counts[2] = a.refcount();\n key_counts[2] = one.refcount();\n val_counts[2] = two.refcount();\n \n ref_counts[0] = obj_counts;\n ref_counts[1] = key_counts;\n ref_counts[2] = val_counts;\n return_val = ref_counts;\n \"\"\"\n obj,key,val = inline_tools.inline(code,['a'])\n assert obj[0] == obj[1] and obj[1] == obj[2]\n assert key[0] + 1 == key[1] and key[1] == key[2]\n assert val[0] + 1 == val[1] and val[1] == val[2]\n \n def check_set_double_exists(self):\n a = UserDict() \n key = 10.0 \n a[key] = 100.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n first = sys.getrefcount(key)\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n second = sys.getrefcount(key)\n assert first == second\n # !! I think the following should be 3\n assert sys.getrefcount(key) == 5\n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n def check_set_double_new(self):\n a = UserDict() \n key = 1.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n assert sys.getrefcount(key) == 4 # should be 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n def check_set_complex(self):\n a = UserDict()\n key = 1+1j \n inline_tools.inline(\"a[key] = 1234;\",['a','key'])\n assert sys.getrefcount(key) == 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 1234\n def check_set_char(self):\n a = UserDict() \n inline_tools.inline('a[\"hello\"] = 123.0;',['a'])\n assert sys.getrefcount(a[\"hello\"]) == 2 \n assert a[\"hello\"] == 123.0\n \n def check_set_class(self):\n a = UserDict() \n class foo:\n def __init__(self,val):\n self.val = val\n def __hash__(self):\n return self.val\n key = foo(4)\n inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n first = sys.getrefcount(key) \n inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n second = sys.getrefcount(key) \n # I don't think we're leaking if this is true\n assert first == second \n # !! BUT -- I think this should be 3\n assert sys.getrefcount(key) == 4 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 'bubba'\n def check_set_from_member(self):\n a = UserDict() \n a['first'] = 1\n a['second'] = 2\n inline_tools.inline('a[\"first\"] = a[\"second\"];',['a'])\n assert a['first'] == a['second']\n\ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_object_construct,'check_'))\n suites.append( makeSuite(test_object_print,'check_'))\n suites.append( makeSuite(test_object_cast,'check_'))\n suites.append( makeSuite(test_object_hasattr,'check_')) \n suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_object_set_attr,'check_'))\n suites.append( makeSuite(test_object_del,'check_'))\n suites.append( makeSuite(test_object_cmp,'check_'))\n suites.append( makeSuite(test_object_repr,'check_'))\n suites.append( makeSuite(test_object_str,'check_'))\n suites.append( makeSuite(test_object_unicode,'check_'))\n suites.append( makeSuite(test_object_is_callable,'check_')) \n suites.append( makeSuite(test_object_call,'check_'))\n suites.append( makeSuite(test_object_mcall,'check_'))\n suites.append( makeSuite(test_object_hash,'check_'))\n suites.append( makeSuite(test_object_is_true,'check_'))\n suites.append( makeSuite(test_object_type,'check_'))\n suites.append( makeSuite(test_object_size,'check_'))\n suites.append( makeSuite(test_object_set_item_op_index,'check_'))\n suites.append( makeSuite(test_object_set_item_op_key,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbose=2):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner(verbosity=verbose)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": null, "methods": [ { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 17, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_float", "long_name": "check_float( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 26, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 34, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 42, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 51, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 60, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_stdout", "long_name": "check_stdout( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_stringio", "long_name": "check_stringio( self )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 81, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_failure", "long_name": "check_failure( self )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 2, "token_count": 21, "parameters": [ "self" ], "start_line": 92, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 106, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 118, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_cast", "long_name": "check_complex_cast( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 124, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 131, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar2", "long_name": "bar2( self , val1 , val2 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "val1", "val2" ], "start_line": 142, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar3", "long_name": "bar3( self , val1 , val2 , val3 = 1 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val1", "val2", "val3" ], "start_line": 144, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 152, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 160, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 169, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_inline", "long_name": "check_inline( self )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 177, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_func", "long_name": "check_func( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 198, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 209, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 220, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_char_fail", "long_name": "check_char_fail( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 223, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 232, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_obj_fail", "long_name": "check_obj_fail( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 245, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_attr_call", "long_name": "check_attr_call( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 255, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generic_existing", "long_name": "generic_existing( self , code , desired )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "self", "code", "desired" ], "start_line": 267, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "generic_new", "long_name": "generic_new( self , code , desired )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self", "code", "desired" ], "start_line": 274, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_existing_char", "long_name": "check_existing_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 280, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_new_char", "long_name": "check_new_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 282, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_string", "long_name": "check_existing_string( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 284, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_new_string", "long_name": "check_new_string( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 286, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_object", "long_name": "check_existing_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 288, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_new_object", "long_name": "check_new_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_new_fail", "long_name": "check_new_fail( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 21, "parameters": [ "self" ], "start_line": 300, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_existing_int", "long_name": "check_existing_int( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 310, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_double", "long_name": "check_existing_double( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 312, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_complex", "long_name": "check_existing_complex( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 314, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_existing_char1", "long_name": "check_existing_char1( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 320, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_string1", "long_name": "check_existing_string1( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 322, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "generic", "long_name": "generic( self , code )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "self", "code" ], "start_line": 330, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 337, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 339, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_object", "long_name": "check_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_equal", "long_name": "check_equal( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 353, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_equal_objects.__init__", "long_name": "check_equal_objects.__init__( self , x )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "x" ], "start_line": 359, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_equal_objects.__cmp__", "long_name": "check_equal_objects.__cmp__( self , other )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self", "other" ], "start_line": 361, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_equal_objects", "long_name": "check_equal_objects( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 357, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_lt", "long_name": "check_lt( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 366, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_gt", "long_name": "check_gt( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 370, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_gte", "long_name": "check_gte( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 374, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_lte", "long_name": "check_lte( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 378, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_not_equal", "long_name": "check_not_equal( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 382, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 386, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_int2", "long_name": "check_int2( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 390, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_unsigned_long", "long_name": "check_unsigned_long( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 394, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 398, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 402, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 406, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_repr.__str__", "long_name": "check_repr.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 418, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_repr.__repr__", "long_name": "check_repr.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 420, "end_line": 421, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_repr", "long_name": "check_repr( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 67, "parameters": [ "self" ], "start_line": 416, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_str.__str__", "long_name": "check_str.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 434, "end_line": 435, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_str.__repr__", "long_name": "check_str.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 436, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_str", "long_name": "check_str( self )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 432, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_unicode.__repr__", "long_name": "check_unicode.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 452, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_unicode.__str__", "long_name": "check_unicode.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 454, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_unicode", "long_name": "check_unicode( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 67, "parameters": [ "self" ], "start_line": 450, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_true.__call__", "long_name": "check_true.__call__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 468, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_true", "long_name": "check_true( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 473, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_noargs.foo", "long_name": "check_noargs.foo( )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 482, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 481, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_args.foo", "long_name": "check_args.foo( val1 , val2 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "val1", "val2" ], "start_line": 488, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 487, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_args_kw.foo", "long_name": "check_args_kw.foo( val1 , val2 , val3 = 1 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "val1", "val2", "val3" ], "start_line": 500, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 499, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_noargs_with_args.foo", "long_name": "check_noargs_with_args.foo( )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 516, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 513, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 1, "token_count": 64, "parameters": [ "self" ], "start_line": 537, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 547, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 558, "end_line": 570, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_std_noargs", "long_name": "check_std_noargs( self )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 571, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_std_args", "long_name": "check_std_args( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 582, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_std_args_kw", "long_name": "check_std_args_kw( self )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 594, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 75, "parameters": [ "self" ], "start_line": 608, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "check_hash.__hash__", "long_name": "check_hash.__hash__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 633, "end_line": 634, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_hash", "long_name": "check_hash( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 631, "end_line": 638, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_true", "long_name": "check_true( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 641, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 647, "end_line": 650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 653, "end_line": 658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_true", "long_name": "check_true( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 659, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_type", "long_name": "check_type( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 665, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_size.__len__", "long_name": "check_size.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 675, "end_line": 676, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_size", "long_name": "check_size( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 673, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_len.__len__", "long_name": "check_len.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 682, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_len", "long_name": "check_len( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 680, "end_line": 686, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_length.__len__", "long_name": "check_length.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 689, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_length", "long_name": "check_length( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 687, "end_line": 693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_list_refcount", "long_name": "check_list_refcount( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 697, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_int", "long_name": "check_set_int( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 704, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_double", "long_name": "check_set_double( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 709, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_char", "long_name": "check_set_char( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 714, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_string", "long_name": "check_set_string( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 719, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_string", "long_name": "check_set_string( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 724, "end_line": 728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_key_refcount", "long_name": "check_key_refcount( self )", "filename": "test_scxx_object.py", "nloc": 30, "complexity": 4, "token_count": 93, "parameters": [ "self" ], "start_line": 732, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_double_exists", "long_name": "check_set_double_exists( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 763, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_set_double_new", "long_name": "check_set_double_new( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 57, "parameters": [ "self" ], "start_line": 776, "end_line": 782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_complex", "long_name": "check_set_complex( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 783, "end_line": 789, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_char", "long_name": "check_set_char( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 790, "end_line": 794, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_class.__init__", "long_name": "check_set_class.__init__( self , val )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "val" ], "start_line": 799, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_set_class.__hash__", "long_name": "check_set_class.__hash__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 801, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_set_class", "long_name": "check_set_class( self )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 95, "parameters": [ "self" ], "start_line": 796, "end_line": 813, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_set_from_member", "long_name": "check_set_from_member( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 814, "end_line": 819, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_object.py", "nloc": 26, "complexity": 2, "token_count": 250, "parameters": [ "level" ], "start_line": 821, "end_line": 847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 849, "end_line": 853, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "check_attr_call", "long_name": "check_attr_call( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 255, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_existing_string", "long_name": "check_existing_string( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 284, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_equal_objects", "long_name": "check_equal_objects( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 357, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_noargs_with_args.foo", "long_name": "check_noargs_with_args.foo( )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 516, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_existing_object", "long_name": "check_existing_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 288, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_unsigned_long", "long_name": "check_unsigned_long( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 394, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_inline", "long_name": "check_inline( self )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 177, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_new_fail", "long_name": "check_new_fail( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 21, "parameters": [ "self" ], "start_line": 300, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_str.__str__", "long_name": "check_str.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 434, "end_line": 435, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_new_char", "long_name": "check_new_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 282, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_std_noargs", "long_name": "check_std_noargs( self )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 571, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_existing_char1", "long_name": "check_existing_char1( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 320, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_len.__len__", "long_name": "check_len.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 682, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 473, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_set_class", "long_name": "check_set_class( self )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 95, "parameters": [ "self" ], "start_line": 796, "end_line": 813, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_func", "long_name": "check_func( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 198, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_stringio", "long_name": "check_stringio( self )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 81, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_std_args_kw", "long_name": "check_std_args_kw( self )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 594, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_set_int", "long_name": "check_set_int( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 704, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_str", "long_name": "check_str( self )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 432, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_set_double_new", "long_name": "check_set_double_new( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 57, "parameters": [ "self" ], "start_line": 776, "end_line": 782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_true.__call__", "long_name": "check_true.__call__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 468, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 60, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_stdout", "long_name": "check_stdout( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_equal_objects.__init__", "long_name": "check_equal_objects.__init__( self , x )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "x" ], "start_line": 359, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_int2", "long_name": "check_int2( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 390, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_true", "long_name": "check_true( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_repr.__str__", "long_name": "check_repr.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 418, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 42, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "bar3", "long_name": "bar3( self , val1 , val2 , val3 = 1 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val1", "val2", "val3" ], "start_line": 144, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_object.py", "nloc": 26, "complexity": 2, "token_count": 250, "parameters": [ "level" ], "start_line": 821, "end_line": 847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "check_existing_int", "long_name": "check_existing_int( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 310, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_lte", "long_name": "check_lte( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 378, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_str.__repr__", "long_name": "check_str.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 436, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_key_refcount", "long_name": "check_key_refcount( self )", "filename": "test_scxx_object.py", "nloc": 30, "complexity": 4, "token_count": 93, "parameters": [ "self" ], "start_line": 732, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 220, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generic", "long_name": "generic( self , code )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "self", "code" ], "start_line": 330, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_lt", "long_name": "check_lt( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 366, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_new_string", "long_name": "check_new_string( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 286, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 34, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_unicode.__repr__", "long_name": "check_unicode.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 452, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_set_class.__init__", "long_name": "check_set_class.__init__( self , val )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "val" ], "start_line": 799, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_gt", "long_name": "check_gt( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 370, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_existing_string1", "long_name": "check_existing_string1( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 322, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 118, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar2", "long_name": "bar2( self , val1 , val2 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "val1", "val2" ], "start_line": 142, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_args_kw.foo", "long_name": "check_args_kw.foo( val1 , val2 , val3 = 1 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "val1", "val2", "val3" ], "start_line": 500, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_hash", "long_name": "check_hash( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 631, "end_line": 638, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_repr.__repr__", "long_name": "check_repr.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 420, "end_line": 421, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_len", "long_name": "check_len( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 680, "end_line": 686, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 131, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_object", "long_name": "check_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_failure", "long_name": "check_failure( self )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 2, "token_count": 21, "parameters": [ "self" ], "start_line": 92, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_new_object", "long_name": "check_new_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "generic_new", "long_name": "generic_new( self , code , desired )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self", "code", "desired" ], "start_line": 274, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 17, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_existing_char", "long_name": "check_existing_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 280, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generic_existing", "long_name": "generic_existing( self , code , desired )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "self", "code", "desired" ], "start_line": 267, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_set_double_exists", "long_name": "check_set_double_exists( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 763, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 849, "end_line": 853, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_set_from_member", "long_name": "check_set_from_member( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 814, "end_line": 819, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_set_char", "long_name": "check_set_char( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 714, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_std_args", "long_name": "check_std_args( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 582, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 209, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_set_string", "long_name": "check_set_string( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 719, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_equal_objects.__cmp__", "long_name": "check_equal_objects.__cmp__( self , other )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self", "other" ], "start_line": 361, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_obj_fail", "long_name": "check_obj_fail( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 245, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_existing_complex", "long_name": "check_existing_complex( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 314, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 499, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_unicode", "long_name": "check_unicode( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 67, "parameters": [ "self" ], "start_line": 450, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_set_double", "long_name": "check_set_double( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 709, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 169, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_size", "long_name": "check_size( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 673, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_type", "long_name": "check_type( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 665, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_size.__len__", "long_name": "check_size.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 675, "end_line": 676, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_hash.__hash__", "long_name": "check_hash.__hash__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 633, "end_line": 634, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_noargs.foo", "long_name": "check_noargs.foo( )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 482, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 51, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_gte", "long_name": "check_gte( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 374, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_length", "long_name": "check_length( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 687, "end_line": 693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_length.__len__", "long_name": "check_length.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 689, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_set_class.__hash__", "long_name": "check_set_class.__hash__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 801, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_repr", "long_name": "check_repr( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 67, "parameters": [ "self" ], "start_line": 416, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 106, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 481, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 487, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_char_fail", "long_name": "check_char_fail( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 223, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_equal", "long_name": "check_equal( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 353, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_set_complex", "long_name": "check_set_complex( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 783, "end_line": 789, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_not_equal", "long_name": "check_not_equal( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 382, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_list_refcount", "long_name": "check_list_refcount( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 697, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_args.foo", "long_name": "check_args.foo( val1 , val2 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "val1", "val2" ], "start_line": 488, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_unicode.__str__", "long_name": "check_unicode.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 454, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 513, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_existing_double", "long_name": "check_existing_double( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 312, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_float", "long_name": "check_float( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 26, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex_cast", "long_name": "check_complex_cast( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 124, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "nloc": 784, "complexity": 136, "token_count": 4226, "diff_parsed": { "added": [ "\"\"\" Test refcounting and behavior of SCXX.", "\"\"\"", "import unittest", "import time", "import os,sys", "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "", "add_grandparent_to_path(__name__)", "import inline_tools", "restore_path()", "", "class test_object_construct(unittest.TestCase):", " #------------------------------------------------------------------------", " # Check that construction from basic types is allowed and have correct", " # reference counts", " #------------------------------------------------------------------------", " def check_int(self):", " # strange int value used to try and make sure refcount is 2.", " code = \"\"\"", " py::object val = 1001;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1001", " def check_float(self):", " code = \"\"\"", " py::object val = (float)1.0;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1.0", " def check_double(self):", " code = \"\"\"", " py::object val = 1.0;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1.0", " def check_complex(self):", " code = \"\"\"", " std::complex num = std::complex(1.0,1.0);", " py::object val = num;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == 1.0+1.0j", " def check_string(self):", " code = \"\"\"", " py::object val = \"hello\";", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == \"hello\"", "", " def check_std_string(self):", " code = \"\"\"", " std::string s = std::string(\"hello\");", " py::object val = s;", " return_val = val;", " \"\"\"", " res = inline_tools.inline(code)", " assert sys.getrefcount(res) == 2", " assert res == \"hello\"", "", "class test_object_print(unittest.TestCase):", " #------------------------------------------------------------------------", " # Check the object print protocol.", " #------------------------------------------------------------------------", " def check_stdout(self):", " code = \"\"\"", " py::object val = \"how now brown cow\";", " val.print(stdout);", " \"\"\"", " res = inline_tools.inline(code)", " # visual check on this one.", " def check_stringio(self):", " import cStringIO", " file_imposter = cStringIO.StringIO()", " code = \"\"\"", " py::object val = \"how now brown cow\";", " val.print(file_imposter);", " \"\"\"", " res = inline_tools.inline(code,['file_imposter'])", " print file_imposter.getvalue()", " assert file_imposter.getvalue() == \"'how now brown cow'\"", "", " def check_failure(self):", " code = \"\"\"", " FILE* file = 0;", " py::object val = \"how now brown cow\";", " val.print(file);", " \"\"\"", " try:", " res = inline_tools.inline(code)", " except:", " # error was supposed to occur.", " pass", "", "", "class test_object_cast(unittest.TestCase):", " def check_int_cast(self):", " code = \"\"\"", " py::object val = 1;", " int raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_double_cast(self):", " code = \"\"\"", " py::object val = 1.0;", " double raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_float_cast(self):", " code = \"\"\"", " py::object val = 1.0;", " float raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_complex_cast(self):", " code = \"\"\"", " std::complex num = std::complex(1.0,1.0);", " py::object val = num;", " std::complex raw_val = val;", " \"\"\"", " inline_tools.inline(code)", " def check_string_cast(self):", " code = \"\"\"", " py::object val = \"hello\";", " std::string raw_val = val;", " \"\"\"", " inline_tools.inline(code)", "", "# test class used for testing python class access from C++.", "class foo:", " def bar(self):", " return \"bar results\"", " def bar2(self,val1,val2):", " return val1, val2", " def bar3(self,val1,val2,val3=1):", " return val1, val2, val3", "", "class str_obj:", " def __str__(self):", " return \"b\"", "", "class test_object_hasattr(unittest.TestCase):", " def check_string(self):", " a = foo()", " a.b = 12345", " code = \"\"\"", " return_val = a.hasattr(\"b\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res", " def check_std_string(self):", " a = foo()", " a.b = 12345", " attr_name = \"b\"", " code = \"\"\"", " return_val = a.hasattr(attr_name);", " \"\"\"", " res = inline_tools.inline(code,['a','attr_name'])", " assert res", " def check_string_fail(self):", " a = foo()", " a.b = 12345", " code = \"\"\"", " return_val = a.hasattr(\"c\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert not res", " def check_inline(self):", " \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE", " \"\"\"", " a = foo()", " a.b = 12345", " code = \"\"\"", " throw_error(PyExc_AttributeError,\"bummer\");", " \"\"\"", " try:", " before = sys.getrefcount(a)", " res = inline_tools.inline(code,['a'])", " except AttributeError:", " after = sys.getrefcount(a)", " try:", " res = inline_tools.inline(code,['a'])", " except:", " after2 = sys.getrefcount(a)", " print \"after and after2 should be equal in the following\"", " print 'before, after, after2:', before, after, after2", " pass", "", " def check_func(self):", " a = foo()", " a.b = 12345", " code = \"\"\"", " return_val = a.hasattr(\"bar\");", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res", "", "class test_object_attr(unittest.TestCase):", "", " def generic_attr(self,code,args=['a']):", " a = foo()", " a.b = 12345", "", " before = sys.getrefcount(a.b)", " res = inline_tools.inline(code,args)", " assert res == a.b", " del res", " after = sys.getrefcount(a.b)", " assert after == before", "", " def check_char(self):", " self.generic_attr('return_val = a.attr(\"b\");')", "", " def check_char_fail(self):", " try:", " self.generic_attr('return_val = a.attr(\"c\");')", " except AttributeError:", " pass", "", " def check_string(self):", " self.generic_attr('return_val = a.attr(std::string(\"b\"));')", "", " def check_string_fail(self):", " try:", " self.generic_attr('return_val = a.attr(std::string(\"c\"));')", " except AttributeError:", " pass", "", " def check_obj(self):", " code = \"\"\"", " py::object name = \"b\";", " return_val = a.attr(name);", " \"\"\"", " self.generic_attr(code,['a'])", "", " def check_obj_fail(self):", " try:", " code = \"\"\"", " py::object name = \"c\";", " return_val = a.attr(name);", " \"\"\"", " self.generic_attr(code,['a'])", " except AttributeError:", " pass", "", " def check_attr_call(self):", " a = foo()", " res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])", " second = sys.getrefcount(res)", " assert res == \"bar results\"", " assert first == second", "", "class test_object_set_attr(unittest.TestCase):", "", " def generic_existing(self, code, desired):", " args = ['a']", " a = foo()", " a.b = 12345", " res = inline_tools.inline(code,args)", " assert a.b == desired", "", " def generic_new(self, code, desired):", " args = ['a']", " a = foo()", " res = inline_tools.inline(code,args)", " assert a.b == desired", "", " def check_existing_char(self):", " self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\")", " def check_new_char(self):", " self.generic_new('a.set_attr(\"b\",\"hello\");',\"hello\")", " def check_existing_string(self):", " self.generic_existing('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")", " def check_new_string(self):", " self.generic_new('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")", " def check_existing_object(self):", " code = \"\"\"", " py::object obj = \"hello\";", " a.set_attr(\"b\",obj);", " \"\"\"", " self.generic_existing(code,\"hello\")", " def check_new_object(self):", " code = \"\"\"", " py::object obj = \"hello\";", " a.set_attr(\"b\",obj);", " \"\"\"", " self.generic_new(code,\"hello\")", " def check_new_fail(self):", " try:", " code = \"\"\"", " py::object obj = 1;", " a.set_attr(obj,\"hello\");", " \"\"\"", " self.generic_new(code,\"hello\")", " except:", " pass", "", " def check_existing_int(self):", " self.generic_existing('a.set_attr(\"b\",1);',1)", " def check_existing_double(self):", " self.generic_existing('a.set_attr(\"b\",1.0);',1.0)", " def check_existing_complex(self):", " code = \"\"\"", " std::complex obj = std::complex(1,1);", " a.set_attr(\"b\",obj);", " \"\"\"", " self.generic_existing(code,1+1j)", " def check_existing_char1(self):", " self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\")", " def check_existing_string1(self):", " code = \"\"\"", " std::string obj = std::string(\"hello\");", " a.set_attr(\"b\",obj);", " \"\"\"", " self.generic_existing(code,\"hello\")", "", "class test_object_del(unittest.TestCase):", " def generic(self, code):", " args = ['a']", " a = foo()", " a.b = 12345", " res = inline_tools.inline(code,args)", " assert not hasattr(a,\"b\")", "", " def check_char(self):", " self.generic('a.del(\"b\");')", " def check_string(self):", " code = \"\"\"", " std::string name = std::string(\"b\");", " a.del(name);", " \"\"\"", " self.generic(code)", " def check_object(self):", " code = \"\"\"", " py::object name = py::object(\"b\");", " a.del(name);", " \"\"\"", " self.generic(code)", "", "class test_object_cmp(unittest.TestCase):", " def check_equal(self):", " a,b = 1,1", " res = inline_tools.inline('return_val = (a == b);',['a','b'])", " assert res == (a == b)", " def check_equal_objects(self):", " class foo:", " def __init__(self,x):", " self.x = x", " def __cmp__(self,other):", " return cmp(self.x,other.x)", " a,b = foo(1),foo(2)", " res = inline_tools.inline('return_val = (a == b);',['a','b'])", " assert res == (a == b)", " def check_lt(self):", " a,b = 1,2", " res = inline_tools.inline('return_val = (a < b);',['a','b'])", " assert res == (a < b)", " def check_gt(self):", " a,b = 1,2", " res = inline_tools.inline('return_val = (a > b);',['a','b'])", " assert res == (a > b)", " def check_gte(self):", " a,b = 1,2", " res = inline_tools.inline('return_val = (a >= b);',['a','b'])", " assert res == (a >= b)", " def check_lte(self):", " a,b = 1,2", " res = inline_tools.inline('return_val = (a <= b);',['a','b'])", " assert res == (a <= b)", " def check_not_equal(self):", " a,b = 1,2", " res = inline_tools.inline('return_val = (a != b);',['a','b'])", " assert res == (a != b)", " def check_int(self):", " a = 1", " res = inline_tools.inline('return_val = (a == 1);',['a'])", " assert res == (a == 1)", " def check_int2(self):", " a = 1", " res = inline_tools.inline('return_val = (1 == a);',['a'])", " assert res == (a == 1)", " def check_unsigned_long(self):", " a = 1", " res = inline_tools.inline('return_val = (a == (unsigned long)1);',['a'])", " assert res == (a == 1)", " def check_double(self):", " a = 1", " res = inline_tools.inline('return_val = (a == 1.0);',['a'])", " assert res == (a == 1.0)", " def check_char(self):", " a = \"hello\"", " res = inline_tools.inline('return_val = (a == \"hello\");',['a'])", " assert res == (a == \"hello\")", " def check_std_string(self):", " a = \"hello\"", " code = \"\"\"", " std::string hello = std::string(\"hello\");", " return_val = (a == hello);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res == (a == \"hello\")", "", "class test_object_repr(unittest.TestCase):", " def check_repr(self):", " class foo:", " def __str__(self):", " return \"str return\"", " def __repr__(self):", " return \"repr return\"", " a = foo()", " res = inline_tools.inline('return_val = a.repr();',['a'])", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.repr();',['a'])", " second = sys.getrefcount(res)", " assert first == second", " assert res == \"repr return\"", "", "class test_object_str(unittest.TestCase):", " def check_str(self):", " class foo:", " def __str__(self):", " return \"str return\"", " def __repr__(self):", " return \"repr return\"", " a = foo()", " res = inline_tools.inline('return_val = a.str();',['a'])", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.str();',['a'])", " second = sys.getrefcount(res)", " assert first == second", " print res", " assert res == \"str return\"", "", "class test_object_unicode(unittest.TestCase):", " # This ain't going to win awards for test of the year...", " def check_unicode(self):", " class foo:", " def __repr__(self):", " return \"repr return\"", " def __str__(self):", " return \"unicode\"", " a= foo()", " res = inline_tools.inline('return_val = a.unicode();',['a'])", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.unicode();',['a'])", " second = sys.getrefcount(res)", " assert first == second", " assert res == \"unicode\"", "", "class test_object_is_callable(unittest.TestCase):", " def check_true(self):", " class foo:", " def __call__(self):", " return 0", " a= foo()", " res = inline_tools.inline('return_val = a.is_callable();',['a'])", " assert res", " def check_false(self):", " class foo:", " pass", " a= foo()", " res = inline_tools.inline('return_val = a.is_callable();',['a'])", " assert not res", "", "class test_object_call(unittest.TestCase):", " def check_noargs(self):", " def foo():", " return (1,2,3)", " res = inline_tools.inline('return_val = foo.call();',['foo'])", " assert res == (1,2,3)", " assert sys.getrefcount(res) == 2", " def check_args(self):", " def foo(val1,val2):", " return (val1,val2)", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = foo.call(args);", " \"\"\"", " res = inline_tools.inline(code,['foo'])", " assert res == (1,\"hello\")", " assert sys.getrefcount(res) == 2", " def check_args_kw(self):", " def foo(val1,val2,val3=1):", " return (val1,val2,val3)", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " py::dict kw;", " kw[\"val3\"] = 3;", " return_val = foo.call(args,kw);", " \"\"\"", " res = inline_tools.inline(code,['foo'])", " assert res == (1,\"hello\",3)", " assert sys.getrefcount(res) == 2", " def check_noargs_with_args(self):", " # calling a function that does take args with args", " # should fail.", " def foo():", " return \"blah\"", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = foo.call(args);", " \"\"\"", " try:", " first = sys.getrefcount(foo)", " res = inline_tools.inline(code,['foo'])", " except TypeError:", " second = sys.getrefcount(foo)", " try:", " res = inline_tools.inline(code,['foo'])", " except TypeError:", " third = sys.getrefcount(foo)", " # first should == second, but the weird refcount error", " assert second == third", "", "class test_object_mcall(unittest.TestCase):", " def check_noargs(self):", " a = foo()", " res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])", " assert res == \"bar results\"", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])", " assert res == \"bar results\"", " second = sys.getrefcount(res)", " assert first == second", " def check_args(self):", " a = foo()", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = a.mcall(\"bar2\",args);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res == (1,\"hello\")", " assert sys.getrefcount(res) == 2", " def check_args_kw(self):", " a = foo()", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " py::dict kw;", " kw[\"val3\"] = 3;", " return_val = a.mcall(\"bar3\",args,kw);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res == (1,\"hello\",3)", " assert sys.getrefcount(res) == 2", " def check_std_noargs(self):", " a = foo()", " method = \"bar\"", " res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])", " assert res == \"bar results\"", " first = sys.getrefcount(res)", " del res", " res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])", " assert res == \"bar results\"", " second = sys.getrefcount(res)", " assert first == second", " def check_std_args(self):", " a = foo()", " method = \"bar2\"", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = a.mcall(method,args);", " \"\"\"", " res = inline_tools.inline(code,['a','method'])", " assert res == (1,\"hello\")", " assert sys.getrefcount(res) == 2", " def check_std_args_kw(self):", " a = foo()", " method = \"bar3\"", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " py::dict kw;", " kw[\"val3\"] = 3;", " return_val = a.mcall(method,args,kw);", " \"\"\"", " res = inline_tools.inline(code,['a','method'])", " assert res == (1,\"hello\",3)", " assert sys.getrefcount(res) == 2", " def check_noargs_with_args(self):", " # calling a function that does take args with args", " # should fail.", " a = foo()", " code = \"\"\"", " py::tuple args(2);", " args[0] = 1;", " args[1] = \"hello\";", " return_val = a.mcall(\"bar\",args);", " \"\"\"", " try:", " first = sys.getrefcount(a)", " res = inline_tools.inline(code,['a'])", " except TypeError:", " second = sys.getrefcount(a)", " try:", " res = inline_tools.inline(code,['a'])", " except TypeError:", " third = sys.getrefcount(a)", " # first should == second, but the weird refcount error", " assert second == third", "", "class test_object_hash(unittest.TestCase):", " def check_hash(self):", " class foo:", " def __hash__(self):", " return 123", " a= foo()", " res = inline_tools.inline('return_val = a.hash(); ',['a'])", " print 'hash:', res", " assert res == 123", "", "class test_object_is_true(unittest.TestCase):", " def check_true(self):", " class foo:", " pass", " a= foo()", " res = inline_tools.inline('return_val = a.is_true();',['a'])", " assert res == 1", " def check_false(self):", " a= None", " res = inline_tools.inline('return_val = a.is_true();',['a'])", " assert res == 0", "", "class test_object_is_true(unittest.TestCase):", " def check_false(self):", " class foo:", " pass", " a= foo()", " res = inline_tools.inline('return_val = a.not();',['a'])", " assert res == 0", " def check_true(self):", " a= None", " res = inline_tools.inline('return_val = a.not();',['a'])", " assert res == 1", "", "class test_object_type(unittest.TestCase):", " def check_type(self):", " class foo:", " pass", " a= foo()", " res = inline_tools.inline('return_val = a.type();',['a'])", " assert res == type(a)", "", "class test_object_size(unittest.TestCase):", " def check_size(self):", " class foo:", " def __len__(self):", " return 10", " a= foo()", " res = inline_tools.inline('return_val = a.size();',['a'])", " assert res == len(a)", " def check_len(self):", " class foo:", " def __len__(self):", " return 10", " a= foo()", " res = inline_tools.inline('return_val = a.len();',['a'])", " assert res == len(a)", " def check_length(self):", " class foo:", " def __len__(self):", " return 10", " a= foo()", " res = inline_tools.inline('return_val = a.length();',['a'])", " assert res == len(a)", "", "from UserList import UserList", "class test_object_set_item_op_index(unittest.TestCase):", " def check_list_refcount(self):", " a = UserList([1,2,3])", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a[1] = 1234;\",['a'])", " before1 = sys.getrefcount(a)", " after1 = sys.getrefcount(a)", " assert after1 == before1", " def check_set_int(self):", " a = UserList([1,2,3])", " inline_tools.inline(\"a[1] = 1234;\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 1234", " def check_set_double(self):", " a = UserList([1,2,3])", " inline_tools.inline(\"a[1] = 123.0;\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 123.0", " def check_set_char(self):", " a = UserList([1,2,3])", " inline_tools.inline('a[1] = \"bubba\";',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'bubba'", " def check_set_string(self):", " a = UserList([1,2,3])", " inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'sissy'", " def check_set_string(self):", " a = UserList([1,2,3])", " inline_tools.inline('a[1] = std::complex(1,1);',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 1+1j", "", "from UserDict import UserDict", "class test_object_set_item_op_key(unittest.TestCase):", " def check_key_refcount(self):", " a = UserDict()", " code = \"\"\"", " py::object one = 1;", " py::object two = 2;", " py::tuple ref_counts(3);", " py::tuple obj_counts(3);", " py::tuple val_counts(3);", " py::tuple key_counts(3);", " obj_counts[0] = a.refcount();", " key_counts[0] = one.refcount();", " val_counts[0] = two.refcount();", " a[1] = 2;", " obj_counts[1] = a.refcount();", " key_counts[1] = one.refcount();", " val_counts[1] = two.refcount();", " a[1] = 2;", " obj_counts[2] = a.refcount();", " key_counts[2] = one.refcount();", " val_counts[2] = two.refcount();", "", " ref_counts[0] = obj_counts;", " ref_counts[1] = key_counts;", " ref_counts[2] = val_counts;", " return_val = ref_counts;", " \"\"\"", " obj,key,val = inline_tools.inline(code,['a'])", " assert obj[0] == obj[1] and obj[1] == obj[2]", " assert key[0] + 1 == key[1] and key[1] == key[2]", " assert val[0] + 1 == val[1] and val[1] == val[2]", "", " def check_set_double_exists(self):", " a = UserDict()", " key = 10.0", " a[key] = 100.0", " inline_tools.inline('a[key] = 123.0;',['a','key'])", " first = sys.getrefcount(key)", " inline_tools.inline('a[key] = 123.0;',['a','key'])", " second = sys.getrefcount(key)", " assert first == second", " # !! I think the following should be 3", " assert sys.getrefcount(key) == 5", " assert sys.getrefcount(a[key]) == 2", " assert a[key] == 123.0", " def check_set_double_new(self):", " a = UserDict()", " key = 1.0", " inline_tools.inline('a[key] = 123.0;',['a','key'])", " assert sys.getrefcount(key) == 4 # should be 3", " assert sys.getrefcount(a[key]) == 2", " assert a[key] == 123.0", " def check_set_complex(self):", " a = UserDict()", " key = 1+1j", " inline_tools.inline(\"a[key] = 1234;\",['a','key'])", " assert sys.getrefcount(key) == 3", " assert sys.getrefcount(a[key]) == 2", " assert a[key] == 1234", " def check_set_char(self):", " a = UserDict()", " inline_tools.inline('a[\"hello\"] = 123.0;',['a'])", " assert sys.getrefcount(a[\"hello\"]) == 2", " assert a[\"hello\"] == 123.0", "", " def check_set_class(self):", " a = UserDict()", " class foo:", " def __init__(self,val):", " self.val = val", " def __hash__(self):", " return self.val", " key = foo(4)", " inline_tools.inline('a[key] = \"bubba\";',['a','key'])", " first = sys.getrefcount(key)", " inline_tools.inline('a[key] = \"bubba\";',['a','key'])", " second = sys.getrefcount(key)", " # I don't think we're leaking if this is true", " assert first == second", " # !! BUT -- I think this should be 3", " assert sys.getrefcount(key) == 4", " assert sys.getrefcount(a[key]) == 2", " assert a[key] == 'bubba'", " def check_set_from_member(self):", " a = UserDict()", " a['first'] = 1", " a['second'] = 2", " inline_tools.inline('a[\"first\"] = a[\"second\"];',['a'])", " assert a['first'] == a['second']", "", "def test_suite(level=1):", " from unittest import makeSuite", " suites = []", " if level >= 5:", " suites.append( makeSuite(test_object_construct,'check_'))", " suites.append( makeSuite(test_object_print,'check_'))", " suites.append( makeSuite(test_object_cast,'check_'))", " suites.append( makeSuite(test_object_hasattr,'check_'))", " suites.append( makeSuite(test_object_attr,'check_'))", " suites.append( makeSuite(test_object_set_attr,'check_'))", " suites.append( makeSuite(test_object_del,'check_'))", " suites.append( makeSuite(test_object_cmp,'check_'))", " suites.append( makeSuite(test_object_repr,'check_'))", " suites.append( makeSuite(test_object_str,'check_'))", " suites.append( makeSuite(test_object_unicode,'check_'))", " suites.append( makeSuite(test_object_is_callable,'check_'))", " suites.append( makeSuite(test_object_call,'check_'))", " suites.append( makeSuite(test_object_mcall,'check_'))", " suites.append( makeSuite(test_object_hash,'check_'))", " suites.append( makeSuite(test_object_is_true,'check_'))", " suites.append( makeSuite(test_object_type,'check_'))", " suites.append( makeSuite(test_object_size,'check_'))", " suites.append( makeSuite(test_object_set_item_op_index,'check_'))", " suites.append( makeSuite(test_object_set_item_op_key,'check_'))", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10,verbose=2):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner(verbosity=verbose)", " runner.run(all_tests)", " return runner", "", "if __name__ == \"__main__\":", " test()" ], "deleted": [] } }, { "old_path": null, "new_path": "weave/tests/test_scxx_sequence.py", "filename": "test_scxx_sequence.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,452 @@\n+\"\"\" Test refcounting and behavior of SCXX.\n+\"\"\"\n+import unittest\n+import time\n+import os,sys\n+from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n+\n+add_grandparent_to_path(__name__)\n+import inline_tools\n+restore_path()\n+\n+# Test:\n+# append DONE\n+# insert DONE\n+# in DONE\n+# count DONE\n+# setItem DONE\n+# operator[] (get)\n+# operator[] (set) DONE\n+\n+from UserList import UserList\n+\n+class test_sequence_base(unittest.TestCase):\n+ seq_type = None\n+\n+ def check_conversion(self):\n+ a = self.seq_type([])\n+ before = sys.getrefcount(a)\n+ import weave\n+ weave.inline(\"\",['a'])\n+ #print 'first:',before\n+ # first call is goofing up refcount.\n+ before = sys.getrefcount(a) \n+ weave.inline(\"\",['a'])\n+ after = sys.getrefcount(a) \n+ #print '2nd,3rd:', before, after\n+ assert(after == before)\n+\n+ def check_in(self):\n+ \"\"\" Test the \"in\" method for lists. We'll assume\n+ it works for sequences if it works here.\n+ \"\"\"\n+ a = self.seq_type([1,2,'alpha',3.1416])\n+\n+ item = 1\n+ code = \"return_val = a.in(item);\"\n+ res = inline_tools.inline(code,['a','item'])\n+ assert res == 1\n+ item = 0\n+ res = inline_tools.inline(code,['a','item'])\n+ assert res == 0\n+ \n+ # check overloaded in(int val) method\n+ code = \"return_val = a.in(1);\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ code = \"return_val = a.in(0);\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 0\n+ \n+ # check overloaded in(double val) method\n+ code = \"return_val = a.in(3.1416);\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ code = \"return_val = a.in(3.1417);\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 0\n+ \n+ # check overloaded in(char* val) method \n+ code = 'return_val = a.in(\"alpha\");'\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ code = 'return_val = a.in(\"beta\");'\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 0\n+ \n+ # check overloaded in(std::string val) method\n+ code = \"\"\"\n+ std::string val = std::string(\"alpha\");\n+ return_val = a.in(val);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ code = \"\"\"\n+ std::string val = std::string(\"beta\");\n+ return_val = a.in(val);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 0\n+\n+ def check_count(self):\n+ \"\"\" Test the \"count\" method for lists. We'll assume\n+ it works for sequences if it works hre.\n+ \"\"\"\n+ a = self.seq_type([1,2,'alpha',3.1416])\n+\n+ item = 1\n+ code = \"return_val = a.count(item);\"\n+ res = inline_tools.inline(code,['a','item'])\n+ assert res == 1\n+ \n+ # check overloaded count(int val) method\n+ code = \"return_val = a.count(1);\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ \n+ # check overloaded count(double val) method\n+ code = \"return_val = a.count(3.1416);\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ \n+ # check overloaded count(char* val) method \n+ code = 'return_val = a.count(\"alpha\");'\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ \n+ # check overloaded count(std::string val) method\n+ code = \"\"\"\n+ std::string alpha = std::string(\"alpha\");\n+ return_val = a.count(alpha);\n+ \"\"\"\n+ res = inline_tools.inline(code,['a'])\n+ assert res == 1\n+ \n+ def check_access_speed(self):\n+ N = 1000000\n+ print '%s access -- val = a[i] for N =', (self.seq_type, N)\n+ a = self.seq_type([0]) * N\n+ val = 0\n+ t1 = time.time()\n+ for i in xrange(N):\n+ val = a[i]\n+ t2 = time.time()\n+ print 'python1:', t2 - t1\n+ t1 = time.time()\n+ for i in a:\n+ val = i\n+ t2 = time.time()\n+ print 'python2:', t2 - t1\n+ \n+ code = \"\"\"\n+ const int N = a.length();\n+ py::object val;\n+ for(int i=0; i < N; i++)\n+ val = a[i];\n+ \"\"\"\n+ # compile not included in timing \n+ inline_tools.inline(code,['a']) \n+ t1 = time.time()\n+ inline_tools.inline(code,['a']) \n+ t2 = time.time()\n+ print 'weave:', t2 - t1\n+\n+ def check_access_set_speed(self):\n+ N = 1000000\n+ print '%s access/set -- b[i] = a[i] for N =', (self.seq_type,N)\n+ a = self.seq_type([0]) * N\n+ # b is always a list so we can assign to it.\n+ b = [1] * N\n+ t1 = time.time()\n+ for i in xrange(N):\n+ b[i] = a[i]\n+ t2 = time.time()\n+ print 'python:', t2 - t1\n+ \n+ a = self.seq_type([0]) * N\n+ b = [1] * N \n+ code = \"\"\"\n+ const int N = a.length();\n+ for(int i=0; i < N; i++)\n+ b[i] = a[i]; \n+ \"\"\"\n+ # compile not included in timing\n+ inline_tools.inline(code,['a','b']) \n+ t1 = time.time()\n+ inline_tools.inline(code,['a','b']) \n+ t2 = time.time()\n+ print 'weave:', t2 - t1\n+ assert list(b) == list(a) \n+\n+class test_tuple(test_sequence_base):\n+ seq_type = tuple\n+\n+ def check_set_item_operator_equal_fail(self):\n+ # Tuples should only allow setting of variables \n+ # immediately after creation.\n+ a = (1,2,3) \n+ try:\n+ inline_tools.inline(\"a[1] = 1234;\",['a'])\n+ except TypeError:\n+ pass \n+ def check_set_item_operator_equal(self): \n+ code = \"\"\"\n+ py::tuple a(3);\n+ a[0] = 1;\n+ a[1] = 2;\n+ a[2] = 3;\n+ return_val = a;\n+ \"\"\"\n+ a = inline_tools.inline(code)\n+ assert a == (1,2,3)\n+ # returned value should only have a single refcount\n+ assert sys.getrefcount(a) == 2\n+\n+ def check_set_item_index_error(self): \n+ code = \"\"\"\n+ py::tuple a(3);\n+ a[4] = 1;\n+ return_val = a;\n+ \"\"\"\n+ try:\n+ a = inline_tools.inline(code)\n+ assert 0\n+ except IndexError:\n+ pass \n+ def check_get_item_operator_index_error(self):\n+ code = \"\"\"\n+ py::tuple a(3);\n+ py::object b = a[4]; // should fail.\n+ \"\"\"\n+ try:\n+ a = inline_tools.inline(code)\n+ assert 0\n+ except IndexError:\n+ pass\n+ \n+class test_list(test_sequence_base):\n+ seq_type = list\n+ def check_append_passed_item(self):\n+ a = []\n+ item = 1\n+ \n+ # temporary refcount fix until I understand why it incs by one.\n+ inline_tools.inline(\"a.append(item);\",['a','item'])\n+ del a[0] \n+ \n+ before1 = sys.getrefcount(a)\n+ before2 = sys.getrefcount(item)\n+ inline_tools.inline(\"a.append(item);\",['a','item'])\n+ assert a[0] is item\n+ del a[0] \n+ after1 = sys.getrefcount(a)\n+ after2 = sys.getrefcount(item)\n+ assert after1 == before1\n+ assert after2 == before2 \n+ def check_append(self):\n+ a = []\n+ # temporary refcount fix until I understand why it incs by one.\n+ inline_tools.inline(\"a.append(1);\",['a'])\n+ del a[0] \n+ \n+ before1 = sys.getrefcount(a)\n+ \n+ # check overloaded append(int val) method\n+ inline_tools.inline(\"a.append(1234);\",['a']) \n+ assert sys.getrefcount(a[0]) == 2 \n+ assert a[0] == 1234\n+ del a[0] \n+\n+ # check overloaded append(double val) method\n+ inline_tools.inline(\"a.append(123.0);\",['a'])\n+ assert sys.getrefcount(a[0]) == 2 \n+ assert a[0] == 123.0\n+ del a[0] \n+ \n+ # check overloaded append(char* val) method \n+ inline_tools.inline('a.append(\"bubba\");',['a'])\n+ assert sys.getrefcount(a[0]) == 2 \n+ assert a[0] == 'bubba'\n+ del a[0] \n+ \n+ # check overloaded append(std::string val) method\n+ inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n+ assert sys.getrefcount(a[0]) == 2 \n+ assert a[0] == 'sissy'\n+ del a[0] \n+ \n+ after1 = sys.getrefcount(a)\n+ assert after1 == before1\n+ def check_insert(self):\n+ a = [1,2,3]\n+ \n+ a.insert(1,234)\n+ del a[1]\n+ \n+ # temporary refcount fix until I understand why it incs by one.\n+ inline_tools.inline(\"a.insert(1,1234);\",['a'])\n+ del a[1] \n+ \n+ before1 = sys.getrefcount(a)\n+ \n+ # check overloaded insert(int ndx, int val) method\n+ inline_tools.inline(\"a.insert(1,1234);\",['a']) \n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 1234\n+ del a[1] \n+\n+ # check overloaded insert(int ndx, double val) method\n+ inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 123.0\n+ del a[1] \n+ \n+ # check overloaded insert(int ndx, char* val) method \n+ inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'bubba'\n+ del a[1] \n+ \n+ # check overloaded insert(int ndx, std::string val) method\n+ inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'sissy'\n+ del a[0] \n+ \n+ after1 = sys.getrefcount(a)\n+ assert after1 == before1\n+\n+ def check_set_item_operator_equal(self):\n+ a = self.seq_type([1,2,3]) \n+ # temporary refcount fix until I understand why it incs by one.\n+ inline_tools.inline(\"a[1] = 1234;\",['a'])\n+ before1 = sys.getrefcount(a)\n+ \n+ # check overloaded insert(int ndx, int val) method\n+ inline_tools.inline(\"a[1] = 1234;\",['a']) \n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 1234\n+\n+ # check overloaded insert(int ndx, double val) method\n+ inline_tools.inline(\"a[1] = 123.0;\",['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 123.0\n+ \n+ # check overloaded insert(int ndx, char* val) method \n+ inline_tools.inline('a[1] = \"bubba\";',['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'bubba'\n+ \n+ # check overloaded insert(int ndx, std::string val) method\n+ code = \"\"\"\n+ std::string val = std::string(\"sissy\");\n+ a[1] = val;\n+ \"\"\"\n+ inline_tools.inline(code,['a'])\n+ assert sys.getrefcount(a[1]) == 2 \n+ assert a[1] == 'sissy'\n+ \n+ after1 = sys.getrefcount(a)\n+ assert after1 == before1\n+ def check_set_item_operator_equal_created(self): \n+ code = \"\"\"\n+ py::list a(3);\n+ a[0] = 1;\n+ a[1] = 2;\n+ a[2] = 3;\n+ return_val = a;\n+ \"\"\"\n+ a = inline_tools.inline(code)\n+ assert a == [1,2,3]\n+ # returned value should only have a single refcount\n+ assert sys.getrefcount(a) == 2\n+ def check_set_item_index_error(self): \n+ code = \"\"\"\n+ py::list a(3);\n+ a[4] = 1;\n+ \"\"\"\n+ try:\n+ a = inline_tools.inline(code)\n+ assert 0\n+ except IndexError:\n+ pass\n+ def check_get_item_index_error(self): \n+ code = \"\"\"\n+ py::list a(3);\n+ py::object o = a[4];\n+ \"\"\"\n+ try:\n+ a = inline_tools.inline(code)\n+ assert 0\n+ except IndexError:\n+ pass\n+\n+ def check_string_add_speed(self):\n+ N = 1000000\n+ print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n+ a = [\"blah\"] * N\n+ desired = [1] * N\n+ t1 = time.time()\n+ for i in xrange(N):\n+ desired[i] = a[i] + 'blah'\n+ t2 = time.time()\n+ print 'python:', t2 - t1\n+ \n+ a = [\"blah\"] * N\n+ b = [1] * N \n+ code = \"\"\"\n+ const int N = a.length();\n+ std::string blah = std::string(\"blah\");\n+ for(int i=0; i < N; i++)\n+ b[i] = (std::string)a[i] + blah; \n+ \"\"\"\n+ # compile not included in timing\n+ inline_tools.inline(code,['a','b']) \n+ t1 = time.time()\n+ inline_tools.inline(code,['a','b']) \n+ t2 = time.time()\n+ print 'weave:', t2 - t1\n+ assert b == desired \n+ def check_int_add_speed(self):\n+ N = 1000000\n+ print 'int add -- b[i] = a[i] + 1 for N =', N \n+ a = [0] * N\n+ desired = [1] * N\n+ t1 = time.time()\n+ for i in xrange(N):\n+ desired[i] = a[i] + 1\n+ t2 = time.time()\n+ print 'python:', t2 - t1\n+ \n+ a = [0] * N\n+ b = [0] * N \n+ code = \"\"\"\n+ const int N = a.length();\n+ for(int i=0; i < N; i++)\n+ b[i] = (int)a[i] + 1; \n+ \"\"\"\n+ # compile not included in timing\n+ inline_tools.inline(code,['a','b']) \n+ t1 = time.time()\n+ inline_tools.inline(code,['a','b']) \n+ t2 = time.time()\n+ print 'weave:', t2 - t1\n+ assert b == desired \n+\n+def test_suite(level=1):\n+ from unittest import makeSuite\n+ suites = [] \n+ if level >= 5:\n+ #suites.append( makeSuite(test_list,'check_'))\n+ suites.append( makeSuite(test_tuple,'check_'))\n+ total_suite = unittest.TestSuite(suites)\n+ return total_suite\n+\n+def test(level=10,verbose=2):\n+ all_tests = test_suite(level)\n+ runner = unittest.TextTestRunner(verbosity=verbose)\n+ runner.run(all_tests)\n+ return runner\n+\n+if __name__ == \"__main__\":\n+ test()\n", "added_lines": 452, "deleted_lines": 0, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nfrom UserList import UserList\n\nclass test_sequence_base(unittest.TestCase):\n seq_type = None\n\n def check_conversion(self):\n a = self.seq_type([])\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n #print 'first:',before\n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n #print '2nd,3rd:', before, after\n assert(after == before)\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = self.seq_type([1,2,'alpha',3.1416])\n\n item = 1\n code = \"return_val = a.in(item);\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = a.in(1);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = a.in(0);\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = a.in(3.1416);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = a.in(3.1417);\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = a.in(\"alpha\");'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = a.in(\"beta\");'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = \"\"\"\n std::string val = std::string(\"alpha\");\n return_val = a.in(val);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"\"\"\n std::string val = std::string(\"beta\");\n return_val = a.in(val);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = self.seq_type([1,2,'alpha',3.1416])\n\n item = 1\n code = \"return_val = a.count(item);\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = a.count(1);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = a.count(3.1416);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = a.count(\"alpha\");'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = \"\"\"\n std::string alpha = std::string(\"alpha\");\n return_val = a.count(alpha);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n def check_access_speed(self):\n N = 1000000\n print '%s access -- val = a[i] for N =', (self.seq_type, N)\n a = self.seq_type([0]) * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self):\n N = 1000000\n print '%s access/set -- b[i] = a[i] for N =', (self.seq_type,N)\n a = self.seq_type([0]) * N\n # b is always a list so we can assign to it.\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = self.seq_type([0]) * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert list(b) == list(a) \n\nclass test_tuple(test_sequence_base):\n seq_type = tuple\n\n def check_set_item_operator_equal_fail(self):\n # Tuples should only allow setting of variables \n # immediately after creation.\n a = (1,2,3) \n try:\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n except TypeError:\n pass \n def check_set_item_operator_equal(self): \n code = \"\"\"\n py::tuple a(3);\n a[0] = 1;\n a[1] = 2;\n a[2] = 3;\n return_val = a;\n \"\"\"\n a = inline_tools.inline(code)\n assert a == (1,2,3)\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n\n def check_set_item_index_error(self): \n code = \"\"\"\n py::tuple a(3);\n a[4] = 1;\n return_val = a;\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass \n def check_get_item_operator_index_error(self):\n code = \"\"\"\n py::tuple a(3);\n py::object b = a[4]; // should fail.\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n \nclass test_list(test_sequence_base):\n seq_type = list\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2 \n def check_append(self):\n a = []\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = self.seq_type([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n code = \"\"\"\n std::string val = std::string(\"sissy\");\n a[1] = val;\n \"\"\"\n inline_tools.inline(code,['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_set_item_operator_equal_created(self): \n code = \"\"\"\n py::list a(3);\n a[0] = 1;\n a[1] = 2;\n a[2] = 3;\n return_val = a;\n \"\"\"\n a = inline_tools.inline(code)\n assert a == [1,2,3]\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n def check_set_item_index_error(self): \n code = \"\"\"\n py::list a(3);\n a[4] = 1;\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n def check_get_item_index_error(self): \n code = \"\"\"\n py::list a(3);\n py::object o = a[4];\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n\n def check_string_add_speed(self):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 'blah'\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [\"blah\"] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n std::string blah = std::string(\"blah\");\n for(int i=0; i < N; i++)\n b[i] = (std::string)a[i] + blah; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n def check_int_add_speed(self):\n N = 1000000\n print 'int add -- b[i] = a[i] + 1 for N =', N \n a = [0] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 1\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [0] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = (int)a[i] + 1; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n #suites.append( makeSuite(test_list,'check_'))\n suites.append( makeSuite(test_tuple,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbose=2):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner(verbosity=verbose)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": null, "methods": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx_sequence.py", "nloc": 9, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 26, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx_sequence.py", "nloc": 39, "complexity": 1, "token_count": 221, "parameters": [ "self" ], "start_line": 39, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx_sequence.py", "nloc": 21, "complexity": 1, "token_count": 124, "parameters": [ "self" ], "start_line": 91, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 26, "complexity": 3, "token_count": 138, "parameters": [ "self" ], "start_line": 125, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 150, "parameters": [ "self" ], "start_line": 154, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_fail", "long_name": "check_set_item_operator_equal_fail( self )", "filename": "test_scxx_sequence.py", "nloc": 6, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 184, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 192, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_set_item_index_error", "long_name": "check_set_item_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 205, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_get_item_operator_index_error", "long_name": "check_get_item_operator_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 216, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx_sequence.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 229, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 246, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx_sequence.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 280, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx_sequence.py", "nloc": 22, "complexity": 1, "token_count": 170, "parameters": [ "self" ], "start_line": 319, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_created", "long_name": "check_set_item_operator_equal_created( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 351, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_set_item_index_error", "long_name": "check_set_item_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 363, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_get_item_index_error", "long_name": "check_get_item_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 373, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_string_add_speed", "long_name": "check_string_add_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 384, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 410, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_sequence.py", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "level" ], "start_line": 436, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_sequence.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 445, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "check_get_item_index_error", "long_name": "check_get_item_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 373, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 150, "parameters": [ "self" ], "start_line": 154, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx_sequence.py", "nloc": 9, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 26, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_set_item_index_error", "long_name": "check_set_item_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 205, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_sequence.py", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "level" ], "start_line": 436, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 246, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 26, "complexity": 3, "token_count": 138, "parameters": [ "self" ], "start_line": 125, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_fail", "long_name": "check_set_item_operator_equal_fail( self )", "filename": "test_scxx_sequence.py", "nloc": 6, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 184, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx_sequence.py", "nloc": 39, "complexity": 1, "token_count": 221, "parameters": [ "self" ], "start_line": 39, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 1 }, { "name": "check_get_item_operator_index_error", "long_name": "check_get_item_operator_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 216, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx_sequence.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 280, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 192, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx_sequence.py", "nloc": 21, "complexity": 1, "token_count": 124, "parameters": [ "self" ], "start_line": 91, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_created", "long_name": "check_set_item_operator_equal_created( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 351, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_sequence.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 445, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx_sequence.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 229, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 410, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_string_add_speed", "long_name": "check_string_add_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 384, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 } ], "nloc": 348, "complexity": 31, "token_count": 1963, "diff_parsed": { "added": [ "\"\"\" Test refcounting and behavior of SCXX.", "\"\"\"", "import unittest", "import time", "import os,sys", "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "", "add_grandparent_to_path(__name__)", "import inline_tools", "restore_path()", "", "# Test:", "# append DONE", "# insert DONE", "# in DONE", "# count DONE", "# setItem DONE", "# operator[] (get)", "# operator[] (set) DONE", "", "from UserList import UserList", "", "class test_sequence_base(unittest.TestCase):", " seq_type = None", "", " def check_conversion(self):", " a = self.seq_type([])", " before = sys.getrefcount(a)", " import weave", " weave.inline(\"\",['a'])", " #print 'first:',before", " # first call is goofing up refcount.", " before = sys.getrefcount(a)", " weave.inline(\"\",['a'])", " after = sys.getrefcount(a)", " #print '2nd,3rd:', before, after", " assert(after == before)", "", " def check_in(self):", " \"\"\" Test the \"in\" method for lists. We'll assume", " it works for sequences if it works here.", " \"\"\"", " a = self.seq_type([1,2,'alpha',3.1416])", "", " item = 1", " code = \"return_val = a.in(item);\"", " res = inline_tools.inline(code,['a','item'])", " assert res == 1", " item = 0", " res = inline_tools.inline(code,['a','item'])", " assert res == 0", "", " # check overloaded in(int val) method", " code = \"return_val = a.in(1);\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = \"return_val = a.in(0);\"", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " # check overloaded in(double val) method", " code = \"return_val = a.in(3.1416);\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = \"return_val = a.in(3.1417);\"", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " # check overloaded in(char* val) method", " code = 'return_val = a.in(\"alpha\");'", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = 'return_val = a.in(\"beta\");'", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " # check overloaded in(std::string val) method", " code = \"\"\"", " std::string val = std::string(\"alpha\");", " return_val = a.in(val);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", " code = \"\"\"", " std::string val = std::string(\"beta\");", " return_val = a.in(val);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res == 0", "", " def check_count(self):", " \"\"\" Test the \"count\" method for lists. We'll assume", " it works for sequences if it works hre.", " \"\"\"", " a = self.seq_type([1,2,'alpha',3.1416])", "", " item = 1", " code = \"return_val = a.count(item);\"", " res = inline_tools.inline(code,['a','item'])", " assert res == 1", "", " # check overloaded count(int val) method", " code = \"return_val = a.count(1);\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " # check overloaded count(double val) method", " code = \"return_val = a.count(3.1416);\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " # check overloaded count(char* val) method", " code = 'return_val = a.count(\"alpha\");'", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " # check overloaded count(std::string val) method", " code = \"\"\"", " std::string alpha = std::string(\"alpha\");", " return_val = a.count(alpha);", " \"\"\"", " res = inline_tools.inline(code,['a'])", " assert res == 1", "", " def check_access_speed(self):", " N = 1000000", " print '%s access -- val = a[i] for N =', (self.seq_type, N)", " a = self.seq_type([0]) * N", " val = 0", " t1 = time.time()", " for i in xrange(N):", " val = a[i]", " t2 = time.time()", " print 'python1:', t2 - t1", " t1 = time.time()", " for i in a:", " val = i", " t2 = time.time()", " print 'python2:', t2 - t1", "", " code = \"\"\"", " const int N = a.length();", " py::object val;", " for(int i=0; i < N; i++)", " val = a[i];", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a'])", " t1 = time.time()", " inline_tools.inline(code,['a'])", " t2 = time.time()", " print 'weave:', t2 - t1", "", " def check_access_set_speed(self):", " N = 1000000", " print '%s access/set -- b[i] = a[i] for N =', (self.seq_type,N)", " a = self.seq_type([0]) * N", " # b is always a list so we can assign to it.", " b = [1] * N", " t1 = time.time()", " for i in xrange(N):", " b[i] = a[i]", " t2 = time.time()", " print 'python:', t2 - t1", "", " a = self.seq_type([0]) * N", " b = [1] * N", " code = \"\"\"", " const int N = a.length();", " for(int i=0; i < N; i++)", " b[i] = a[i];", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a','b'])", " t1 = time.time()", " inline_tools.inline(code,['a','b'])", " t2 = time.time()", " print 'weave:', t2 - t1", " assert list(b) == list(a)", "", "class test_tuple(test_sequence_base):", " seq_type = tuple", "", " def check_set_item_operator_equal_fail(self):", " # Tuples should only allow setting of variables", " # immediately after creation.", " a = (1,2,3)", " try:", " inline_tools.inline(\"a[1] = 1234;\",['a'])", " except TypeError:", " pass", " def check_set_item_operator_equal(self):", " code = \"\"\"", " py::tuple a(3);", " a[0] = 1;", " a[1] = 2;", " a[2] = 3;", " return_val = a;", " \"\"\"", " a = inline_tools.inline(code)", " assert a == (1,2,3)", " # returned value should only have a single refcount", " assert sys.getrefcount(a) == 2", "", " def check_set_item_index_error(self):", " code = \"\"\"", " py::tuple a(3);", " a[4] = 1;", " return_val = a;", " \"\"\"", " try:", " a = inline_tools.inline(code)", " assert 0", " except IndexError:", " pass", " def check_get_item_operator_index_error(self):", " code = \"\"\"", " py::tuple a(3);", " py::object b = a[4]; // should fail.", " \"\"\"", " try:", " a = inline_tools.inline(code)", " assert 0", " except IndexError:", " pass", "", "class test_list(test_sequence_base):", " seq_type = list", " def check_append_passed_item(self):", " a = []", " item = 1", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.append(item);\",['a','item'])", " del a[0]", "", " before1 = sys.getrefcount(a)", " before2 = sys.getrefcount(item)", " inline_tools.inline(\"a.append(item);\",['a','item'])", " assert a[0] is item", " del a[0]", " after1 = sys.getrefcount(a)", " after2 = sys.getrefcount(item)", " assert after1 == before1", " assert after2 == before2", " def check_append(self):", " a = []", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.append(1);\",['a'])", " del a[0]", "", " before1 = sys.getrefcount(a)", "", " # check overloaded append(int val) method", " inline_tools.inline(\"a.append(1234);\",['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 1234", " del a[0]", "", " # check overloaded append(double val) method", " inline_tools.inline(\"a.append(123.0);\",['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 123.0", " del a[0]", "", " # check overloaded append(char* val) method", " inline_tools.inline('a.append(\"bubba\");',['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 'bubba'", " del a[0]", "", " # check overloaded append(std::string val) method", " inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])", " assert sys.getrefcount(a[0]) == 2", " assert a[0] == 'sissy'", " del a[0]", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", " def check_insert(self):", " a = [1,2,3]", "", " a.insert(1,234)", " del a[1]", "", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a.insert(1,1234);\",['a'])", " del a[1]", "", " before1 = sys.getrefcount(a)", "", " # check overloaded insert(int ndx, int val) method", " inline_tools.inline(\"a.insert(1,1234);\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 1234", " del a[1]", "", " # check overloaded insert(int ndx, double val) method", " inline_tools.inline(\"a.insert(1,123.0);\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 123.0", " del a[1]", "", " # check overloaded insert(int ndx, char* val) method", " inline_tools.inline('a.insert(1,\"bubba\");',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'bubba'", " del a[1]", "", " # check overloaded insert(int ndx, std::string val) method", " inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'sissy'", " del a[0]", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", "", " def check_set_item_operator_equal(self):", " a = self.seq_type([1,2,3])", " # temporary refcount fix until I understand why it incs by one.", " inline_tools.inline(\"a[1] = 1234;\",['a'])", " before1 = sys.getrefcount(a)", "", " # check overloaded insert(int ndx, int val) method", " inline_tools.inline(\"a[1] = 1234;\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 1234", "", " # check overloaded insert(int ndx, double val) method", " inline_tools.inline(\"a[1] = 123.0;\",['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 123.0", "", " # check overloaded insert(int ndx, char* val) method", " inline_tools.inline('a[1] = \"bubba\";',['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'bubba'", "", " # check overloaded insert(int ndx, std::string val) method", " code = \"\"\"", " std::string val = std::string(\"sissy\");", " a[1] = val;", " \"\"\"", " inline_tools.inline(code,['a'])", " assert sys.getrefcount(a[1]) == 2", " assert a[1] == 'sissy'", "", " after1 = sys.getrefcount(a)", " assert after1 == before1", " def check_set_item_operator_equal_created(self):", " code = \"\"\"", " py::list a(3);", " a[0] = 1;", " a[1] = 2;", " a[2] = 3;", " return_val = a;", " \"\"\"", " a = inline_tools.inline(code)", " assert a == [1,2,3]", " # returned value should only have a single refcount", " assert sys.getrefcount(a) == 2", " def check_set_item_index_error(self):", " code = \"\"\"", " py::list a(3);", " a[4] = 1;", " \"\"\"", " try:", " a = inline_tools.inline(code)", " assert 0", " except IndexError:", " pass", " def check_get_item_index_error(self):", " code = \"\"\"", " py::list a(3);", " py::object o = a[4];", " \"\"\"", " try:", " a = inline_tools.inline(code)", " assert 0", " except IndexError:", " pass", "", " def check_string_add_speed(self):", " N = 1000000", " print 'string add -- b[i] = a[i] + \"blah\" for N =', N", " a = [\"blah\"] * N", " desired = [1] * N", " t1 = time.time()", " for i in xrange(N):", " desired[i] = a[i] + 'blah'", " t2 = time.time()", " print 'python:', t2 - t1", "", " a = [\"blah\"] * N", " b = [1] * N", " code = \"\"\"", " const int N = a.length();", " std::string blah = std::string(\"blah\");", " for(int i=0; i < N; i++)", " b[i] = (std::string)a[i] + blah;", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a','b'])", " t1 = time.time()", " inline_tools.inline(code,['a','b'])", " t2 = time.time()", " print 'weave:', t2 - t1", " assert b == desired", " def check_int_add_speed(self):", " N = 1000000", " print 'int add -- b[i] = a[i] + 1 for N =', N", " a = [0] * N", " desired = [1] * N", " t1 = time.time()", " for i in xrange(N):", " desired[i] = a[i] + 1", " t2 = time.time()", " print 'python:', t2 - t1", "", " a = [0] * N", " b = [0] * N", " code = \"\"\"", " const int N = a.length();", " for(int i=0; i < N; i++)", " b[i] = (int)a[i] + 1;", " \"\"\"", " # compile not included in timing", " inline_tools.inline(code,['a','b'])", " t1 = time.time()", " inline_tools.inline(code,['a','b'])", " t2 = time.time()", " print 'weave:', t2 - t1", " assert b == desired", "", "def test_suite(level=1):", " from unittest import makeSuite", " suites = []", " if level >= 5:", " #suites.append( makeSuite(test_list,'check_'))", " suites.append( makeSuite(test_tuple,'check_'))", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10,verbose=2):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner(verbosity=verbose)", " runner.run(all_tests)", " return runner", "", "if __name__ == \"__main__\":", " test()" ], "deleted": [] } } ] }, { "hash": "efb9df078950abbf660dba18c3b95b2a0db9670e", "msg": "type was returning PyObject*. Changed to py::object", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-10-10T09:14:17+00:00", "author_timezone": 0, "committer_date": "2002-10-10T09:14:17+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b9e184cb5bc0f9c2fa2aa4d4e78b6c45541fa73a" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/scxx/object.h", "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -687,7 +687,7 @@ public:\n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n- PyObject* type() const {\n+ object type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n", "added_lines": 1, "deleted_lines": 1, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //-------------------------------------------------------------------------\n object repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n object str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n bool not() const {\n return PyObject_Not(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n object type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //-------------------------------------------------------------------------\n object repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n object str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n bool not() const {\n return PyObject_Not(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n PyObject* type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "methods": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 140, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 146, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 160, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 186, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 207, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 224, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 243, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 250, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 265, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 272, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 279, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 287, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 301, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 309, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 316, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 323, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 353, "end_line": 358, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 360, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 367, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 377, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 382, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 387, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 397, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 408, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 412, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 416, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 421, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 453, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 475, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 497, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 519, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 566, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 574, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 583, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 598, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 606, "end_line": 612, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 614, "end_line": 620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 622, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 625, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 628, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 637, "end_line": 642, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 649, "end_line": 654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 659, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 666, "end_line": 671, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 676, "end_line": 678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::not", "long_name": "py::object::not() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 683, "end_line": 685, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 690, "end_line": 695, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 703, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 722, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 745, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 750, "end_line": 752, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 772, "end_line": 773, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 774, "end_line": 774, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 776, "end_line": 780, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 781, "end_line": 784, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 785, "end_line": 788, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 789, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 793, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 797, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 140, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 146, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 160, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 186, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 207, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 224, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 243, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 250, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 265, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 272, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 279, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 287, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 301, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 309, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 316, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 323, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 353, "end_line": 358, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 360, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 367, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 377, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 382, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 387, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 397, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 408, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 412, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 416, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 421, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 453, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 475, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 497, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 519, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 566, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 574, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 583, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 598, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 606, "end_line": 612, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 614, "end_line": 620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 622, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 625, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 628, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 637, "end_line": 642, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 649, "end_line": 654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 659, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 666, "end_line": 671, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 676, "end_line": 678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::not", "long_name": "py::object::not() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 683, "end_line": 685, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 690, "end_line": 695, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 703, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 722, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 745, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 750, "end_line": 752, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 772, "end_line": 773, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 774, "end_line": 774, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 776, "end_line": 780, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 781, "end_line": 784, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 785, "end_line": 788, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 789, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 793, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 797, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 690, "end_line": 695, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "nloc": 578, "complexity": 184, "token_count": 4205, "diff_parsed": { "added": [ " object type() const {" ], "deleted": [ " PyObject* type() const {" ] } } ] }, { "hash": "4fa203f15bb4c83b73bff3649b15c5bbd4828d19", "msg": "removed py::number from a test as it is no longer used by weave.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-10-11T06:48:45+00:00", "author_timezone": 0, "committer_date": "2002-10-11T06:48:45+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "efb9df078950abbf660dba18c3b95b2a0db9670e" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 8, "insertions": 6, "lines": 14, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "weave/tests/test_c_spec.py", "new_path": "weave/tests/test_c_spec.py", "filename": "test_c_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -408,18 +408,16 @@ def check_speed(self):\n mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n- py::number v = py::number();\n- int vv, sum = 0; \n+ int v, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n- vv = (int)v;\n- if (vv % 2)\n- sum += vv;\n+ if (v % 2)\n+ sum += v;\n else\n- sum -= vv; \n+ sum -= v; \n }\n- return_val = PyInt_FromLong(sum);\n+ return_val = sum;\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n@@ -436,7 +434,7 @@ def check_speed(self):\n else\n sum -= vv; \n }\n- return_val = PyInt_FromLong(sum);\n+ return_val = sum;\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n", "added_lines": 6, "deleted_lines": 8, "source_code": "import unittest\nimport time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nimport ext_tools\nfrom catalog import unique_file\nfrom build_tools import msvc_exists, gcc_exists\nimport c_spec\nrestore_path()\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n compiler = ''\n def check_py_to_file(self):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n compiler=''\n def check_call_function(self):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n py::tuple args(2);\n args[0] = search_str;\n args[1] = sub_str;\n return_val = func.call(args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(unittest.TestCase): \n compiler = ''\n def check_convert_to_dict(self):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=py::list();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=py::list();\n a.append(\"hello\");\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n int v, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n if (v % 2)\n sum += v;\n else\n sum -= v; \n }\n return_val = sum;\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = sum;\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=py::tuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=py::tuple(2);\n a[0] = \"hello\";\n a.set_item(1,py::None);\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=py::dict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=py::dict();\n a[\"hello\"] = 5;\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n \ndef test_suite(level=1):\n from unittest import makeSuite\n global test_dir\n test_dir = setup_test_location()\n suites = [] \n if level >= 5:\n if msvc_exists():\n suites.append( makeSuite(test_msvc_file_converter,'check_'))\n suites.append( makeSuite(test_msvc_instance_converter,'check_'))\n suites.append( makeSuite(test_msvc_callable_converter,'check_'))\n suites.append( makeSuite(test_msvc_sequence_converter,'check_'))\n suites.append( makeSuite(test_msvc_string_converter,'check_'))\n suites.append( makeSuite(test_msvc_list_converter,'check_'))\n suites.append( makeSuite(test_msvc_tuple_converter,'check_'))\n suites.append( makeSuite(test_msvc_dict_converter,'check_'))\n suites.append( makeSuite(test_msvc_int_converter,'check_'))\n suites.append( makeSuite(test_msvc_float_converter,'check_')) \n suites.append( makeSuite(test_msvc_complex_converter,'check_'))\n else: # unix\n suites.append( makeSuite(test_unix_file_converter,'check_'))\n suites.append( makeSuite(test_unix_instance_converter,'check_'))\n suites.append( makeSuite(test_unix_callable_converter,'check_'))\n suites.append( makeSuite(test_unix_sequence_converter,'check_'))\n suites.append( makeSuite(test_unix_string_converter,'check_'))\n suites.append( makeSuite(test_unix_list_converter,'check_'))\n suites.append( makeSuite(test_unix_tuple_converter,'check_'))\n suites.append( makeSuite(test_unix_dict_converter,'check_'))\n suites.append( makeSuite(test_unix_int_converter,'check_'))\n suites.append( makeSuite(test_unix_float_converter,'check_')) \n suites.append( makeSuite(test_unix_complex_converter,'check_')) \n # run gcc tests also on windows\n if gcc_exists() and sys.platform == 'win32': \n suites.append( makeSuite(test_gcc_file_converter,'check_'))\n suites.append( makeSuite(test_gcc_instance_converter,'check_'))\n suites.append( makeSuite(test_gcc_callable_converter,'check_'))\n suites.append( makeSuite(test_gcc_sequence_converter,'check_'))\n suites.append( makeSuite(test_gcc_string_converter,'check_'))\n suites.append( makeSuite(test_gcc_list_converter,'check_'))\n suites.append( makeSuite(test_gcc_tuple_converter,'check_'))\n suites.append( makeSuite(test_gcc_dict_converter,'check_'))\n suites.append( makeSuite(test_gcc_int_converter,'check_'))\n suites.append( makeSuite(test_gcc_float_converter,'check_')) \n suites.append( makeSuite(test_gcc_complex_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": "import unittest\nimport time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nimport ext_tools\nfrom catalog import unique_file\nfrom build_tools import msvc_exists, gcc_exists\nimport c_spec\nrestore_path()\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n compiler = ''\n def check_py_to_file(self):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n compiler=''\n def check_call_function(self):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n py::tuple args(2);\n args[0] = search_str;\n args[1] = sub_str;\n return_val = func.call(args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(unittest.TestCase): \n compiler = ''\n def check_convert_to_dict(self):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=py::list();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=py::list();\n a.append(\"hello\");\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n py::number v = py::number();\n int vv, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n vv = (int)v;\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = PyInt_FromLong(sum);\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=py::tuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=py::tuple(2);\n a[0] = \"hello\";\n a.set_item(1,py::None);\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=py::dict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=py::dict();\n a[\"hello\"] = 5;\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n \ndef test_suite(level=1):\n from unittest import makeSuite\n global test_dir\n test_dir = setup_test_location()\n suites = [] \n if level >= 5:\n if msvc_exists():\n suites.append( makeSuite(test_msvc_file_converter,'check_'))\n suites.append( makeSuite(test_msvc_instance_converter,'check_'))\n suites.append( makeSuite(test_msvc_callable_converter,'check_'))\n suites.append( makeSuite(test_msvc_sequence_converter,'check_'))\n suites.append( makeSuite(test_msvc_string_converter,'check_'))\n suites.append( makeSuite(test_msvc_list_converter,'check_'))\n suites.append( makeSuite(test_msvc_tuple_converter,'check_'))\n suites.append( makeSuite(test_msvc_dict_converter,'check_'))\n suites.append( makeSuite(test_msvc_int_converter,'check_'))\n suites.append( makeSuite(test_msvc_float_converter,'check_')) \n suites.append( makeSuite(test_msvc_complex_converter,'check_'))\n else: # unix\n suites.append( makeSuite(test_unix_file_converter,'check_'))\n suites.append( makeSuite(test_unix_instance_converter,'check_'))\n suites.append( makeSuite(test_unix_callable_converter,'check_'))\n suites.append( makeSuite(test_unix_sequence_converter,'check_'))\n suites.append( makeSuite(test_unix_string_converter,'check_'))\n suites.append( makeSuite(test_unix_list_converter,'check_'))\n suites.append( makeSuite(test_unix_tuple_converter,'check_'))\n suites.append( makeSuite(test_unix_dict_converter,'check_'))\n suites.append( makeSuite(test_unix_int_converter,'check_'))\n suites.append( makeSuite(test_unix_float_converter,'check_')) \n suites.append( makeSuite(test_unix_complex_converter,'check_')) \n # run gcc tests also on windows\n if gcc_exists() and sys.platform == 'win32': \n suites.append( makeSuite(test_gcc_file_converter,'check_'))\n suites.append( makeSuite(test_gcc_instance_converter,'check_'))\n suites.append( makeSuite(test_gcc_callable_converter,'check_'))\n suites.append( makeSuite(test_gcc_sequence_converter,'check_'))\n suites.append( makeSuite(test_gcc_string_converter,'check_'))\n suites.append( makeSuite(test_gcc_list_converter,'check_'))\n suites.append( makeSuite(test_gcc_tuple_converter,'check_'))\n suites.append( makeSuite(test_gcc_dict_converter,'check_'))\n suites.append( makeSuite(test_gcc_int_converter,'check_'))\n suites.append( makeSuite(test_gcc_float_converter,'check_')) \n suites.append( makeSuite(test_gcc_complex_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "unique_mod", "long_name": "unique_mod( d , file_name )", "filename": "test_c_spec.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "d", "file_name" ], "start_line": 23, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 28, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_c_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 35, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 69, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 118, "parameters": [ "self" ], "start_line": 124, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 148, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 179, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 106, "parameters": [ "self" ], "start_line": 202, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 225, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 14, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 266, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 286, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 289, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 292, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 295, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 301, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 304, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 307, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 310, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 313, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 89, "parameters": [ "self" ], "start_line": 337, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 356, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 361, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 114, "parameters": [ "self" ], "start_line": 364, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 387, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 59, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 405, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 467, "end_line": 471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 472, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 115, "parameters": [ "self" ], "start_line": 475, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 498, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 519, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 524, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 527, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 550, "end_line": 566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [], "start_line": 648, "end_line": 655, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 659, "end_line": 664, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 666, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 44, "complexity": 5, "token_count": 418, "parameters": [ "level" ], "start_line": 669, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 716, "end_line": 720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "unique_mod", "long_name": "unique_mod( d , file_name )", "filename": "test_c_spec.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "d", "file_name" ], "start_line": 23, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 28, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_c_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 35, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 69, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 118, "parameters": [ "self" ], "start_line": 124, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 148, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 179, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 106, "parameters": [ "self" ], "start_line": 202, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 225, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 14, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 266, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 286, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 289, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 292, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 295, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 301, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 304, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 307, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 310, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 313, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 89, "parameters": [ "self" ], "start_line": 337, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 356, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 361, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 114, "parameters": [ "self" ], "start_line": 364, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 387, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 61, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 405, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 469, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 474, "end_line": 476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 115, "parameters": [ "self" ], "start_line": 477, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 500, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 521, "end_line": 525, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 526, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 529, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 552, "end_line": 568, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [], "start_line": 650, "end_line": 657, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 661, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 44, "complexity": 5, "token_count": 418, "parameters": [ "level" ], "start_line": 671, "end_line": 716, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 718, "end_line": 722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 59, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 405, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 } ], "nloc": 645, "complexity": 79, "token_count": 3824, "diff_parsed": { "added": [ " int v, sum = 0;", " if (v % 2)", " sum += v;", " sum -= v;", " return_val = sum;", " return_val = sum;" ], "deleted": [ " py::number v = py::number();", " int vv, sum = 0;", " vv = (int)v;", " if (vv % 2)", " sum += vv;", " sum -= vv;", " return_val = PyInt_FromLong(sum);", " return_val = PyInt_FromLong(sum);" ] } } ] }, { "hash": "b90b0c14865353bd2adb94af1e2a2eb44b77e16b", "msg": "removed the not() operator from object.h. For some reason, it was causing problems in gcc 3.2 -- is it reserved or something? Anyway, I haven't used it and don't consider it to be critical at the moment, so I've just commented it out until there is more time to look it over.\n\nFixed const function declaration problems on py::sequenc::in().", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-10-12T00:50:45+00:00", "author_timezone": 0, "committer_date": "2002-10-12T00:50:45+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "4fa203f15bb4c83b73bff3649b15c5bbd4828d19" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 6, "insertions": 12, "lines": 18, "files": 2, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/scxx/object.h", "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -677,13 +677,15 @@ public:\n return PyObject_IsTrue(_obj) == 1;\n };\n \n- //-------------------------------------------------------------------------\n+ /*\n+ * //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n bool not() const {\n return PyObject_Not(_obj) == 1;\n };\n- \n+ */\n+\n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n", "added_lines": 4, "deleted_lines": 2, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //-------------------------------------------------------------------------\n object repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n object str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n \n /*\n * //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n bool not() const {\n return PyObject_Not(_obj) == 1;\n };\n */\n\n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n object type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //-------------------------------------------------------------------------\n object repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n object str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n bool not() const {\n return PyObject_Not(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n object type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "methods": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 140, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 146, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 160, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 186, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 207, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 224, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 243, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 250, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 265, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 272, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 279, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 287, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 301, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 309, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 316, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 323, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 353, "end_line": 358, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 360, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 367, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 377, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 382, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 387, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 397, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 408, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 412, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 416, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 421, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 453, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 475, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 497, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 519, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 566, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 574, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 583, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 598, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 606, "end_line": 612, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 614, "end_line": 620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 622, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 625, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 628, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 637, "end_line": 642, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 649, "end_line": 654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 659, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 666, "end_line": 671, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 676, "end_line": 678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 692, "end_line": 697, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 705, "end_line": 710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 711, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 714, "end_line": 716, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 724, "end_line": 728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 747, "end_line": 750, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 752, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 774, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 776, "end_line": 776, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 778, "end_line": 782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 783, "end_line": 786, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 787, "end_line": 790, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 791, "end_line": 794, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 795, "end_line": 798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 799, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 140, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 146, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 160, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 186, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 207, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 224, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 243, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 250, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 265, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 272, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 279, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 287, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 301, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 309, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 316, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 323, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 353, "end_line": 358, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 360, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 367, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 377, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 382, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 387, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 397, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 408, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 412, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 416, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 421, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 453, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 475, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 497, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 519, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 566, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 574, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 583, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 598, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 606, "end_line": 612, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 614, "end_line": 620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 622, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 625, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 628, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 637, "end_line": 642, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 649, "end_line": 654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 659, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 666, "end_line": 671, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 676, "end_line": 678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::not", "long_name": "py::object::not() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 683, "end_line": 685, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 690, "end_line": 695, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 703, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 722, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 745, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 750, "end_line": 752, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 772, "end_line": 773, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 774, "end_line": 774, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 776, "end_line": 780, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 781, "end_line": 784, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 785, "end_line": 788, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 789, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 793, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 797, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [], "nloc": 575, "complexity": 183, "token_count": 4189, "diff_parsed": { "added": [ " /*", " * //-------------------------------------------------------------------------", " */", "" ], "deleted": [ " //-------------------------------------------------------------------------", "" ] } }, { "old_path": "weave/scxx/sequence.h", "new_path": "weave/scxx/sequence.h", "filename": "sequence.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -148,19 +148,23 @@ public:\n fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n }; \n- bool sequence::in(int value) {\n+ bool sequence::in(int value) const {\n object val = value;\n return in(val);\n };\n- bool sequence::in(double value) {\n+ bool sequence::in(double value) const {\n object val = value;\n return in(val);\n };\n- bool sequence::in(const char* value) {\n+ bool sequence::in(const std::complex& value) const {\n object val = value;\n return in(val);\n };\n- bool sequence::in(std::string& value) {\n+ bool sequence::in(const char* value) const {\n+ object val = value;\n+ return in(val);\n+ };\n+ bool sequence::in(const std::string& value) const {\n object val = value.c_str();\n return in(val);\n };\n", "added_lines": 8, "deleted_lines": 4, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n#if !defined(SEQUENCE_H_INCLUDED_)\n#define SEQUENCE_H_INCLUDED_\n\n#include \n#include \n\n#include \"object.h\"\n\nnamespace py {\n \n//---------------------------------------------------------------------------\n// !! This isn't being picked up out of object.h for some reason, so I'll \n// !! redeclare it.\n//---------------------------------------------------------------------------\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// base class for list and tuple objects.\n//---------------------------------------------------------------------------\nclass sequence : public object\n{\npublic:\n //-------------------------------------------------------------------------\n // constructors\n //-------------------------------------------------------------------------\n sequence() : object() {};\n sequence(const sequence& other) : object(other) {};\n sequence(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n\n //-------------------------------------------------------------------------\n // destructors\n //------------------------------------------------------------------------- \n virtual ~sequence() {}\n\n //-------------------------------------------------------------------------\n // operator=\n //-------------------------------------------------------------------------\n virtual sequence& operator=(const sequence& other) {\n grab_ref(other);\n return *this;\n };\n /*virtual*/ sequence& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // type checking.\n //------------------------------------------------------------------------- \n virtual void _violentTypeCheck() {\n if (!PySequence_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a sequence\");\n }\n };\n \n //-------------------------------------------------------------------------\n // operator+ -- concatenation\n //-------------------------------------------------------------------------\n sequence operator+(const sequence& rhs) const {\n PyObject* rslt = PySequence_Concat(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for +\");\n return lose_ref(rslt);\n };\n\n //-------------------------------------------------------------------------\n // count -- count the number of objects in a sequence.\n //-------------------------------------------------------------------------\n int count(const object& value) const {\n int rslt = PySequence_Count(_obj, value);\n if (rslt == -1)\n fail(PyExc_RuntimeError, \"failure in count\");\n return rslt;\n };\n int count(int value) const {\n object val = value;\n return count(val);\n };\n int count(double value) const {\n object val = value;\n return count(val);\n };\n int count(char* value) const {\n object val = value;\n return count(val);\n };\n int count(std::string& value) const {\n object val = value.c_str();\n return count(val);\n };\n\n //-------------------------------------------------------------------------\n // set_item -- virtual so that set_item for tuple and list use \n // type specific xxx_SetItem function calls.\n //-------------------------------------------------------------------------\n virtual void set_item(int ndx, object& val) {\n int rslt = PySequence_SetItem(_obj, ndx, val);\n if (rslt==-1)\n fail(PyExc_IndexError, \"Index out of range\");\n };\n\n\n //-------------------------------------------------------------------------\n // operator[] -- non-const version defined in list and tuple sub-types.\n //-------------------------------------------------------------------------\n object operator [] (int i) {\n PyObject* o = PySequence_GetItem(_obj, i);\n // don't throw error for when [] fails because it might be on left hand \n // side (a[0] = 1). If the sequence was just created, it will be filled \n // with NULL values, and setting the values should be ok. However, we\n // do want to catch index errors that might occur on the right hand side\n // (obj = a[4] when a has len==3).\n if (!o) {\n if (PyErr_ExceptionMatches(PyExc_IndexError))\n throw 1;\n }\n return lose_ref(o);\n };\n \n //-------------------------------------------------------------------------\n // slice -- handles slice operations.\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n sequence slice(int lo, int hi) const {\n PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n if (o == 0)\n fail(PyExc_IndexError, \"could not obtain slice\");\n return lose_ref(o);\n };\n \n //-------------------------------------------------------------------------\n // in -- find whether a value is in the given sequence.\n // overloaded to handle the standard types used in weave.\n //-------------------------------------------------------------------------\n bool in(const object& value) const {\n int rslt = PySequence_In(_obj, value);\n if (rslt==-1)\n fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n }; \n bool sequence::in(int value) const {\n object val = value;\n return in(val);\n };\n bool sequence::in(double value) const {\n object val = value;\n return in(val);\n };\n bool sequence::in(const std::complex& value) const {\n object val = value;\n return in(val);\n };\n bool sequence::in(const char* value) const {\n object val = value;\n return in(val);\n };\n bool sequence::in(const std::string& value) const {\n object val = value.c_str();\n return in(val);\n };\n \n //-------------------------------------------------------------------------\n // index -- find whether a value is in the given sequence.\n // overloaded to handle the standard types used in weave.\n //-------------------------------------------------------------------------\n int index(const object& value) const {\n int rslt = PySequence_Index(_obj, value);\n if (rslt==-1)\n fail(PyExc_IndexError, \"value not found\");\n return rslt;\n };\n int sequence::index(int value) const {\n object val = value;\n return index(val);\n }; \n int sequence::index(double value) const {\n object val = value;\n return index(val);\n };\n int sequence::index(const std::complex& value) const {\n object val = value;\n return index(val);\n };\n int sequence::index(const char* value) const {\n object val = value;\n return index(val);\n }; \n int sequence::index(const std::string& value) const {\n object val = value;\n return index(val);\n };\n\n //-------------------------------------------------------------------------\n // len, length, size -- find the length of the sequence. \n // version inherited from py::object ok.\n //-------------------------------------------------------------------------\n \n //-------------------------------------------------------------------------\n // operator* -- repeat a list multiple times.\n //-------------------------------------------------------------------------\n sequence operator * (int count) const {\n PyObject* rslt = PySequence_Repeat(_obj, count);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"sequence repeat failed\");\n return lose_ref(rslt);\n };\n};\n\n//---------------------------------------------------------------------------\n// indexed_ref -- return reference obj when operator[] is used as an lvalue.\n//\n// list and tuple objects return this for non-const calls to operator[].\n// It is similar to object::keyed_ref, except that it stores an integer\n// index instead of py::object key.\n//---------------------------------------------------------------------------\nclass indexed_ref : public object\n{\n sequence& _parent;\n int _ndx;\npublic:\n indexed_ref::indexed_ref(PyObject* obj, sequence& parent, int ndx)\n : object(obj), _parent(parent), _ndx(ndx) { };\n virtual ~indexed_ref() {};\n \n indexed_ref& indexed_ref::operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_ndx, *this);\n return *this;\n };\n indexed_ref& indexed_ref::operator=(int other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(double other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(const std::complex& other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(const char* other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(const std::string& other) {\n object oth = other;\n return operator=(oth);\n };\n};\n\n\n} // namespace py\n\n#endif // PWOSEQUENCE_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n#if !defined(SEQUENCE_H_INCLUDED_)\n#define SEQUENCE_H_INCLUDED_\n\n#include \n#include \n\n#include \"object.h\"\n\nnamespace py {\n \n//---------------------------------------------------------------------------\n// !! This isn't being picked up out of object.h for some reason, so I'll \n// !! redeclare it.\n//---------------------------------------------------------------------------\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// base class for list and tuple objects.\n//---------------------------------------------------------------------------\nclass sequence : public object\n{\npublic:\n //-------------------------------------------------------------------------\n // constructors\n //-------------------------------------------------------------------------\n sequence() : object() {};\n sequence(const sequence& other) : object(other) {};\n sequence(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n\n //-------------------------------------------------------------------------\n // destructors\n //------------------------------------------------------------------------- \n virtual ~sequence() {}\n\n //-------------------------------------------------------------------------\n // operator=\n //-------------------------------------------------------------------------\n virtual sequence& operator=(const sequence& other) {\n grab_ref(other);\n return *this;\n };\n /*virtual*/ sequence& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // type checking.\n //------------------------------------------------------------------------- \n virtual void _violentTypeCheck() {\n if (!PySequence_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a sequence\");\n }\n };\n \n //-------------------------------------------------------------------------\n // operator+ -- concatenation\n //-------------------------------------------------------------------------\n sequence operator+(const sequence& rhs) const {\n PyObject* rslt = PySequence_Concat(_obj, rhs);\n if (rslt==0)\n fail(PyExc_TypeError, \"Improper rhs for +\");\n return lose_ref(rslt);\n };\n\n //-------------------------------------------------------------------------\n // count -- count the number of objects in a sequence.\n //-------------------------------------------------------------------------\n int count(const object& value) const {\n int rslt = PySequence_Count(_obj, value);\n if (rslt == -1)\n fail(PyExc_RuntimeError, \"failure in count\");\n return rslt;\n };\n int count(int value) const {\n object val = value;\n return count(val);\n };\n int count(double value) const {\n object val = value;\n return count(val);\n };\n int count(char* value) const {\n object val = value;\n return count(val);\n };\n int count(std::string& value) const {\n object val = value.c_str();\n return count(val);\n };\n\n //-------------------------------------------------------------------------\n // set_item -- virtual so that set_item for tuple and list use \n // type specific xxx_SetItem function calls.\n //-------------------------------------------------------------------------\n virtual void set_item(int ndx, object& val) {\n int rslt = PySequence_SetItem(_obj, ndx, val);\n if (rslt==-1)\n fail(PyExc_IndexError, \"Index out of range\");\n };\n\n\n //-------------------------------------------------------------------------\n // operator[] -- non-const version defined in list and tuple sub-types.\n //-------------------------------------------------------------------------\n object operator [] (int i) {\n PyObject* o = PySequence_GetItem(_obj, i);\n // don't throw error for when [] fails because it might be on left hand \n // side (a[0] = 1). If the sequence was just created, it will be filled \n // with NULL values, and setting the values should be ok. However, we\n // do want to catch index errors that might occur on the right hand side\n // (obj = a[4] when a has len==3).\n if (!o) {\n if (PyErr_ExceptionMatches(PyExc_IndexError))\n throw 1;\n }\n return lose_ref(o);\n };\n \n //-------------------------------------------------------------------------\n // slice -- handles slice operations.\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n sequence slice(int lo, int hi) const {\n PyObject* o = PySequence_GetSlice(_obj, lo, hi);\n if (o == 0)\n fail(PyExc_IndexError, \"could not obtain slice\");\n return lose_ref(o);\n };\n \n //-------------------------------------------------------------------------\n // in -- find whether a value is in the given sequence.\n // overloaded to handle the standard types used in weave.\n //-------------------------------------------------------------------------\n bool in(const object& value) const {\n int rslt = PySequence_In(_obj, value);\n if (rslt==-1)\n fail(PyExc_RuntimeError, \"problem in in\");\n return (rslt==1);\n }; \n bool sequence::in(int value) {\n object val = value;\n return in(val);\n };\n bool sequence::in(double value) {\n object val = value;\n return in(val);\n };\n bool sequence::in(const char* value) {\n object val = value;\n return in(val);\n };\n bool sequence::in(std::string& value) {\n object val = value.c_str();\n return in(val);\n };\n \n //-------------------------------------------------------------------------\n // index -- find whether a value is in the given sequence.\n // overloaded to handle the standard types used in weave.\n //-------------------------------------------------------------------------\n int index(const object& value) const {\n int rslt = PySequence_Index(_obj, value);\n if (rslt==-1)\n fail(PyExc_IndexError, \"value not found\");\n return rslt;\n };\n int sequence::index(int value) const {\n object val = value;\n return index(val);\n }; \n int sequence::index(double value) const {\n object val = value;\n return index(val);\n };\n int sequence::index(const std::complex& value) const {\n object val = value;\n return index(val);\n };\n int sequence::index(const char* value) const {\n object val = value;\n return index(val);\n }; \n int sequence::index(const std::string& value) const {\n object val = value;\n return index(val);\n };\n\n //-------------------------------------------------------------------------\n // len, length, size -- find the length of the sequence. \n // version inherited from py::object ok.\n //-------------------------------------------------------------------------\n \n //-------------------------------------------------------------------------\n // operator* -- repeat a list multiple times.\n //-------------------------------------------------------------------------\n sequence operator * (int count) const {\n PyObject* rslt = PySequence_Repeat(_obj, count);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"sequence repeat failed\");\n return lose_ref(rslt);\n };\n};\n\n//---------------------------------------------------------------------------\n// indexed_ref -- return reference obj when operator[] is used as an lvalue.\n//\n// list and tuple objects return this for non-const calls to operator[].\n// It is similar to object::keyed_ref, except that it stores an integer\n// index instead of py::object key.\n//---------------------------------------------------------------------------\nclass indexed_ref : public object\n{\n sequence& _parent;\n int _ndx;\npublic:\n indexed_ref::indexed_ref(PyObject* obj, sequence& parent, int ndx)\n : object(obj), _parent(parent), _ndx(ndx) { };\n virtual ~indexed_ref() {};\n \n indexed_ref& indexed_ref::operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_ndx, *this);\n return *this;\n };\n indexed_ref& indexed_ref::operator=(int other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(double other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(const std::complex& other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(const char* other) {\n object oth = other;\n return operator=(oth);\n }; \n indexed_ref& indexed_ref::operator=(const std::string& other) {\n object oth = other;\n return operator=(oth);\n };\n};\n\n\n} // namespace py\n\n#endif // PWOSEQUENCE_H_INCLUDED_\n", "methods": [ { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 32, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( const sequence & other)", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( PyObject * obj)", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 34, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::~sequence", "long_name": "py::sequence::~sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 41, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const sequence & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::_violentTypeCheck", "long_name": "py::sequence::_violentTypeCheck()", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 59, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator +", "long_name": "py::sequence::operator +( const sequence & rhs) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 69, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 79, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( int value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "value" ], "start_line": 85, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( double value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "value" ], "start_line": 89, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( char * value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 93, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( std :: string & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::set_item", "long_name": "py::sequence::set_item( int ndx , object & val)", "filename": "sequence.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "ndx", "val" ], "start_line": 106, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::operator [ ]", "long_name": "py::sequence::operator [ ]( int i)", "filename": "sequence.h", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "i" ], "start_line": 116, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 2 }, { "name": "py::sequence::slice", "long_name": "py::sequence::slice( int lo , int hi) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 134, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::in", "long_name": "py::sequence::in( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 145, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( int value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 151, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( double value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 155, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( const std :: complex & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( const char * value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( const std :: string & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 167, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::index", "long_name": "py::sequence::index( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 176, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( int value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 182, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( double value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 186, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const std :: complex & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 190, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const char * value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 194, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const std :: string & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 198, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::operator *", "long_name": "py::sequence::operator *( int count) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::indexed_ref", "long_name": "py::indexed_ref::indexed_ref::indexed_ref( PyObject * obj , sequence & parent , int ndx)", "filename": "sequence.h", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 231, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::indexed_ref::~indexed_ref", "long_name": "py::indexed_ref::~indexed_ref()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 233, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 235, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( int other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 240, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( double other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 244, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const std :: complex & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 248, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const char * other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 252, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const std :: string & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 256, "end_line": 259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 32, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( const sequence & other)", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::sequence", "long_name": "py::sequence::sequence( PyObject * obj)", "filename": "sequence.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 34, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::sequence::~sequence", "long_name": "py::sequence::~sequence()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 41, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const sequence & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::operator =", "long_name": "py::sequence::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::_violentTypeCheck", "long_name": "py::sequence::_violentTypeCheck()", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 59, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::operator +", "long_name": "py::sequence::operator +( const sequence & rhs) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "rhs" ], "start_line": 69, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 79, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( int value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "value" ], "start_line": 85, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( double value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "value" ], "start_line": 89, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( char * value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 93, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::count", "long_name": "py::sequence::count( std :: string & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::set_item", "long_name": "py::sequence::set_item( int ndx , object & val)", "filename": "sequence.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "ndx", "val" ], "start_line": 106, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::sequence::operator [ ]", "long_name": "py::sequence::operator [ ]( int i)", "filename": "sequence.h", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "i" ], "start_line": 116, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 2 }, { "name": "py::sequence::slice", "long_name": "py::sequence::slice( int lo , int hi) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "lo", "hi" ], "start_line": 134, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::in", "long_name": "py::sequence::in( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "value" ], "start_line": 145, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( int value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 151, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( double value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 155, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( const char * value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "value" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( std :: string & value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::index", "long_name": "py::sequence::index( const object & value) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "value" ], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( int value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 178, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( double value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 182, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const std :: complex & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 186, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const char * value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 190, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::index", "long_name": "py::sequence::sequence::index( const std :: string & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 194, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::operator *", "long_name": "py::sequence::operator *( int count) const", "filename": "sequence.h", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "count" ], "start_line": 207, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::indexed_ref", "long_name": "py::indexed_ref::indexed_ref::indexed_ref( PyObject * obj , sequence & parent , int ndx)", "filename": "sequence.h", "nloc": 2, "complexity": 1, "token_count": 32, "parameters": [ "obj", "parent", "ndx" ], "start_line": 227, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::indexed_ref::~indexed_ref", "long_name": "py::indexed_ref::~indexed_ref()", "filename": "sequence.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 229, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const object & other)", "filename": "sequence.h", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "other" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( int other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 236, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( double other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 240, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const std :: complex & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 244, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const char * other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 248, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::indexed_ref::indexed_ref::operator =", "long_name": "py::indexed_ref::indexed_ref::operator =( const std :: string & other)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 252, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( const std :: complex & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( const char * value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "value" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( int value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 151, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( double value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "value" ], "start_line": 155, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( const std :: string & value) const", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 167, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( double value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 155, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( const char * value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "value" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( std :: string & value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::sequence::sequence::in", "long_name": "py::sequence::sequence::in( int value)", "filename": "sequence.h", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "value" ], "start_line": 151, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "nloc": 170, "complexity": 47, "token_count": 1076, "diff_parsed": { "added": [ " bool sequence::in(int value) const {", " bool sequence::in(double value) const {", " bool sequence::in(const std::complex& value) const {", " bool sequence::in(const char* value) const {", " object val = value;", " return in(val);", " };", " bool sequence::in(const std::string& value) const {" ], "deleted": [ " bool sequence::in(int value) {", " bool sequence::in(double value) {", " bool sequence::in(const char* value) {", " bool sequence::in(std::string& value) {" ] } } ] }, { "hash": "4d97933a6b23d73304253266f90e654f05b3064d", "msg": "removed blitz converters from being declared by default so that weave can work\nfor people who do not have Numeric installed.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-10-12T00:52:20+00:00", "author_timezone": 0, "committer_date": "2002-10-12T00:52:20+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b90b0c14865353bd2adb94af1e2a2eb44b77e16b" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 13, "insertions": 17, "lines": 30, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/converters.py", "new_path": "weave/converters.py", "filename": "converters.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -41,9 +41,9 @@\n except IndexError: \n pass \n \n-#------------------------------------------------------------------------\n+#----------------------------------------------------------------------------\n # Add VTK support\n-#-----------------------------------------------------------------------\n+#----------------------------------------------------------------------------\n \n try: \n import vtk_spec\n@@ -51,11 +51,11 @@\n except IndexError: \n pass\n \n-#------------------------------------------------------------------------\n+#----------------------------------------------------------------------------\n # Add \"sentinal\" catchall converter\n #\n # if everything else fails, this one is the last hope (it always works)\n-#-----------------------------------------------------------------------\n+#----------------------------------------------------------------------------\n \n default.append(c_spec.catchall_converter())\n \n@@ -66,14 +66,18 @@\n # Blitz conversion classes\n #\n # same as default, but will convert Numeric arrays to blitz C++ classes \n+# !! only available if Numeric is installed !!\n #----------------------------------------------------------------------------\n-import blitz_spec\n-blitz = [blitz_spec.array_converter()] + default\n-\n-#------------------------------------------------------------------------\n-# Add \"sentinal\" catchall converter\n-#\n-# if everything else fails, this one is the last hope (it always works)\n-#-----------------------------------------------------------------------\n+try:\n+ import blitz_spec\n+ blitz = [blitz_spec.array_converter()] + default\n+ #-----------------------------------\n+ # Add \"sentinal\" catchall converter\n+ #\n+ # if everything else fails, this one \n+ # is the last hope (it always works)\n+ #-----------------------------------\n+ blitz.append(c_spec.catchall_converter())\n+except:\n+ pass\n \n-blitz.append(c_spec.catchall_converter())\n", "added_lines": 17, "deleted_lines": 13, "source_code": "\"\"\" converters.py\n\"\"\"\n\nimport common_info\nimport c_spec\n\n#----------------------------------------------------------------------------\n# The \"standard\" conversion classes\n#----------------------------------------------------------------------------\n\ndefault = [c_spec.int_converter(),\n c_spec.float_converter(),\n c_spec.complex_converter(),\n c_spec.unicode_converter(),\n c_spec.string_converter(),\n c_spec.list_converter(),\n c_spec.dict_converter(),\n c_spec.tuple_converter(),\n c_spec.file_converter(),\n c_spec.instance_converter(),] \n #common_spec.module_converter()]\n\n#----------------------------------------------------------------------------\n# If Numeric is installed, add numeric array converters to the default\n# converter list.\n#----------------------------------------------------------------------------\ntry: \n import standard_array_spec\n default.append(standard_array_spec.array_converter())\nexcept ImportError: \n pass \n\n#----------------------------------------------------------------------------\n# Add wxPython support\n#----------------------------------------------------------------------------\n\ntry: \n # this is currently safe because it doesn't import wxPython.\n import wx_spec\n default.insert(0,wx_spec.wx_converter())\nexcept IndexError: \n pass \n\n#----------------------------------------------------------------------------\n# Add VTK support\n#----------------------------------------------------------------------------\n\ntry: \n import vtk_spec\n default.insert(0,vtk_spec.vtk_converter())\nexcept IndexError: \n pass\n\n#----------------------------------------------------------------------------\n# Add \"sentinal\" catchall converter\n#\n# if everything else fails, this one is the last hope (it always works)\n#----------------------------------------------------------------------------\n\ndefault.append(c_spec.catchall_converter())\n\nstandard_info = [common_info.basic_module_info()]\nstandard_info += [x.generate_build_info() for x in default]\n\n#----------------------------------------------------------------------------\n# Blitz conversion classes\n#\n# same as default, but will convert Numeric arrays to blitz C++ classes \n# !! only available if Numeric is installed !!\n#----------------------------------------------------------------------------\ntry:\n import blitz_spec\n blitz = [blitz_spec.array_converter()] + default\n #-----------------------------------\n # Add \"sentinal\" catchall converter\n #\n # if everything else fails, this one \n # is the last hope (it always works)\n #-----------------------------------\n blitz.append(c_spec.catchall_converter())\nexcept:\n pass\n\n", "source_code_before": "\"\"\" converters.py\n\"\"\"\n\nimport common_info\nimport c_spec\n\n#----------------------------------------------------------------------------\n# The \"standard\" conversion classes\n#----------------------------------------------------------------------------\n\ndefault = [c_spec.int_converter(),\n c_spec.float_converter(),\n c_spec.complex_converter(),\n c_spec.unicode_converter(),\n c_spec.string_converter(),\n c_spec.list_converter(),\n c_spec.dict_converter(),\n c_spec.tuple_converter(),\n c_spec.file_converter(),\n c_spec.instance_converter(),] \n #common_spec.module_converter()]\n\n#----------------------------------------------------------------------------\n# If Numeric is installed, add numeric array converters to the default\n# converter list.\n#----------------------------------------------------------------------------\ntry: \n import standard_array_spec\n default.append(standard_array_spec.array_converter())\nexcept ImportError: \n pass \n\n#----------------------------------------------------------------------------\n# Add wxPython support\n#----------------------------------------------------------------------------\n\ntry: \n # this is currently safe because it doesn't import wxPython.\n import wx_spec\n default.insert(0,wx_spec.wx_converter())\nexcept IndexError: \n pass \n\n#------------------------------------------------------------------------\n# Add VTK support\n#-----------------------------------------------------------------------\n\ntry: \n import vtk_spec\n default.insert(0,vtk_spec.vtk_converter())\nexcept IndexError: \n pass\n\n#------------------------------------------------------------------------\n# Add \"sentinal\" catchall converter\n#\n# if everything else fails, this one is the last hope (it always works)\n#-----------------------------------------------------------------------\n\ndefault.append(c_spec.catchall_converter())\n\nstandard_info = [common_info.basic_module_info()]\nstandard_info += [x.generate_build_info() for x in default]\n\n#----------------------------------------------------------------------------\n# Blitz conversion classes\n#\n# same as default, but will convert Numeric arrays to blitz C++ classes \n#----------------------------------------------------------------------------\nimport blitz_spec\nblitz = [blitz_spec.array_converter()] + default\n\n#------------------------------------------------------------------------\n# Add \"sentinal\" catchall converter\n#\n# if everything else fails, this one is the last hope (it always works)\n#-----------------------------------------------------------------------\n\nblitz.append(c_spec.catchall_converter())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 38, "complexity": 0, "token_count": 187, "diff_parsed": { "added": [ "#----------------------------------------------------------------------------", "#----------------------------------------------------------------------------", "#----------------------------------------------------------------------------", "#----------------------------------------------------------------------------", "# !! only available if Numeric is installed !!", "try:", " import blitz_spec", " blitz = [blitz_spec.array_converter()] + default", " #-----------------------------------", " # Add \"sentinal\" catchall converter", " #", " # if everything else fails, this one", " # is the last hope (it always works)", " #-----------------------------------", " blitz.append(c_spec.catchall_converter())", "except:", " pass" ], "deleted": [ "#------------------------------------------------------------------------", "#-----------------------------------------------------------------------", "#------------------------------------------------------------------------", "#-----------------------------------------------------------------------", "import blitz_spec", "blitz = [blitz_spec.array_converter()] + default", "", "#------------------------------------------------------------------------", "# Add \"sentinal\" catchall converter", "#", "# if everything else fails, this one is the last hope (it always works)", "#-----------------------------------------------------------------------", "blitz.append(c_spec.catchall_converter())" ] } } ] }, { "hash": "9a1742745f3c76f9de7cf92c0bf5dfd725bd6357", "msg": "added a PYTHONINCLUDE environment variable that weave searches for include\nfiles during compilation. I added this to handle the recent switch I have\nmade to using a system installed python while storing my own python packages\nin my home directory. (python setup.py install --prefix=~/)\n\nUnfortunately, there isn't another way to tell weave where to find installed\nheader files if they aren't in the normal place. Actaully... If Numeric\nstored the location of its header files in a variable called __include_dirs__,\nthis would go a long way to automating the process for most users and they\nwould never need to mess with the PYTHONINCLUDE variables.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-10-12T01:43:39+00:00", "author_timezone": 0, "committer_date": "2002-10-12T01:43:39+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "4d97933a6b23d73304253266f90e654f05b3064d" ], "project_name": "repo_copy", "project_path": "/tmp/tmpokm3nn60/repo_copy", "deletions": 1, "insertions": 17, "lines": 18, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -179,7 +179,23 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n- \n+ \n+ #--------------------------------------------------------------------\n+ # added access to environment variable that user can set to specify\n+ # where python (and other) include files are located. This is \n+ # very useful on systems where python is installed by the root, but\n+ # the user has also installed numerous packages in their own \n+ # location.\n+ #--------------------------------------------------------------------\n+ if os.environ.has_key('PYTHONINCLUDE'):\n+ path_string = os.environ['PYTHONINCLUDE'] \n+ if sys.platform == \"win32\":\n+ extra_include_dirs = path_string.split(';')\n+ else: \n+ extra_include_dirs = path_string.split(':')\n+ include_dirs = kw.get('include_dirs',[])\n+ kw['include_dirs'] = include_dirs + extra_include_dirs\n+\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n", "added_lines": 17, "deleted_lines": 1, "source_code": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\n\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n distutils.sysconfig._config_vars['LDSHARED'] = ld \n\ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add gccX.X to the \n # path.\n compiler_dir = get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1: verb = 1 \n else: verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n \n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n if compiler_name is None:\n compiler_dir = ''\n elif compiler_name == 'gcc': \n status, text = run_command(compiler_name + ' --version')\n try:\n import re\n version = re.findall('\\d\\.\\d',text)[0]\n except IndexError:\n version = ''\n compiler_dir = compiler_name + version\n else: \n compiler_dir = compiler_name\n return compiler_dir\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler (distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, \n dry_run, force)\n \n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\n\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n distutils.sysconfig._config_vars['LDSHARED'] = ld \n\ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add gccX.X to the \n # path.\n compiler_dir = get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1: verb = 1 \n else: verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n \n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n if compiler_name is None:\n compiler_dir = ''\n elif compiler_name == 'gcc': \n status, text = run_command(compiler_name + ' --version')\n try:\n import re\n version = re.findall('\\d\\.\\d',text)[0]\n except IndexError:\n version = ''\n compiler_dir = compiler_name + version\n else: \n compiler_dir = compiler_name\n return compiler_dir\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler (distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, \n dry_run, force)\n \n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "methods": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [], "start_line": 32, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 60, "complexity": 11, "token_count": 452, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 53, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 187, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 242, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 254, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 257, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 265, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 288, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 310, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 330, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 64, "parameters": [ "compiler_name" ], "start_line": 339, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 359, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 375, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 412, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 466, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 476, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 507, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 511, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [], "start_line": 32, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 52, "complexity": 9, "token_count": 390, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 53, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 171, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 226, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 238, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 241, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 249, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 272, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 294, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 314, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 64, "parameters": [ "compiler_name" ], "start_line": 323, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 343, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 359, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 396, "end_line": 438, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 450, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 460, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 491, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 495, "end_line": 497, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 60, "complexity": 11, "token_count": 452, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 53, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 187, "top_nesting_level": 0 } ], "nloc": 265, "complexity": 63, "token_count": 1646, "diff_parsed": { "added": [ "", " #--------------------------------------------------------------------", " # added access to environment variable that user can set to specify", " # where python (and other) include files are located. This is", " # very useful on systems where python is installed by the root, but", " # the user has also installed numerous packages in their own", " # location.", " #--------------------------------------------------------------------", " if os.environ.has_key('PYTHONINCLUDE'):", " path_string = os.environ['PYTHONINCLUDE']", " if sys.platform == \"win32\":", " extra_include_dirs = path_string.split(';')", " else:", " extra_include_dirs = path_string.split(':')", " include_dirs = kw.get('include_dirs',[])", " kw['include_dirs'] = include_dirs + extra_include_dirs", "" ], "deleted": [ "" ] } } ] } ]