Skip to content

Commit f17cd62

Browse files
authored
GG-27755: Bool arrays now return as bool array, not int array (#8)
1 parent 2b0e27e commit f17cd62

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ at *RTD* for your convenience.
6767
If you want to build the documentation from source, do the developer
6868
installation as described above, then run the following commands:
6969
```
70-
$ cd gridgain/modules/platforms/python
70+
$ cd pygridgain
7171
$ pip install -r requirements/docs.txt
7272
$ cd docs
7373
$ make html
7474
```
7575

76-
Then open `gridgain/modules/platforms/python/docs/generated/html/index.html`
76+
Then open `pygridgain/docs/generated/html/index.html`
7777
in your browser.
7878

7979
## Examples
8080
Some examples of using pygridgain are provided in
81-
`gridgain/modules/platforms/python/examples` folder. They are extensively
81+
`pygridgain/examples` folder. They are extensively
8282
commented in the
8383
[Examples of usage](https://pygridgain.readthedocs.io/en/latest/examples.html)
8484
section of the documentation.

pygridgain/datatypes/primitive_arrays.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,10 @@ class BoolArrayObject(PrimitiveArrayObject):
297297
_type_id = TYPE_BOOLEAN_ARR
298298
primitive_type = Bool
299299
type_code = TC_BOOL_ARRAY
300+
301+
@classmethod
302+
def to_python(cls, ctype_object, *args, **kwargs):
303+
result = []
304+
for i in range(ctype_object.length):
305+
result.append(ctype_object.data[i] != 0)
306+
return result

tests/test_datatypes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
6666
# array of bool
6767
([True, False, True], None),
68+
([True, False], BoolArrayObject),
69+
([False, True], BoolArrayObject),
70+
([True, False, True, False], BoolArrayObject),
6871
6972
# string
7073
('Little Mary had a lamb', None),
@@ -140,6 +143,10 @@ def test_put_get_data(client, cache, value, value_hint):
140143
assert result.status == 0
141144
assert result.value == value
142145

146+
if isinstance(result.value, list):
147+
for res, val in zip(result.value, value):
148+
assert type(res) == type(val)
149+
143150

144151
@pytest.mark.parametrize(
145152
'value',

tests/util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def get_ignite_runner():
6969
if os.path.exists(runner):
7070
return runner
7171

72-
raise Exception("Ignite not found.")
72+
raise Exception("Ignite not found. Please make sure your IGNITE_HOME environment variable points to directory with "
73+
"a valid Ignite instance")
7374

7475

7576
def get_ignite_config_path(idx=1):
@@ -120,8 +121,8 @@ def start_ignite(idx=1, debug=False):
120121
raise Exception("Failed to start Ignite: timeout while trying to connect")
121122

122123

123-
def start_ignite_gen(idx=1):
124-
srv = start_ignite(idx)
124+
def start_ignite_gen(idx=1, debug=False):
125+
srv = start_ignite(idx, debug)
125126
yield srv
126127
kill_process_tree(srv.pid)
127128

0 commit comments

Comments
 (0)