Pine Script - ternary operator in "display" parameter in plot call causes invalid argument error - pine-script-v5

//#version=5
strategy(title='Test',overlay=true)
i_hide_eq = input.bool(true, title='Hide Equity Curve')
plot(strategy.equity, display=i_hide_eq ? display.none : display.all)
plot(series=1.5, color=color.red, style=plot.style_linebr, title='Test Point')
Why does this code cause following error? I am using "Possible values".
Invalid argument 'display' in 'plot' call. Possible values: [display.none, display.all]

Make it in this way.
//#version=5
strategy(title='Test',overlay=true)
i_hide_eq = input.bool(true, title='Hide Equity Curve')
plot(i_hide_eq == true ? strategy.equity : na)
plot(series=1.5, color=color.red, style=plot.style_linebr, title='Test Point')

Related

How to Enter Text and Db value in a ternary operator in certificate.pug file

I need Text and value in same line in certificate.pug file as a ternary operator
I tried
td.border-top-1.border-bottom-0(class="wrapword" colspan='15')
b
i= (10 == '10' ? +'Text Welds'+ thicknessRQValueMin - buttThicknessRQValueMax; +'Fillet Welds'+ filletThicknessRQValueMin - filletThicknessRQValueMax : +'Butt Welds'+ buttThicknessRQValueMin - buttThicknessRQValueMax)
I expect the coorect line

Talos --> TypeError: __init__() got an unexpected keyword argument 'grid_downsample'

I am trying to run a hyperparameters optimization with Talos. As I have a lot of parameters to test, I want to use a 'grid_downsample' argument that will select 30% of all possible hyperparameters combinations. However when I run my code I get: TypeError: __init__() got an unexpected keyword argument 'grid_downsample'
I tested the code below without the 'grid_downsample' option and with less hyperparameters.
#load data
data = pd.read_csv('data.txt', sep="\t", encoding = "latin1")
# split into input (X) and output (y) variables
Y = np.array(data['Y'])
data_bis = data.drop(['Y'], axis = 1)
X = np.array(data_bis)
p = {'activation':['relu'],
'optimizer': ['Nadam'],
'first_hidden_layer': [12],
'second_hidden_layer': [12],
'batch_size': [20],
'epochs': [10,20],
'dropout_rate':[0.0, 0.2]}
def dnn_model(x_train, y_train, x_val, y_val, params):
model = Sequential()
#input layer
model.add(Dense(params['first_hidden_layer'], input_shape=(1024,)))
model.add(Dropout(params['dropout_rate']))
model.add(Activation(params['activation']))
#hidden layer 2
model.add(Dense(params['second_hidden_layer']))
model.add(Dropout(params['dropout_rate']))
model.add(Activation(params['activation']))
# output layer with one node
model.add(Dense(1))
model.add(Activation(params['activation']))
# Compile model
model.compile(loss='binary_crossentropy', optimizer=params['optimizer'], metrics=['accuracy'])
out = model.fit(x_train, y_train,
batch_size=params['batch_size'],
epochs=params['epochs'],
validation_data=[x_val, y_val],
verbose=0)
return out, model
scan_object = ta.Scan(X, Y, model=dnn_model, params=p, experiment_name="test")
reporting = ta.Reporting(scan_object)
report = reporting.data
report.to_csv('./Random_search/dnn/report_talos.txt', sep = '\t')
This code works well. If I change the scan_object as the end to: scan_object = ta.Scan(X, Y, model=dnn_model, grid_downsample=0.3, params=p, experiment_name="test"), it gives me the error: TypeError: __init__() got an unexpected keyword argument 'grid_downsample' while I was expecting to have the same results format as a normal grid search but with less combinations. What am I missing? Did the name of the argument change? I'm using Talos 0.6.3 in a conda environment.
Thank you!
might be too late for you now but they've switched it to fraction_limit. It would give this for you
scan_object = ta.Scan(X, Y, model=dnn_model, params=p, experiment_name="test", fraction_limit = 0.1)
Sadly, the doc isn't well updated
Check out their examples on GitHub:
https://github.com/autonomio/talos/blob/master/examples/Hyperparameter%20Optimization%20with%20Keras%20for%20the%20Iris%20Prediction.ipynb

In Drools, how to find the keyword with the least number of matches?

I have some tokenized string like this
declare UserAddress
tokens : List
end
and I have a list of recognized tokens like this
rule "Count Frequency of RealTokens occurrence in RealAddresses"
salience -10
when
$token : RealToken();
$count : List() from collect(RealAddress(tokens contains $token.getToken()));
then
modify($token) { setCount($count) };
end
Using drools, how can I determine, which of the tokens in a given UserAddress matches the RealToken with the lowest possible $count value?
I already tried this:
rule "Find the Most Statistically Significant Token for each User Address"
salience -20
$ua : UserAddress();
$ut : String( length() > 0) from $ua.getTokens().subList(1, $ua.getTokens().size());
$rt : RealToken(token == $ut);
not(RealToken(token == $ut && this.count < $rt.count));
then
System.out.println("MSST: " + $ua.toString() + " = " + $rt.toString());
end
But couldn't get past the DRL syntax issue:
java.lang.IllegalArgumentException: Found errors in package builder
[85,1]: [ERR 102] Line 85:1 mismatched input '$ua' in rule "Find the Most Statistically Significant Token for each User Address"
[0,0]: Parser returned a null Package
The error message is quite clear, and when you would have bothered to look at line 85, you would have found that
rule "Find the Most Statistically Significant Token for each User Address"
salience -20
$ua : UserAddress(); ############################### line 85
$ut : String( length() > 0) from $ua.getTokens().subList(1, $ua.getTokens().size());
$rt : RealToken(token == $ut);
there is no keyword when preceding the first pattern.

MATLAB: errorn in butter() command

I wrote the following function:
function [output_signal] = AddDirectivityError (bat_loc_index, butter_deg_vector, sound_matrix)
global chirp_initial_freq ;
global chirp_end_freq;
global sampling_rate;
global num_of_mics;
global sound_signal_length;
for (i=1 : num_of_mics)
normalized_co_freq = (chirp_initial_freq + chirp_end_freq)/ (1.6* sampling_rate);
A=sound_matrix ( i, : ) ;
peak_signal=max(A);
B=find(abs(A)>peak_signal/100);
if (butter_deg_vector(i)==0)
butter_deg_vector(i)=2;
end
[num, den] = butter(butter_deg_vector(i), normalized_co_freq, 'low');// HERE!!!
filtered_signal=filter(num,den, A );
output_signal(i, :)=filtered_signal;
end
This functions runs many-many times without any error. However, when I reach the line: [num, den] = butter ( butter_deg_vector(i), normalized_co_freq, 'low');
And the local variables are: i=3, butter_deg_vector(i)=1, normalized_co_freq=5.625000e-001
MATLAB prompts an error says:
??? Error using ==> buttap Expected N to be integer-valued.
"Error in ==> buttap at 15 validateattributes(n,{'numeric'},{'scalar','integer','positive'},'buttap','N');
Error in ==> butter at 70 [z,p,k] = buttap(n);"
I don't understand why this problem occurs especially in this iteration. Why does this function prompt an error especially in this case?
Try to change the code line for:
[num, den] = butter (round(butter_deg_vector(i)), normalized_co_freq, 'low');

Compile error of the .f source code in gfortran; reading a text file into 2D array

I have a problem with the following source. When it is compiled in gfortran, it does not work properly and then two error message showed up.
How do I solve this problem?
Any comment would be very helpful.
Thanks in advance.
program driver
integer i,ln,n,e,count,x,a,b,total
character driverid*12,var*12,ch*12
parameter (n=720321)
c parameter (n=55062)
dimension var(n),a(n),b(n)
write(*,*) 'input run id(text)'
read(*,55) driverid
55 format(a)
ln=index(driverid,' ')-1
open(6,file=driverid(1:ln)//'.out',form='formatted'
+,status='unknown')
open(1,file=driverid(1:ln)//'.txt',status='old')
do i=1,2
read(1,*)
end do
read(1,*) (var(i),i=1,n)
close(1)
total=0
count=1
do i=1,n
b(i)=0
read(var(i),*,iostat=e) x
if (e .eq. 0) then
a(count)=x
count=count+1
else
ln=index(var(i),' ')-1
if (var(i)(ln-1:ln-1) .eq. 'r') then
var(i)=var(i)(1:ln-2)
else
var(i)=var(i)(1:ln-1)
end if
read(var(i),'(i)') b(count-1)
end if
end do
do i=1,count
total=total+1+b(i)
end do
do i=1,total
write(6,'(10i)') (a(i),j=1,b(i))
end do
close(6)
end
Error message is following as
$ gfortran driver.f
driver.f:43.23:
read(var(i),'(i)') b(count-1)
1
Error: Nonnegative width required in format string at (1)
driver.f:53.20:
write(6,'(10i)') (a(i),j=1,b(i))
1
Error: Nonnegative width required in format string at (1)
When specifying a format for an integer, you must specify the field width. If you want to have it flexible, you can set it to zero:
write(6, "(10I0)") ...