Skip to content

Commit

Permalink
Merge pull request #370 from davidhassell/dask-round
Browse files Browse the repository at this point in the history
dask: `Data.__round__`
  • Loading branch information
davidhassell authored Apr 20, 2022
2 parents 55cfa9e + eff87ca commit 6b8bfea
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
13 changes: 0 additions & 13 deletions cf/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,19 +793,6 @@ def __float__(self):
"""
return float(self._get_dask())

def __round__(self, *ndigits):
"""Called to implement the built-in function `round`
x.__round__(*ndigits) <==> round(x, *ndigits)
"""
if self.size != 1:
raise TypeError(
"only length-1 arrays can be converted to Python scalars"
)

return round(self.datum(), *ndigits)

@daskified(_DASKIFIED_VERBOSE)
def __int__(self):
"""Called to implement the built-in function `int`
Expand Down
26 changes: 0 additions & 26 deletions cf/test/test_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2318,32 +2318,6 @@ def test_Data__int__(self):
with self.assertRaises(Exception):
_ = int(cf.Data([1, 2]))

def test_Data__round__(self):
if self.test_only and inspect.stack()[0][3] not in self.test_only:
return

for ndigits in ([], [0], [1], [2], [3]):
for x in (
-1.9123,
-1.5789,
-1.4123,
-1.789,
0,
1.123,
1.0234,
1.412,
1.9345,
):
self.assertEqual(
round(cf.Data(x), *ndigits), round(x, *ndigits)
)
self.assertEqual(
round(cf.Data(x), *ndigits), round(x, *ndigits)
)

with self.assertRaises(Exception):
_ = round(cf.Data([1, 2]))

def test_Data_argmax(self):
if self.test_only and inspect.stack()[0][3] not in self.test_only:
return
Expand Down

0 comments on commit 6b8bfea

Please sign in to comment.