Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
firanka
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
firanka
Commits
24652e9b
Commit
24652e9b
authored
7 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
tests
parent
eda3be19
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
firanka/series/__init__.py
+6
-2
6 additions, 2 deletions
firanka/series/__init__.py
firanka/series/range.py
+8
-2
8 additions, 2 deletions
firanka/series/range.py
tests/test_series/test_range.py
+10
-1
10 additions, 1 deletion
tests/test_series/test_range.py
with
24 additions
and
5 deletions
firanka/series/__init__.py
+
6
−
2
View file @
24652e9b
...
@@ -3,7 +3,11 @@ from __future__ import print_function, absolute_import, division
...
@@ -3,7 +3,11 @@ from __future__ import print_function, absolute_import, division
import
six
import
six
import
logging
import
logging
logger
=
logging
.
getLogger
(
__name__
)
from
.exceptions
import
OutOfRangeError
,
EmptyDomainError
from
.exceptions
import
OutOfRangeError
,
EmptyDomainError
from
.range
import
Range
__all__
=
[
'
OutOfRangeError
'
,
'
EmptyDomainError
'
,
'
Range
'
]
This diff is collapsed.
Click to expand it.
firanka/series/range.py
+
8
−
2
View file @
24652e9b
...
@@ -5,6 +5,7 @@ import logging
...
@@ -5,6 +5,7 @@ import logging
import
re
import
re
from
satella.coding
import
for_argument
from
satella.coding
import
for_argument
import
functools
import
functools
import
math
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -25,8 +26,8 @@ class Range(object):
...
@@ -25,8 +26,8 @@ class Range(object):
def
__init__
(
self
,
*
args
):
def
__init__
(
self
,
*
args
):
if
len
(
args
)
==
1
:
if
len
(
args
)
==
1
:
rs
,
=
args
rs
,
=
args
assert
rs
.
startswith
(
'
<
'
)
or
rs
.
startswith
(
'
(
'
)
assert
rs
[
0
]
in
'
<(
'
assert
rs
.
endswith
(
'
>
'
)
or
rs
.
endswith
(
'
)
'
)
assert
rs
[
-
1
]
in
'
>
)
'
lend_inclusive
=
rs
[
0
]
==
'
<
'
lend_inclusive
=
rs
[
0
]
==
'
<
'
rend_inclusive
=
rs
[
-
1
]
==
'
>
'
rend_inclusive
=
rs
[
-
1
]
==
'
>
'
...
@@ -41,6 +42,11 @@ class Range(object):
...
@@ -41,6 +42,11 @@ class Range(object):
else
:
else
:
start
,
stop
,
lend_inclusive
,
rend_inclusive
=
args
start
,
stop
,
lend_inclusive
,
rend_inclusive
=
args
if
lend_inclusive
and
math
.
isinf
(
start
):
raise
ValueError
(
'
Greater or equal with infinity!
'
)
if
rend_inclusive
and
math
.
isinf
(
stop
):
raise
ValueError
(
'
Greater or equal with infinity!
'
)
self
.
start
=
start
self
.
start
=
start
self
.
stop
=
stop
self
.
stop
=
stop
self
.
lend_inclusive
=
lend_inclusive
self
.
lend_inclusive
=
lend_inclusive
...
...
This diff is collapsed.
Click to expand it.
tests/test_series/test_range.py
+
10
−
1
View file @
24652e9b
...
@@ -13,4 +13,13 @@ class TestRange(unittest.TestCase):
...
@@ -13,4 +13,13 @@ class TestRange(unittest.TestCase):
def
test_str
(
self
):
def
test_str
(
self
):
self
.
assertEqual
(
str
(
Range
(
-
1
,
1
,
True
,
True
)),
'
<-1;1>
'
)
self
.
assertEqual
(
str
(
Range
(
-
1
,
1
,
True
,
True
)),
'
<-1;1>
'
)
\ No newline at end of file
def
test_contains
(
self
):
self
.
assertFalse
(
-
1
in
Range
(
'
<-10;-1)
'
))
self
.
assertTrue
(
-
10
in
Range
(
'
<-10;-1)
'
))
self
.
assertFalse
(
-
10
in
Range
(
'
(-10;-1>
'
))
self
.
assertTrue
(
-
1
in
Range
(
'
(-10;-1>
'
))
self
.
assertTrue
(
-
5
in
Range
(
'
(-10;-1>
'
))
self
.
assertFalse
(
-
20
in
Range
(
'
(-10;-1>
'
))
self
.
assertFalse
(
1
in
Range
(
'
(-10;-1>
'
))
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