Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OpenQlab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
las-nq
OpenQlab
Commits
78d85f5a
Commit
78d85f5a
authored
Dec 11, 2019
by
Jan Petermann
Browse files
Options
Downloads
Patches
Plain Diff
test_from_lin done
parent
8d584eee
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tests/test_conversion/tests_db/test_from_lin.py
+34
-0
34 additions, 0 deletions
src/tests/test_conversion/tests_db/test_from_lin.py
src/tests/test_conversion/tests_db/test_to_lin.py
+1
-1
1 addition, 1 deletion
src/tests/test_conversion/tests_db/test_to_lin.py
with
35 additions
and
1 deletion
src/tests/test_conversion/tests_db/test_from_lin.py
0 → 100644
+
34
−
0
View file @
78d85f5a
import
unittest
import
numpy
as
np
import
pandas
as
pd
from
openqlab.conversion.db
import
from_lin
class
TestFromLin
(
unittest
.
TestCase
):
def
test_positive_integer
(
self
):
self
.
assertEqual
(
from_lin
(
10
),
10
)
self
.
assertEqual
(
from_lin
(
100000
),
50
)
self
.
assertAlmostEqual
(
from_lin
(
1.9952623
),
3
)
def
test_negative_integer
(
self
):
self
.
assertEqual
(
from_lin
(
0.1
),
-
10
)
self
.
assertEqual
(
from_lin
(
1e-5
),
-
50
)
self
.
assertAlmostEqual
(
from_lin
(
0.5011872336272722
),
-
3
)
def
test_positive_float
(
self
):
self
.
assertAlmostEqual
(
from_lin
(
2.23872113
),
3.5
)
def
test_negative_float
(
self
):
self
.
assertAlmostEqual
(
from_lin
(
0.446683592
),
-
3.5
)
def
test_dataframe
(
self
):
df
=
pd
.
DataFrame
([
10
,
0.1
,
1e5
])
expected_df
=
pd
.
DataFrame
([
10
,
-
10
,
50
],
dtype
=
"
float64
"
)
pd
.
testing
.
assert_frame_equal
(
from_lin
(
df
),
expected_df
)
def
test_numpy_array
(
self
):
a
=
np
.
array
([
10
,
0.1
,
1e5
])
expected_array
=
np
.
array
([
10
,
-
10
,
50
])
np
.
testing
.
assert_array_equal
(
from_lin
(
a
),
expected_array
)
This diff is collapsed.
Click to expand it.
src/tests/test_conversion/tests_db/test_to_lin.py
+
1
−
1
View file @
78d85f5a
...
@@ -15,7 +15,7 @@ class TestToLin(unittest.TestCase):
...
@@ -15,7 +15,7 @@ class TestToLin(unittest.TestCase):
def
test_negative_integer
(
self
):
def
test_negative_integer
(
self
):
self
.
assertEqual
(
to_lin
(
-
10
),
0.1
)
self
.
assertEqual
(
to_lin
(
-
10
),
0.1
)
self
.
assertEqual
(
to_lin
(
-
50
),
1e-5
)
self
.
assertEqual
(
to_lin
(
-
50
),
1e-5
)
self
.
assertAlmostEqual
(
to_lin
(
-
3
),
0.5011872
)
self
.
assertAlmostEqual
(
to_lin
(
-
3
),
0.5011872
336272722
)
def
test_positive_float
(
self
):
def
test_positive_float
(
self
):
self
.
assertAlmostEqual
(
to_lin
(
3.5
),
2.23872113
)
self
.
assertAlmostEqual
(
to_lin
(
3.5
),
2.23872113
)
...
...
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