Skip to content

Commit

Permalink
Added RExp#_class() method
Browse files Browse the repository at this point in the history
  • Loading branch information
vruusmann committed Dec 17, 2024
1 parent 57c00a3 commit a613938
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void encodeResponse(S4Object responses, RExpEncoder encoder){

RExp targetVariable = variables.getElement(variableName);

RStringVector targetVariableClass = RExpUtil.getClassNames(targetVariable);
RStringVector targetVariableClass = targetVariable._class();

RStringVector targetCategories = levels.getStringElement(variableName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected ConverterFactory(){
}

public <R extends RExp> Converter<R> newConverter(R rexp){
RStringVector classNames = RExpUtil.getClassNames(rexp);
RStringVector classNames = rexp._class();

for(String className : classNames){
Class<? extends Converter<?>> clazz = ConverterFactory.converters.get(className);
Expand Down
2 changes: 1 addition & 1 deletion pmml-rexp/src/main/java/org/jpmml/rexp/DecorationUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public RVector<?> getVectorElement(RGenericVector model, String name){

static
private RuntimeException toDecorationException(RGenericVector model, String name, Exception e){
RStringVector classNames = RExpUtil.getClassNames(model);
RStringVector classNames = model._class();

String className = classNames.getValue(0);

Expand Down
4 changes: 4 additions & 0 deletions pmml-rexp/src/main/java/org/jpmml/rexp/RExp.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public void write(RDataOutput output) throws IOException {
throw new UnsupportedOperationException();
}

public RStringVector _class(){
return getStringAttribute("class");
}

public RStringVector names(){
return getStringAttribute("names");
}
Expand Down
7 changes: 0 additions & 7 deletions pmml-rexp/src/main/java/org/jpmml/rexp/RExpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ public String getVectorType(Class<?> clazz){
return vectorType;
}

static
public RStringVector getClassNames(RExp rexp){
RStringVector result = rexp.getStringAttribute("class");

return result;
}

static
public String makeName(String string){
StringBuilder sb = new StringBuilder();
Expand Down
2 changes: 1 addition & 1 deletion pmml-rexp/src/test/java/org/jpmml/rexp/SerializeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void checkDataFrame(RGenericVector dataFrame){
assertTrue(dataFrame.hasAttribute("names"));
assertTrue(dataFrame.hasAttribute("row.names"));

assertEquals(Arrays.asList("data.frame"), (dataFrame.getStringAttribute("class")).getValues());
assertEquals(Arrays.asList("data.frame"), (dataFrame._class()).getValues());

assertEquals(5, dataFrame.size());

Expand Down

0 comments on commit a613938

Please sign in to comment.