Skip to content

Commit

Permalink
unnecessary logging #484 #496
Browse files Browse the repository at this point in the history
  • Loading branch information
yxu927 committed Jun 14, 2024
1 parent e93403c commit acd7586
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package lphystudio.core.codecolorizer;


import lphy.core.logger.LoggerUtils;
import lphy.core.model.RandomVariable;
import lphy.core.model.Value;
import lphy.core.parser.LPhyParserAction;
Expand Down Expand Up @@ -195,10 +196,10 @@ public Object visitRange_list(Range_listContext ctx) {
TextElement textElement = (TextElement)visit(ctx.getChild(0));
for (int i = 1; i < ctx.getChildCount(); i++) {
TextElement element = (TextElement)visit(ctx.getChild(i));
if (element != null) {
textElement.add(new TextElement(",", punctuationStyle));
textElement.add(element);
}
if (element != null) {
textElement.add(new TextElement(",", punctuationStyle));
textElement.add(element);
}
}
return textElement;
}
Expand Down Expand Up @@ -393,9 +394,9 @@ public Object visitFunction(FunctionContext ctx) {
@Override
public Object visitMethodCall(MethodCallContext ctx) {

// lphystudio.core.codecolorizer.Var var = (Var)visit(ctx.getChild(0));
// TextElement e = var.getTextElement(parser, context);
// String methodName = ctx.children.get(2).getText();
// lphystudio.core.codecolorizer.Var var = (Var)visit(ctx.getChild(0));
// TextElement e = var.getTextElement(parser, context);
// String methodName = ctx.children.get(2).getText();

String objectName = ctx.children.get(0).getText();
String methodName = ctx.children.get(2).getText();
Expand Down Expand Up @@ -433,7 +434,7 @@ private TextElement getIDElement(String key) {

public Object parse(String CASentence) {

System.out.println("Parsing " + CASentence + " in code colouriser");
LoggerUtils.log.fine("Parsing " + CASentence + " in code colouriser");

// Traverse parse tree
AbstractParseTreeVisitor visitor = new DataModelASTVisitor();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package lphystudio.core.codecolorizer;


import lphy.core.logger.LoggerUtils;
import lphy.core.model.RandomVariable;
import lphy.core.model.Value;
import lphy.core.parser.LPhyParserAction;
Expand Down Expand Up @@ -170,7 +171,7 @@ public Object visitStoch_relation(Stoch_relationContext ctx) {

return ctx.getText();
}

@Override
public Object visitExpression(ExpressionContext ctx) {
if (ctx.getChildCount() == 1) {
Expand Down Expand Up @@ -368,7 +369,7 @@ public Object visitMethodCall(MethodCallContext ctx) {
}

public Object parse(String CASentence) {
System.out.println("Parsing " + CASentence + " in code colouriser");
LoggerUtils.log.fine("Parsing " + CASentence + " in code colouriser");

LPhyASTVisitor visitor = new LPhyASTVisitor();
// no data and model blocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected void draw2DArray(Object[][] matrix, boolean editable) {
int maxHeight = preferredElementSize.height * rowCount + GAP * (rowCount + 1);

setMaximumSize(new Dimension(maxWidth, maxHeight));
System.out.println("Max size = " + maxWidth + ", " + maxHeight);
// LoggerUtils.log.fine("Max size = " + maxWidth + ", " + maxHeight);

}

Expand Down
13 changes: 7 additions & 6 deletions lphy/src/main/java/lphy/core/simulator/Sampler.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ public List<Value> sample(Long seed) {
replaceValueInModelDict(value, newValue, variables, sampled);

// add new Value back to Model Map
// addValueToModelDictionary(newValue);
// addValueToModelDictionary(newValue);
}
}
System.out.println("Resample variable : " + sampled);
LoggerUtils.log.info("Resample variable : " + sampled);

if (parserDict.getModelDictionary().size() != nModelDictSize)
throw new RuntimeException("The number of stored values are not correct in parser model dictionary during resampling !\n" +
"It should be " + nModelDictSize + "; but get " + parserDict.getModelDictionary().size());
Expand Down Expand Up @@ -206,7 +207,7 @@ public Map<Integer, List<Value>> sampleAll(int numReplicates,
for (SimulatorListener logger : loggers)
logger.complete();

// parser.notifyListeners();
// parser.notifyListeners();
return valuesAllRepsMap;
}

Expand Down Expand Up @@ -267,7 +268,7 @@ private Map<String, Value> getNewlySampledParams(Generator generator, List<Rando
// but also re-generate its value for the deterministic functions,
// when its parameter value is changed.

// if (val.isRandom()) {
// if (val.isRandom()) {
if (val.isAnonymous() || !sampled.contains(val.getId())) {
// re-sample if it has a generator, this will exclude constant Values.
// AND this value is NOT generated by the code in the data block.
Expand All @@ -277,7 +278,7 @@ private Map<String, Value> getNewlySampledParams(Generator generator, List<Rando
Value nv = resample(val, val.getGenerator(), removedRandomValues, sampled);

newlySampledParams.put(e.getKey(), nv);
// addValueToModelDictionary(nv);
// addValueToModelDictionary(nv);
// replace old Value with new Value both in Model Map and Value Set
replaceValueInModelDict(val, nv, removedRandomValues, sampled);
} else {
Expand All @@ -289,7 +290,7 @@ private Map<String, Value> getNewlySampledParams(Generator generator, List<Rando
String id = e.getValue().getId();
newlySampledParams.put(e.getKey(), getParserDictionary().getModelDictionary().get(id));
}
// }
// }
}
return newlySampledParams;
}
Expand Down

0 comments on commit acd7586

Please sign in to comment.