Conditional breakpoint not honored - pydev

I have the following snippet in a method.
cnt = chunk.count('abc')
x = 1
I set a conditional breakpoint on the second statement with the condition cnt > 0. However, the breakpoint happens when the value of cnt is zero. How do I get the breakpoint to happen only when cnt > 0?
The code is in a multiprocessing process.

This is a known bug: https://www.brainwy.com/tracker/PyDev/895
I hope to have this fixed for PyDev 6.3.3.

Related

PL/SQL How to implement conditional select

I have a small problem which I believed I could solve simply, it turns out I'm not able to figure out.
I have following query:
SELECT custom_field
INTO v_start_of_invoice
FROM BILL
WHERE BIMA_TRACKING_ID = v_previous_BIMAtrackingID
AND BSCO_CODE_ID = 'PRPAYMENT'
AND PREP_SEQ_NUM = 0
AND ITEM_CAT_CODE_ID = 1
AND PARTITION_KEY = v_prev_partition
AND SUBPARTITION_KEY = v_prev_subpartition;
What I would like to achieve here is to give to variable v_start_of_invoice the value "0" if one or all the where condition are not met.
In simple word I don't want the script to fail but I want the variable either to be set with some value if all the where conditions are matched, otherwise I want to assign the value 0.
I'm sure there are quite a few ways but I need to check what could be the best way to achieve that.
Many Thks in advance
M.
You seem to have a misunderstanding of what the exception block actually does. First off you cannot avoid the exception. If you use "select into" the query is successful only when exactly 1 row is returned. Otherwise PLSQL will internally raise the NO_DATA_FOUND when the query returns 0 rows, and TOO_MANY_ROWS when it returns more then 1 row. The exception block tells PLSQL what to do when an error is generated. Basically the exception block tells what action to take on specific errors and whether to continue error processing or discard the error. (Check the RAISE and RAISE_APPLICATION_ERROR statements.)
Keep in mind that blocks can be nested. With this in mind and in context of a outer block the solution offered by #are is exactly what you want. The structure becomes:
Begin
.
.
.
begin
place #are's code here.
end ;
-- Continue your code here: The Error has been handled and execution continues as though the exception never happened.
.
.
.
end;
As far as the "NVL(v_start_of_invoice, 0);" it's a function that will return 0 if v_start_of_invoice is NULL and v_start_of_invoice otherwise. Note the value of INTO variables is not it the select generates an error unless you set it in the exception block.
begin
SELECT custom_field
INTO v_start_of_invoice
FROM BILL
WHERE BIMA_TRACKING_ID = v_previous_BIMAtrackingID
AND BSCO_CODE_ID = 'PRPAYMENT'
AND PREP_SEQ_NUM = 0
AND ITEM_CAT_CODE_ID = 1
AND PARTITION_KEY = v_prev_partition
AND SUBPARTITION_KEY = v_prev_subpartition;
exception WHEN NO_DATA_FOUND THEN
v_start_of_invoice := 0;
end;

Transform fortran code to matlab

How do i tranform this code below to matlab? I got confused on goto statement.
do 57 i=1,10
statement 1
if(k .eq. nx) then
statement 2
go to 58
end if
57 continue
statement 3
58 continue
Using GOTO command is not considered as a good procedural programming.
Use the following program instead:
i=1;
t=true;
while (i<=10)&&t
statement1;
t=k~=nx;
i=i+1;
end
if t
statement2;
else
statement3;
end
This Fortran Snippet has a very bad code-smell to it.
But here are a few things:
true here seems to be a variable. The correct value for true in Fortran is .TRUE. (or .true.). Assuming that that variable is always .TRUE., then the code can be rewritten very easily:
statement 1
statement 2
And that's it. Your code would immediately jump out of the loop and over statement 3, so each of the statements would only be executed once.
But assuming that true is some variable or expression that has to be re-evaluated in each iteration of the loop, this is a better way:
do i = 1, 10
statement 1
if (true) exit
end do
if (true) then
statement 2
else
statement 3
end if
Now this still assumes that true is a static expression, that is that it won't change it's value between calls.

Constraint gives a warning on ranges are not relevant

the following code creates a warning on DEPR_NEG_OR_LARGE_SELECT_WEIGHT:
keep soft MyVar == select {
0xffffffffff: 0;
10: [1..10];
10: [11..20];
};
keep MyVar != 0;
i would expect the check to consider only the relevant ranges...
0xffffffffff is not a legal syntax of a select weight. Only values between 0 and MAX_INT are valid.
The tool simply protects you from illegal expressions. Just as you get a load/compile time error if you write any other illegal code. It doesn't try to understand the deeper meaning, or whether the code is at all called.
This should be enough for your needs.
keep soft MyVar == select {
1: [1..10];
1: [11..20];
};
keep MyVar != 0;
keep soft MyVar in [1..20]; // This is also enough in place of weighted random constraint.

use debugger in matlab

i want to debug following simplest code in matlab and clarify why it executes always if statement
function testfile(x)
if 3<x<6
disp('in the middle of range');
else
disp('out of range');
end
end
i have used following code for debugger
echo testfile on
testfile(-2)
in the middle of range
testfile(6)
in the middle of range
why it does not execute else statement?i have used following code as a test
5<4<8
ans =
1
so does it mean that writing if statement in this style is wrong?a i understood it is same as if 5<4 || 4<8?then it makes clear for me why it executes only if statement and never reaches to else
5<4<8 is evaluated as (5<4)<8. If we resolve the expression in the parentheses first, we have 0<8, which is true. Test with 5<4==0, which evaluates to true.
What you want to do is check whether x is both bigger than 3 and smaller than 6, i.e.
3<x && x<6

'Undefined function or variable' in Matlab

Here is my code:
function [im,sindx,end1]=alln(im,i,j,secret,sindx,end1)
slen=length(secret);
p=im(i,j);
neigh= [im(i-1,j) im(i+1,j) im(i,j-1) im(i,j+1) im(i-1,j-1) im(i+1,j-1) im(i-1,j+1) im(i+1,j+1)];
minpix = min (neigh)
maxpix = max (neigh)
if minpix < p < maxpix
lowlim = minpix+1;
highlim = maxpix-1;
range = highlim-lowlim+1;
nbits=floor(log2(abs(range)));
if sindx+nbits-1>slen
end1=1;
return
end
for k=1:nbits
bin(k)=secret(sindx+k-1);
end
b = bin2dec(bin);
newvalue1 = abs (minpix + b);
newvalue2 = abs (maxpix - b);
if abs(p-newvalue1)<= abs(p-newvalue2)
im(i,j) = newvalue1;
else
im(i,j) = newvalue2;
end
sindx=sindx+nbits;
end
end
My main program calls this function. When I run the program, I get the following error message:
??? Undefined function or variable "bin".
Error in ==> alln at 34
b = bin2dec(bin);
I know there are many experts for whom this is not a problem at all. I am new to MATLAB. Please guys, show me the way, which type of modification in the code can overcome this problem?
First of all, are there some lines missing from the file? Perhaps you've stripped some comments from the top? Because the error message says that
b = bin2dec(bin);
is line 34, but it's line 22 in the code you present.
OK, that aside...
The error message says that 'bin' isn't defined, but I see that it's being set on the line...
bin(k)=secret(sindx+k-1);
That suggests to me that THAT line isn't being run.
I see that that bin = ... line is inside of a 'for' loop, so I suspect that the for loop is run zero times, meaning that 'bin' never gets defined. What is nbits? Is it 1, or perhaps less than 1? THAT would prevent the loop from running at all.
Try removing the semicolon from the end of the
nbits=floor(log2(abs(range)));
line and run your code again.
Leaving off the semicolon will force the value of nbits to be printed in the Command Window. I bet you'll find that it's 1 or less. If that's the case, then start looking at HOW nbits is calculated, and I bet you'll find the problem.
At what input arguments to the function alln, are you getting the error?
Lets suppose that nbits is 0, then the following loop will not run:
for k=1:nbits
bin(k)=secret(sindx+k-1);
end
So, bin will be undefined. So, the error happens. This is one of the cases where the error can happen. There are many such possible cases.