Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Issue_1885_Feature_request_abs (#2970)
Browse files Browse the repository at this point in the history
Co-authored-by: Dhivya Kanakabala <12594529+dhivyaaxim@users.noreply.github.com>
  • Loading branch information
Hoyt Koepke and dhivyaaxim committed Jan 30, 2020
1 parent 647f678 commit 4994f05
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/python/turicreate/data_structures/sarray.py
Expand Up @@ -4434,4 +4434,20 @@ def __deepcopy__(self, memo):
return SArray(_proxy = self.__proxy__)

def abs(self):
"""
Returns a new SArray containing the absolute value of each element.
Examples
--------
>>> tc.SArray([1, -1, -2]).abs()
dtype: int
Rows: 3
[1, 1, 2]
>>> tc.SArray([-1., -2.]).abs()
dtype: float
Rows: 2
[1.0, 2.0]
"""

return abs(self)
1 change: 0 additions & 1 deletion src/python/turicreate/test/test_sarray.py
Expand Up @@ -3221,4 +3221,3 @@ def test_abs(self):
result = sa.abs()
expected = [1.1, 2.0, 3.33, 4.0]
self.__test_equal(result, expected, float)

0 comments on commit 4994f05

Please sign in to comment.