# Path: tensorflow_decision_forests/component/py_tree/condition.py
# class AbstractCondition(object):
# class IsMissingInCondition(AbstractCondition):
# class IsTrueCondition(AbstractCondition):
# class NumericalHigherThanCondition(AbstractCondition):
# class CategoricalIsInCondition(AbstractCondition):
# class CategoricalSetContainsCondition(AbstractCondition):
# class NumericalSparseObliqueCondition(AbstractCondition):
#   def __init__(self, missing_evaluation: Optional[bool]):
#   def missing_evaluation(self):
#   def features(self) -> List[SimpleColumnSpec]:
#   def __repr__(self):
#   def __init__(self, feature: SimpleColumnSpec):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def feature(self):
#   def __init__(self, feature: SimpleColumnSpec,
#                missing_evaluation: Optional[bool]):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def feature(self):
#   def __init__(self, feature: SimpleColumnSpec, threshold: float,
#                missing_evaluation: Optional[bool]):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def feature(self):
#   def threshold(self):
#   def __init__(self, feature: SimpleColumnSpec, mask: Union[List[str],
#                                                             List[int]],
#                missing_evaluation: Optional[bool]):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def feature(self):
#   def mask(self):
#   def __init__(self, feature: SimpleColumnSpec, mask: Union[List[str],
#                                                             List[int]],
#                missing_evaluation: Optional[bool]):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def feature(self):
#   def mask(self):
#   def __init__(self, features: List[SimpleColumnSpec], weights: List[float],
#                threshold: float, missing_evaluation: Optional[bool]):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def weights(self):
#   def threshold(self):
# def core_condition_to_condition(
#     core_condition: decision_tree_pb2.NodeCondition,
#     dataspec: data_spec_pb2.DataSpecification) -> AbstractCondition:
# def column_spec_bitmap_to_items(column_spec: data_spec_pb2.Column,
#                                 bitmap: bytes) -> Union[List[int], List[str]]:
# def column_spec_items_to_bitmap(column_spec: data_spec_pb2.Column,
#                                 items: List[int]) -> bytes:
# def set_core_node(condition: AbstractCondition,
#                   dataspec: data_spec_pb2.DataSpecification,
#                   core_node: decision_tree_pb2.Node):
# 
# Path: tensorflow_decision_forests/component/py_tree/dataspec.py
# OUT_OF_DICTIONARY = "<OOD>"
# class SimpleColumnSpec(NamedTuple):
#   def __repr__(self):
# def make_simple_column_spec(dataspec: data_spec_pb2.DataSpecification,
#                             col_idx: int) -> SimpleColumnSpec:
# def categorical_value_idx_to_value(column_spec: data_spec_pb2.Column,
#                                    value_idx: int) -> Union[int, str]:
# def categorical_column_dictionary_to_list(
#     column_spec: data_spec_pb2.Column) -> List[str]:
# def label_value_idx_to_value(column_spec: data_spec_pb2.Column,
#                              value_idx: int) -> Union[int, str]:
# def discretized_numerical_to_numerical(column_spec: data_spec_pb2.Column,
#                                        value: int) -> float:
# def column_name_to_column_idx(name: str,
#                               dataspec: data_spec_pb2.DataSpecification) -> int:


from absl.testing import parameterized
from tensorflow_decision_forests.component.py_tree import condition as condition_lib
from tensorflow_decision_forests.component.py_tree import dataspec as dataspec_lib
from yggdrasil_decision_forests.dataset import data_spec_pb2
from yggdrasil_decision_forests.model.decision_tree import decision_tree_pb2
import tensorflow as tf
# Copyright 2021 Google LLC.
#
# Licensed 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
#
#     https://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.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function




class ConditionTest(parameterized.TestCase, tf.test.TestCase):

  def test_column_spec_bitmap_to_items_integer(self):
    column_spec = data_spec_pb2.Column()
    column_spec.categorical.number_of_unique_values = 10
    column_spec.categorical.is_already_integerized = True
    # b1100101101 => 32Dh
    self.assertEqual(

# Path: tensorflow_decision_forests/component/py_tree/condition.py
# class AbstractCondition(object):
# class IsMissingInCondition(AbstractCondition):
# class IsTrueCondition(AbstractCondition):
# class NumericalHigherThanCondition(AbstractCondition):
# class CategoricalIsInCondition(AbstractCondition):
# class CategoricalSetContainsCondition(AbstractCondition):
# class NumericalSparseObliqueCondition(AbstractCondition):
#   def __init__(self, missing_evaluation: Optional[bool]):
#   def missing_evaluation(self):
#   def features(self) -> List[SimpleColumnSpec]:
#   def __repr__(self):
#   def __init__(self, feature: SimpleColumnSpec):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def feature(self):
#   def __init__(self, feature: SimpleColumnSpec,
#                missing_evaluation: Optional[bool]):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def feature(self):
#   def __init__(self, feature: SimpleColumnSpec, threshold: float,
#                missing_evaluation: Optional[bool]):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def feature(self):
#   def threshold(self):
#   def __init__(self, feature: SimpleColumnSpec, mask: Union[List[str],
#                                                             List[int]],
#                missing_evaluation: Optional[bool]):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def feature(self):
#   def mask(self):
#   def __init__(self, feature: SimpleColumnSpec, mask: Union[List[str],
#                                                             List[int]],
#                missing_evaluation: Optional[bool]):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def feature(self):
#   def mask(self):
#   def __init__(self, features: List[SimpleColumnSpec], weights: List[float],
#                threshold: float, missing_evaluation: Optional[bool]):
#   def features(self):
#   def __repr__(self):
#   def __eq__(self, other):
#   def weights(self):
#   def threshold(self):
# def core_condition_to_condition(
#     core_condition: decision_tree_pb2.NodeCondition,
#     dataspec: data_spec_pb2.DataSpecification) -> AbstractCondition:
# def column_spec_bitmap_to_items(column_spec: data_spec_pb2.Column,
#                                 bitmap: bytes) -> Union[List[int], List[str]]:
# def column_spec_items_to_bitmap(column_spec: data_spec_pb2.Column,
#                                 items: List[int]) -> bytes:
# def set_core_node(condition: AbstractCondition,
#                   dataspec: data_spec_pb2.DataSpecification,
#                   core_node: decision_tree_pb2.Node):
# 
# Path: tensorflow_decision_forests/component/py_tree/dataspec.py
# OUT_OF_DICTIONARY = "<OOD>"
# class SimpleColumnSpec(NamedTuple):
#   def __repr__(self):
# def make_simple_column_spec(dataspec: data_spec_pb2.DataSpecification,
#                             col_idx: int) -> SimpleColumnSpec:
# def categorical_value_idx_to_value(column_spec: data_spec_pb2.Column,
#                                    value_idx: int) -> Union[int, str]:
# def categorical_column_dictionary_to_list(
#     column_spec: data_spec_pb2.Column) -> List[str]:
# def label_value_idx_to_value(column_spec: data_spec_pb2.Column,
#                              value_idx: int) -> Union[int, str]:
# def discretized_numerical_to_numerical(column_spec: data_spec_pb2.Column,
#                                        value: int) -> float:
# def column_name_to_column_idx(name: str,
#                               dataspec: data_spec_pb2.DataSpecification) -> int:


# Path: tensorflow_decision_forests/component/py_tree/condition_test.py
from absl.testing import parameterized
from tensorflow_decision_forests.component.py_tree import condition as condition_lib
from tensorflow_decision_forests.component.py_tree import dataspec as dataspec_lib
from yggdrasil_decision_forests.dataset import data_spec_pb2
from yggdrasil_decision_forests.model.decision_tree import decision_tree_pb2
import tensorflow as tf

# Copyright 2021 Google LLC.
#
# Licensed 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
#
#     https://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.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function




class ConditionTest(parameterized.TestCase, tf.test.TestCase):

  def test_column_spec_bitmap_to_items_integer(self):
    column_spec = data_spec_pb2.Column()
    column_spec.categorical.number_of_unique_values = 10
    column_spec.categorical.is_already_integerized = True
    # b1100101101 => 32Dh
    self.assertEqual(

        condition_lib.column_spec_bitmap_to_items(column_spec, b"\x2D\x03"),