Skip to content

Commit

Permalink
Merge pull request #148 from madsbk/master
Browse files Browse the repository at this point in the history
Release v0.4
  • Loading branch information
madsbk committed Dec 22, 2016
2 parents 9f7918c + 824f061 commit 61d6321
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
8 changes: 5 additions & 3 deletions bridge/npbackend/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

def execfile_wrapper(path):
"""execfile() does not exist in Python 3"""

# We need this ugly code in order to avoid wrapping the script execution in a try/except construct
try:
execfile(path)
execfile
except NameError:
import runpy
return runpy.run_path(path, run_name="__main__")

return runpy.run_path(path, init_globals={}, run_name="__main__")
return execfile(path, {"__name__": "__main__", "__file__": path})

# numpy becomes bohrium
sys.modules['numpy_force'] = numpy
Expand Down
2 changes: 1 addition & 1 deletion bridge/npbackend/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def run(self):
shutil.copy2(srcpath('_util.pyx'), buildpath('_util.pyx'))

setup(name='Bohrium',
version='0.3',
version='0.4',
description='Bohrium NumPy',
long_description='Bohrium NumPy',
author='The Bohrium Team',
Expand Down
11 changes: 9 additions & 2 deletions bridge/npbackend/src/_bh.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ static PyObject* _simply_new_array(PyTypeObject *type, PyArray_Descr *descr,
static PyObject *
BhArray_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *ret;
//If this is a "simple" new array, we can use our own memory allocation
{
static char *kwlist[] = {"shape", "dtype", NULL};//We only support simple arrays
Expand All @@ -316,12 +317,18 @@ BhArray_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
if(descr == NULL)//Get default dtype
descr = PyArray_DescrFromType(NPY_DEFAULT_TYPE);
return _simply_new_array(type, descr, nelem * descr->elsize, shape);
ret = _simply_new_array(type, descr, nelem * descr->elsize, shape);
if(shape.len > 0)
{
assert(shape.ptr != NULL);
free(shape.ptr);
}
return ret;
}
}
}
//If it is not a simple new array, we let NumPy create it
PyObject *ret = PyArray_Type.tp_new(type, args, kwds);
ret = PyArray_Type.tp_new(type, args, kwds);
if(ret == NULL)
return NULL;
//And then protect the memory afterwards
Expand Down
2 changes: 1 addition & 1 deletion package/debian/build-package.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Section: devel
Priority: optional
Maintainer: Bohrium Builder <builder@bh107.org>
Build-Depends: python-numpy, python-dev, cython, python3-numpy, python3-dev, cython3, debhelper, cmake, swig, fftw3-dev, ocl-icd-opencl-dev, libgl-dev, libboost-serialization-dev, libboost-filesystem-dev, libboost-system-dev, libboost-regex-dev, mono-devel, libhwloc-dev, freeglut3-dev, libxmu-dev, libxi-dev, zlib1g-dev
Build-Depends: python-dev, python-numpy, cython, python3-dev, python3-numpy, python3-dev, cython3, debhelper, cmake, swig, fftw3-dev, ocl-icd-opencl-dev, libgl-dev, libboost-serialization-dev, libboost-filesystem-dev, libboost-system-dev, libboost-regex-dev, mono-devel, libhwloc-dev, freeglut3-dev, libxmu-dev, libxi-dev, zlib1g-dev
Standards-Version: 3.9.5
Homepage: http://www.bh107.org
Expand Down

0 comments on commit 61d6321

Please sign in to comment.