prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [FEAT] Enable ignoring Null values in the Is Single Value check
  **Is your feature request related to a problem? Please describe.**
  Currently, if the data has both a single value and NaNs in the same column, this column will be considered to have 2 unique values.
  
  **Describe the solution you'd like**
  Add a Boolean parameter telling the check to disregard NaN's
  
  **Additional context**
  Issue raised by @galsr in the [Deepchecks Community](https://join.slack.com/t/deepcheckscommunity/shared_invite/zt-1973c7twx-Ytb7_yJefTT4PmnMZj2p7A) support channel. 
  
  </issue>
  <code>
  [start of docs/source/checks/tabular/data_integrity/plot_is_single_value.py]
  1 # -*- coding: utf-8 -*-
  2 """
  3 Is Single Value
  4 ***************
  5 """
  6 
  7 #%%
  8 # Imports
  9 # =======
  10 
  11 import pandas as pd
  12 from sklearn.datasets import load_iris
  13 
  14 from deepchecks.tabular.checks import IsSingleValue
  15 
  16 #%%
  17 # Load Data
  18 # =========
  19 
  20 iris = load_iris()
  21 X = iris.data
  22 df = pd.DataFrame({'a':[3,4,1], 'b':[2,2,2], 'c':[None, None, None], 'd':['a', 4, 6]})
  23 df
  24 
  25 #%%
  26 # See functionality
  27 # =================
  28 
  29 IsSingleValue().run(pd.DataFrame(X))
  30 
  31 #%%
  32 
  33 IsSingleValue().run(pd.DataFrame({'a':[3,4], 'b':[2,2], 'c':[None, None], 'd':['a', 4]}))
  34 
  35 #%%
  36 
  37 sv = IsSingleValue()
  38 sv.run(df)
  39 
  40 #%%
  41 
  42 sv_ignore = IsSingleValue(ignore_columns=['b','c'])
  43 sv_ignore.run(df)
  44
  [end of docs/source/checks/tabular/data_integrity/plot_is_single_value.py]
  [start of deepchecks/tabular/checks/data_integrity/is_single_value.py]
  1 # ----------------------------------------------------------------------------
  2 # Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)
  3 #
  4 # This file is part of Deepchecks.
  5 # Deepchecks is distributed under the terms of the GNU Affero General
  6 # Public License (version 3 or later).
  7 # You should have received a copy of the GNU Affero General Public License
  8 # along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.
  9 # ----------------------------------------------------------------------------
  10 #
  11 """Module contains is_single_value check."""
  12 from typing import List, Union
  13 
  14 from deepchecks.core import CheckResult, ConditionCategory, ConditionResult
  15 from deepchecks.tabular import Context, SingleDatasetCheck
  16 from deepchecks.tabular.utils.messages import get_condition_passed_message
  17 from deepchecks.utils.dataframes import select_from_dataframe
  18 from deepchecks.utils.typing import Hashable
  19 
  20 __all__ = ['IsSingleValue']
  21 
  22 
  23 class IsSingleValue(SingleDatasetCheck):
  24     """Check if there are columns which have only a single unique value in all rows.
  25 
  26     Parameters
  27     ----------
  28     columns : Union[Hashable, List[Hashable]] , default: None
  29         Columns to check, if none are given checks all
  30         columns except ignored ones.
  31     ignore_columns : Union[Hashable, List[Hashable]] , default: None
  32         Columns to ignore, if none given checks based
  33         on columns variable.
  34     """
  35 
  36     def __init__(
  37         self,
  38         columns: Union[Hashable, List[Hashable], None] = None,
  39         ignore_columns: Union[Hashable, List[Hashable], None] = None,
  40         **kwargs
  41     ):
  42         super().__init__(**kwargs)
  43         self.columns = columns
  44         self.ignore_columns = ignore_columns
  45 
  46     def run_logic(self, context: Context, dataset_type: str = 'train') -> CheckResult:
  47         """Run check.
  48 
  49         Returns
  50         -------
  51         CheckResult
  52             value of result is a dict of all columns with number of unique values in format {column: number_of_uniques}
  53             display is a series with columns that have only one unique
  54         """
  55         # Validate parameters
  56         if dataset_type == 'train':
  57             df = context.train.data
  58         else:
  59             df = context.test.data
  60 
  61         df = select_from_dataframe(df, self.columns, self.ignore_columns)
  62 
  63         num_unique_per_col = df.nunique(dropna=False)
  64         is_single_unique_value = (num_unique_per_col == 1)
  65 
  66         if is_single_unique_value.any():
  67             # get names of columns with one unique value
  68             # pylint: disable=unsubscriptable-object
  69             cols_with_single = is_single_unique_value[is_single_unique_value].index.to_list()
  70             uniques = df.loc[:, cols_with_single].head(1)
  71             uniques.index = ['Single unique value']
  72             display = ['The following columns have only one unique value', uniques]
  73         else:
  74             display = None
  75 
  76         return CheckResult(num_unique_per_col.to_dict(), header='Single Value in Column', display=display)
  77 
  78     def add_condition_not_single_value(self):
  79         """Add condition - not single value."""
  80         name = 'Does not contain only a single value'
  81 
  82         def condition(result):
  83             single_value_cols = [k for k, v in result.items() if v == 1]
  84             if single_value_cols:
  85                 details = f'Found {len(single_value_cols)} out of {len(result)} columns with a single value: ' \
  86                           f'{single_value_cols}'
  87                 return ConditionResult(ConditionCategory.FAIL, details)
  88             else:
  89                 return ConditionResult(ConditionCategory.PASS, get_condition_passed_message(result))
  90 
  91         return self.add_condition(name, condition)
  92
  [end of deepchecks/tabular/checks/data_integrity/is_single_value.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/deepchecks/tabular/checks/data_integrity/is_single_value.py b/deepchecks/tabular/checks/data_integrity/is_single_value.py
  --- a/deepchecks/tabular/checks/data_integrity/is_single_value.py
  +++ b/deepchecks/tabular/checks/data_integrity/is_single_value.py
  @@ -11,6 +11,8 @@
   """Module contains is_single_value check."""
   from typing import List, Union
   
  +import pandas as pd
  +
   from deepchecks.core import CheckResult, ConditionCategory, ConditionResult
   from deepchecks.tabular import Context, SingleDatasetCheck
   from deepchecks.tabular.utils.messages import get_condition_passed_message
  @@ -31,17 +33,21 @@
       ignore_columns : Union[Hashable, List[Hashable]] , default: None
           Columns to ignore, if none given checks based
           on columns variable.
  +    ignore_nan : bool, default True
  +        Whether to ignore NaN values in a column when counting the number of unique values.
       """
   
       def __init__(
           self,
           columns: Union[Hashable, List[Hashable], None] = None,
           ignore_columns: Union[Hashable, List[Hashable], None] = None,
  +        ignore_nan: bool = True,
           **kwargs
       ):
           super().__init__(**kwargs)
           self.columns = columns
           self.ignore_columns = ignore_columns
  +        self.ignore_nan = ignore_nan
   
       def run_logic(self, context: Context, dataset_type: str = 'train') -> CheckResult:
           """Run check.
  @@ -60,14 +66,17 @@
   
           df = select_from_dataframe(df, self.columns, self.ignore_columns)
   
  -        num_unique_per_col = df.nunique(dropna=False)
  +        num_unique_per_col = df.nunique(dropna=self.ignore_nan)
           is_single_unique_value = (num_unique_per_col == 1)
   
           if is_single_unique_value.any():
               # get names of columns with one unique value
               # pylint: disable=unsubscriptable-object
               cols_with_single = is_single_unique_value[is_single_unique_value].index.to_list()
  -            uniques = df.loc[:, cols_with_single].head(1)
  +            uniques = pd.DataFrame({
  +                column_name: [column.sort_values(kind='mergesort').values[0]]
  +                for column_name, column in df.loc[:, cols_with_single].items()
  +            })
               uniques.index = ['Single unique value']
               display = ['The following columns have only one unique value', uniques]
           else:
  diff --git a/docs/source/checks/tabular/data_integrity/plot_is_single_value.py b/docs/source/checks/tabular/data_integrity/plot_is_single_value.py
  --- a/docs/source/checks/tabular/data_integrity/plot_is_single_value.py
  +++ b/docs/source/checks/tabular/data_integrity/plot_is_single_value.py
  @@ -8,6 +8,7 @@
   # Imports
   # =======
   
  +import numpy as np
   import pandas as pd
   from sklearn.datasets import load_iris
   
  @@ -41,3 +42,14 @@
   
   sv_ignore = IsSingleValue(ignore_columns=['b','c'])
   sv_ignore.run(df)
  +
  +#%%
  +
  +# Ignoring NaN values
  +
  +IsSingleValue(ignore_nan=True).run(pd.DataFrame({
  +    'a': [3, np.nan], 
  +    'b': [2, 2],
  +    'c': [None, np.nan], 
  +    'd': ['a', 4]
  +}))
  
verification_info: {"golden_diff": "diff --git a/deepchecks/tabular/checks/data_integrity/is_single_value.py b/deepchecks/tabular/checks/data_integrity/is_single_value.py\n--- a/deepchecks/tabular/checks/data_integrity/is_single_value.py\n+++ b/deepchecks/tabular/checks/data_integrity/is_single_value.py\n@@ -11,6 +11,8 @@\n \"\"\"Module contains is_single_value check.\"\"\"\n from typing import List, Union\n \n+import pandas as pd\n+\n from deepchecks.core import CheckResult, ConditionCategory, ConditionResult\n from deepchecks.tabular import Context, SingleDatasetCheck\n from deepchecks.tabular.utils.messages import get_condition_passed_message\n@@ -31,17 +33,21 @@\n     ignore_columns : Union[Hashable, List[Hashable]] , default: None\n         Columns to ignore, if none given checks based\n         on columns variable.\n+    ignore_nan : bool, default True\n+        Whether to ignore NaN values in a column when counting the number of unique values.\n     \"\"\"\n \n     def __init__(\n         self,\n         columns: Union[Hashable, List[Hashable], None] = None,\n         ignore_columns: Union[Hashable, List[Hashable], None] = None,\n+        ignore_nan: bool = True,\n         **kwargs\n     ):\n         super().__init__(**kwargs)\n         self.columns = columns\n         self.ignore_columns = ignore_columns\n+        self.ignore_nan = ignore_nan\n \n     def run_logic(self, context: Context, dataset_type: str = 'train') -> CheckResult:\n         \"\"\"Run check.\n@@ -60,14 +66,17 @@\n \n         df = select_from_dataframe(df, self.columns, self.ignore_columns)\n \n-        num_unique_per_col = df.nunique(dropna=False)\n+        num_unique_per_col = df.nunique(dropna=self.ignore_nan)\n         is_single_unique_value = (num_unique_per_col == 1)\n \n         if is_single_unique_value.any():\n             # get names of columns with one unique value\n             # pylint: disable=unsubscriptable-object\n             cols_with_single = is_single_unique_value[is_single_unique_value].index.to_list()\n-            uniques = df.loc[:, cols_with_single].head(1)\n+            uniques = pd.DataFrame({\n+                column_name: [column.sort_values(kind='mergesort').values[0]]\n+                for column_name, column in df.loc[:, cols_with_single].items()\n+            })\n             uniques.index = ['Single unique value']\n             display = ['The following columns have only one unique value', uniques]\n         else:\ndiff --git a/docs/source/checks/tabular/data_integrity/plot_is_single_value.py b/docs/source/checks/tabular/data_integrity/plot_is_single_value.py\n--- a/docs/source/checks/tabular/data_integrity/plot_is_single_value.py\n+++ b/docs/source/checks/tabular/data_integrity/plot_is_single_value.py\n@@ -8,6 +8,7 @@\n # Imports\n # =======\n \n+import numpy as np\n import pandas as pd\n from sklearn.datasets import load_iris\n \n@@ -41,3 +42,14 @@\n \n sv_ignore = IsSingleValue(ignore_columns=['b','c'])\n sv_ignore.run(df)\n+\n+#%%\n+\n+# Ignoring NaN values\n+\n+IsSingleValue(ignore_nan=True).run(pd.DataFrame({\n+    'a': [3, np.nan], \n+    'b': [2, 2],\n+    'c': [None, np.nan], \n+    'd': ['a', 4]\n+}))\n", "issue": "[FEAT] Enable ignoring Null values in the Is Single Value check\n**Is your feature request related to a problem? Please describe.**\r\nCurrently, if the data has both a single value and NaNs in the same column, this column will be considered to have 2 unique values.\r\n\r\n**Describe the solution you'd like**\r\nAdd a Boolean parameter telling the check to disregard NaN's\r\n\r\n**Additional context**\r\nIssue raised by @galsr in the [Deepchecks Community](https://join.slack.com/t/deepcheckscommunity/shared_invite/zt-1973c7twx-Ytb7_yJefTT4PmnMZj2p7A) support channel. \n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"\nIs Single Value\n***************\n\"\"\"\n\n#%%\n# Imports\n# =======\n\nimport pandas as pd\nfrom sklearn.datasets import load_iris\n\nfrom deepchecks.tabular.checks import IsSingleValue\n\n#%%\n# Load Data\n# =========\n\niris = load_iris()\nX = iris.data\ndf = pd.DataFrame({'a':[3,4,1], 'b':[2,2,2], 'c':[None, None, None], 'd':['a', 4, 6]})\ndf\n\n#%%\n# See functionality\n# =================\n\nIsSingleValue().run(pd.DataFrame(X))\n\n#%%\n\nIsSingleValue().run(pd.DataFrame({'a':[3,4], 'b':[2,2], 'c':[None, None], 'd':['a', 4]}))\n\n#%%\n\nsv = IsSingleValue()\nsv.run(df)\n\n#%%\n\nsv_ignore = IsSingleValue(ignore_columns=['b','c'])\nsv_ignore.run(df)\n", "path": "docs/source/checks/tabular/data_integrity/plot_is_single_value.py"}, {"content": "# ----------------------------------------------------------------------------\n# Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)\n#\n# This file is part of Deepchecks.\n# Deepchecks is distributed under the terms of the GNU Affero General\n# Public License (version 3 or later).\n# You should have received a copy of the GNU Affero General Public License\n# along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.\n# ----------------------------------------------------------------------------\n#\n\"\"\"Module contains is_single_value check.\"\"\"\nfrom typing import List, Union\n\nfrom deepchecks.core import CheckResult, ConditionCategory, ConditionResult\nfrom deepchecks.tabular import Context, SingleDatasetCheck\nfrom deepchecks.tabular.utils.messages import get_condition_passed_message\nfrom deepchecks.utils.dataframes import select_from_dataframe\nfrom deepchecks.utils.typing import Hashable\n\n__all__ = ['IsSingleValue']\n\n\nclass IsSingleValue(SingleDatasetCheck):\n    \"\"\"Check if there are columns which have only a single unique value in all rows.\n\n    Parameters\n    ----------\n    columns : Union[Hashable, List[Hashable]] , default: None\n        Columns to check, if none are given checks all\n        columns except ignored ones.\n    ignore_columns : Union[Hashable, List[Hashable]] , default: None\n        Columns to ignore, if none given checks based\n        on columns variable.\n    \"\"\"\n\n    def __init__(\n        self,\n        columns: Union[Hashable, List[Hashable], None] = None,\n        ignore_columns: Union[Hashable, List[Hashable], None] = None,\n        **kwargs\n    ):\n        super().__init__(**kwargs)\n        self.columns = columns\n        self.ignore_columns = ignore_columns\n\n    def run_logic(self, context: Context, dataset_type: str = 'train') -> CheckResult:\n        \"\"\"Run check.\n\n        Returns\n        -------\n        CheckResult\n            value of result is a dict of all columns with number of unique values in format {column: number_of_uniques}\n            display is a series with columns that have only one unique\n        \"\"\"\n        # Validate parameters\n        if dataset_type == 'train':\n            df = context.train.data\n        else:\n            df = context.test.data\n\n        df = select_from_dataframe(df, self.columns, self.ignore_columns)\n\n        num_unique_per_col = df.nunique(dropna=False)\n        is_single_unique_value = (num_unique_per_col == 1)\n\n        if is_single_unique_value.any():\n            # get names of columns with one unique value\n            # pylint: disable=unsubscriptable-object\n            cols_with_single = is_single_unique_value[is_single_unique_value].index.to_list()\n            uniques = df.loc[:, cols_with_single].head(1)\n            uniques.index = ['Single unique value']\n            display = ['The following columns have only one unique value', uniques]\n        else:\n            display = None\n\n        return CheckResult(num_unique_per_col.to_dict(), header='Single Value in Column', display=display)\n\n    def add_condition_not_single_value(self):\n        \"\"\"Add condition - not single value.\"\"\"\n        name = 'Does not contain only a single value'\n\n        def condition(result):\n            single_value_cols = [k for k, v in result.items() if v == 1]\n            if single_value_cols:\n                details = f'Found {len(single_value_cols)} out of {len(result)} columns with a single value: ' \\\n                          f'{single_value_cols}'\n                return ConditionResult(ConditionCategory.FAIL, details)\n            else:\n                return ConditionResult(ConditionCategory.PASS, get_condition_passed_message(result))\n\n        return self.add_condition(name, condition)\n", "path": "deepchecks/tabular/checks/data_integrity/is_single_value.py"}]}