From 71df26de63d0f6b0eb0f4c6f08e248468b1a47c8 Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Feb 2022 20:53:14 +0000 Subject: [PATCH 1/9] Convert Data.sin from use of func() to use of Dask built-in --- cf/data/data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cf/data/data.py b/cf/data/data.py index 78868d0336..1fb95de89b 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -11840,7 +11840,10 @@ def sin(self, inplace=False, i=False): if d.Units.equivalent(_units_radians): d.Units = _units_radians - d.func(np.sin, units=_units_1, inplace=True) + dx = d._get_dask() + d._set_dask(da.sin(dx), reset_mask_hardness=False) + + d.override_units(_units_1, inplace=True) return d From 3f80e8ace0e07833804d790d803c84c3e9227b1f Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Feb 2022 22:51:05 +0000 Subject: [PATCH 2/9] Convert Data.cos from use of func() to use of Dask built-in --- cf/data/data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cf/data/data.py b/cf/data/data.py index 1fb95de89b..f65e08f5bf 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -8585,7 +8585,10 @@ def cos(self, inplace=False, i=False): if d.Units.equivalent(_units_radians): d.Units = _units_radians - d.func(np.cos, units=_units_1, inplace=True) + dx = d._get_dask() + d._set_dask(da.cos(dx), reset_mask_hardness=False) + + d.override_units(_units_1, inplace=True) return d From ce55ad04cb7dccde5e2b095335b5df8c58c5e09c Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Feb 2022 22:55:41 +0000 Subject: [PATCH 3/9] Convert Data.tan from use of func() to use of Dask built-in --- cf/data/data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cf/data/data.py b/cf/data/data.py index f65e08f5bf..edfa9ad290 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -12229,7 +12229,10 @@ def tan(self, inplace=False, i=False): if d.Units.equivalent(_units_radians): d.Units = _units_radians - d.func(np.tan, units=_units_1, inplace=True) + dx = d._get_dask() + d._set_dask(da.tan(dx), reset_mask_hardness=False) + + d.override_units(_units_1, inplace=True) return d From 59a571f22d376d7aedd2f23f2f4d453ffbaaa29b Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Feb 2022 23:19:37 +0000 Subject: [PATCH 4/9] Convert Data.sinh from use of func() to use of Dask built-in --- cf/data/data.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cf/data/data.py b/cf/data/data.py index edfa9ad290..ab2e50ff97 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -11904,7 +11904,11 @@ def sinh(self, inplace=False): if d.Units.equivalent(_units_radians): d.Units = _units_radians - d.func(np.sinh, units=_units_1, inplace=True) + dx = d._get_dask() + d._set_dask(da.sinh(dx), reset_mask_hardness=False) + + d.override_units(_units_1, inplace=True) + return d @daskified(_DASKIFIED_VERBOSE) From 5a482fc9fcf64ae44d73c57773b78289507bca54 Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Feb 2022 23:21:52 +0000 Subject: [PATCH 5/9] Convert Data.cosh from use of func() to use of Dask built-in --- cf/data/data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cf/data/data.py b/cf/data/data.py index ab2e50ff97..6cb3330c7c 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -11963,7 +11963,10 @@ def cosh(self, inplace=False): if d.Units.equivalent(_units_radians): d.Units = _units_radians - d.func(np.cosh, units=_units_1, inplace=True) + dx = d._get_dask() + d._set_dask(da.cosh(dx), reset_mask_hardness=False) + + d.override_units(_units_1, inplace=True) return d From 1832c86d9415cc2f461a6d3365e68e9f78f96f8e Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Feb 2022 23:22:54 +0000 Subject: [PATCH 6/9] Convert Data.tanh from use of func() to use of Dask built-in --- cf/data/data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cf/data/data.py b/cf/data/data.py index 6cb3330c7c..b30d65ba80 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -12025,7 +12025,10 @@ def tanh(self, inplace=False): if d.Units.equivalent(_units_radians): d.Units = _units_radians - d.func(np.tanh, units=_units_1, inplace=True) + dx = d._get_dask() + d._set_dask(da.tanh(dx), reset_mask_hardness=False) + + d.override_units(_units_1, inplace=True) return d From 42b9fd418b2a6ddfb829f9fe45bac56098c0d7b8 Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Feb 2022 23:29:24 +0000 Subject: [PATCH 7/9] Convert Data.arctan from use of func() to use of Dask built-in --- cf/data/data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cf/data/data.py b/cf/data/data.py index b30d65ba80..4a75f71f81 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -6696,7 +6696,10 @@ def arctan(self, inplace=False): """ d = _inplace_enabled_define_and_cleanup(self) - d.func(np.arctan, units=_units_radians, inplace=True) + dx = d._get_dask() + d._set_dask(da.arctan(dx), reset_mask_hardness=False) + + d.override_units(_units_radians, inplace=True) return d From dd426af4d28d11b2f65980035a8d16acae4c3441 Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Feb 2022 23:32:04 +0000 Subject: [PATCH 8/9] Convert Data.arcsinh from use of func() to use of Dask built-in --- cf/data/data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cf/data/data.py b/cf/data/data.py index 4a75f71f81..946032ccd0 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -6891,7 +6891,10 @@ def arcsinh(self, inplace=False): """ d = _inplace_enabled_define_and_cleanup(self) - d.func(np.arcsinh, units=_units_radians, inplace=True) + dx = d._get_dask() + d._set_dask(da.arcsinh(dx), reset_mask_hardness=False) + + d.override_units(_units_radians, inplace=True) return d From 49ef9f679e4002e8065a68d6a67d750b2cec9da1 Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Thu, 3 Feb 2022 00:04:35 +0000 Subject: [PATCH 9/9] Add comments RE why Data.func is used for restricted-domain methods --- cf/data/data.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cf/data/data.py b/cf/data/data.py index 946032ccd0..d61b165cb8 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -6787,7 +6787,9 @@ def arctanh(self, inplace=False): """ d = _inplace_enabled_define_and_cleanup(self) - # preserve_invalid necessary because arctanh has a restricted domain + # Data.func is used instead of the Dask built-in in this case because + # arctanh has a restricted domain therefore it is necessary to use our + # custom logic implemented via the `preserve_invalid` keyword to func. d.func( np.arctanh, units=_units_radians, @@ -6840,7 +6842,9 @@ def arcsin(self, inplace=False): """ d = _inplace_enabled_define_and_cleanup(self) - # preserve_invalid necessary because arcsin has a restricted domain + # Data.func is used instead of the Dask built-in in this case because + # arcsin has a restricted domain therefore it is necessary to use our + # custom logic implemented via the `preserve_invalid` keyword to func. d.func( np.arcsin, units=_units_radians, @@ -6942,7 +6946,9 @@ def arccos(self, inplace=False): """ d = _inplace_enabled_define_and_cleanup(self) - # preserve_invalid necessary because arccos has a restricted domain + # Data.func is used instead of the Dask built-in in this case because + # arccos has a restricted domain therefore it is necessary to use our + # custom logic implemented via the `preserve_invalid` keyword to func. d.func( np.arccos, units=_units_radians, @@ -6995,7 +7001,9 @@ def arccosh(self, inplace=False): """ d = _inplace_enabled_define_and_cleanup(self) - # preserve_invalid necessary because arccosh has a restricted domain + # Data.func is used instead of the Dask built-in in this case because + # arccosh has a restricted domain therefore it is necessary to use our + # custom logic implemented via the `preserve_invalid` keyword to func. d.func( np.arccosh, units=_units_radians,