what this error means in predictions on test set in WEKA - weka

I am a beginner on using WEKA. The problem is when I am trying to test a new dataset on my model by using supplied test set choice, the prediction is OK but it gives + signs in error field what is that mean?. In addition, confusion matrix and accuracy details gave some cells empty.
== Predictions on test set ===
inst# actual predicted error prediction
1 2:' ST' 1: NT + 1
2 2:' ST' 1: NT + 1
3 2:' ST' 1: NT + 1
4 2:' ST' 1: NT + 1
5 2:' ST' 1: NT + 1
6 2:' ST' 1: NT + 1
7 2:' ST' 1: NT + 1
8 2:' ST' 1: NT + 1
9 2:' ST' 1: NT + 1
10 2:' ST' 1: NT + 1
11 2:' ST' 1: NT + 1
12 2:' ST' 1: NT + 1
13 2:' ST' 1: NT + 1
14 2:' ST' 1: NT + 1
15 2:' ST' 1: NT + 1
16 2:' ST' 1: NT + 1
17 2:' ST' 1: NT + 1
18 2:' ST' 1: NT + 1
19 2:' ST' 1: NT + 1
20 2:' ST' 1: NT + 1
21 2:' ST' 1: NT + 1
22 2:' ST' 1: NT + 1
23 2:' ST' 1: NT + 1
24 2:' ST' 1: NT + 1
25 2:' ST' 1: NT + 1
26 2:' ST' 1: NT + 1
27 2:' ST' 1: NT + 1
28 2:' ST' 1: NT + 1
29 2:' ST' 1: NT + 1
30 2:' ST' 1: NT + 1
31 2:' ST' 1: NT + 1
32 2:' ST' 1: NT + 1
33 2:' ST' 1: NT + 1
34 2:' ST' 1: NT + 1
35 2:' ST' 1: NT + 1
36 2:' ST' 1: NT + 1
37 2:' ST' 1: NT + 1
38 2:' ST' 1: NT + 1
39 2:' ST' 1: NT + 1
40 2:' ST' 1: NT + 1
41 2:' ST' 1: NT + 1
42 2:' ST' 1: NT + 1
43 2:' ST' 1: NT + 1
44 2:' ST' 1: NT + 1
45 2:' ST' 1: NT + 1
46 2:' ST' 1: NT + 1
47 2:' ST' 1: NT + 1
48 2:' ST' 1: NT + 1
49 2:' ST' 1: NT + 1
50 2:' ST' 1: NT + 1
51 2:' ST' 1: NT + 1
52 2:' ST' 1: NT + 1
53 2:' ST' 1: NT + 1
54 2:' ST' 1: NT + 1
55 2:' ST' 1: NT + 1
56 2:' ST' 1: NT + 1
57 2:' ST' 1: NT + 1
58 2:' ST' 1: NT + 1
59 2:' ST' 1: NT + 1
60 2:' ST' 1: NT + 1
61 2:' ST' 1: NT + 1
62 2:' ST' 1: NT + 1
63 2:' ST' 1: NT + 1
64 2:' ST' 1: NT + 1
65 2:' ST' 1: NT + 1
66 2:' ST' 1: NT + 1
67 2:' ST' 1: NT + 1
68 2:' ST' 1: NT + 1
69 2:' ST' 1: NT + 1
70 2:' ST' 1: NT + 1
71 2:' ST' 1: NT + 1
72 2:' ST' 1: NT + 1
73 2:' ST' 1: NT + 1
74 2:' ST' 1: NT + 1
75 2:' ST' 1: NT + 1
76 1:' NT' 1: NT 1
77 1:' NT' 1: NT 1
78 1:' NT' 1: NT 1
79 1:' NT' 1: NT 1
80 1:' NT' 1: NT 1
81 1:' NT' 1: NT 1
82 1:' NT' 1: NT 1
83 1:' NT' 1: NT 1
84 1:' NT' 1: NT 1
85 1:' NT' 1: NT 1
86 1:' NT' 1: NT 1
87 1:' NT' 1: NT 1
88 1:' NT' 1: NT 1
89 1:' NT' 1: NT 1
90 1:' NT' 1: NT 1
91 1:' NT' 1: NT 1
92 1:' NT' 1: NT 1
93 1:' NT' 1: NT 1
94 1:' NT' 1: NT 1
95 1:' NT' 1: NT 1
96 1:' NT' 1: NT 1
97 1:' NT' 1: NT 1
98 1:' NT' 1: NT 1
99 1:' NT' 1: NT 1
100 1:' NT' 1: NT 1
101 1:' NT' 1: NT 1
102 1:' NT' 1: NT 1
103 1:' NT' 1: NT 1
104 1:' NT' 1: NT 1
105 1:' NT' 1: NT 1
106 1:' NT' 1: NT 1
107 1:' NT' 1: NT 1
108 1:' NT' 1: NT 1
109 1:' NT' 1: NT 1
110 1:' NT' 1: NT 1
111 1:' NT' 1: NT 1
112 1:' NT' 1: NT 1
113 1:' NT' 1: NT 1
114 1:' NT' 1: NT 1
115 1:' NT' 1: NT 1
116 1:' NT' 1: NT 1
117 1:' NT' 1: NT 1
118 1:' NT' 1: NT 1
119 1:' NT' 1: NT 1
120 1:' NT' 1: NT 1
121 1:' NT' 1: NT 1
122 1:' NT' 1: NT 1
123 1:' NT' 1: NT 1
124 1:' NT' 1: NT 1
125 1:' NT' 1: NT 1
126 1:' NT' 1: NT 1
127 1:' NT' 1: NT 1
128 1:' NT' 1: NT 1
129 1:' NT' 1: NT 1
130 1:' NT' 1: NT 1
131 1:' NT' 1: NT 1
132 1:' NT' 1: NT 1
133 1:' NT' 1: NT 1
134 1:' NT' 1: NT 1
135 1:' NT' 1: NT 1
136 1:' NT' 1: NT 1
137 1:' NT' 1: NT 1
138 1:' NT' 1: NT 1
139 1:' NT' 1: NT 1
140 1:' NT' 1: NT 1
141 1:' NT' 1: NT 1
142 1:' NT' 1: NT 1
143 1:' NT' 1: NT 1
144 1:' NT' 1: NT 1
145 1:' NT' 1: NT 1
146 1:' NT' 1: NT 1
147 1:' NT' 1: NT 1
148 1:' NT' 1: NT 1
149 1:' NT' 1: NT 1
150 1:' NT' 1: NT 1
=== Evaluation on test set ===
Time taken to test model on supplied test set: 0.13 seconds
=== Summary ===
Correctly Classified Instances 75 50 %
Incorrectly Classified Instances 75 50 %
Kappa statistic 0
Mean absolute error 0.5
Root mean squared error 0.7071
Relative absolute error 100 %
Root relative squared error 141.4214 %
Total Number of Instances 150
=== Detailed Accuracy By Class ===
TP Rate FP Rate Precision Recall F-Measure MCC ROC Area PRC Area Class
1.000 1.000 0.500 1.000 0.667 ? 0.500 0.500 NT
0.000 0.000 ? 0.000 ? ? 0.500 0.500 ST
Weighted Avg. 0.500 0.500 ? 0.500 ? ? 0.500 0.500
=== Confusion Matrix ===
a b <-- classified as
75 0 | a = NT
75 0 | b = ST
Is it possible that all ST predicted wrong?
I searched a lot to figure out the problem with no results.
the training and testing data are compatible and the testing data are labeled.

According to the confusion matrix, all of your predictions are NT. So all instances labeled as ST are predicted as NT.

Related

Effeciently extract last 12 month data from master table for each id and month using sas

I am currently practicing SAS programming on using two SAS dataset(sample and master) . Below are the hypothetical or dummy data created for illustration purpose to solve my problem through SAS programming . I would like to extract the data for the id's in sample dataset from master dataset. I have given an example with few id's as sample dataset, for which i need to extract last 12 month information from master table for each id's based on the yearmonth information( desired output given in the third output).
similar to this, i have many column which i need 12 months data for each id and yearmonth.
I have written a code with do loop to iterate each row of sample dataset then find the data in the master table from start (yearmonth and end date(12 month ago) for each iteration, and then transpose it using proc transpose. Then merge the sample dataset with transpose data using data step merge using id and yearmonth. But i feel the code which i have written is not optimized because it is lopping several times for each row in sample dataset and finds data from master table . Can anyone help me in solving this problem using SAS programming with optimized way.
One sample dataset (dataset name - sample).
ID YEARMONTH NO_OF_CUST
1 200909 50
1 201005 65
1 201008 78
1 201106 95
2 200901 65
2 200902 45
2 200903 69
2 201005 14
2 201006 26
2 201007 98
3 201011 75
3 201012 75
One master dataset(dataset name - master dataset huge dataset over the year for each id from start of the account to till date.)
ID YEARMONTH NO_OF_CUST
1 200808 125
1 200809 125
1 200810 111
1 200811 174
1 200812 98
1 200901 45
1 200902 74
1 200903 73
1 200904 101
1 200905 164
1 200906 104
1 200907 22
1 200908 35
1 200909 50
1 200910 77
1 200911 86
1 200912 95
1 201001 95
1 201002 87
1 201003 79
1 201004 71
1 201005 65
1 201006 66
1 201007 66
1 201008 78
1 201009 88
1 201010 54
1 201011 45
1 201012 100
1 201101 136
1 201102 111
1 201103 17
1 201104 77
1 201105 111
1 201106 95
1 201107 79
1 201108 777
1 201109 758
1 201110 32
1 201111 15
1 201112 22
2 200711 150
2 200712 150
2 200801 44
2 200802 385
2 200803 65
2 200804 66
2 200805 200
2 200806 333
2 200807 285
2 200808 265
2 200809 222
2 200810 220
2 200811 205
2 200812 185
2 200901 65
2 200902 45
2 200903 69
2 200904 546
2 200905 21
2 200906 256
2 200907 214
2 200908 14
2 200909 44
2 200910 65
2 200911 88
2 200912 79
2 201001 65
2 201002 45
2 201003 69
2 201004 54
2 201005 14
2 201006 26
2 201007 98
3 200912 77
3 201001 66
3 201002 69
3 201003 7
3 201004 7
3 201005 7
3 201006 65
3 201007 75
3 201008 85
3 201009 89
3 201010 100
3 201011 75
3 201012 75
Below is sample output which i am trying to update for an each sample id's in sample dataset.
Without sample code of what you've been trying to do so far it is a bit difficult to figure out what you want but a "SAS" way of getting the same result as the image file might be the following.
EDIT: Edited my answer so it takes the last 12 months by ID
data test;
infile datalines dlm='09'x;
input ID YEARMONTH NO_OF_CUST;
datalines;
1 200808 125
1 200809 125
1 200810 111
1 200811 174
1 200812 98
1 200901 45
1 200902 74
1 200903 73
1 200904 101
1 200905 164
1 200906 104
1 200907 22
1 200908 35
1 200909 50
1 200910 77
1 200911 86
1 200912 95
1 201001 95
1 201002 87
1 201003 79
1 201004 71
1 201005 65
1 201006 66
1 201007 66
1 201008 78
1 201009 88
1 201010 54
1 201011 45
1 201012 100
1 201101 136
1 201102 111
1 201103 17
1 201104 77
1 201105 111
1 201106 95
1 201107 79
1 201108 777
1 201109 758
1 201110 32
1 201111 15
1 201112 22
2 200711 150
2 200712 150
2 200801 44
2 200802 385
2 200803 65
2 200804 66
2 200805 200
2 200806 333
2 200807 285
2 200808 265
2 200809 222
2 200810 220
2 200811 205
2 200812 185
2 200901 65
2 200902 45
2 200903 69
2 200904 546
2 200905 21
2 200906 256
2 200907 214
2 200908 14
2 200909 44
2 200910 65
2 200911 88
2 200912 79
2 201001 65
2 201002 45
2 201003 69
2 201004 54
2 201005 14
2 201006 26
2 201007 98
3 200912 77
3 201001 66
3 201002 69
3 201003 7
3 201004 7
3 201005 7
3 201006 65
3 201007 75
3 201008 85
3 201009 89
3 201010 100
3 201011 75
3 201012 75
;
run;
proc sort data=test;
by id yearmonth;
run;
data result;
set test;
array prev_month {13} PREV_MONTH_0-PREV_MONTH_12;
by id;
if first.id then do;
do i = 1 to 13;
prev_month(i) = 0;
end;
end;
do i = 13 to 2 by -1;
prev_month(i) = prev_month(i-1);
end;
prev_month(1) = NO_OF_CUST;
drop i PREV_MONTH_0;
retain PREV_MONTH:;
run;

Python multiprocess plot issue in Mac OSX Sierra - exception type EXC_BAD_INSTRUCTION

I've developed a GitHub repo with an example of a multiprocess script in python2.7 for plotting. Basically, the script allocates one process to generate the data, and such data are passed via a queue to a second process that is responsible to generate the plot. When I run both the examples 'multiproc_processIPC.py' or 'multiproc_poolQUEUE.py' I get the following error.
Note that this error came up AFTER upgrading my mac to OSX Sierra.
Has anyone a clue of the origin of this issue?
Any help will be highly appreciated
===== ERROR REPORT =====
Process: python2.7 [82890]
Path: /Users/USER/*/python
Identifier: python2.7
Version: ???
Code Type: X86-64 (Native)
Parent Process: python2.7 [82883]
Responsible: python2.7 [82890]
User ID: 501
Date/Time: 2016-12-04 22:34:29.874 +0100
OS Version: Mac OS X 10.12.1 (16B2555)
Report Version: 12
Anonymous UUID: 689587A6-D759-0F81-671D-1079942B7C42
Time Awake Since Boot: 9000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
Application Specific Information:
BUG IN CLIENT OF LIBDISPATCH: _dispatch_main_queue_callback_4CF called from the wrong thread
crashed on child side of fork pre-exec
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libdispatch.dylib 0x00007fff8f9ddd21 _dispatch_main_queue_callback_4CF + 1291
1 com.apple.CoreFoundation 0x00007fff7a97abe9 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
2 com.apple.CoreFoundation 0x00007fff7a93c00d __CFRunLoopRun + 2205
3 com.apple.CoreFoundation 0x00007fff7a93b514 CFRunLoopRunSpecific + 420
4 com.apple.HIToolbox 0x00007fff79ed8fbc RunCurrentEventLoopInMode + 240
5 com.apple.HIToolbox 0x00007fff79ed8df1 ReceiveNextEventCommon + 432
6 com.apple.HIToolbox 0x00007fff79ed8c26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
7 com.apple.AppKit 0x00007fff785c2b79 _DPSNextEvent + 1093
8 com.apple.AppKit 0x00007fff78cd81c3 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1637
9 Tk 0x0000000104b01285 0x104a47000 + 762501
10 Tk 0x0000000104b0171f 0x104a47000 + 763679
11 Tcl 0x00000001049d75f8 Tcl_DoOneEvent + 317
12 Tk 0x0000000104a55932 0x104a47000 + 59698
13 Tcl 0x00000001049695b7 0x10495b000 + 58807
14 Tcl 0x0000000104969e46 Tcl_EvalObjv + 59
15 _tkinter.so 0x00000001037dfe39 Tkapp_Call + 617
16 libpython2.7.dylib 0x00000001000a3302 PyEval_EvalFrameEx + 3730
17 libpython2.7.dylib 0x00000001000ac913 fast_function + 179
18 libpython2.7.dylib 0x00000001000a338a PyEval_EvalFrameEx + 3866
19 libpython2.7.dylib 0x00000001000ac7dc PyEval_EvalCodeEx + 2092
20 libpython2.7.dylib 0x00000001000ac988 fast_function + 296
21 libpython2.7.dylib 0x00000001000a338a PyEval_EvalFrameEx + 3866
22 libpython2.7.dylib 0x00000001000ac7dc PyEval_EvalCodeEx + 2092
23 libpython2.7.dylib 0x00000001000ac988 fast_function + 296
24 libpython2.7.dylib 0x00000001000a338a PyEval_EvalFrameEx + 3866
25 libpython2.7.dylib 0x00000001000ac7dc PyEval_EvalCodeEx + 2092
26 libpython2.7.dylib 0x0000000100035c1b function_call + 347
27 libpython2.7.dylib 0x000000010000c761 PyObject_Call + 97
28 libpython2.7.dylib 0x00000001000a3cea PyEval_EvalFrameEx + 6266
29 libpython2.7.dylib 0x00000001000ac7dc PyEval_EvalCodeEx + 2092
30 libpython2.7.dylib 0x00000001000ac988 fast_function + 296
31 libpython2.7.dylib 0x00000001000a338a PyEval_EvalFrameEx + 3866
32 libpython2.7.dylib 0x00000001000ac7dc PyEval_EvalCodeEx + 2092
33 libpython2.7.dylib 0x0000000100035c1b function_call + 347
34 libpython2.7.dylib 0x000000010000c761 PyObject_Call + 97
35 libpython2.7.dylib 0x000000010001e7d7 instancemethod_call + 503
36 libpython2.7.dylib 0x000000010000c761 PyObject_Call + 97
37 libpython2.7.dylib 0x000000010006673a slot_tp_init + 106
38 libpython2.7.dylib 0x0000000100062465 type_call + 229
39 libpython2.7.dylib 0x000000010000c761 PyObject_Call + 97
40 libpython2.7.dylib 0x00000001000a35a5 PyEval_EvalFrameEx + 4405
41 libpython2.7.dylib 0x00000001000ac7dc PyEval_EvalCodeEx + 2092
42 libpython2.7.dylib 0x0000000100035c1b function_call + 347
43 libpython2.7.dylib 0x000000010000c761 PyObject_Call + 97
44 libpython2.7.dylib 0x000000010001e7d7 instancemethod_call + 503
45 libpython2.7.dylib 0x000000010000c761 PyObject_Call + 97
46 libpython2.7.dylib 0x000000010006673a slot_tp_init + 106
47 libpython2.7.dylib 0x0000000100062465 type_call + 229
48 libpython2.7.dylib 0x000000010000c761 PyObject_Call + 97
49 libpython2.7.dylib 0x00000001000a3cea PyEval_EvalFrameEx + 6266
50 libpython2.7.dylib 0x00000001000ac913 fast_function + 179
51 libpython2.7.dylib 0x00000001000a338a PyEval_EvalFrameEx + 3866
52 libpython2.7.dylib 0x00000001000ac913 fast_function + 179
53 libpython2.7.dylib 0x00000001000a338a PyEval_EvalFrameEx + 3866
54 libpython2.7.dylib 0x00000001000ac7dc PyEval_EvalCodeEx + 2092
55 libpython2.7.dylib 0x0000000100035c1b function_call + 347
56 libpython2.7.dylib 0x000000010000c761 PyObject_Call + 97
57 libpython2.7.dylib 0x000000010001e7d7 instancemethod_call + 503
58 libpython2.7.dylib 0x000000010000c761 PyObject_Call + 97
59 libpython2.7.dylib 0x000000010006673a slot_tp_init + 106
60 libpython2.7.dylib 0x0000000100062465 type_call + 229
61 libpython2.7.dylib 0x000000010000c761 PyObject_Call + 97
62 libpython2.7.dylib 0x00000001000a35a5 PyEval_EvalFrameEx + 4405
63 libpython2.7.dylib 0x00000001000ac913 fast_function + 179
64 libpython2.7.dylib 0x00000001000a338a PyEval_EvalFrameEx + 3866
65 libpython2.7.dylib 0x00000001000ac7dc PyEval_EvalCodeEx + 2092
66 libpython2.7.dylib 0x00000001000ac856 PyEval_EvalCode + 54
67 libpython2.7.dylib 0x00000001000cb3d4 PyRun_FileExFlags + 164
68 libpython2.7.dylib 0x00000001000cc709 PyRun_SimpleFileExFlags + 409
69 libpython2.7.dylib 0x00000001000e01ca Py_Main + 2938
70 python 0x0000000100000f14 start + 52
Thread 1:
0 libsystem_kernel.dylib 0x00007fff8fb354e6 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8fc1d622 _pthread_wqthread + 1023
2 libsystem_pthread.dylib 0x00007fff8fc1d211 start_wqthread + 13
Thread 2:
0 libsystem_kernel.dylib 0x00007fff8fb354e6 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8fc1d622 _pthread_wqthread + 1023
2 libsystem_pthread.dylib 0x00007fff8fc1d211 start_wqthread + 13
Thread 3:
0 libsystem_kernel.dylib 0x00007fff8fb354e6 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8fc1d7b5 _pthread_wqthread + 1426
2 libsystem_pthread.dylib 0x00007fff8fc1d211 start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff8fb34f4e __select + 10
1 Tcl 0x0000000104a08271 0x10495b000 + 709233
2 libsystem_pthread.dylib 0x00007fff8fc1daab _pthread_body + 180
3 libsystem_pthread.dylib 0x00007fff8fc1d9f7 _pthread_start + 286
4 libsystem_pthread.dylib 0x00007fff8fc1d221 thread_start + 13
Thread 5:: com.apple.NSEventThread
0 libsystem_kernel.dylib 0x00007fff8fb2d41a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff8fb2c867 mach_msg + 55
2 libsystem_kernel.dylib 0x00007fff8fb21ed1 _kernelrpc_mach_port_set_attributes + 150
3 libdispatch.dylib 0x00007fff8f9e7739 _dispatch_runloop_queue_handle_init + 171
4 libdispatch.dylib 0x00007fff8f9d84b7 _dispatch_runloop_root_queue_create_4CF + 133
5 com.apple.CoreFoundation 0x00007fff7a9091e6 __CFRunLoopFindMode + 502
6 com.apple.CoreFoundation 0x00007fff7a909889 CFRunLoopAddSource + 201
7 com.apple.HIToolbox 0x00007fff79ed9897 AdjustCGSSourceInRunLoop(void ()(__CFRunLoop, __CFRunLoopSource*, __CFString const*), __CFRunLoop*, __CFRunLoopSource*) + 180
8 com.apple.HIToolbox 0x00007fff79ed97bb AddCGSSourceToRunLoop(__CFRunLoop*) + 78
9 com.apple.HIToolbox 0x00007fff79eecc52 _BeginEventReceiptOnThread + 181
10 com.apple.AppKit 0x00007fff7870f4f8 _NSEventThread + 37
11 libsystem_pthread.dylib 0x00007fff8fc1daab _pthread_body + 180
12 libsystem_pthread.dylib 0x00007fff8fc1d9f7 _pthread_start + 286
13 libsystem_pthread.dylib 0x00007fff8fc1d221 thread_start + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000307 rbx: 0x00000001003d93f0 rcx: 0x00007fff8f9f9530 rdx: 0x0000000000000307
rdi: 0x0000000000000001 rsi: 0x0000000000000006 rbp: 0x00007fff5fbfa160 rsp: 0x00007fff5fbfa0f0
r8: 0x0000000000000040 r9: 0x00000001003d9408 r10: 0xffffffffffffffff r11: 0x0000000000012068
r12: 0x00000001003d93e0 r13: 0x00000001003d94a0 r14: 0x00007fff986f5a80 r15: 0x0000000102076898
rip: 0x00007fff8f9ddd21 rfl: 0x0000000000010202 cr2: 0x00007fff9db1224b
Logical CPU: 3
Error Code: 0x00000000
Trap Number: 6
Binary Images:
0x100000000 - 0x100000ff7 +python (???) /Users/USER//python
0x100003000 - 0x100146ff7 +libpython2.7.dylib (2.7) <87FF0E63-058F-3190-A882-8E25F3D889C7> /Users/USER//libpython2.7.dylib
0x1002db000 - 0x1002dcff7 +_locale.so (???) /Users/USER//_locale.so
0x1002e0000 - 0x1002e6ff7 +itertools.so (???) /Users/USER//itertools.so
<<<<<< LINES OMITTED FOR BREVITY >>>>>>
0x7fff8fc2b000 - 0x7fff8fc32fff libsystem_symptoms.dylib (532.1.1) <8FB7CA37-79EF-3651-B5B9-B5E1E0947067> /usr/lib/system/libsystem_symptoms.dylib
0x7fff8fc33000 - 0x7fff8fc53ff7 libsystem_trace.dylib (518.20.8) /usr/lib/system/libsystem_trace.dylib
0x7fff8fc54000 - 0x7fff8fc59ffb libunwind.dylib (35.3) <9F7C2AD8-A9A7-3DE4-828D-B0F0F166AAA0> /usr/lib/system/libunwind.dylib
0x7fff8fc5a000 - 0x7fff8fc83ff7 libxpc.dylib (972.20.3) <85EB25FD-218F-38EE-9E69-391CC8EBE6C5> /usr/lib/system/libxpc.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 542465
thread_create: 0
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=254.5M resident=0K(0%) swapped_out_or_unallocated=254.5M(100%)
Writable regions: Total=96.5M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=96.5M(100%)
VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced)
=========== ======= =======
Activity Tracing 256K 2
CoreUI image file 144K 3
Dispatch continuations 8192K 2
Kernel Alloc Once 8K 2
MALLOC 61.8M 54
MALLOC guard page 32K 7
Memory Tag 242 12K 2
STACK GUARD 56.0M 7
Stack 10.1M 7
VM_ALLOCATE 48K 7
__DATA 21.0M 292
__IMAGE 528K 2
__LINKEDIT 115.0M 66
__TEXT 139.5M 288
__UNICODE 556K 2
mapped file 43.2M 9
shared memory 16.3M 12
=========== ======= =======
TOTAL 472.4M 747
Model: MacBookPro11,1, BootROM MBP111.0138.B17, 2 processors, Intel Core i5, 2,4 GHz, 8 GB, SMC 2.16f68
Graphics: Intel Iris, Intel Iris, Built-In
Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1600 MHz, 0x80AD, 0x484D54343531533641465238412D50422020
Memory Module: BANK 1/DIMM0, 4 GB, DDR3, 1600 MHz, 0x80AD, 0x484D54343531533641465238412D50422020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x112), Broadcom BCM43xx 1.0 (7.21.171.47.1a8)
Bluetooth: Version 5.0.1f7, 3 services, 17 devices, 1 incoming serial ports
Network Service: AirPort, AirPort, en0
Serial ATA Device: APPLE SSD SM0256F, 251 GB
USB Device: USB 3.0 Bus
USB Device: Apple Internal Keyboard / Trackpad
USB Device: BRCM20702 Hub
USB Device: Bluetooth USB Host Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 17.2
Try setting the "start method" to "spawn" instead of the default of "fork". See https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods for further details.
This worked for me on a similar problem.
Ok, more info: If I run a first process from terminal, whose script 'visl.py' is:
#!/usr/bin/env python
from multiprocessing import Process
import sys
sys.path.insert(0, './lib')
import visualizer
visualizer.Visualizer()
and then a second process from a different terminal instance, whose script 'logr.py' is:
#!/usr/bin/env python
from multiprocessing import Process
import sys
sys.path.insert(0, './lib')
import logger
args_logger = {'sampling_time_ms': 5, 'plotting_time_ms': 100}
logger.Logger(args_logger)
It works. Then: how to run two python processes from a single script?

Inserting tables with group and subgroup codes in SAS

First please consider the following list of WC variable...
1101 1201 1301 1401 1501 1601
1102 1202 1302 1402 1502 1602
1103 1203 1303 1403 1503 1603
1104 1204 1304 1404 1504 1604
1105 1205 1305 1405 1505 1605
1106 1206 1306 1406 1506 1606
1107 1207 1307 1407 1507 1607
1108 1208 1308 1408 1508 1608
1109 1209 1309 1409 1509 1609
1110 1210 1310 1410 1510 1610
1111 1211 1311 1411 1511 1611
1112 1212 1312 1412 1512 1612
1113 1213 1313 1413 1513 1613
1114 1214 1314 1414 1514 1614
1115 1215 1315 1415 1515 1615
1116 1216 1316 1416 1516 1616
1117 1217 1317 1417 1517 1617
1118 1218 1318 1418 1518 1618
1119
1120
Now understand what I am trying to achieve.
I have a very long dataset where in i have two variables are shown in the below table...
WC ASN
1101 0
1101 1
1101 2
1101 3
1101 4
1101 20
1101 21
1101 22
1101 23
1101 24
1101 25
1101 26
1101 27
1101 28
1101 45
1101 46
1101 47
1101 48
1201 4
1201 5
1201 6
1201 7
1201 8
1201 16
1201 17
1201 18
1201 19
1201 20
1201 28
1201 29
1201 30
1201 31
1201 32
1201 41
1201 42
1201 43
1201 44
1202 4
1202 5
1202 6
1202 7
1202 8
1202 16
1202 17
1202 18
1202 19
1202 20
1202 29
1202 30
1202 31
1202 32
1202 40
1202 41
1202 42
1202 43
1202 44
What I want to do is to add two more columns Group and SubGroup such that I get the final table as shown below:
WC ASN Group SubGroup
1101 0 1 1
1101 1 1 1
1101 2 1 1
1101 3 1 1
1101 4 1 1
1101 20 1 1
1101 21 1 1
1101 22 1 1
1101 23 1 1
1101 24 1 1
1101 25 1 1
1101 26 1 1
1101 27 1 1
1101 28 1 1
1101 45 1 1
1101 46 1 1
1101 47 1 1
1101 48 1 1
1201 4 1 2
1201 5 1 2
1201 6 1 2
1201 7 1 2
1201 8 1 2
1201 16 1 2
1201 17 1 2
1201 18 1 2
1201 19 1 2
1201 20 1 2
1201 28 1 2
1201 29 1 2
1201 30 1 2
1201 31 1 2
1201 32 1 2
1201 41 1 2
1201 42 1 2
1201 43 1 2
1201 44 1 2
1301 8 1 3
1301 9 1 3
1301 10 1 3
1301 11 1 3
1301 12 1 3
1301 13 1 3
1301 14 1 3
1301 15 1 3
1301 16 1 3
1301 32 1 3
1301 33 1 3
1301 34 1 3
1301 35 1 3
1301 36 1 3
1301 37 1 3
1301 38 1 3
1301 39 1 3
1301 40 1 3
1401 8 1 4
1401 9 1 4
1401 10 1 4
1401 11 1 4
1401 12 1 4
1401 13 1 4
1401 14 1 4
1401 15 1 4
1401 16 1 4
1401 33 1 4
1401 34 1 4
1401 35 1 4
1401 36 1 4
1401 37 1 4
1401 38 1 4
1401 39 1 4
1401 40 1 4
1501 4 1 5
1501 5 1 5
1501 6 1 5
1501 7 1 5
1501 8 1 5
1501 16 1 5
1501 17 1 5
1501 18 1 5
1501 19 1 5
1501 20 1 5
1501 29 1 5
1501 30 1 5
1501 31 1 5
1501 32 1 5
1501 40 1 5
1501 41 1 5
1501 42 1 5
1501 43 1 5
1501 44 1 5
1601 0 1 6
1601 1 1 6
1601 2 1 6
1601 3 1 6
1601 4 1 6
1601 20 1 6
1601 21 1 6
1601 22 1 6
1601 23 1 6
1601 24 1 6
1601 25 1 6
1601 26 1 6
1601 27 1 6
1601 28 1 6
1601 44 1 6
1601 45 1 6
1601 46 1 6
1601 47 1 6
1601 48 1 6
I was trying something like this...
select;
when (WC = 1101) group = 1 subgroup=1;
when (WC = 1201) group = 1 subgroup=2;
when (WC = 1301) group = 1 subgroup=3;
when (WC = 1401) group = 1 subgroup=4;
when (WC = 1501) group = 1 subgroup=5;
when (WC = 1601) group = 1 subgroup=6;
when (WC = 1102) group = 2 subgroup=1;
when (WC = 1202) group = 2 subgroup=2;
when (WC = 1302) group = 2 subgroup=3;
when (WC = 1402) group = 2 subgroup=4;
.
.
.
when (WC = 1617) group = 18 subgroup=5;
when (WC = 1618) group = 18 subgroup=6;
when (WC = 1119) group = 1 subgroup=1;
otherwise group = 20 subgroup=1;
end;
This is seriously long, tedious and confusing. I am sure there are better and short ways of doing it.
Please help.
As Joe and Keith suggested, I am adding this explanation.
WC in the table as the appear..
WC1 WC2 WC3 WC4 WC5 WC6 Group
1101 1201 1301 1401 1501 1601 1
1102 1202 1302 1402 1502 1602 2
1103 1203 1303 1403 1503 1603 3
.
.
.
WC ASN Group SubGroup
1101 0 1 1 (because last two digits are 01 and 2nd degit is 1)
.
.
1206 1 6 2
.
.
1201 2 1 2
.
.
1213 3 13 2
.
.
1610 4 10 6
Seems like a case for substr to me.
group = substr(wc,1,1);
subgroup = substr(wc,2,1);
Or whatever your rule is. If your rule is more complicated than that, explain the rule.

Formatting MMSS in SAS

DATA USCFootballStatsProject;
INPUT OPPONENT $ 1-12 WINORLOSS 13-14 TIMEOFPOSSESSION 15-19 THIRDDOWNCONVERSIONPERCENTAGE 21-26 RUSHINGYARDS;
FORMAT TIMEOFPOSSESSION MMSS.;
CARDS;
UCF 1 24:30 0.125 32
GEORGIA 0 26:59 0.333 43
ALABAMA 0 22:53 0.333 71
TROY 1 31:47 0.333 116
AUBURN 0 28:51 0.167 70
KENTUCKY 1 29:11 0.636 139
VANDERBILT 1 24:50 0.333 132
TENNESSEE 1 32:08 0.353 65
ARKANSAS 1 27:53 0.429 45
FLORIDA 1 25:50 0.300 120
CLEMSON 0 28:12 0.250 167
MISSOURI 0 31:19 0.316 142
MISSSTATE 1 32:39 0.231 81
GEORGIA 0 29:08 0.364 35
WOFFORD 1 24:21 0.417 165
FLOATLANTIC 1 32:39 0.429 200
AUBURN 0 30:20 0.462 109
KENTUCKY 1 31:07 0.538 190
VANDERBILT 1 30:54 0.727 194
TENNESSEE 0 31:33 0.417 165
ARKANSAS 0 23:06 0.333 51
FLORIDA 0 30:31 0.500 135
MTENNESSEE 1 28:17 0.778 154
CLEMSON 1 32:57 0.600 208
HOUSTON 1 33:19 0.500 189
LOUISLFY 1 31:38 0.538 195
GEORGIA 1 30:34 0.091 140
SCSTATE 1 26:53 0.364 223
LSU 0 27:09 0.500 17
MISSSTATE 1 29:39 0.500 123
KENTUCKY 1 29:57 0.462 86
NCAROLINA 1 25:56 0.083 110
VANDERBILT 0 26:36 0.083 26
TENNESSEE 0 36:25 0.438 39
ARKANSAS 0 30:55 0.400 125
FLORIDA 0 25:39 0.167 68
CLEMSON 0 21:23 0.375 80
NCSTATE 1 34:15 0.357 171
VANDERBILT 0 29:58 0.400 92
GEORGIA 0 24:47 0.417 18
WOFFORD 1 31:07 0.636 172
UAB 1 34:59 0.500 158
OLEMISS 1 31:21 0.538 78
KENTUCKY 1 30:43 0.471 74
LSU 0 25:28 0.111 39
TENNESSEE 1 32:30 0.500 101
ARKANSAS 1 29:06 0.417 132
FLORIDA 0 29:50 0.067 53
CLEMSON 0 27:13 0.471 92
IOWA 0 24:06 0.455 43
NCSTATE 1 32:25 0.333 108
GEORGIA 0 34:21 0.353 114
FLOATLANTIC 1 27:50 0.300 287
OLEMISS 1 33:35 0.375 65
SCSTATE 1 27:13 0.538 213
KENTUCKY 1 29:17 0.500 128
ALABAMA 0 31:43 0.474 64
VANDERBILT 1 32:22 0.375 119
TENNESSEE 0 26:35 0.267 65
ARKANSAS 0 27:37 0.500 53
FLORIDA 0 31:21 0.250 61
CLEMSON 1 36:31 0.375 223
CONN 0 24:32 0.200 76
SOUTHERMISS 1 28:52 0.400 224
GEORGIA 1 35:15 0.643 189
FURMAN 1 33:30 0.600 182
AUBURN 0 28:52 0.500 79
ALABAMA 1 27:33 0.545 110
KENTUCKY 0 25:13 0.500 90
VANDERBILT 1 37:21 0.529 129
TENNESSEE 1 28:28 0.538 212
ARKANSAS 0 25:40 0.417 105
FLORIDA 1 40:46 0.500 239
TROY 1 30:49 0.455 212
CLEMSON 1 34:43 0.333 95
AUBURN 0 28:59 0.417 156
FLORIDAST 0 26:32 0.500 139
ECU 1 30:02 0.500 220
GEORGIA 1 29:02 0.286 253
NAVY 1 31:15 0.556 254
VANDERBILT 1 34:08 0.526 131
AUBURN 0 24:13 0.200 129
KENTUCKY 1 38:37 0.500 288
MISSSTATE 1 32:34 0.200 110
TENNESSEE 1 36:18 0.556 231
ARKANSAS 0 29:05 0.667 79
FLORIDA 1 32:04 0.214 215
CITADEL 1 26:44 0.667 256
CLEMSON 1 37:17 0.444 210
NEBRASKA 1 29:11 0.308 121
VANDERBILT 1 31:36 0.250 205
ECU 1 28:42 0.533 131
UAB 1 23:47 0.500 179
MISSOURI 1 32:33 0.500 144
KENTUCKY 1 31:17 0.500 200
GEORGIA 1 33:13 0.417 230
LSU 0 23:03 0.231 34
FLORIDA 0 24:32 0.214 36
TENNESSEE 1 35:22 0.400 147
ARKANSAS 1 31:45 0.538 104
WOFFORD 1 29:11 0.538 171
CLEMSON 1 39:58 0.524 134
MICHIGAN 1 22:01 0.300 85
NCAROLINA 1 29:33 0.357 228
GEORGIA 0 24:58 0.455 226
VANDERBILT 1 37:10 0.647 220
UCF 1 30:49 0.556 225
KENTUCKY 1 29:45 0.556 178
ARKANSAS 1 43:25 0.563 277
TENNESSEE 0 27:38 0.286 218
MISSOURI 1 34:27 0.294 75
MISSSTATE 1 26:14 0.091 160
FLORIDA 1 28:59 0.313 164
CCAROLINA 1 34:31 0.556 352
CLEMSON 1 38:09 0.526 140
WISCONSIN 1 30:34 0.444 117
TAMU 0 22:22 0.222 67
ECU 1 36:19 0.538 175
GEORGIA 1 31:27 0.222 176
VANDERBILT 1 31:02 0.583 212
MISSOURI 0 35:55 0.381 119
KENTUCKY 0 34:20 0.600 282
FURMAN 1 29:37 0.333 267
AUBURN 0 33:31 0.429 119
TENNESSEE 0 30:13 0.462 248
FLORIDA 1 31:30 0.471 95
SALABAMA 1 24:12 0.400 210
CLEMSON 0 31:20 0.400 63
MIAMI 1 28:50 0.467 60
;
PROC PRINT DATA = USCFootballStatsProject;
RUN;
As it currently stands, it is not printing any of the times in the column for TIMEOFPOSSESSION, but it is printing everything else fine. Any ideas as to why it isn't printing that column? I'm using FORMAT TIMEOFPOSSESSION MMSS.;
I plan on doing a logistic regression with the WINORLOSS being the response variable, but I want to make sure that the data is being read in correctly.
Thanks.
Because you told it to read columns 15 to 19 as a number, but the value has a colon in it. You need to either use formatted input.
input ... #15 TIMEOFPOSSESSION STIMER5. ... ;
Or use list mode input with an attached INFORMAT.
informat TIMEOFPOSSESSION stimer5.;
input ... #15 TIMEOFPOSSESSION ... ;

Three threads are created that instantiate the same class. But shortly only one thread continues to run?

Three threads are created that instantiate the same class.
Each thread has a different delay.
But after some time only 1 thread executes. ???
GenNum1 = new CGenerateNumbers();
GenNum1->m_threadNumber = 1;
GenNum1->m_usec = 10000;
connect(GenNum1, SIGNAL(OnIndexReady()), this, SLOT(hGenNumOnIndexReady1()));
QThread *tGenNum1 = new QThread;
GenNum1->moveToThread(tGenNum1);
GenNum1->connect(tGenNum1, SIGNAL(started()), GenNum1, SLOT(Started()), Qt::DirectConnection);
tGenNum1->start();
GenNum2 = new CGenerateNumbers();
GenNum2->m_threadNumber = 2;
GenNum2->m_usec = 15000;
connect(GenNum2, SIGNAL(OnIndexReady()), this, SLOT(hGenNumOnIndexReady2()));
QThread *tGenNum2 = new QThread;
GenNum2->moveToThread(tGenNum2);
GenNum2->connect(tGenNum2, SIGNAL(started()), GenNum2, SLOT(Started()), Qt::DirectConnection);
tGenNum2->start();
GenNum3 = new CGenerateNumbers();
GenNum3->m_threadNumber = 3;
GenNum3->m_usec = 20000;
connect(GenNum3, SIGNAL(OnIndexReady()), this, SLOT(hGenNumOnIndexReady3()));
QThread *tGenNum3 = new QThread;
GenNum3->moveToThread(tGenNum3);
GenNum3->connect(tGenNum3, SIGNAL(started()), GenNum3, SLOT(Started()), Qt::DirectConnection);
tGenNum3->start();
//this is what each thread calls to:
void CGenerateNumbers::Started()
{
int i = 0;
int c = 0;
char v;
while(1){
usleep(m_usec);
v = (i % 26) + 65;
for(int j = 0; j < 11; j++){
mem->m_cmMessageWrite.cMessage[j] = v;
}
mem->m_cmMessageWrite.cMessage[0] = m_threadNumber + 48;
mem->m_cmMessageWrite.cMessage[1] = 32;
mem->Write();
m_i = i;
emit OnIndexReady();
i++;
}
}
index index thread message
0 0 1 AAAAAAAAA
1 1 2 AAAAAAAAA
2 2 3 AAAAAAAAA
3 3 1 BBBBBBBBB
4 4 1 CCCCCCCCC
5 5 2 BBBBBBBBB
6 6 3 BBBBBBBBB
7 7 1 DDDDDDDDD
8 8 2 CCCCCCCCC
9 9 1 EEEEEEEEE
10 10 3 CCCCCCCCC
11 11 1 FFFFFFFFF
12 12 2 DDDDDDDDD
13 13 1 GGGGGGGGG
14 14 2 EEEEEEEEE
15 15 3 DDDDDDDDD
16 16 1 HHHHHHHHH
17 17 1 IIIIIIIII
18 18 2 FFFFFFFFF
19 19 3 EEEEEEEEE
20 20 1 JJJJJJJJJ
21 21 2 GGGGGGGGG
22 22 1 KKKKKKKKK
23 23 3 FFFFFFFFF
24 24 2 HHHHHHHHH
25 25 1 LLLLLLLLL
26 26 2 IIIIIIIII
27 27 3 GGGGGGGGG
28 28 1 MMMMMMMMM
29 29 1 NNNNNNNNN
30 30 2 JJJJJJJJJ
31 31 3 HHHHHHHHH
32 32 1 OOOOOOOOO
33 33 2 KKKKKKKKK
34 34 1 PPPPPPPPP
35 35 3 IIIIIIIII
36 36 1 QQQQQQQQQ
37 37 2 LLLLLLLLL
38 38 1 RRRRRRRRR
39 39 2 MMMMMMMMM
40 40 1 SSSSSSSSS
41 41 2 NNNNNNNNN
42 42 1 TTTTTTTTT
43 43 1 UUUUUUUUU
44 44 1 VVVVVVVVV
45 45 1 WWWWWWWWW
46 46 2 OOOOOOOOO
47 47 1 XXXXXXXXX
48 48 2 PPPPPPPPP
49 49 1 YYYYYYYYY
50 50 2 QQQQQQQQQ
51 51 1 ZZZZZZZZZ
52 52 1 AAAAAAAAA
53 53 2 RRRRRRRRR
54 54 1 BBBBBBBBB
55 55 2 SSSSSSSSS
56 56 1 CCCCCCCCC
57 57 1 DDDDDDDDD
58 58 2 TTTTTTTTT
59 59 1 EEEEEEEEE
60 60 2 UUUUUUUUU
61 61 1 FFFFFFFFF
62 62 1 GGGGGGGGG
63 63 2 VVVVVVVVV
64 64 1 HHHHHHHHH
65 65 2 WWWWWWWWW
66 66 1 IIIIIIIII
67 67 1 JJJJJJJJJ
68 68 2 XXXXXXXXX
69 69 1 KKKKKKKKK
70 70 2 YYYYYYYYY
71 71 1 LLLLLLLLL
72 72 1 MMMMMMMMM
73 73 2 ZZZZZZZZZ
74 74 1 NNNNNNNNN
75 75 2 AAAAAAAAA
76 76 1 OOOOOOOOO
77 77 1 PPPPPPPPP
78 78 2 BBBBBBBBB
79 79 1 QQQQQQQQQ
80 80 2 CCCCCCCCC
81 81 1 RRRRRRRRR
82 82 1 SSSSSSSSS
83 83 2 DDDDDDDDD
84 84 1 TTTTTTTTT
85 85 2 EEEEEEEEE
86 86 1 UUUUUUUUU
87 87 1 VVVVVVVVV
88 88 2 FFFFFFFFF
89 89 1 WWWWWWWWW
90 90 2 GGGGGGGGG
91 91 1 XXXXXXXXX
92 92 1 YYYYYYYYY
93 93 2 HHHHHHHHH
94 94 1 ZZZZZZZZZ
95 95 2 IIIIIIIII
96 96 1 AAAAAAAAA
97 97 1 BBBBBBBBB
98 98 2 JJJJJJJJJ
99 99 1 CCCCCCCCC
100 100 2 KKKKKKKKK
101 101 1 DDDDDDDDD
102 102 2 LLLLLLLLL
103 103 1 EEEEEEEEE
104 104 2 MMMMMMMMM
105 105 1 FFFFFFFFF
106 106 1 GGGGGGGGG
107 107 2 NNNNNNNNN
108 108 1 HHHHHHHHH
109 109 2 OOOOOOOOO
110 110 1 IIIIIIIII
111 111 1 JJJJJJJJJ
112 112 2 PPPPPPPPP
113 113 1 KKKKKKKKK
114 114 2 QQQQQQQQQ
115 115 1 LLLLLLLLL
116 116 1 MMMMMMMMM
117 117 2 RRRRRRRRR
118 118 1 NNNNNNNNN
119 119 2 SSSSSSSSS
120 120 1 OOOOOOOOO
121 121 1 PPPPPPPPP
122 122 2 TTTTTTTTT
123 123 1 QQQQQQQQQ
124 124 2 UUUUUUUUU
125 125 1 RRRRRRRRR
126 126 2 VVVVVVVVV
127 127 1 SSSSSSSSS
128 128 1 TTTTTTTTT
129 129 2 WWWWWWWWW
130 130 1 UUUUUUUUU
131 131 2 XXXXXXXXX
132 132 1 VVVVVVVVV
133 133 2 YYYYYYYYY
134 134 1 WWWWWWWWW
135 135 1 XXXXXXXXX
136 136 2 ZZZZZZZZZ
137 137 1 YYYYYYYYY
138 138 2 AAAAAAAAA
139 139 1 ZZZZZZZZZ
140 140 1 AAAAAAAAA
141 141 2 BBBBBBBBB
142 142 1 BBBBBBBBB
143 143 2 CCCCCCCCC
144 144 1 CCCCCCCCC
145 145 1 DDDDDDDDD
146 146 2 DDDDDDDDD
147 147 1 EEEEEEEEE
148 148 2 EEEEEEEEE
149 149 1 FFFFFFFFF
150 150 1 GGGGGGGGG
151 151 2 FFFFFFFFF
152 152 1 HHHHHHHHH
153 153 2 GGGGGGGGG
154 154 1 IIIIIIIII
155 155 2 HHHHHHHHH
156 156 1 JJJJJJJJJ
157 157 1 KKKKKKKKK
158 158 2 IIIIIIIII
159 159 1 LLLLLLLLL
160 160 2 JJJJJJJJJ
161 161 1 MMMMMMMMM
162 162 1 NNNNNNNNN
163 163 2 KKKKKKKKK
164 164 1 OOOOOOOOO
165 165 2 LLLLLLLLL
166 166 1 PPPPPPPPP
167 167 1 QQQQQQQQQ
168 168 2 MMMMMMMMM
169 169 1 RRRRRRRRR
170 170 2 NNNNNNNNN
171 171 1 SSSSSSSSS
172 172 1 TTTTTTTTT
173 173 2 OOOOOOOOO
174 174 1 UUUUUUUUU
175 175 2 PPPPPPPPP
176 176 1 VVVVVVVVV
177 177 2 QQQQQQQQQ
178 178 1 WWWWWWWWW
179 179 1 XXXXXXXXX
180 180 2 RRRRRRRRR
181 181 1 YYYYYYYYY
182 182 2 SSSSSSSSS
183 183 1 ZZZZZZZZZ
184 184 1 AAAAAAAAA
185 185 2 TTTTTTTTT
186 186 1 BBBBBBBBB
187 187 2 UUUUUUUUU
188 188 1 CCCCCCCCC
189 189 1 DDDDDDDDD
190 190 2 VVVVVVVVV
191 191 2 WWWWWWWWW
192 192 1 EEEEEEEEE
193 193 1 FFFFFFFFF
194 194 2 XXXXXXXXX
195 195 1 GGGGGGGGG
196 196 2 YYYYYYYYY
197 197 1 HHHHHHHHH
198 198 2 ZZZZZZZZZ
199 199 1 IIIIIIIII
200 200 1 JJJJJJJJJ
201 201 2 AAAAAAAAA
202 202 1 KKKKKKKKK
203 203 2 BBBBBBBBB
204 204 1 LLLLLLLLL
205 205 1 MMMMMMMMM
206 206 2 CCCCCCCCC
207 207 1 NNNNNNNNN
208 208 2 DDDDDDDDD
209 209 1 OOOOOOOOO
210 210 2 EEEEEEEEE
211 211 2 FFFFFFFFF
212 212 1 PPPPPPPPP
213 213 1 QQQQQQQQQ
214 214 1 RRRRRRRRR
215 215 1 SSSSSSSSS
216 216 1 TTTTTTTTT
217 217 1 UUUUUUUUU
218 218 1 VVVVVVVVV
219 219 1 WWWWWWWWW
220 220 1 XXXXXXXXX
221 221 1 YYYYYYYYY
222 222 1 ZZZZZZZZZ
223 223 1 AAAAAAAAA
224 224 1 BBBBBBBBB
225 225 1 CCCCCCCCC
226 226 1 DDDDDDDDD
227 227 1 EEEEEEEEE
228 228 1 FFFFFFFFF
229 229 1 GGGGGGGGG
230 230 1 HHHHHHHHH
231 231 1 IIIIIIIII
232 232 1 JJJJJJJJJ
233 233 1 KKKKKKKKK
234 234 1 LLLLLLLLL
235 235 1 MMMMMMMMM
236 236 1 NNNNNNNNN
237 237 1 OOOOOOOOO
238 238 1 PPPPPPPPP
239 239 1 QQQQQQQQQ
240 240 1 RRRRRRRRR
241 241 1 SSSSSSSSS
242 242 1 TTTTTTTTT
243 243 1 UUUUUUUUU
There are two issues:
You do not want to tell connect to use a direct connection, just leave that off, the default will be properly chosen for you. In this case, the two QObjects that you connect between live in different threads. The QThread object lives in the current thread - it's not a thread, it's a controller. The CGenerateNumbers instance lives in the new thread. So you do not want a direct connection, it must be a queued connection!
In my applications I'm using a custom build of Qt and I've done a global search-replace of QThread with QThreadController. The latter is a more descriptive and less misleading name. There is no Qt class that is really equivalent to a thread per se.
The mem->Write(); call may be blocking. It would not cause a thread to "die", but merely to block. If it's a deadlock, as I presume it might well be, the thread is stopped forever (deadlocked). It's not dead, only appears to be.
The code below demonstrates a SSCCE that works fine on both Qt 5 and Qt 4. You'd need to reduce your code to a similarly simple example, my bet is that your problem is with code that is NOT shown. Perhaps in the process of reduction you'll figure it out.
# threads-18369174.pro
QT += core
QT -= gui
TARGET = threads-18369174
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
.
// main.cpp
#include <QCoreApplication>
#include <QObjectList>
#include <QList>
#include <QThread>
#include <iostream>
const int cycleCount = 500; //!< number of cycles to run at, set to 0 to run forever
const int threadCount = 5; //!< number of threads to create
class Object : public QObject
{
Q_OBJECT
int m_threadNumber;
int m_delayUs;
volatile bool m_active;
public:
explicit Object(int delayUs, int no) : m_threadNumber(no), m_delayUs(delayUs) {}
Q_SIGNAL void indexReady(int);
Q_SLOT void stop() { m_active = false; }
Q_SLOT void start()
{
m_active = true;
while (m_active) {
usleep(m_delayUs);
emit indexReady(m_threadNumber);
}
}
};
class Consumer : public QObject
{
Q_OBJECT
QList<Object*> m_objects;
QList<QThread*> m_threads;
int m_threadCount; //!< number of active threads in m_threads
int m_count;
public:
Consumer() : m_count(0) {}
void addObject(Object * o) { m_objects << o; }
void addThread(QThread * t) {
m_threads << t;
m_threadCount ++;
connect(t, SIGNAL(finished()), SLOT(done()));
connect(t, SIGNAL(terminated()), SLOT(done()));
}
Q_SLOT void ready(int n) {
std::cout << "<" << m_count++ << ":" << n << ">" << std::endl;
if (m_count == cycleCount) {
foreach (Object * o, m_objects) o->stop();
foreach (QThread * t, m_threads) t->wait();
}
}
Q_SLOT void done() {
QThread * t = qobject_cast<QThread*>(sender());
int i = m_threads.indexOf(t);
if (t) t->deleteLater();
if (i>=0) {
std::cout << "\nThread " << i << " is done." << std::endl;
m_threadCount --;
}
if (! m_threadCount) qApp->quit();
}
};
int main(int argc, char *argv[])
{
Consumer c;
QObjectList l;
QCoreApplication a(argc, argv);
std::cout << "Running under Qt version " << qVersion() << std::endl;
for (int i = 0; i < threadCount; ++i) {
Object * o = new Object(10000 + 5000*i, i+1);
QThread * t = new QThread;
c.addObject(o);
c.addThread(t);
o->moveToThread(t);
o->connect(t, SIGNAL(started()), SLOT(start()));
c.connect(o, SIGNAL(indexReady(int)), SLOT(ready(int)));
t->start();
t->exit();
l << o;
}
return a.exec();
}
#include "main.moc"
For a given time period, thread 1 produces the most messages as it has the smallest sleep.
If your message receiver reads messages at a slower rate than the sending rate, then above output is expected as there were most messages from thread 1 and least messages from thread 3 in the message queue.