Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions futhark_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
err = self._read_response()
raise Failure('\n'.join(err))
elif l == '':
raise Exception('Unexpected EOF from Futhark server process.')

Check failure on line 57 in futhark_server/__init__.py

View workflow job for this annotation

GitHub Actions / test (3.10)

Unexpected EOF from Futhark server process.

Check failure on line 57 in futhark_server/__init__.py

View workflow job for this annotation

GitHub Actions / test (3.11)

Unexpected EOF from Futhark server process.

Check failure on line 57 in futhark_server/__init__.py

View workflow job for this annotation

GitHub Actions / test (3.10)

Unexpected EOF from Futhark server process.

Check failure on line 57 in futhark_server/__init__.py

View workflow job for this annotation

GitHub Actions / test (3.11)

Unexpected EOF from Futhark server process.
ls = ls + [l[:-1]] # Remove final \n

def cmd(self, *args):
Expand Down Expand Up @@ -100,8 +100,8 @@
def cmd_inputs(self, entry):
return self.cmd('inputs', entry)

def cmd_outputs(self, entry):
return self.cmd('outputs', entry)
def cmd_output(self, entry):
return self.cmd('output', entry)

def cmd_clear(self):
self.cmd('clear')
Expand Down Expand Up @@ -136,8 +136,9 @@
def get_value(self, v):
"""Retrieve Futhark value in given variable.

This only produces a meaningful value if the type of the value
is non-opaque (i.e., a primitive or array of primitives).
This only produces a meaningful value if the type of the value is
non-opaque (i.e., a primitive, array of primitives, or tuple of
primitives).

"""
def unpack(val):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import find_packages, setup

setup(name='futhark-server',
version='1.0.0',
version='1.0.1',
url='https://github.com/diku-dk/futhark-server-python',
license='ISC',
author='Troels Henriksen',
Expand Down
7 changes: 5 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ let
my-python-packages = ps: with ps; [
(buildPythonPackage rec {
pname = "futhark-data";
version = "1.0.2";
version = "1.0.3";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-FJOhVr65U3kP408BbA42jbGGD6x+tVh+TNhsYv8bUT0=";
sha256 = "sha256-HoxeSLXt2B1X3PZmfZmnIOipLec4ba3VkUBLtZhVPPU=";
};
pyproject = true;
dependencies = [ numpy ] ;
build-system = [ setuptools ];
doCheck = false;
})
numpy
Expand Down
6 changes: 4 additions & 2 deletions test.fut
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ entry f0 : i64 = 1337

entry f1 (x: i64) : i64 = x + 1

type r = {a:i64, b:bool}
entry const_record : r = {a=42,b=true}
type r = {a: i64, b: bool}
entry const_record : r = {a = 42, b = true}

entry failing (x: i64) : i64 = assert false (x + 1)

entry ensure_i32_arr (x: []i32) = x

entry get_pair (x: i32) = (x + 1, x + 2)
7 changes: 7 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,12 @@ def test_put_arr_i32(self):
self.server.put_value('v', arr)
self.assertEqual(self.server.get_value('v').tolist(), arr.tolist())

def test_get_pair(self):
self.server.put_value('v', np.int32(42))
self.server.cmd_call('get_pair', 'out', 'v')
x, y = self.server.get_value('out')
self.assertEqual(x, np.int32(43))
self.assertEqual(y, np.int32(44))

if __name__ == '__main__':
unittest.main()
Loading