Skip to content

Commit

Permalink
Merge branch 'py3k' into develop
Browse files Browse the repository at this point in the history
        Comment a print statement in macroNode, which was put in after
2to3.
  • Loading branch information
aganders3 committed Nov 2, 2015
2 parents 2028d82 + e6cf01d commit 7a90a53
Show file tree
Hide file tree
Showing 63 changed files with 1,020 additions and 419 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.so
*.o
*.DS_Store
VERSION
build/
/node/
/local/
Expand Down
2 changes: 1 addition & 1 deletion bin/gpi_launch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python # DEV
#!/usr/bin/env python

# Copyright (C) 2014 Dignity Health
#
Expand Down
42 changes: 42 additions & 0 deletions bin/gpi_update
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python

# Copyright (C) 2014 Dignity Health
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# NO CLINICAL USE. THE SOFTWARE IS NOT INTENDED FOR COMMERCIAL PURPOSES
# AND SHOULD BE USED ONLY FOR NON-COMMERCIAL RESEARCH PURPOSES. THE
# SOFTWARE MAY NOT IN ANY EVENT BE USED FOR ANY CLINICAL OR DIAGNOSTIC
# PURPOSES. YOU ACKNOWLEDGE AND AGREE THAT THE SOFTWARE IS NOT INTENDED FOR
# USE IN ANY HIGH RISK OR STRICT LIABILITY ACTIVITY, INCLUDING BUT NOT
# LIMITED TO LIFE SUPPORT OR EMERGENCY MEDICAL OPERATIONS OR USES. LICENSOR
# MAKES NO WARRANTY AND HAS NOR LIABILITY ARISING FROM ANY USE OF THE
# SOFTWARE IN ANY HIGH RISK OR STRICT LIABILITY ACTIVITIES.

import sys, os

# Check for Anaconda PREFIX, or assume that THIS file location is the CWD.
GPI_PREFIX = '/opt/anaconda1anaconda2anaconda3' # ANACONDA
if GPI_PREFIX == '/opt/'+''.join(['anaconda'+str(i) for i in range(1,4)]):
GPI_PREFIX, _ = os.path.split(os.path.dirname(os.path.realpath(__file__)))

GPI_LIB_DIR = os.path.join(GPI_PREFIX, 'lib')
if GPI_LIB_DIR not in sys.path:
sys.path.insert(0, GPI_LIB_DIR)

# gpi
from gpi import update

if __name__ == '__main__':
update.update()
35 changes: 35 additions & 0 deletions gpi_py3k_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: py3k
dependencies:
- astyle=2.05.1=0
- eigen=3.2.5=0
- fftw=3.3.4=0
- freetype=2.5.2=2
- gpi=0.6.0=py3k
- h5py=2.5.0=np19py35_3
- hdf5=1.8.15.1=1
- libpng=1.6.17=0
- matplotlib=1.4.3=np19py35_3
- numpy=1.9.2=py35_0
- openssl=1.0.1k=1
- pip=7.1.2=py35_0
- psutil=3.2.0=py35_0
- pyopengl=3.1.1a1=np19py35_0
- pyparsing=2.0.3=py35_0
- pyqt=4.11.3=py35_0
- python=3.5.0=0
- python-dateutil=2.4.2=py35_0
- pytz=2015.4=py35_0
- qt=4.8.6=3
- readline=6.2=2
- scipy=0.16.0=np19py35_1
- setuptools=18.1=py35_0
- sip=4.16.5=py35_0
- six=1.9.0=py35_0
- sqlite=3.8.4.1=1
- tk=8.5.18=0
- wheel=0.24.0=py35_0
- xz=5.0.5=0
- zlib=1.2.8=0
- pip:
- qimage2ndarray==1.5

4 changes: 2 additions & 2 deletions include/PyFI/PyFIArray_WrappedNUMPY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ void printArray(Array<T> &in)
{
string code;
code = "def func(in1):\n"
" print type(in1), in1.dtype, in1.shape\n"
" print in1\n";
" print(type(in1), in1.dtype, in1.shape)\n"
" print(in1)\n";
PyCallable printer(code);
printer.SetArg_Array(&in);
printer.Run();
Expand Down
20 changes: 15 additions & 5 deletions include/PyFI/PyFIMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,36 @@ inline T __PYFI_itself(T arg)
#define PYFI_FUNCDESC_TEMPLATE(_nam, _tmpl, _desc) { #_nam "_" #_tmpl, (PyCFunction) __PYFI_itself(_nam <_tmpl>), METH_VARARGS|METH_KEYWORDS, _desc }
#define PYFI_FUNCDESC_TERM() {NULL, NULL, 0, NULL}

#define PYFI_METHOD_TABLE(_nam_str) static struct PyModuleDef __pyfimstruct = { PyModuleDef_HEAD_INIT, _nam_str, NULL, -1, Methods };

/* avoid this numpy macro return issue */
void *numpy_import_array(void)
{
import_array();
return NULL;
}

/* PyMODINIT_FUNC stringifications
*/
#define STR_MOD_NAME1(_x) #_x
#define STR_MOD_NAME(_x) STR_MOD_NAME1(_x)
#define MAKE_FN_NAME(_x) PyMODINIT_FUNC init ## _x (void)
#define MAKE_FN_NAME(_x) PyMODINIT_FUNC PyInit_ ## _x (void)
#define FUNCTION_NAME(_x) MAKE_FN_NAME(_x)
#define PYFI_MODINIT() \
FUNCTION_NAME(MOD_NAME) \
{ \
PyObject *m; \
m = Py_InitModule(STR_MOD_NAME(MOD_NAME), Methods); \
m = PyModule_Create(&__pyfimstruct); \
if (m == NULL) \
return; \
import_array(); \
return NULL; \
numpy_import_array(); \
return m; \
}


/* further simplify mod delcarations */
#define PYFI_LIST_START_ PYFI_FUNCLIST = {
#define PYFI_LIST_END_ PYFI_FUNCDESC_TERM() }; PYFI_MODINIT();
#define PYFI_LIST_END_ PYFI_FUNCDESC_TERM() }; PYFI_METHOD_TABLE(STR_MOD_NAME(MOD_NAME)); PYFI_MODINIT();
#define PYFI_DESC(_nam, _desc) PYFI_FUNCDESC(_nam, _desc),
#define PYFI_T_DESC(_nam, _tmpl, _desc) PYFI_FUNCDESC_TEMPLATE(_nam, _tmpl, _desc),

Expand Down
16 changes: 11 additions & 5 deletions include/PyFI/PyFunctionIF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,15 @@ void Parm_STRING::Convert_In(void)
}
else
{
local_val = string(PyString_AsString(pyobj_ptr));
local_val = string(PyUnicode_AS_DATA(pyobj_ptr));
val = (void *)&local_val;
}
}

void Parm_STRING::Convert_Out(void)
{
/* new ref */
pyobj_ptr = PyString_FromString((*(string *)val).c_str());
pyobj_ptr = PyUnicode_FromString((*(string *)val).c_str());
}

/**** DOUBLE ****/
Expand Down Expand Up @@ -1403,6 +1403,12 @@ class PyCallable
delete *_arrays_itr;
}

void *__import_array(void)
{
import_array(); /* required for using numpy arrays */
return NULL;
}

/* 1) check if python has been initialized
* 2) initialize numpy
*/
Expand All @@ -1412,7 +1418,7 @@ class PyCallable
if (Py_IsInitialized() == 0)
{
Py_Initialize();
import_array(); /* required for using numpy arrays */
__import_array(); /* required for using numpy arrays */
}
/*
else
Expand Down Expand Up @@ -1681,7 +1687,7 @@ class PyCallable
}

/* convert to python string */
PyObject *pItem = PyString_FromString(in.c_str());
PyObject *pItem = PyUnicode_FromString(in.c_str());

/* add to list */
if (PyList_Append(_pArgList, pItem) != _PYCALLABLE_SUCCESS)
Expand Down Expand Up @@ -1845,7 +1851,7 @@ class PyCallable
* calling function, not sure what the behavior will
* be for this as it is. */
_PYFI_PYCALLABLE_ACQUIRE_GIL
string out = PyString_AsString(curVal);
string out = PyUnicode_AS_DATA(curVal);
_PYFI_PYCALLABLE_RELEASE_GIL
return(out);
}
Expand Down
10 changes: 5 additions & 5 deletions include/PyFI/embedded_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import numpy as np

def script(in1, in2, in3):
print "start script"
print "in1:", in1, type(in1)
print "in2:", in2, type(in2)
print "in array: ", in3, type(in3)
print "end script"
print("start script")
print(("in1:", in1, type(in1)))
print(("in2:", in2, type(in2)))
print(("in array: ", in3, type(in3)))
print("end script")
return (0, 1, np.array([1,2,3],dtype=np.float32))

4 changes: 3 additions & 1 deletion include/PyFI/template_PyMOD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ PYFI_FUNC(IFtest2)

Array<float> arr_copy(*arr);

cout << "Printing using PyFI" << endl;
coutv(arr_copy);
cout << "Printing using Numpy" << endl;
Numpy::printArray(arr_copy);

//arr_copy(1000);
Expand Down Expand Up @@ -222,7 +224,7 @@ PYFI_FUNC(IFtest2)
coutv(*out);

/* write your own function */
PyCallable mycode("def func(in1):\n print \'in1\', in1\n return 1\n");
PyCallable mycode("def func(in1):\n print(\'in1\', in1)\n return 1\n");
mycode.SetArg_Long(777);
coutv(mycode.GetReturn_Long());

Expand Down
34 changes: 17 additions & 17 deletions include/PyFI/template_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@


# PYCALLABLE
A = np.array(range(4), dtype=np.float32)
A = np.array(list(range(4)), dtype=np.float32)
A.shape = [2,2]
print "A:", A
print "Ainv:", npl.pinv(A)
print("A:", A)
print("Ainv:", npl.pinv(A))

x = np.array(range(24), dtype=np.float32)
x = np.array(list(range(24)), dtype=np.float32)
x.shape = [4,3,2]

print x
print(x)

print "matmult (PYTHON)"
print "A: ", A
print "AdotA: ", np.dot(A,A)
print("matmult (PYTHON)")
print("A: ", A)
print("AdotA: ", np.dot(A,A))

st = time.time()
aarr, c = temp.IFtest2(x)
print "IFtest time: ", time.time()-st
print("IFtest time: ", time.time()-st)

print c
print(c)

print "aarr:", aarr
print("aarr:", aarr)


temp.math_double()
Expand All @@ -76,16 +76,16 @@
# testing the PyFI interface.
def test(thetest, name):
if thetest:
print '\t-'+name+' passed'
print('\t-'+name+' passed')
return 1
else:
print '\t-'+name+' failed'
print('\t-'+name+' failed')
return 0




print "\n\nInterface testing..."
print("\n\nInterface testing...")
mi = 111
mf = 111.111
ms = 'hello from python'
Expand Down Expand Up @@ -139,8 +139,8 @@ def test(thetest, name):
cnt += test((kla == al).all(), 'mykwlarr')
tot += 1

print '\nTest Summary:'
print('\nTest Summary:')
if cnt == tot:
print '\tSUCCESS: '+str(cnt)+'/'+str(tot)
print('\tSUCCESS: '+str(cnt)+'/'+str(tot))
else:
print '\tFAILED: '+str(cnt)+'/'+str(tot)
print('\tFAILED: '+str(cnt)+'/'+str(tot))
4 changes: 2 additions & 2 deletions include/PyFI/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
x = np.array([1,2,3,4], dtype=np.float32)
y = bm.add_one(x)

print 'x: ', x
print 'y: ', y
print('x: ', x)
print('y: ', y)
12 changes: 6 additions & 6 deletions launch/GPI.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>AMStayOpen</key>
<false/>
<key>BuildMachineOSBuild</key>
<string>12E39</string>
<string>11E53</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
Expand Down Expand Up @@ -46,21 +46,21 @@
<key>CFBundleURLTypes</key>
<array/>
<key>CFBundleVersion</key>
<string>346</string>
<string>339.2</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>4F250</string>
<string>11E53</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>12E39</string>
<string>11E53</string>
<key>DTSDKName</key>
<string></string>
<key>DTXcode</key>
<string>0440</string>
<string>0410</string>
<key>DTXcodeBuild</key>
<string>4F250</string>
<string>11E53</string>
<key>LSMinimumSystemVersion</key>
<string>10.5</string>
<key>LSMinimumSystemVersionByArchitecture</key>
Expand Down
Binary file modified launch/GPI.app/Contents/MacOS/Application Stub
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/ar.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/ca.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/da.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/el.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/he.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/hr.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/hu.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/pt_PT.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/ro.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/ru.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/sk.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/th.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/tr.lproj/ApplicationStub.nib
Binary file not shown.
Binary file modified launch/GPI.app/Contents/Resources/uk.lproj/ApplicationStub.nib
Binary file not shown.
Loading

0 comments on commit 7a90a53

Please sign in to comment.