Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michele Nottoli
gext
Commits
5d5353dd
Commit
5d5353dd
authored
1 year ago
by
Michele Nottoli
Browse files
Options
Downloads
Patches
Plain Diff
Updated.
parent
3d456f81
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
grext/buffer.py
+1
-1
1 addition, 1 deletion
grext/buffer.py
tests/test_buffer.py
+18
-1
18 additions, 1 deletion
tests/test_buffer.py
with
19 additions
and
2 deletions
grext/buffer.py
+
1
−
1
View file @
5d5353dd
...
...
@@ -32,4 +32,4 @@ class CircularBuffer:
raise
ValueError
(
"
`m` is larger than the stored matrices.
"
)
start_idx
=
(
self
.
index
-
m
)
%
self
.
n
return
[
self
.
buffer
[
i
]
for
i
in
range
(
start_idx
,
start_idx
+
m
)]
return
[
self
.
buffer
[
(
start_idx
+
i
)
%
self
.
n
]
for
i
in
range
(
m
)]
This diff is collapsed.
Click to expand it.
tests/test_buffer.py
+
18
−
1
View file @
5d5353dd
...
...
@@ -10,7 +10,7 @@ def test_buffer():
shape
=
(
5
,
5
)
buffer_size
=
10
nframes
=
10
0
nframes
=
2
0
buffer
=
CircularBuffer
(
buffer_size
,
shape
)
...
...
@@ -31,6 +31,11 @@ def test_buffer():
assert
len
(
buffer
.
get
(
0
))
==
0
for
m
in
[
buffer_size
//
2
,
buffer_size
//
2
-
1
,
buffer_size
//
2
-
2
]:
matrices
=
buffer
.
get
(
m
)
for
value
,
matrix
in
zip
(
list
(
range
(
buffer_size
//
2
-
m
,
buffer_size
//
2
)),
matrices
):
assert
matrix
[
0
,
0
]
==
value
# finish the loading
for
i
in
range
(
buffer_size
//
2
,
nframes
):
matrix
=
np
.
full
(
shape
,
i
)
...
...
@@ -51,3 +56,15 @@ def test_buffer():
matrices
=
buffer
.
get
(
m
)
for
value
,
matrix
in
zip
(
list
(
range
(
nframes
-
m
,
nframes
)),
matrices
):
assert
matrix
[
0
,
0
]
==
value
def
test_buffer_manual
():
shape
=
(
5
,
5
)
buffer
=
CircularBuffer
(
6
,
shape
)
for
i
in
range
(
6
):
matrix
=
np
.
full
(
shape
,
i
)
buffer
.
push
(
matrix
)
matrices
=
buffer
.
get
(
6
)
for
matrix
,
value
in
zip
(
matrices
,
range
(
6
)):
assert
matrix
[
0
,
0
]
==
value
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment