def set_protobuf_float(column_schema, feature): domain = column_schema.properties.get("domain", {}) feature.float_domain.CopyFrom( schema_pb2.FloatDomain( name=column_schema.name, min=domain.get("min", None), max=domain.get("max", None), )) feature.type = schema_pb2.FeatureType.FLOAT return feature
'x': schema_pb2.StringDomain(value=['a', 'b']) } }, { 'testcase_name': 'float_domain', 'ascii_proto': """ feature: { name: "x" type: FLOAT float_domain {min: 0.0 max: 0.5} } """, 'feature_spec': { 'x': tf.io.VarLenFeature(tf.float32) }, 'domains': { 'x': schema_pb2.FloatDomain(min=0.0, max=0.5) } }, { 'testcase_name': 'sparse_feature_rank_0', 'ascii_proto': """ feature { name: "value_key" type: INT } sparse_feature { name: "x" value_feature {name: "value_key"} } """, 'feature_spec': {
'feature_name': 'x', 'domain': schema_pb2.IntDomain(min=1, max=5), 'output_schema_proto_text': ''' feature { name: 'x' int_domain { min: 1 max: 5 } }''' }, { 'testcase_name': 'float_domain', 'input_schema_proto_text': '''feature { name: 'x' }''', 'feature_name': 'x', 'domain': schema_pb2.FloatDomain(min=1.1, max=5.1), 'output_schema_proto_text': ''' feature { name: 'x' float_domain { min: 1.1 max: 5.1 } }''' }, { 'testcase_name': 'string_domain', 'input_schema_proto_text': '''feature { name: 'x' }''', 'feature_name': 'x', 'domain': schema_pb2.StringDomain(value=['a', 'b']), 'output_schema_proto_text': ''' feature { name: 'x' string_domain { value: 'a' value: 'b' } }'''
}, 'exception_type': ValueError, 'error_message': 'Invalid semantic_domain_stats_sample_rate 2' }, { 'testcase_name': 'categorical_float_without_sketch_generators', 'stats_options_kwargs': { 'experimental_use_sketch_based_topk_uniques': False, 'schema': schema_pb2.Schema(feature=[ schema_pb2.Feature( name='f', type=schema_pb2.FLOAT, float_domain=schema_pb2.FloatDomain(is_categorical=True)) ], ), }, 'exception_type': ValueError, 'error_message': ('Categorical float features set in schema require ' 'experimental_use_sketch_based_topk_uniques'), }, { 'testcase_name': 'both_slice_fns_and_slice_sqls_specified', 'stats_options_kwargs': { 'experimental_slice_functions': [lambda x: (None, x)], 'experimental_slice_sqls': [''] }, 'exception_type': ValueError, 'error_message': 'Only one of experimental_slice_functions or'