e-strauss commented on code in PR #2113: URL: https://github.com/apache/systemds/pull/2113#discussion_r1772295133
########## src/main/python/systemds/operator/nodes/frame.py: ########## @@ -112,68 +136,94 @@ def transform_apply(self, spec: "Scalar", meta: "Frame"): params_dict = {"target": self, "spec": spec, "meta": meta} return Matrix(self.sds_context, "transformapply", named_input_nodes=params_dict) - def rbind(self, other) -> 'Frame': + def rbind(self, other) -> "Frame": """ - Row-wise frame concatenation, by concatenating the second frame as additional rows to the first frame. + Row-wise frame concatenation, by concatenating the second frame as additional rows to the first frame. :param: The other frame to bind to the right hand side :return: The OperationNode containing the concatenated frames. """ return Frame(self.sds_context, "rbind", [self, other]) - def cbind(self, other) -> 'Frame': + def cbind(self, other) -> "Frame": """ - Column-wise frame concatenation, by concatenating the second frame as additional columns to the first frame. + Column-wise frame concatenation, by concatenating the second frame as additional columns to the first frame. :param: The other frame to bind to the right hand side. :return: The Frame containing the concatenated frames. """ return Frame(self.sds_context, "cbind", [self, other]) - def replace(self, pattern: str, replacement: str) -> 'Frame': + def replace(self, pattern: str, replacement: str) -> "Frame": """ Replace all instances of string with replacement string :param: pattern the string to replace :param: replacement the string to replace with - :return: The Frame containing the replaced values + :return: The Frame containing the replaced values """ - return Frame(self.sds_context, "replace", named_input_nodes={"target": self, "pattern": f"'{pattern}'", "replacement": f"'{replacement}'"}) + return Frame( + self.sds_context, + "replace", + named_input_nodes={ + "target": self, + "pattern": f"'{pattern}'", + "replacement": f"'{replacement}'", + }, + ) - def to_string(self, **kwargs: Dict[str, VALID_INPUT_TYPES]) -> 'Scalar': - """ Converts the input to a string representation. + def to_string(self, **kwargs: Dict[str, VALID_INPUT_TYPES]) -> "Scalar": + """Converts the input to a string representation. :return: `Scalar` containing the string. """ - return Scalar(self.sds_context, 'toString', [self], kwargs, output_type=OutputType.STRING) + return Scalar( + self.sds_context, "toString", [self], kwargs, output_type=OutputType.STRING + ) + + def to_matrix(self): + return Matrix(self.sds_context, "as.matrix", [self]) + + def to_scalar(self): + return Scalar(self.sds_context, "as.scalar", [self]) def __str__(self): return "FrameNode" - def nRow(self) -> 'Scalar': - return Scalar(self.sds_context, 'nrow', [self]) + def nRow(self) -> "Scalar": Review Comment: All the formatting comes from black, as you recommended -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@systemds.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org