Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix arange float & tests devices #638

Merged
merged 5 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- [#634](https://github.com/helmholtz-analytics/heat/pull/634) New features: `kmedians`, `kmedoids`, `manhattan`
- [#633](https://github.com/helmholtz-analytics/heat/pull/633) Documentation: updated contributing.md
- [#635](https://github.com/helmholtz-analytics/heat/pull/635) `DNDarray.__getitem__` balances and resplits the given key to None if the key is a DNDarray
- [#638](https://github.com/helmholtz-analytics/heat/pull/638) Fix: arange returns float32 with single input of type float & update skipped device tests

# v0.4.0

Expand Down
2 changes: 1 addition & 1 deletion heat/core/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def arange(*args, dtype=None, split=None, device=None, comm=None):
if num_of_param == 1:
if dtype is None:
# use int32 as default instead of int64 used in numpy
dtype = types.int32
dtype = types.int32 if all_ints else types.float32
start = 0
stop = int(np.ceil(args[0]))
step = 1
Expand Down
12 changes: 6 additions & 6 deletions heat/core/tests/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@


class TestDevices(TestCase):
@unittest.skipIf(envar not in ["cpu", "lgpu"], "only supported for cpu")
@unittest.skipIf(envar not in ["cpu"], "only supported for cpu")
def test_get_default_device_cpu(self):
self.assertIs(ht.get_device(), ht.cpu)

@unittest.skipIf(envar not in ["gpu", "lcpu"], "only supported for gpu")
@unittest.skipIf(envar not in ["gpu"], "only supported for gpu")
def test_get_default_device_gpu(self):
if ht.torch.cuda.is_available():
self.assertIs(ht.get_device(), ht.gpu)

@unittest.skipIf(envar not in ["cpu", "lgpu"], "only supported for cpu")
@unittest.skipIf(envar not in ["cpu"], "only supported for cpu")
def test_sanitize_device_cpu(self):
self.assertIs(ht.sanitize_device("cpu"), ht.cpu)
self.assertIs(ht.sanitize_device("cPu"), ht.cpu)
Expand All @@ -30,7 +30,7 @@ def test_sanitize_device_cpu(self):
with self.assertRaises(ValueError):
self.assertIs(ht.sanitize_device(1), ht.cpu)

@unittest.skipIf(envar not in ["gpu", "lcpu"], "only supported for gpu")
@unittest.skipIf(envar not in ["gpu"], "only supported for gpu")
def test_sanitize_device_gpu(self):
if ht.torch.cuda.is_available():
self.assertIs(ht.sanitize_device("gpu"), ht.gpu)
Expand All @@ -44,7 +44,7 @@ def test_sanitize_device_gpu(self):
with self.assertRaises(ValueError):
self.assertIs(ht.sanitize_device(1), ht.gpu)

@unittest.skipIf(envar not in ["cpu", "lgpu"], "only supported for cpu")
@unittest.skipIf(envar not in ["cpu"], "only supported for cpu")
def test_set_default_device_cpu(self):
ht.use_device("cpu")
self.assertIs(ht.get_device(), ht.cpu)
Expand All @@ -58,7 +58,7 @@ def test_set_default_device_cpu(self):
with self.assertRaises(ValueError):
ht.use_device(1)

@unittest.skipIf(envar not in ["gpu", "lcpu"], "only supported for gpu")
@unittest.skipIf(envar not in ["gpu"], "only supported for gpu")
def test_set_default_device_gpu(self):
if ht.torch.cuda.is_available():
ht.use_device("gpu")
Expand Down