Shafaq-Siddiqi commented on a change in pull request #1117:
URL: https://github.com/apache/systemds/pull/1117#discussion_r531558217



##########
File path: scripts/builtin/statsNA.dml
##########
@@ -0,0 +1,212 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+# TODO Question: Is there a tool/template to generate the function 
documentation? Who updates the documentation on the website?
+
+m_statsNA = function(Matrix[Double] X, Integer bins = 4, Boolean print_result 
= TRUE)
+  return(Integer length_series,
+         Double number_nans,
+         Double percentage_nans,
+         Double number_nan_gaps,
+         Double average_size_nan_gaps,
+         Integer longest_nan_gap,
+         Integer most_frequent_nan_gap,
+         Integer most_weighty_nan_gap
+         )
+{
+    #TODO Question: Do we need to check if the input matrix is a vector? and 
if yes in with direction should it go?
+    if(ncol(X) != 1) {
+       stop("CONFUSION MATRIX: expect a matrix with only one column");
+    }
+
+    # Count total entries
+    # TODO Question: Why returns length a double and not an integer?
+    length_series = length(X);
+
+    # TODO Question: What should happen when the input matrix is empty?
+    if (length_series == 0) {
+       stop("EMPTY MATRIX")
+    }
+
+    # TODO Question: What should happen when the number of bins is higher than 
length of the input matrix?

Review comment:
       use the default bin values in this case and also print a meaningful 
message something like  "number of bins exceeds the length of series, using 
default bin value = 4"
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to