# Path: bartpy/errors.py
# class NoSplittableVariableException(Exception):
#     pass
# 
# Path: bartpy/splitcondition.py
# class SplitCondition(object):
#     """
#     A representation of a split in feature space.
#     The two main components are:
# 
#         - splitting_variable: which variable is being split on
#         - splitting_value: the value being split on
#                            all values less than or equal to this go left, all values greater go right
# 
#     """
# 
#     def __init__(self, 
#                  splitting_variable: int, 
#                  splitting_value: float, 
#                  operator: Callable[[float, float], bool], 
#                  condition=None,
#                  carry_y_sum=None,
#                  carry_n_obsv=None):
#         self.splitting_variable = splitting_variable
#         self.splitting_value = splitting_value
#         self._condition = condition
#         self.operator = operator
# 
#         self.carry_y_sum = carry_y_sum
#         self.carry_n_obsv = carry_n_obsv
# 
#     def __str__(self):
#         return str(self.splitting_variable) + ": " + str(self.splitting_value)
# 
#     def __eq__(self, other: 'SplitCondition'):
#         return self.splitting_variable == other.splitting_variable and self.splitting_value == other.splitting_value and self.operator == other.operator


from operator import gt, le
from typing import Any, List, Optional, Union
from bartpy.errors import NoSplittableVariableException
from bartpy.splitcondition import SplitCondition
import numpy as np
import pandas as pd
        -------
        List[int]
            List of column numbers that can be split on
        """
        for i in range(0, self._n_features):
            if self._splittable_variables[i] is None:
                self._splittable_variables[i] = is_not_constant(self.get_column(i))
        
        return [i for (i, x) in enumerate(self._splittable_variables) if x is True]        

    @property
    def n_splittable_variables(self) -> int:
        return len(self.splittable_variables())

    def is_at_least_one_splittable_variable(self) -> bool:
        if any(self._splittable_variables):
            return True
        else:
            return len(self.splittable_variables()) > 0
    
    def random_splittable_variable(self) -> str:
        """
        Choose a variable at random from the set of splittable variables
        Returns
        -------
            str - a variable name that can be split on
        """
        if self.is_at_least_one_splittable_variable():
            return np.random.choice(np.array(self.splittable_variables()), 1)[0]
        else:

# Path: bartpy/errors.py
# class NoSplittableVariableException(Exception):
#     pass
# 
# Path: bartpy/splitcondition.py
# class SplitCondition(object):
#     """
#     A representation of a split in feature space.
#     The two main components are:
# 
#         - splitting_variable: which variable is being split on
#         - splitting_value: the value being split on
#                            all values less than or equal to this go left, all values greater go right
# 
#     """
# 
#     def __init__(self, 
#                  splitting_variable: int, 
#                  splitting_value: float, 
#                  operator: Callable[[float, float], bool], 
#                  condition=None,
#                  carry_y_sum=None,
#                  carry_n_obsv=None):
#         self.splitting_variable = splitting_variable
#         self.splitting_value = splitting_value
#         self._condition = condition
#         self.operator = operator
# 
#         self.carry_y_sum = carry_y_sum
#         self.carry_n_obsv = carry_n_obsv
# 
#     def __str__(self):
#         return str(self.splitting_variable) + ": " + str(self.splitting_value)
# 
#     def __eq__(self, other: 'SplitCondition'):
#         return self.splitting_variable == other.splitting_variable and self.splitting_value == other.splitting_value and self.operator == other.operator


# Path: bartpy/data.py
from operator import gt, le
from typing import Any, List, Optional, Union
from bartpy.errors import NoSplittableVariableException
from bartpy.splitcondition import SplitCondition
import numpy as np
import pandas as pd

        -------
        List[int]
            List of column numbers that can be split on
        """
        for i in range(0, self._n_features):
            if self._splittable_variables[i] is None:
                self._splittable_variables[i] = is_not_constant(self.get_column(i))
        
        return [i for (i, x) in enumerate(self._splittable_variables) if x is True]        

    @property
    def n_splittable_variables(self) -> int:
        return len(self.splittable_variables())

    def is_at_least_one_splittable_variable(self) -> bool:
        if any(self._splittable_variables):
            return True
        else:
            return len(self.splittable_variables()) > 0
    
    def random_splittable_variable(self) -> str:
        """
        Choose a variable at random from the set of splittable variables
        Returns
        -------
            str - a variable name that can be split on
        """
        if self.is_at_least_one_splittable_variable():
            return np.random.choice(np.array(self.splittable_variables()), 1)[0]
        else:

            raise NoSplittableVariableException()