Repository: sdv-dev/RDT (language: python)

Issue:
Add support for numpy 2.0.0
### Problem Description
- Currently, we restrict numpy < 2 for all python versions.
- We would like to support the newest major release of numpy. 

### Expected behavior
- RDT supports numpy 2.0

### Additional context
- Remove upper bound restriction in pyproject.toml
- Update any associated tests


Discussion / hints:

Fix patch:
diff --git a/pyproject.toml b/pyproject.toml
index 3e502dca..2c6f32fc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,9 +21,9 @@ license = { text = 'BSL-1.1' }
 requires-python = '>=3.8,<3.13'
 readme = 'README.md'
 dependencies = [
-    "numpy>=1.21.0,<2.0.0;python_version<'3.10'",
-    "numpy>=1.23.3,<2.0.0;python_version>='3.10' and python_version<'3.12'",
-    "numpy>=1.26.0,<2.0.0;python_version>='3.12'",
+    "numpy>=1.21.0;python_version<'3.10'",
+    "numpy>=1.23.3;python_version>='3.10' and python_version<'3.12'",
+    "numpy>=1.26.0;python_version>='3.12'",
     "pandas>=1.4.0;python_version<'3.11'",
     "pandas>=1.5.0;python_version>='3.11' and python_version<'3.12'",
     "pandas>=2.1.1;python_version>='3.12'",


Test patch:
diff --git a/tests/datasets/tests/test_categorical.py b/tests/datasets/tests/test_categorical.py
index 35e81b7b..ded1b3cd 100644
--- a/tests/datasets/tests/test_categorical.py
+++ b/tests/datasets/tests/test_categorical.py
@@ -1,5 +1,6 @@
 import numpy as np
 import pandas as pd
+from pandas.api.types import is_integer_dtype
 
 from rdt.performance.datasets import categorical
 
@@ -8,7 +9,7 @@ class TestRandomIntegerGenerator:
     def test(self):
         output = categorical.RandomIntegerGenerator.generate(10)
         assert len(output) == 10
-        assert output.dtype == int
+        assert is_integer_dtype(output.dtype)
         assert len(pd.unique(output)) < 6
         assert np.isnan(output).sum() == 0
 
@@ -60,7 +61,7 @@ class TestSingleIntegerGenerator:
     def test(self):
         output = categorical.SingleIntegerGenerator.generate(10)
         assert len(output) == 10
-        assert output.dtype == int
+        assert is_integer_dtype(output.dtype)
         assert len(pd.unique(output)) == 1
         assert np.isnan(output).sum() == 0
 
@@ -96,7 +97,7 @@ class TestUniqueIntegerGenerator:
     def test(self):
         output = categorical.UniqueIntegerGenerator.generate(10)
         assert len(output) == 10
-        assert output.dtype == int
+        assert is_integer_dtype(output.dtype)
         assert len(pd.unique(output)) == 10
         assert np.isnan(output).sum() == 0
 
diff --git a/tests/datasets/tests/test_numerical.py b/tests/datasets/tests/test_numerical.py
index 7948317e..ab99428e 100644
--- a/tests/datasets/tests/test_numerical.py
+++ b/tests/datasets/tests/test_numerical.py
@@ -1,5 +1,6 @@
 import numpy as np
 import pandas as pd
+from pandas.api.types import is_integer_dtype
 
 from rdt.performance.datasets import numerical
 
@@ -8,7 +9,7 @@ class TestRandomIntegerGenerator:
     def test(self):
         output = numerical.RandomIntegerGenerator.generate(10)
         assert len(output) == 10
-        assert output.dtype == int
+        assert is_integer_dtype(output.dtype)
         assert len(pd.unique(output)) > 1
         assert np.isnan(output).sum() == 0
 
@@ -26,7 +27,7 @@ class TestConstantIntegerGenerator:
     def test(self):
         output = numerical.ConstantIntegerGenerator.generate(10)
         assert len(output) == 10
-        assert output.dtype == int
+        assert is_integer_dtype(output.dtype)
         assert len(pd.unique(output)) == 1
         assert np.isnan(output).sum() == 0
 
@@ -44,7 +45,7 @@ class TestAlmostConstantIntegerGenerator:
     def test(self):
         output = numerical.AlmostConstantIntegerGenerator.generate(10)
         assert len(output) == 10
-        assert output.dtype == int
+        assert is_integer_dtype(output.dtype)
         assert len(pd.unique(output)) == 2
         assert np.isnan(output).sum() == 0
 
diff --git a/tests/unit/transformers/test_categorical.py b/tests/unit/transformers/test_categorical.py
index ee32f264..8f99f127 100644
--- a/tests/unit/transformers/test_categorical.py
+++ b/tests/unit/transformers/test_categorical.py
@@ -485,12 +485,12 @@ def test__fit_error(self):
         If the data being fit is not in ``self.order`` an error should be raised.
         """
         # Setup
-        data = pd.Series([1, 2, 3, 2, 1, 4])
-        transformer = OrderedUniformEncoder(order=[2, 1])
+        data = pd.Series(['1', '2', '3', '2', '1', '4'], dtype='object')
+        transformer = OrderedUniformEncoder(order=['2', '1'])
 
         # Run / Assert
         message = re.escape(
-            "Unknown categories '[3, 4]'. All possible categories must be defined in the "
+            "Unknown categories '['3', '4']'. All possible categories must be defined in the "
             "'order' parameter."
         )
         with pytest.raises(TransformerInputError, match=message):
@@ -567,12 +567,12 @@ def test__transform_error(self):
         If the data being transformed is not in ``self.order`` an error should be raised.
         """
         # Setup
-        data = pd.Series([1, 2, 3, 2, 1, 4])
-        transformer = OrderedUniformEncoder(order=[2, 1])
+        data = pd.Series(['1', '2', '3', '2', '1', '4'], dtype='object')
+        transformer = OrderedUniformEncoder(order=['2', '1'])
 
         # Run / Assert
         message = re.escape(
-            "Unknown categories '[3, 4]'. All possible categories must be defined in the "
+            "Unknown categories '['3', '4']'. All possible categories must be defined in the "
             "'order' parameter."
         )
         with pytest.raises(TransformerInputError, match=message):
@@ -1791,12 +1791,12 @@ def test__transform_unknown(self):
         # Run
         warning_msg = re.escape(
             'The data contains 1 new categories that were not '
-            'seen in the original data (examples: {4.0}). Creating '
+            "seen in the original data (examples: {'4'}). Creating "
             'a vector of all 0s. If you want to model new categories, '
             'please fit the transformer again with the new data.'
         )
         with pytest.warns(UserWarning, match=warning_msg):
-            transform_data = pd.Series([1, 2, np.nan, 4])
+            transform_data = pd.Series([1, 2, np.nan, '4'], dtype='object')
             out = ohe._transform(transform_data)
 
         # Assert
@@ -2375,24 +2375,14 @@ def test__fit_error(self):
         """Test the ``_fit`` method checks that data is in ``self.order``.
 
         If the data being fit is not in ``self.order`` an error should be raised.
-
-        Setup:
-            - create an instance of the ``OrderedLabelEncoder``.
-
-        Input:
-            - a pandas series.
-
-        Side effects:
-            - set the ``values_to_categories`` dictionary to the appropriate value.
-            - set ``categories_to_values`` dictionary to the appropriate value.
         """
         # Setup
-        data = pd.Series([1, 2, 3, 2, 1, 4])
-        transformer = OrderedLabelEncoder(order=[2, 1])
+        data = pd.Series(['1', '2', '3', '2', '1', '4'], dtype='object')
+        transformer = OrderedLabelEncoder(order=['2', '1'])
 
         # Run / Assert
         message = re.escape(
-            "Unknown categories '[3, 4]'. All possible categories must be defined in the "
+            "Unknown categories '['3', '4']'. All possible categories must be defined in the "
             "'order' parameter."
         )
         with pytest.raises(TransformerInputError, match=message):