Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
3d7fb6dd
Commit
3d7fb6dd
authored
Jul 12, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2c043d29
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
26 deletions
+31
-26
bigarray/tests/test_arrayzodb.py
bigarray/tests/test_arrayzodb.py
+5
-3
bigarray/tests/test_basic.py
bigarray/tests/test_basic.py
+21
-19
bigfile/tests/test_basic.py
bigfile/tests/test_basic.py
+3
-3
bigfile/tests/test_filezodb.py
bigfile/tests/test_filezodb.py
+2
-1
No files found.
bigarray/tests/test_arrayzodb.py
View file @
3d7fb6dd
# Wendeling.core.bigarray | Tests for ZBigArray
# Copyright (C) 2014-201
5
Nexedi SA and Contributors.
# Copyright (C) 2014-201
9
Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -512,7 +512,8 @@ def test_zbigarray_vs_conflicts():
tm1
.
commit
()
# txn2 should raise ConflictError and stay at 11 state
raises
(
ConflictError
,
'tm2.commit()'
)
with
raises
(
ConflictError
):
tm2
.
commit
()
tm2
.
abort
()
assert
a2
[
0
:
1
]
==
[
11
]
# re-read in conn2 XXX -> [0] == 11 after BigArray can
...
...
@@ -570,7 +571,8 @@ def test_zbigarray_vs_conflicts_metadata():
tm1
.
commit
()
# txn2 should raise ConflictError and stay at 11 state
raises
(
ConflictError
,
'tm2.commit()'
)
with
raises
(
ConflictError
):
tm2
.
commit
()
tm2
.
abort
()
assert
len
(
a2
)
==
11
# re-read in conn2
...
...
bigarray/tests/test_basic.py
View file @
3d7fb6dd
# -*- coding: utf-8 -*-
# Wendeling.core.bigarray | Basic tests
# Copyright (C) 2014-201
8
Nexedi SA and Contributors.
# Copyright (C) 2014-201
9
Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -109,7 +109,8 @@ def test_bigarray_noobject(testbig):
# it will become S0 or U0
obj_dtypev
=
[
numpy
.
object
,
'O'
,
'i4, O'
,
[(
'x'
,
'i4'
),
(
'y'
,
'i4, O'
)]]
for
dtype_
in
obj_dtypev
:
raises
(
TypeError
,
"BigArray((1,), dtype_, Zh)"
)
with
raises
(
TypeError
):
BigArray
((
1
,),
dtype_
,
Zh
)
# basic ndarray-compatibility attributes of BigArray
...
...
@@ -118,7 +119,7 @@ def test_bigarray_basic(testbig):
A
=
BigArray
((
10
,
3
),
int32
,
Zh
)
raises
(
TypeError
,
"A.data"
)
with
raises
(
TypeError
):
A
.
data
assert
A
.
strides
==
(
12
,
4
)
assert
A
.
dtype
==
dtype
(
int32
)
# XXX .flags?
...
...
@@ -137,7 +138,7 @@ def test_bigarray_basic(testbig):
B
=
BigArray
((
10
,
3
),
int32
,
Zh
,
order
=
'F'
)
raises
(
TypeError
,
"B.data"
)
with
raises
(
TypeError
):
B
.
data
assert
B
.
strides
==
(
4
,
40
)
assert
B
.
dtype
==
dtype
(
int32
)
# XXX .flags?
...
...
@@ -191,15 +192,15 @@ def test_bigarray_indexing_1d(testbig):
# (in numpy they create _copy_ picking up elements)
A_
[
0
:
5
]
=
range
(
0
,
10
,
2
)
assert
array_equal
(
A_
[[
0
,
1
,
2
,
3
,
4
]],
[
0
,
2
,
4
,
6
,
8
])
raises
(
TypeError
,
'A[[0,1,2,3,4]]'
)
with
raises
(
TypeError
):
A
[[
0
,
1
,
2
,
3
,
4
]]
# index out of range
# - element access -> raises IndexError
# - slice access -> empty
A_
[
-
1
]
=
0
assert
AA
[
10
*
PS
-
1
]
==
(
0
,
0
)
raises
(
IndexError
,
'A_[10*PS]'
)
raises
(
IndexError
,
'A [10*PS]'
)
with
raises
(
IndexError
):
A_
[
10
*
PS
]
with
raises
(
IndexError
):
A
[
10
*
PS
]
a
,
_
=
AA
[
10
*
PS
:
10
*
PS
+
1
]
assert
isinstance
(
a
,
ndarray
)
assert
array_equal
(
a
,
_
)
...
...
@@ -329,7 +330,8 @@ def test_bigarray_indexing_1d(testbig):
assert
a
[
2
*
PS
+
5
]
==
5
assert
a
[
2
*
PS
+
6
]
==
5
assert
raises
(
ValueError
,
'A[:4] = range(5)'
)
with
raises
(
ValueError
):
A
[:
4
]
=
range
(
5
)
# indexing where accessed element overlaps edge between pages
...
...
@@ -442,8 +444,8 @@ def test_bigarray_indexing_Nd(testbig):
# out-of-range element access
idx
[
idxpos
]
=
shape
[
idxpos
]
# 0, 0, 0, Ni , 0 ,0, 0
raises
(
IndexError
,
'A [idxt()]'
)
raises
(
IndexError
,
'A_[idxt()]'
)
with
raises
(
IndexError
):
A
[
idxt
()]
with
raises
(
IndexError
):
A_
[
idxt
()]
# out-of-range slice access
idx
[
idxpos
]
=
slice
(
shape
[
idxpos
],
# 0, 0, 0, Ni:Ni+1 , 0 ,0, 0
...
...
@@ -516,7 +518,7 @@ def test_bigarray_resize(testbig):
assert
b
[
10
-
1
,
-
1
]
==
10
*
3
-
1
# we cannot access old mapping beyond it's end
assert
raises
(
IndexError
,
'a[10,:]'
)
with
raises
(
IndexError
):
a
[
10
,:]
# we can change tail
b
[
10
,:]
=
arange
(
10
*
3
,
(
10
+
1
)
*
3
)
...
...
@@ -563,15 +565,15 @@ def test_bigarray_append(testbig):
assert
array_equal
(
A
[:],
arange32
(
0
,
4
))
# append with incorrect shape - rejected, original stays the same
assert
raises
(
ValueError
,
'A.append(arange(3))'
)
with
raises
(
ValueError
):
A
.
append
(
arange
(
3
)
)
assert
array_equal
(
A
[:],
arange32
(
0
,
4
))
assert
raises
(
ValueError
,
'A.append(arange(3*2).reshape(3,2))'
)
with
raises
(
ValueError
):
A
.
append
(
arange
(
3
*
2
).
reshape
(
3
,
2
)
)
assert
array_equal
(
A
[:],
arange32
(
0
,
4
))
# append with correct shape, but incompatible dtype - rejected, original stays the same
assert
raises
(
ValueError
,
{
'C'
:
'A.append(asarray([[[0,1], [2,3], [4,"abc"]]], dtype=object))'
,
'F'
:
'A.append(asarray([[[0],[1],[2]], [[3],[4],["abc"]]], dtype=object))'
}
[
order
]
)
with
raises
(
ValueError
):
if
order
==
'C'
:
A
.
append
(
asarray
([[[
0
,
1
],
[
2
,
3
],
[
4
,
"abc"
]]],
dtype
=
object
))
if
order
==
'F'
:
A
.
append
(
asarray
([[[
0
],[
1
],[
2
]],
[[
3
],[
4
],[
"abc"
]]],
dtype
=
object
)
)
assert
array_equal
(
A
[:],
arange32
(
0
,
4
))
...
...
@@ -612,8 +614,8 @@ def test_bigarray_to_ndarray(testbig):
# converting it to ndarray is should be not possible
for
i
in
range
(
48
,
65
):
C
=
BigArray
(((
1
<<
i
)
-
1
,),
uint8
,
Zh
)
raises
(
MemoryError
,
'asarray(C)'
)
with
raises
(
MemoryError
):
asarray
(
C
)
...
...
@@ -688,7 +690,7 @@ def test_arrayref(testbig):
assert
isinstance
(
m_
,
memoryview
)
#assert m_ is m XXX strangely it is another object, not exactly m
# XXX however rdata.strides<0 and no rdata.base.base is enough for us here.
raises
(
AttributeError
,
'm_.base'
)
with
raises
(
AttributeError
):
m_
.
base
a
=
rdata
[
100
:
140
]
ref
=
ArrayRef
(
a
)
...
...
bigfile/tests/test_basic.py
View file @
3d7fb6dd
...
...
@@ -76,7 +76,7 @@ def test_basic():
f
=
XBigFile
(
b'abcd'
,
PS
)
assert
f
.
blksize
==
PS
raises
(
ROAttributeError
,
"f.blksize = 1"
)
# RO attribute
with
raises
(
ROAttributeError
):
f
.
blksize
=
1
# RO attribute
assert
f
.
head
==
b'abcd'
fh
=
f
.
fileh_open
()
# TODO + ram
...
...
@@ -452,5 +452,5 @@ def test_writeout_err_notfatal():
# call writeout 2 times as previously upon error it was leaving internal
# flag set that writeout was still in progress and second call to writeout
# was leading to BUG and thus process crash.
raises
(
StoreError
,
"fh.dirty_writeout(WRITEOUT_STORE)"
)
raises
(
StoreError
,
"fh.dirty_writeout(WRITEOUT_STORE)"
)
with
raises
(
StoreError
):
fh
.
dirty_writeout
(
WRITEOUT_STORE
)
with
raises
(
StoreError
):
fh
.
dirty_writeout
(
WRITEOUT_STORE
)
bigfile/tests/test_filezodb.py
View file @
3d7fb6dd
...
...
@@ -667,7 +667,8 @@ def test_bigfile_filezodb_vs_conflicts():
tm1
.
commit
()
# txn2 should raise ConflictError and stay at 11 state
raises
(
ConflictError
,
'tm2.commit()'
)
with
raises
(
ConflictError
):
tm2
.
commit
()
tm2
.
abort
()
assert
Blk
(
vma2
,
0
)[
0
]
==
11
# re-read in conn2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment