blob: 26ae6123a39eaff9ffa215c8514487bf223c878c [file]
#-------------------------------------------------------------
#
# 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.
#
#-------------------------------------------------------------
source("scripts/nn/util.dml") as util
source("src/test/scripts/applications/nn/util.dml") as test_util
threshold = function() {
/*
* Test for the threshold function.
*/
print("Testing the threshold function.")
# Generate data
X = matrix("0.31 0.24 0.87
0.45 0.66 0.65
0.24 0.91 0.13", rows=3, cols=3)
thresh = 0.5
target_matrix = matrix("0.0 0.0 1.0
0.0 1.0 1.0
0.0 1.0 0.0", rows=3, cols=3)
# Get the indicator matrix
indicator_matrix = util::threshold(X, thresh)
# Equivalency check
out = test_util::check_all_equal(indicator_matrix, target_matrix)
}
threshold()