Issue with rounding number in robotframework - robotframework

I have problem with rounding number with 500. I am giving my example below and want to see how i can resolve this problem.
example:
Here i am calculating based on values from application:
{expectedResults} = 2242.31
{income} = 7166.67
${expectedResults}= Evaluate (${expectedResults} / ${income})*100
${expectedResults}= Convert To Number ${expectedResults} 2
my results would be like :31.29%
but if i get results like 30.0001 then i am getting my value as 30.0 instead of 30.00. I wanted to get the value as 30.00 but not able to find solution. Can any one give me the solution to this problem? Thank you in advance.

If you're already using evaluate - just use it a bit more.
${expectedResults}= Evaluate "%.2f" % ${expectedResults}
Full solution:
*** Testcases ***
Hello Computation
${expectedResults}= Evaluate (${expectedResults} / ${income})*100
${expectedResults}= Convert To Number ${expectedResults} 2
${expectedResults}= Evaluate "%.2f" % ${expectedResults}
Log ${expectedResults}
Log to Console ${expectedResults}
*** Variables ***
${expectedResults} 2242.31
${income} 7166.67

Related

Template keywords can't handle line break in RF 3.2.1

This test case if working fine in Robot Framework 3.1.2 but in 3.2.1 I'm getting error message:
Setting 'Template' accepts only one value, got 2.
I can't see that there is any updates to the documentation that explains this. Any ideas?
*** Test Cases ***
Test Case
[Template] The result of ${calculation}
... should be ${expected}
1 + 1 2
2 + 2 4
*** Keywords ***
The result of ${calculation} should be ${expected}
${result} = Evaluate ${calculation}
Should Be Equal As Integers ${result} ${expected}
The ... marks an argument boundary. What you did is exactly the same as this:
[Template] The result of ${calculation} should be ${expected}
Like the error says, the [Template] setting only accepts a single argument but you're passing two. You cannot define the keyword on multiple lines.
It appears that the old (pre 3.2) parser may have been a bit lax and allowed you to split the template keyword on multiple lines. The new parser doesn't allow that.

Is it possible to give arguments inside variables in robot framework?

Library REST ${base_url}
*** Keywords ***
Get Requests
GET ${rest_of_the_url}
Output response body
*** Test Cases ***
Do some searching
Get Requests
*** Variables ***
${base_url} https://business.com
${rest_of_the_url} /api/${department}/${person_name}
How can I assign values to ${department} and ${person_name}? I don't want to set those inside Variables because then I cannot write multiple scenarios inside one .robot file. Is it possible to do the assignment as arguments?
i do not think there is a way to pass arguments within the variables,
The below section is straight from the documentation of Robotframework,
where you can create Variables inside variables
Variables inside variables
Variables are allowed also inside variables, and when this syntax is used, variables are resolved from the inside out. For example, if you have a variable ${var${x}}, then ${x} is resolved first. If it has the value name, the final value is then the value of the variable ${varname}. There can be several nested variables, but resolving the outermost fails, if any of them does not exist.
In the example below, Do X gets the value ${JOHN HOME} or ${JANE HOME}, depending on if Get Name returns john or jane. If it returns something else, resolving ${${name} HOME} fails.
*** Variables ***
${JOHN HOME} /home/john
${JANE HOME} /home/jane
*** Test Cases ***
Example
${name} = Get Name
Do X ${${name} HOME}
E.g.,
${person_name}= Set Variable Matt
${department}= Set Variable R&D
# then your code continues
${rest_of_the_url} /api/${department}/${person_name}
Set Variable documentation.
Try to see this using the Set Test / Suite / Global Variable keywords here:
https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html
Use "Set Suite Variable" keyword then enter the variables $ {person_name} e
$ {department} inside * Variables * then you should read the value inside the test.

Scilab Error 10000

Hi I am new to scilab and don't have much mathematical background.
I have been following code for another example and am being shown error 10000 for the following code:
function [z]=f(x,y)
z=0.026*(1.0-(y/ym))*y;
endfunction;
ym=12000;
x0=1950;y0=2555;xn=5;h=10;
x=[x0:h:xn];
y=ode("rk",y0,x0,x,f);
disp("x y")
disp("--------")
disp([x'y']);
function z=fe(x)
z=ym/(1-(1-ym/y0)*e^(-k*(t-t0)));
endfunction;
xe=(x0:h/10:xn);
n=length(xe)
for i=1:n
ye(i)=fe(xe(i));
end;
plot (x,y,'ro',xe, ye,'-b');legend ('rk4','Exact',3);
xtitle('solving dy/dx=k(1-y/ym)y','x','y');
I have worked through several other error messages. I am lost and don't know if the problem is in the code or the way I set up the problem. The following is the current error message:
!--error 10000
plot: Wrong size for input argument #2: A non empty matrix expected.
at line 57 of function checkXYPair called by :
at line 235 of function plot called by :
plot (x,y,'ro',xe, ye,'-b');legend ('rk4','Exact',3);
at line 25 of exec file called by :
I would appreciate any help.
Thanks
Start by adding clear as first statement, this will erase all variables before running your function. In the above script you don't declare ye.
Also the statement x=[x0:h:xn]; is strange with those values for x0,h and xn. You are now trying to get a list of x-values starting at 1950 and with positive steps of 10 up until 5 is reached.
I would recommend to try each line and see if the outcome is as expected. You do not need to know everything about the code, but probaly x and y should contain at least some values. The error is telling you that it expected a non-empty matrix for argument 2. This is y, so essentially it is telling you y is empty.

Pari-gp znorder gives compile error

I run this simple query:
for(x=1,10, p=prime(x);a=Mod(100, p);print(a);print(znorder(a)))
This gives me:
Mod(0, 2)
*** at top-level: ...od(100,p);print(a);print(znorder(a));)
*** ^-------------
*** znorder: not an element of (Z/nZ)* in order.
*** Break loop: type 'break' to go back to GP
Replacing p by 3 run normally. What am I doing wrong?
I found it. The problem was where p divides 100, and then it's order is undefined.

glm probit "cannot find valid starting values" error message

I am trying to use R for the first time to do some probit analaysis.
I get the following error:
Error in if (!(validmu(mu) && valideta(eta))) stop("cannot find valid starting values: please specify some", :
missing value where TRUE/FALSE needed
This is the command I am using:
m1=glm(Good~Stg.Days+Dev.Deployments+Check.Ins+NoOfDevelopers,family=poisson(link = "probit"),data=deploy[1:4,])
My data deploy[1:4,] are as loaded in from a CSV file follows:
Good,Application Type,Project,Start Date,End Date,Stg Days,Dev Deployments,Check Ins,NoOfDevelopers
1,DocumentPlatform,ZCP,11/08/2010,11/11/2010,0.6,0,12,4
1,DocumentPlatform,ZCP,11/11/2010,09/12/2010,0.4,0,4,1
0,DocumentPlatform,ZCP,09/12/2010,07/03/2011,10,0,7,3
1,FactsheetPlatform,Process.ARCH,28/06/2010,09/03/2011,7.1,0,18,2
deploy is in reality a much bigger vector than 1:4 I am just using a subset of the data to help determine the problem.
Any ideas what is wrong?
As i commented: Using ?glm I found tha the poisoon family supports the following links: log, identity, and sqrt.
Testing on another link:
test <- data.frame('Good'=c(1,1,0,1),'Stg Days'=c(0.6,0.4,10,7.1),'Dev Deployments'=c(0,0,0,0),'Check Ins'=c(12,4,7,18),'NoOfDevelopers'=c(4,1,3,2))
m1=glm(Good~ . ,family=poisson(link = "log"),data=test)
Gives no errors. So I think your link = "probit" is the problem.

Resources