Skip to content

Commit

Permalink
Minimal modifications so runtests.py will 'run' even though all tests…
Browse files Browse the repository at this point in the history
… currently fail
  • Loading branch information
Ian Stokes-Rees authored and piannucci committed Aug 26, 2015
1 parent 575c2b7 commit 5e3fb67
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 32 deletions.
9 changes: 8 additions & 1 deletion examples/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ def inc(self,amount):
#----------------------------------------------------------------------------
# indexing of values.
#----------------------------------------------------------------------------
from UserList import UserList

import sys

if sys.version_info.major == 3:
from collections import UserList
else:
from UserList import UserList

obj = UserList([1,[1,2],"hello"])
code = """
int i;
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import os


if not sys.version_info[:2] in [(2, 6), (2, 7)]:
if not sys.version_info[:2] in [(2, 6), (2, 7), (3, 4)]:
raise RuntimeError("Python version 2.6 or 2.7 required.")


Expand Down
2 changes: 1 addition & 1 deletion weave/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import sys


if not sys.version_info[:2] in [(2, 6), (2, 7)]:
if not sys.version_info[:2] in [(2, 6), (2, 7), (3, 4)]:
raise RuntimeError("Weave only supports Python 2.6 and 2.7")


Expand Down
8 changes: 6 additions & 2 deletions weave/base_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
"""
from __future__ import absolute_import, print_function

import UserList
import sys

if sys.version_info.major == 3:
from collections import UserList
else:
from UserList import UserList

class base_info(object):
_warnings = []
Expand Down Expand Up @@ -128,7 +132,7 @@ def add_extra_link_arg(self,link_arg):
return self._extra_link_args.append(link_arg)


class info_list(UserList.UserList):
class info_list(UserList):
def get_unique_values(self,attribute):
all_values = []
for info in self:
Expand Down
9 changes: 7 additions & 2 deletions weave/base_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,16 @@ def variable(self):
def variable_as_string(self):
return '"' + self.name + '"'

import UserList
import sys

if sys.version_info.major == 3:
from collections import UserList
else:
from UserList import UserList
from . import base_info


class arg_spec_list(UserList.UserList):
class arg_spec_list(UserList):
def build_information(self):
all_info = base_info.info_list()
for i in self:
Expand Down
1 change: 0 additions & 1 deletion weave/build_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import os
import time
import tempfile
import commands
import subprocess
import warnings

Expand Down
42 changes: 23 additions & 19 deletions weave/c_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from .base_spec import base_converter
from . import base_info

import io
import sys

#----------------------------------------------------------------------------
# C++ code template for converting code from python objects to C++ objects
#
Expand Down Expand Up @@ -218,7 +221,7 @@ def init_info(self):
self.c_type = 'std::string'
self.return_type = 'std::string'
self.to_c_return = "std::string(PyString_AsString(py_obj))"
self.matching_types = [types.StringType]
self.matching_types = [bytes]
self.headers.append('<string>')

def c_to_py_code(self):
Expand Down Expand Up @@ -247,7 +250,7 @@ def init_info(self):
self.c_type = 'Py_UNICODE*'
self.return_type = self.c_type
self.to_c_return = "PyUnicode_AS_UNICODE(py_obj)"
self.matching_types = [types.UnicodeType]
self.matching_types = [str]
# self.headers.append('<string>')

def declaration_code(self,templatize=0,inline=0):
Expand All @@ -273,7 +276,7 @@ def init_info(self):
self.return_type = self.c_type
self.to_c_return = "PyFile_AsFile(py_obj)"
self.headers = ['<stdio.h>']
self.matching_types = [types.FileType]
self.matching_types = [io.IOBase]

def c_to_py_code(self):
# !! Need to dedent returned code.
Expand Down Expand Up @@ -343,15 +346,16 @@ def init_info(self):
# This has to be int for SCXX to work.


class int_converter(scalar_converter):
def init_info(self):
scalar_converter.init_info(self)
self.type_name = 'int'
self.check_func = 'PyInt_Check'
self.c_type = 'int'
self.return_type = 'int'
self.to_c_return = "(int) PyInt_AsLong(py_obj)"
self.matching_types = [types.IntType]
if sys.version_info.major < 3:
class int_converter(scalar_converter):
def init_info(self):
scalar_converter.init_info(self)
self.type_name = 'int'
self.check_func = 'PyInt_Check'
self.c_type = 'int'
self.return_type = 'int'
self.to_c_return = "(int) PyInt_AsLong(py_obj)"
self.matching_types = [int]


class long_converter(scalar_converter):
Expand All @@ -363,7 +367,7 @@ def init_info(self):
self.c_type = 'longlong'
self.return_type = 'longlong'
self.to_c_return = "(longlong) PyLong_AsLongLong(py_obj)"
self.matching_types = [types.LongType]
self.matching_types = [int]


class float_converter(scalar_converter):
Expand All @@ -375,7 +379,7 @@ def init_info(self):
self.c_type = 'double'
self.return_type = 'double'
self.to_c_return = "PyFloat_AsDouble(py_obj)"
self.matching_types = [types.FloatType]
self.matching_types = [float]


class complex_converter(scalar_converter):
Expand All @@ -387,7 +391,7 @@ def init_info(self):
self.return_type = 'std::complex<double>'
self.to_c_return = "std::complex<double>(PyComplex_RealAsDouble(py_obj),"\
"PyComplex_ImagAsDouble(py_obj))"
self.matching_types = [types.ComplexType]
self.matching_types = [complex]

#----------------------------------------------------------------------------
#
Expand Down Expand Up @@ -417,7 +421,7 @@ def init_info(self):
self.c_type = 'py::list'
self.return_type = 'py::list'
self.to_c_return = 'py::list(py_obj)'
self.matching_types = [types.ListType]
self.matching_types = [list]
# ref counting handled by py::list
self.use_ref_count = 0

Expand All @@ -430,7 +434,7 @@ def init_info(self):
self.c_type = 'py::tuple'
self.return_type = 'py::tuple'
self.to_c_return = 'py::tuple(py_obj)'
self.matching_types = [types.TupleType]
self.matching_types = [tuple]
# ref counting handled by py::tuple
self.use_ref_count = 0

Expand All @@ -443,7 +447,7 @@ def init_info(self):
self.c_type = 'py::dict'
self.return_type = 'py::dict'
self.to_c_return = 'py::dict(py_obj)'
self.matching_types = [types.DictType]
self.matching_types = [dict]
# ref counting handled by py::dict
self.use_ref_count = 0

Expand All @@ -460,7 +464,7 @@ def init_info(self):
self.c_type = 'py::object'
self.return_type = 'py::object'
self.to_c_return = 'py::object(py_obj)'
self.matching_types = [types.InstanceType]
self.matching_types = [object]
# ref counting handled by py::object
self.use_ref_count = 0

Expand Down
5 changes: 4 additions & 1 deletion weave/size_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

import sys

numericTypes = (int, long, float, complex)
if sys.version_info.major == 3:
numericTypes = (int, float, complex)
else:
numericTypes = (int, long, float, complex)


def isnumeric(t):
Expand Down
9 changes: 5 additions & 4 deletions weave/tests/test_scxx_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from __future__ import absolute_import, print_function

import sys
from UserList import UserList
if sys.version_info.major == 3:
from collections import UserDict, UserList
else:
from UserList import UserList
from UserDict import UserDict

from numpy.testing import (TestCase, dec, assert_equal, assert_, assert_raises,
run_module_suite)
Expand Down Expand Up @@ -893,9 +897,6 @@ def test_set_string2(self):
assert_equal(a[1],1+1j)


from UserDict import UserDict


class TestObjectSetItemOpKey(TestCase):

@dec.slow
Expand Down

0 comments on commit 5e3fb67

Please sign in to comment.