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/profile/basic_suite_builder_profiler.py b/great_expectations/profile/basic_suite_builder_profiler.py
--- a/great_expectations/profile/basic_suite_builder_profiler.py
+++ b/great_expectations/profile/basic_suite_builder_profiler.py
@@ -153,10 +153,11 @@ def _create_non_nullity_expectations(cls, dataset, column):
         not_null_result = dataset.expect_column_values_to_not_be_null(column)
         if not not_null_result.success:
             unexpected_percent = float(not_null_result.result["unexpected_percent"])
-            mostly_value = round(
-                max(0.001, (100.0 - unexpected_percent - 10) / 100.0), 2
+            potential_mostly_value = (100.0 - unexpected_percent - 10) / 100.0
+            safe_mostly_value = round(max(0.001, potential_mostly_value), 3)
+            dataset.expect_column_values_to_not_be_null(
+                column, mostly=safe_mostly_value
             )
-            dataset.expect_column_values_to_not_be_null(column, mostly=mostly_value)
 
     @classmethod
     def _create_expectations_for_numeric_column(cls, dataset, column):


Test patch:
diff --git a/tests/profile/fixtures/expected_evrs_BasicSuiteBuilderProfiler_on_titanic_demo_mode.json b/tests/profile/fixtures/expected_evrs_BasicSuiteBuilderProfiler_on_titanic_demo_mode.json
--- a/tests/profile/fixtures/expected_evrs_BasicSuiteBuilderProfiler_on_titanic_demo_mode.json
+++ b/tests/profile/fixtures/expected_evrs_BasicSuiteBuilderProfiler_on_titanic_demo_mode.json
@@ -739,7 +739,7 @@
       "expectation_config": {
         "kwargs": {
           "column": "Age",
-          "mostly": 0.48,
+          "mostly": 0.476,
           "result_format": "SUMMARY"
         },
         "meta": {},
diff --git a/tests/profile/fixtures/expected_evrs_SuiteBuilderProfiler_on_titanic_with_configurations.json b/tests/profile/fixtures/expected_evrs_SuiteBuilderProfiler_on_titanic_with_configurations.json
--- a/tests/profile/fixtures/expected_evrs_SuiteBuilderProfiler_on_titanic_with_configurations.json
+++ b/tests/profile/fixtures/expected_evrs_SuiteBuilderProfiler_on_titanic_with_configurations.json
@@ -515,7 +515,7 @@
         "meta": {},
         "kwargs": {
           "column": "Age",
-          "mostly": 0.48,
+          "mostly": 0.476,
           "result_format": "SUMMARY"
         },
         "expectation_type": "expect_column_values_to_not_be_null"
diff --git a/tests/profile/test_basic_suite_builder_profiler.py b/tests/profile/test_basic_suite_builder_profiler.py
--- a/tests/profile/test_basic_suite_builder_profiler.py
+++ b/tests/profile/test_basic_suite_builder_profiler.py
@@ -610,7 +610,7 @@ def test_BasicSuiteBuilderProfiler_uses_all_columns_if_configuration_does_not_ha
                 "expectation_type": "expect_column_values_to_be_unique",
             },
             {
-                "kwargs": {"column": "nulls", "mostly": 0.47},
+                "kwargs": {"column": "nulls", "mostly": 0.471},
                 "meta": {"BasicSuiteBuilderProfiler": {"confidence": "very low"}},
                 "expectation_type": "expect_column_values_to_not_be_null",
             },
@@ -911,7 +911,7 @@ def test_BasicSuiteBuilderProfiler_respects_included_expectations_on_pandas(
             },
             {
                 "meta": {"BasicSuiteBuilderProfiler": {"confidence": "very low"}},
-                "kwargs": {"column": "nulls", "mostly": 0.47},
+                "kwargs": {"column": "nulls", "mostly": 0.471},
                 "expectation_type": "expect_column_values_to_not_be_null",
             },
         ],
@@ -1088,7 +1088,7 @@ def test_BasicSuiteBuilderProfiler_uses_all_expectations_if_excluded_expectation
                 "meta": {"BasicSuiteBuilderProfiler": {"confidence": "very low"}},
             },
             {
-                "kwargs": {"column": "nulls", "mostly": 0.47},
+                "kwargs": {"column": "nulls", "mostly": 0.471},
                 "expectation_type": "expect_column_values_to_not_be_null",
                 "meta": {"BasicSuiteBuilderProfiler": {"confidence": "very low"}},
             },
@@ -1234,7 +1234,7 @@ def test_BasicSuiteBuilderProfiler_uses_all_columns_if_excluded_columns_are_fals
             {
                 "expectation_type": "expect_column_values_to_not_be_null",
                 "meta": {"BasicSuiteBuilderProfiler": {"confidence": "very low"}},
-                "kwargs": {"column": "nulls", "mostly": 0.47},
+                "kwargs": {"column": "nulls", "mostly": 0.471},
             },
         ],
     )