Retrieving chisel source description inside of treadle - scala

I'm currently working on trying to add coverage to treadle. I was able to do so for the input LoFIRRTL code as follows:
COVERAGE REPORT:
+ circuit Test_1 :
+ module Test_1 :
+ input in$a : UInt<1>
+ input in$b$0 : UInt<2>
+ input in$b$1 : UInt<2>
+ input clock : Clock
+ output io_cov_valid_0 : UInt<1>
+ output io_cov_valid_1 : UInt<1>
+ output out : UInt<2>
+
+ io_cov_valid_0 <= in$a
- io_cov_valid_1 <= mux(in$a, UInt<1>("h0"), UInt<1>("h1"))
+ out <= mux(in$a, in$b$0, in$b$1)
Where + means that the line was covered by a test and - means that it wasn't. The goal would be to map this information to the Chisel source, which would be more useful.
So is there a way to retrieve the chisel source inside of treadle? If not would there be a pre-existing tool allowing one to reconstruct a Chisel description from LoFIRRTL code?

Treadle's symbols have an info field which contains (if present) the source locator that references the chisel source. Muxs do not have source locators but you the symbol on the left hand side would be the closest you can get. Good luck, I'm happy to answer any Treadle internals questions

Related

Name convention error with write to file in Matlab

I'm running into a problem with the following code and writing an excel file name. This code is driven by user defined inputs for location and chemical compound desired. The desired output is a file with the chemical compound and location appended for the name. The problem is that any compound with a . in it errors out. For example, if I want PM2.5 for site Kenny, the file name should be PM2.5 Kenny. The code however is recognizing ".5" as a file extension when this is to be part of the name. Any help how to get around this would be appreciated.
The error this gives is:
Unrecognized file extension '.5 Kenny'. Use the 'FileType' parameter to specify the file type.
j = 1
i = 1
while j <= width(c_locations_of_interest)
while i <= width(c_data_types_of_interest)
Value = c_data_types_of_interest{1,i}
Location = c_locations_of_interest{1,j}
output_excel_file = append(Value,' ',Location)
STATEMENTS
writetable(T, output_excel_file)
i = i + 1
end
i = 1
j = j + 1
end
I was able to reproduce your problem with a crude example. Indeed Matlab complains about file extensions. This is because I believe that you are missing the file extension, in your case '.xlsx'
Using sprintf instead of Append:
value = "PM2.5";
location = " Kenny"
extension = "xlsx";
output_excel_file= sprintf("%s%s.%s", value, location, extension);
writetable(T, output_excel_file);
Hope it is clear
EDIT: Corrected my own variables naming ¬¬

Linear Box Cox Transformation for different parameters for dependent variable/ and independent vaiable

I've been stuck on this for quite some time. Is there a command in R that will create a Box Cox Linear transformation that has a different a parameter for my independent variable and dependent variable?
chicago.reg <- lm(data = Chichagodata, sprice ~ nrooms + lvarea + hage + lsize + ptaxes + sspend + mspend +
medinc + dfcl + particle + sulfur+pctwht+ dfni +aircon+ garage+ nbath + cook+ohare)
Note that I do not want to transform my variables pctwht, dfni, aircon, garage, nbath, cook,and ohare as they are dummy variables.
Thank you if you can provide me insight on this issue.
You should have a look into coxBox and boxcox functions. The former allow to transform individual variables/lists, while the latter works on lm (or aov) objects. In addition you might want to read this and this posts...

How to pass arguments within a function in imageJ macro?

I want to pass in foldername into the run() function and the save() function but they are within quotes and I don't know how to pass the variable names.
I generated the run() and save() function using the record command in imageJ.
The aim of this program to to automate the process of running the plugin "T2 analysis mouse" on multiple folders.
Any other tweets or help will be appreciated.
I found this online source https://imagej.nih.gov/ij/macros/ArgumentPassingDemo.txt but it does not work.
I tried multiple ways inclusing /&foldername/3 T2 &filename/3 T2 /&foldername 3 T2``/&foldername3 T2 /&filename 3 T2``/&filename3 T2
Here is the code I wrote:
function makeT2(foldername)
{
filename = foldername;
print(filename);
run("T2 Analysis mouse", "select=[/Users/Vineeth/Desktop/New stuff Feb 5/&filename 3 T2]
image=[32-bit Signed] width=256 height=128 offset=0 number=902 gap=0 little-endian");
run("Save", "save=[/Users/Vineeth/Desktop/New stuff Feb 5/&foldername3 T2/T2map.tif]");
close();
}
folders = getFileList("/Users/Vineeth/Desktop/New stuff Feb 5/");
for( i = 0; i < folders.length; i++)
{
print(folders[i]);
file = getFileList("/Users/Vineeth/Desktop/New stuff Feb 5/" + folders[i]);
for( j = 0; j < file.length; j++)
{
if(file[j] == "3 T2/")
{
print("made t2 for " + folders[i] + file[j]);
makeT2(folders[i]);
}
}
}
The various print() functions are for testing the code and the code mostly works expect for the makeT2 function.
This is the error:
java.lang.NullPointerException
at T2_Analysis_mouse.getImage(T2_Analysis_mouse.java:183)
at T2_Analysis_mouse.run(T2_Analysis_mouse.java:56)
at ij.IJ.runUserPlugIn(IJ.java:183)
at ij.IJ.runPlugIn(IJ.java:150)
at ij.Executer.runCommand(Executer.java:124)
at ij.Executer.run(Executer.java:61)
at ij.IJ.run(IJ.java:249)
at ij.macro.Functions.doRun(Functions.java:561)
at ij.macro.Functions.doFunction(Functions.java:79)
at ij.macro.Interpreter.doStatement(Interpreter.java:203)
at ij.macro.Interpreter.doBlock(Interpreter.java:518)
at ij.macro.Interpreter.runUserFunction(Interpreter.java:278)
at ij.macro.Interpreter.doStatement(Interpreter.java:206)
at ij.macro.Interpreter.doBlock(Interpreter.java:518)
at ij.macro.Interpreter.doStatement(Interpreter.java:239)
at ij.macro.Interpreter.doIf(Interpreter.java:852)
at ij.macro.Interpreter.doStatement(Interpreter.java:215)
at ij.macro.Interpreter.doBlock(Interpreter.java:518)
at ij.macro.Interpreter.doStatement(Interpreter.java:239)
at ij.macro.Interpreter.doFor(Interpreter.java:464)
at ij.macro.Interpreter.doStatement(Interpreter.java:221)
at ij.macro.Interpreter.doBlock(Interpreter.java:518)
at ij.macro.Interpreter.doStatement(Interpreter.java:239)
at ij.macro.Interpreter.doFor(Interpreter.java:464)
at ij.macro.Interpreter.doStatement(Interpreter.java:221)
at ij.macro.Interpreter.doStatements(Interpreter.java:191)
at ij.macro.Interpreter.run(Interpreter.java:102)
at ij.macro.Interpreter.run(Interpreter.java:72)
at ij.macro.MacroRunner.run(MacroRunner.java:124)
at java.lang.Thread.run(Thread.java:695)
and this is the log after running the progran:
LeeMouseOld_30Jan18.LH1/
made t2 for LeeMouseOld_30Jan18.LH1/3 T2/
LeeMouseOld_30Jan18.LH1/
Please choose a directory where the T1 or T2 folder is the last item in the path (i.e. 5_t1 or 6_t2)
Directory return for General T folder: /Users/Vineeth/Desktop/New stuff Feb 5/&filename 3 T2/
Please adjust import settings to:
Image type: 32-bit signed
Width: 128 pixels
Height: 256 pixels
Number of images: 50 images
Check Little-endian byte order
As you can see &filename remains the same but I want the data within the variable filename to be in its place.
Use string concatenation:
run("T2 Analysis mouse", "select=[/Users/Vineeth/Desktop/New stuff Feb 5/" + filename + " 3 T2]
image=[32-bit Signed] width=256 height=128 offset=0 number=902 gap=0 little-endian");
run("Save", "save=[/Users/Vineeth/Desktop/New stuff Feb 5/" + foldername + "3 T2/T2map.tif]");
See the macro function documentation (emphasis added):
run("command"[, "options"])
Executes an ImageJ menu command. The optional second argument contains values that are automatically entered into dialog boxes (must be GenericDialog or OpenDialog). Use the Command Recorder (Plugins>Macros>Record) to generate run() function calls. Use string concatentation to pass a variable as an argument. With ImageJ 1.43 and later, variables can be passed without using string concatenation by adding "&" to the variable name. For examples, see the ArgumentPassingDemo macro.
The mentioned shortcut syntax with & does not work between square brackets [] in the option string.
A number of questions on the ImageJ forum also discuss this.

Extending Stargazer to multiwaycov

I'm using stargazer to create regression outputs for my bachelor thesis. Due to the structure of my data I have to use clustered models (code below). I'm using the vcovclust command from the multiwaycov package, which works perfectly. However, stargazer does not support it. Do you know another way to create outputs as nice as stargazer does? Or do you know an other package/command to cluster the models, which is suppported by stargazer?
model1.1.2 <- lm(leaflet ~ partisan + as.factor(gender) + age + as.factor(education) + meaning + as.factor(polintrest), data = voxit)
summary(model1.1.2)
#clustering
vcov_clust1.1.2 <- cluster.vcov(model1.1.2, cbind(voxit$id, voxit$projetx))
coeftest(model1.1.2, vcov_clust1.1.2)
You can supply the adjusted p- and se-values to stargazer manually.
# model1 and model2 are both objects returned from coeftest()
# Capture them in an object and extract the ses (2nd column) and ps (4th column) in a list
ses <- list(model1[,2], model2[,2])
ps <- list(model1[,4], model2[,4])
# you can then run your normal stargazer command and supply
# the se- and p-values manually to the stargazer function
stargazer(model1, model2, type = "text", se = ses, p = ps, p.auto = F)
Hope this helps!

Chef file evaluation only_if

Attempting to File.readlines fails at converge even with 'only_if' check:
ruby_block 'set_archive_mode' do
only_if (File.exists?(node['ORACLE_DATABASE']['ORACLE_ADMIN'] + '/' +
node['ORACLE_DATABASE']['ORACLE_SID'] + '/database_archive_verify.test'))
if File.readlines(node['ORACLE_DATABASE']['ORACLE_ADMIN'] + '/' +
node['ORACLE_DATABASE']['ORACLE_SID'] +
'/database_archive_verify.test').grep(/^NOARCHIVELOG/).size > 0
node.run_state['archive_mode'] = 'noarchivelog'
else
node.run_state['archive_mode'] = 'archivelog'
end
end
The code just needs to set a node.run_state transient attribute based on the contents of the file. I've tried several different approaches all resulting in various errors. The above code include 'only_if', but the File.readlines is still being evaluated at converge.
You are using ruby_block wrong, your "readlines" code should be put in the block attribute.