Skip to content

Commit

Permalink
Remove if __name__ == "__main__" from test files because it is unus…
Browse files Browse the repository at this point in the history
…ed with pytest
  • Loading branch information
smokestacklightnin committed Oct 18, 2024
1 parent e282cc3 commit 474ffcb
Show file tree
Hide file tree
Showing 90 changed files with 0 additions and 196 deletions.
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/api/dataframe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,5 +516,3 @@ def testAutoPivot_PlotsDataFrameCollapseColumnNames(self):
)
pd.testing.assert_frame_equal(expected, df, check_column_type=False)

if __name__ == '__main__':
tf.test.main()
3 changes: 0 additions & 3 deletions tensorflow_model_analysis/api/model_eval_lib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,3 @@ def testBytesProcessedCountForRecordBatches(self):
self.assertEqual(actual_counter[0].committed, expected_num_bytes)


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/api/types_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,3 @@ def testVarLenTensorValueEmpty(self):
)


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,3 @@ def testBinaryConfusionMatricesInProcess(
self.assertDictEqual(actual, expected_result)


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,3 @@ def check_result(got):
util.assert_that(got[constants.ANALYSIS_KEY], check_result)


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,3 @@ def check_result(got_pcoll):
util.assert_that(result, check_result)


if __name__ == '__main__':
absltest.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/evaluators/counter_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,3 @@ def testMetricsSpecBeamCounter(self):
self.assertEqual(actual_metrics_count, 1)


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/evaluators/evaluator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,3 @@ def testVerifyEvaluatorRaisesValueError(self):
)


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/evaluators/jackknife_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,5 +276,3 @@ def check_result(got_pcoll):
util.assert_that(result, check_result)


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,3 @@ def testCalculateConfidenceInterval(self):
)


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,3 @@ def testMetricsSpecsCountersInModelAgnosticMode(self):
self.assertEqual(actual_metrics_count, 1)


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,3 @@ def testValidateMetricsDivByZero(self):
self.assertFalse(result.validation_ok)


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -349,5 +349,3 @@ def check_result(got_pcoll):
util.assert_that(result, check_result)


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ def testWhitespaceTokenization(self, input_text, expected_output):
self.assertAllEqual(actual, expected)


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/extractors/extractor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,3 @@ def check_result(got):
util.assert_that(got, check_result)


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/extractors/inference_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,5 +407,3 @@ def testInsertPredictionLogsWithCustomPathIntoExtracts(self):
self.assertEqual(extracts['foo']['bar'], ref_extracts['foo']['bar'])


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/extractors/labels_extractor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,3 @@ def testMaterializeFeaturesWithExcludes(self):
self.assertNotIn('features__s', result)


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,3 @@ def testGetSparseTensorValue(self):
)


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,3 @@ def check_result(got):
util.assert_that(result, check_result)


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,3 @@ def check_result(got):
util.assert_that(slice_keys_extracts, check_result)


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,3 @@ def check_result(got):
util.assert_that(result, check_result)


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,3 @@ def check_result(batches):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -556,5 +556,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/aggregation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/attributions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,5 +531,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -575,5 +575,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/bleu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,5 +640,3 @@ def check_result(got):
util.assert_that(result['metrics'], check_result, label='result')


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -422,5 +422,3 @@ def testRebinWithSparseData(self):
dataclasses.astuple(got[i]), dataclasses.astuple(expected[i]))


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/calibration_plot_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,5 +440,3 @@ def testCalibrationPlotWithSchema(self, eval_config, schema, model_names,
self.assertEqual(expected_range, histogram.combiner._range)


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/calibration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,3 @@ def testConfusionMatrixFeatureSamplers(
)


if __name__ == '__main__':
tf.compat.v1.enable_v2_behavior()
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
absltest.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/exact_match_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/example_count_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,3 @@ def check_result(got):
util.assert_that(result['metrics'], check_result, label='result')


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/flip_metrics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,5 +343,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
absltest.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/metric_specs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,5 +694,3 @@ def testToComputationsWithMixedAggregationAndNonAggregationMetrics(self):
self.assertLen(computations, 3)


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/metric_types_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,3 @@ def testMultiModelMultiOutputPreprocessors(self):
})


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/metric_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,5 +908,3 @@ def testTopKIndicesWithBinaryClassification(self):
self.assertAllClose(scores[got], np.array([0.8]))


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/min_label_position_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -403,5 +403,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -333,5 +333,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
2 changes: 0 additions & 2 deletions tensorflow_model_analysis/metrics/ndcg_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
tf.test.main()
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,3 @@ def check_result(got):
util.assert_that(result['metrics'], check_result, label='result')


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,3 @@ def check_result(got):
util.assert_that(result['plots'], check_result, label='result')


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -368,5 +368,3 @@ def check_result(got):
util.assert_that(result['metrics'], check_result, label='result')


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,3 @@ def check_result(got):
util.assert_that(result, check_result, label='result')


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,3 @@ def testLabelPreidictionImageSizeMismatch(self):
)


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,3 @@ def testLabelPreidictionSizeMismatch(self):
)


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -333,5 +333,3 @@ def check_result(result):
beam_testing_util.assert_that(updated_pcoll, check_result)


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -389,5 +389,3 @@ def testMismatchClassesAndScores(self):
)


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,3 @@ def test_input_check_sort_boxes_by_confidence(self):
np.array([20, 60, 290]))


if __name__ == '__main__':
absltest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,3 @@ def test_boxes_to_label_prediction_filter(self, raw_input, expected_result):
np.testing.assert_allclose(result[2], expected_result['example_weights'])


if __name__ == '__main__':
absltest.main()
Loading

0 comments on commit 474ffcb

Please sign in to comment.