summaryrefslogtreecommitdiff
blob: 1cf9d254b3f2083ac373aef57cde3fc4e50b5d93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
--- rpy-1.0.2.orig/examples/faithful.dat	1970-01-01 01:00:00.000000000 +0100
+++ rpy-1.0.2/examples/faithful.dat	2010-04-15 17:44:06.000000000 +0100
@@ -0,0 +1,273 @@
+"eruptions" "waiting"
+3.6 79
+1.8 54
+3.333 74
+2.283 62
+4.533 85
+2.883 55
+4.7 88
+3.6 85
+1.95 51
+4.35 85
+1.833 54
+3.917 84
+4.2 78
+1.75 47
+4.7 83
+2.167 52
+1.75 62
+4.8 84
+1.6 52
+4.25 79
+1.8 51
+1.75 47
+3.45 78
+3.067 69
+4.533 74
+3.6 83
+1.967 55
+4.083 76
+3.85 78
+4.433 79
+4.3 73
+4.467 77
+3.367 66
+4.033 80
+3.833 74
+2.017 52
+1.867 48
+4.833 80
+1.833 59
+4.783 90
+4.35 80
+1.883 58
+4.567 84
+1.75 58
+4.533 73
+3.317 83
+3.833 64
+2.1 53
+4.633 82
+2 59
+4.8 75
+4.716 90
+1.833 54
+4.833 80
+1.733 54
+4.883 83
+3.717 71
+1.667 64
+4.567 77
+4.317 81
+2.233 59
+4.5 84
+1.75 48
+4.8 82
+1.817 60
+4.4 92
+4.167 78
+4.7 78
+2.067 65
+4.7 73
+4.033 82
+1.967 56
+4.5 79
+4 71
+1.983 62
+5.067 76
+2.017 60
+4.567 78
+3.883 76
+3.6 83
+4.133 75
+4.333 82
+4.1 70
+2.633 65
+4.067 73
+4.933 88
+3.95 76
+4.517 80
+2.167 48
+4 86
+2.2 60
+4.333 90
+1.867 50
+4.817 78
+1.833 63
+4.3 72
+4.667 84
+3.75 75
+1.867 51
+4.9 82
+2.483 62
+4.367 88
+2.1 49
+4.5 83
+4.05 81
+1.867 47
+4.7 84
+1.783 52
+4.85 86
+3.683 81
+4.733 75
+2.3 59
+4.9 89
+4.417 79
+1.7 59
+4.633 81
+2.317 50
+4.6 85
+1.817 59
+4.417 87
+2.617 53
+4.067 69
+4.25 77
+1.967 56
+4.6 88
+3.767 81
+1.917 45
+4.5 82
+2.267 55
+4.65 90
+1.867 45
+4.167 83
+2.8 56
+4.333 89
+1.833 46
+4.383 82
+1.883 51
+4.933 86
+2.033 53
+3.733 79
+4.233 81
+2.233 60
+4.533 82
+4.817 77
+4.333 76
+1.983 59
+4.633 80
+2.017 49
+5.1 96
+1.8 53
+5.033 77
+4 77
+2.4 65
+4.6 81
+3.567 71
+4 70
+4.5 81
+4.083 93
+1.8 53
+3.967 89
+2.2 45
+4.15 86
+2 58
+3.833 78
+3.5 66
+4.583 76
+2.367 63
+5 88
+1.933 52
+4.617 93
+1.917 49
+2.083 57
+4.583 77
+3.333 68
+4.167 81
+4.333 81
+4.5 73
+2.417 50
+4 85
+4.167 74
+1.883 55
+4.583 77
+4.25 83
+3.767 83
+2.033 51
+4.433 78
+4.083 84
+1.833 46
+4.417 83
+2.183 55
+4.8 81
+1.833 57
+4.8 76
+4.1 84
+3.966 77
+4.233 81
+3.5 87
+4.366 77
+2.25 51
+4.667 78
+2.1 60
+4.35 82
+4.133 91
+1.867 53
+4.6 78
+1.783 46
+4.367 77
+3.85 84
+1.933 49
+4.5 83
+2.383 71
+4.7 80
+1.867 49
+3.833 75
+3.417 64
+4.233 76
+2.4 53
+4.8 94
+2 55
+4.15 76
+1.867 50
+4.267 82
+1.75 54
+4.483 75
+4 78
+4.117 79
+4.083 78
+4.267 78
+3.917 70
+4.55 79
+4.083 70
+2.417 54
+4.183 86
+2.217 50
+4.45 90
+1.883 54
+1.85 54
+4.283 77
+3.95 79
+2.333 64
+4.15 75
+2.35 47
+4.933 86
+2.9 63
+4.583 85
+3.833 82
+2.083 57
+4.367 82
+2.133 67
+4.35 74
+2.2 54
+4.45 83
+3.567 73
+4.5 73
+4.15 88
+3.817 80
+3.917 71
+4.45 83
+2 56
+4.283 79
+4.767 78
+4.533 84
+1.85 58
+4.25 83
+1.983 43
+2.25 60
+4.75 75
+4.117 81
+2.15 46
+4.417 90
+1.817 46
+4.467 74
--- rpy-1.0.2.orig/examples/nnet.py	1970-01-01 01:00:00.000000000 +0100
+++ rpy-1.0.4/examples/nnet.py	2010-04-15 17:44:06.000000000 +0100
@@ -0,0 +1,29 @@
+from rpy import *
+
+# avoid automatic conversion
+set_default_mode(NO_CONVERSION)
+
+
+r.library("nnet")
+model = r("Fxy~x+y")
+
+df = r.data_frame(x = r.c(0,2,5,10,15)
+                   ,y = r.c(0,2,5,8,10)
+                   ,Fxy = r.c(0,2,5,8,10))
+
+NNModel = r.nnet(model, data = df
+                  , size =10, decay =1e-3
+                  , lineout=True, skip=True
+                  , maxit=1000, Hess =True)
+
+XG = r.expand_grid(x = r.seq(0,7,1), y = r.seq(0,7,1))
+x = r.seq(0,7,1)
+y = r.seq(0,7,1)
+
+
+# turn automatic conversion back on
+set_default_mode(BASIC_CONVERSION)
+
+fit = r.predict(NNModel,XG)
+print fit
+
--- rpy-1.0.2.orig/rpy.py	2008-01-02 17:57:09.000000000 +0000
+++ rpy-1.0.2/rpy.py	2010-04-15 17:44:06.000000000 +0100
@@ -139,6 +139,7 @@
 
 # Version
 from rpy_version import rpy_version
+__version__ = rpy_version
 
 # Symbolic names for conversion modes
 TOP_CONVERSION = 4
@@ -332,7 +333,7 @@
         self.print_(helpobj)
 
     def __repr__(self):
-        Rver = self.__getitem__('R_version_string')
+        Rver = self.__getitem__('R.version.string')
         return "RPy version %s [%s]" % (rpy_version, Rver)
 
     def __str__(self):
--- rpy-1.0.2.orig/rpy_tools.py	2010-04-15 17:53:14.000000000 +0100
+++ rpy-1.0.2/rpy_tools.py	2010-04-15 17:44:06.000000000 +0100
@@ -97,8 +97,7 @@
     if stat or len(output)<=0:
       raise RuntimeError("Couldn't execute the R interpreter" +
                          " `%s'.\n" % rexec )
-    # edd 05 Apr 2006  version = re.search("R +([0-9]\.[0-9]\.[0-9])", output)
-    version = re.search(" version ([0-9]\.[0-9]\.[0-9])", output)
+    version = re.search(" +([0-9]+\.[0-9]+\.[0-9]+)", output)
     if not version:
       raise RuntimeError("Couldn't obtain version number from output\n"
                                "of `R --version'.\n")
@@ -143,3 +142,20 @@
                        % PYTHON_DIR )
     
   return PYTHON_DIR
+
+def get_R_LAPACK_LIB_FLAGS(RHOME=get_R_HOME()):
+  """
+  Determine the necessary link arguments for lapack 
+  """
+  rexec = os.path.join(RHOME, 'bin', 'R')
+  stat, output = getstatusoutput('"%s" CMD config LAPACK_LIBS' % rexec )
+  if stat or len(output)<=0:
+    raise RuntimeError("Couldn't execute the R interpreter" +
+                       " `%s'.\n" % rexec )
+  
+  LAPACK_LIB_FLAGS = output.strip()
+  if not LAPACK_LIB_FLAGS:
+    raise RuntimeError("Couldn't obtain LAPACK_LIBS information from output\n"
+                       "of `R CMD config LAPACK_LIBS'.\n")
+  
+  return LAPACK_LIB_FLAGS
--- rpy-1.0.2.orig/rpy_version.py	2008-04-03 14:51:23.000000000 +0100
+++ rpy-1.0.2/rpy_version.py	2010-04-15 17:44:06.000000000 +0100
@@ -1 +1 @@
-rpy_version = "1.0.2"
+rpy_version = "1.0.3"
--- rpy-1.0.2.orig/setup.py	2007-11-27 02:06:32.000000000 +0000
+++ rpy-1.0.2/setup.py	2010-04-15 17:44:06.000000000 +0100
@@ -30,13 +30,14 @@
 See the files INSTALL.UNIX and INSTALL.WINDOWS for more details.
 """
 
-DEBUG=True
+DEBUG=False
 
-import os, os.path, sys, shutil
+import os, os.path, sys, shutil, re
 from distutils.core import setup, Extension
 from distutils.sysconfig import *
 from distutils.errors import *
 import rpy_tools
+
 if sys.platform=="win32":
     import rpy_wintools
 
@@ -66,6 +67,15 @@
 #if sys.platform=="win32":
 #    rpy_wintools.CreatePythonWinLib()
 
+# On Mac OS X ("darwin") it is necessary to change the symlink
+#   /Library/Frameworks/R.framework/Versions/Current
+# to point to the current version of R in
+#  /Library/Frameworks/R.framework/Versions/X.Y
+# for that version of R to execute.  So, we need to store the original
+# symlink here so we can restore it when we are done
+if sys.platform=="darwin":
+  darwin_original_version = os.readlink("/Library/Frameworks/R.framework/Versions/Current")
+
 modules = []
 for RHOME in RHOMES:
    
@@ -76,7 +86,7 @@
         get_config_vars()['OPT'] = '-g -Wall'
     else:
         # to avoid strict prototypes errors from R includes
-        get_config_vars()['OPT'] = '-DNDEBUG -g -O3 -Wall'
+        get_config_vars()['OPT'] = '-DNDEBUG -O3 -Wall'
 
     # get the Python version
     if sys.version[:3] >= '2.2':
@@ -87,6 +97,16 @@
         UNDEF = []
 
     # configure the R paths
+    #if sys.platform=="darwin":
+    #  version = 
+    #  if os.symlink("/Library/Frameworks/R.framework/Versions/Current")
+    #  if RHOME.endswith('/'):
+    #    RHOME = RHOME[:-1]
+    #  print "RHOME=",os.path.join(os.path.dirname(RHOME),
+    #                              os.readlink(RHOME) )
+    #  sys.exit()
+      
+    
     RVERSION = rpy_tools.get_R_VERSION(RHOME, force_exec=True)
     RVER     = rpy_tools.get_R_VERSION_CODE(RVERSION)
 
@@ -130,22 +150,21 @@
         library_dirs= r_libs
         runtime_libs = r_libs
         extra_compile_args=[]
-    elif sys.platform=='osf1V5':
-        include_dirs = [ os.path.join(RHOME.strip(), 'include'), 
-                         'src' ]
-        libraries=['R','Rlapack']
-        library_dirs = r_libs
-        runtime_libs = r_libs
-        extra_compile_args=["-shared"]
-        source_files = source_files + ["src/setenv.c"]
+        
     else: # unix-like systems, this is known to work for Linux and Solaris
         include_dirs = [ os.path.join(RHOME.strip(), 'include'), 
                          'src', '/usr/share/R/include' ]
-        libraries=['R','Rlapack']
+
         library_dirs = r_libs
         runtime_libs = r_libs
         extra_compile_args=["-shared"]
         source_files = source_files + ["src/setenv.c"]
+        
+        libraries=['R']
+          
+        # Ask R to tell us how to properly link against lapack
+        extra_compile_args += [ rpy_tools.get_R_LAPACK_LIB_FLAGS( RHOME ) ]
+
 
     # Discover which array packages are present
     try: 
--- rpy-1.0.2.orig/src/io.c	2008-01-02 17:34:22.000000000 +0000
+++ rpy-1.0.2/src/io.c	2010-04-15 17:44:06.000000000 +0100
@@ -130,7 +130,7 @@
     PyErr_Clear();
     return 0;
   }
-  snprintf(buf, len, "%s", PyString_AsString(input_data));
+  snprintf( (char*) buf, len, "%s", PyString_AsString(input_data));
   Py_DECREF(input_data);
   return 1;
 }
--- rpy-1.0.2.orig/src/RPy.h	2010-04-15 17:52:52.000000000 +0100
+++ rpy-1.0.4/src/RPy.h	2010-04-15 17:44:06.000000000 +0100
@@ -52,6 +52,13 @@
 #include <Rdefines.h>
 #include <Rinternals.h>
 #include <Rversion.h>
+
+#if (R_VERSION >= R_Version(2,4,0)) 
+#include <Rembedded.h>
+#endif
+
+
+
 #undef _POSIX_C_SOURCE
 #include <Python.h>
 #include <R_ext/Rdynload.h>
@@ -74,9 +81,8 @@
 #  endif
 #endif  /* _WIN32 */
 
-#if R_VERSION < 133120
-#include <Rdevices.h> /* must follow Graphics.h */
-#endif
+#include <Rembedded.h> /* must follow Graphics.h */
+
 
 /* Missing definitions from Rinterface.h or RStartup.h */
 # define CleanEd		Rf_CleanEd
--- rpy-1.0.2.orig/src/rpymodule.c	2010-04-15 17:52:33.000000000 +0100
+++ rpy-1.0.4/src/rpymodule.c	2010-04-15 17:44:06.000000000 +0100
@@ -1772,13 +1772,15 @@
 
 void r_finalize(void)
 {
+#if (R_VERSION < R_Version(2,4,0)) 
     unsigned char buf[1024];
     char * tmpdir;
+#endif
 
     R_dot_Last();           
     R_RunExitFinalizers();  
     CleanEd();              
-#if (R_VERSION >= R_Version(2,7,0)) 
+#if (R_VERSION >= R_Version(2,7,0))
     Rf_KillAllDevices();
 #else
     KillAllDevices();