Repository: great-expectations/great_expectations

Issue:
Use cleaner solution for non-truncating division in python 2
Prefer `from __future__ import division` to `1.*x/y`


Discussion:
Done inline during improve_partitions push.

Resolving patch:
diff --git a/great_expectations/rule_based_profiler/parameter_builder/partition_parameter_builder.py b/great_expectations/rule_based_profiler/parameter_builder/partition_parameter_builder.py
--- a/great_expectations/rule_based_profiler/parameter_builder/partition_parameter_builder.py
+++ b/great_expectations/rule_based_profiler/parameter_builder/partition_parameter_builder.py
@@ -49,6 +49,9 @@ def __init__(
         self,
         name: str,
         bucketize_data: Union[str, bool] = True,
+        bins: str = "uniform",
+        n_bins: int = 10,
+        allow_relative_error: bool = False,
         evaluation_parameter_builder_configs: Optional[
             List[ParameterBuilderConfig]
         ] = None,
@@ -60,6 +63,10 @@ def __init__(
             it is not the fully-qualified parameter name; a fully-qualified parameter name must start with "$parameter."
             and may contain one or more subsequent parts (e.g., "$parameter.<my_param_from_config>.<metric_name>").
             bucketize_data: If True (default), then data is continuous (non-categorical); hence, must bucketize it.
+            bins: Partitioning strategy (one of "uniform", "ntile", "quantile", "percentile", or "auto"); please refer
+            to "ColumnPartition" (great_expectations/expectations/metrics/column_aggregate_metrics/column_partition.py).
+            n_bins: Number of bins for histogram computation (ignored and recomputed if "bins" argument is "auto").
+            allow_relative_error: Used for partitionong strategy values that involve quantiles (all except "uniform").
             evaluation_parameter_builder_configs: ParameterBuilder configurations, executing and making whose respective
             ParameterBuilder objects' outputs available (as fully-qualified parameter names) is pre-requisite.
             These "ParameterBuilder" configurations help build parameters needed for this "ParameterBuilder".
@@ -74,8 +81,9 @@ def __init__(
                 metric_name="column.partition",
                 metric_domain_kwargs=DOMAIN_KWARGS_PARAMETER_FULLY_QUALIFIED_NAME,
                 metric_value_kwargs={
-                    "bins": "auto",
-                    "allow_relative_error": False,
+                    "bins": bins,
+                    "n_bins": n_bins,
+                    "allow_relative_error": allow_relative_error,
                 },
                 enforce_numeric_metric=False,
                 replace_nan_with_zero=False,
@@ -176,7 +184,7 @@ def _build_parameters(
 
         if bins is None:
             is_categorical = True
-        else:
+        elif not is_categorical:
             ndarray_is_datetime_type: bool = is_ndarray_datetime_dtype(
                 data=bins,
                 parse_strings_as_datetimes=True,
@@ -189,10 +197,8 @@ def _build_parameters(
             else:
                 bins_ndarray_as_float = bins
 
-            is_categorical = (
-                is_categorical
-                or ndarray_is_datetime_type
-                or not np.all(np.diff(bins_ndarray_as_float) > 0.0)
+            is_categorical = ndarray_is_datetime_type or not np.all(
+                np.diff(bins_ndarray_as_float) > 0.0
             )
 
         fully_qualified_column_values_nonnull_count_metric_parameter_builder_name: str = f"{RAW_PARAMETER_KEY}{self._column_values_nonnull_count_metric_single_batch_parameter_builder_config.name}"


Test patch:
diff --git a/tests/rule_based_profiler/parameter_builder/test_partition_parameter_builder.py b/tests/rule_based_profiler/parameter_builder/test_partition_parameter_builder.py
--- a/tests/rule_based_profiler/parameter_builder/test_partition_parameter_builder.py
+++ b/tests/rule_based_profiler/parameter_builder/test_partition_parameter_builder.py
@@ -57,6 +57,7 @@ def test_partition_parameter_builder_alice_continuous(
     parameter_builder: ParameterBuilder = PartitionParameterBuilder(
         name="my_name",
         bucketize_data=True,
+        bins="auto",
         evaluation_parameter_builder_configs=None,
         data_context=data_context,
     )
@@ -125,6 +126,7 @@ def test_partition_parameter_builder_alice_categorical(
     parameter_builder: ParameterBuilder = PartitionParameterBuilder(
         name="my_name",
         bucketize_data=False,
+        bins="auto",
         evaluation_parameter_builder_configs=None,
         data_context=data_context,
     )
@@ -192,6 +194,7 @@ def test_partition_parameter_builder_alice_continuous_changed_to_categorical(
     parameter_builder: ParameterBuilder = PartitionParameterBuilder(
         name="my_name",
         bucketize_data=True,
+        bins="auto",
         evaluation_parameter_builder_configs=None,
         data_context=data_context,
     )
@@ -257,6 +260,7 @@ def test_partition_parameter_builder_alice_continuous_check_serialized_keys(
     parameter_builder: ParameterBuilder = PartitionParameterBuilder(
         name="my_name",
         bucketize_data=True,
+        bins="auto",
         evaluation_parameter_builder_configs=None,
         data_context=data_context,
     )