Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Unsupervised Video Summarization
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Hussain Kanafani
Unsupervised Video Summarization
Commits
5e1782bc
Commit
5e1782bc
authored
4 years ago
by
Hussain Kanafani
Browse files
Options
Downloads
Patches
Plain Diff
has_string method implemented and tested
parent
52dcc433
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/utils.py
+9
-0
9 additions, 0 deletions
src/utils.py
test/test_utils.py
+9
-3
9 additions, 3 deletions
test/test_utils.py
with
18 additions
and
3 deletions
src/utils.py
+
9
−
0
View file @
5e1782bc
...
...
@@ -101,3 +101,12 @@ def drop_file_extension(file_name):
raise
ValueError
file_name
=
file_name
.
split
(
'
.
'
)[:
-
1
]
return
'
.
'
.
join
(
file_name
)
def
has_string
(
string
,
sub_string
):
if
string
is
None
or
sub_string
is
None
:
raise
ValueError
string
=
str
(
string
).
lower
()
sub_string
=
str
(
sub_string
).
lower
()
return
sub_string
in
string
This diff is collapsed.
Click to expand it.
test/test_utils.py
+
9
−
3
View file @
5e1782bc
from
unittest
import
TestCase
import
unittest.mock
as
mock
from
src.utils
import
digits_in_string
,
make_directory
,
read_json
,
drop_file_extension
,
make_sorted_sample
,
\
sample_from_video_with_gt
from
src.utils
import
*
import
random
import
os.path
as
osp
import
os
...
...
@@ -73,4 +72,11 @@ class TestUtils(TestCase):
user_scores
=
np
.
expand_dims
(
user_scores
,
axis
=
1
)
video_frames
=
list
(
np
.
random
.
randn
(
n_frames
))
sampled_frames
,
sampled_gt
=
sample_from_video_with_gt
(
video_frames
,
user_scores
,
duration
,
fps
,
n_samples
=
2
)
self
.
assertEquals
(
len
(
sampled_frames
),
len
(
sampled_gt
))
\ No newline at end of file
self
.
assertEquals
(
len
(
sampled_frames
),
len
(
sampled_gt
))
def
test_has_string
(
self
):
self
.
assertTrue
(
has_string
(
'
Frame123
'
,
'
frame
'
))
self
.
assertTrue
(
has_string
(
'
frame123
'
,
'
Frame
'
))
self
.
assertFalse
(
has_string
(
''
,
'
frame
'
))
with
self
.
assertRaises
(
ValueError
):
has_string
(
None
,
'
string
'
)
\ No newline at end of file
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