) _COVARIANCE_WITH_LARGE_NUMBERS_TEST = dict( testcase_name='CovarianceWithLargeNumbers', combiner=analyzers.CovarianceCombiner(output_shape=(2, 2), numpy_dtype=np.float64), batches=[ (np.array([[2e15, 0], [1e15, 0]]), ), (np.array([[-2e15, 0], [-1e15, 0]]), ), ], expected_outputs=[np.array([[2.5e30, 0], [0, 0]], dtype=np.float64)], ) _PCA_WITH_DEGENERATE_COVARIANCE_MATRIX_TEST = dict( testcase_name='PCAWithDegenerateCovarianceMatrix', combiner=analyzers.PCACombiner(output_shape=(3, 3), numpy_dtype=np.float64), batches=[ (np.array([[0, 0, 1]]), ), (np.array([[4, 0, 1], [2, -1, 1]]), ), (np.array([[2, 1, 1]]), ), ], expected_outputs=[ np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype=np.float64) ], ) def _make_mean_and_var_accumulator_from_instance(instance, axis=None): return analyzers._WeightedMeanAndVarAccumulator( count=np.sum(np.ones_like(instance), axis=axis), mean=np.mean(instance, axis=axis),
], ) _COVARIANCE_WITH_LARGE_NUMBERS_TEST = dict( testcase_name='CovarianceWithLargeNumbers', combiner=analyzers.CovarianceCombiner(numpy_dtype=np.float64), batches=[ (np.array([[2e15, 0], [1e15, 0]]), ), (np.array([[-2e15, 0], [-1e15, 0]]), ), ], expected_outputs=[np.array([[2.5e30, 0], [0, 0]], dtype=np.float64)], ) _PCA_WITH_DEGENERATE_COVARIANCE_MATRIX_TEST = dict( testcase_name='PCAWithDegenerateCovarianceMatrix', combiner=analyzers.PCACombiner(numpy_dtype=np.float64), batches=[ (np.array([[0, 0, 1]]), ), (np.array([[4, 0, 1], [2, -1, 1]]), ), (np.array([[2, 1, 1]]), ), ], expected_outputs=[ np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype=np.float64) ], ) def _make_mean_and_var_accumulator_from_instance(instance, axis=None): return analyzers._MeanAndVarAccumulator(count=np.sum( np.ones_like(instance), axis=axis), mean=np.mean(instance, axis=axis),