Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
finam
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Code
Merge requests
3
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FINAM
finam
Commits
e95b9394
Commit
e95b9394
authored
2 years ago
by
Martin Lange
Browse files
Options
Downloads
Patches
Plain Diff
add tests for non-numpy data preparation
parent
fbb585ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!240
More log levels
Pipeline
#134936
passed with stages
in 4 minutes and 36 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/finam/data/tools.py
+0
-8
0 additions, 8 deletions
src/finam/data/tools.py
tests/data/test_tools.py
+15
-0
15 additions, 0 deletions
tests/data/test_tools.py
with
15 additions
and
8 deletions
src/finam/data/tools.py
+
0
−
8
View file @
e95b9394
...
...
@@ -66,14 +66,6 @@ def prepare(data, info, time_entries=1, force_copy=False, report_conversion=Fals
f
"
Given data has incompatible units.
"
f
"
Got
{
data
.
units
}
, expected
{
units
}
.
"
)
if
not
isinstance
(
data
.
magnitude
,
np
.
ndarray
):
if
force_copy
:
data
=
copy
.
copy
(
data
.
magnitude
)
else
:
data
=
data
.
magnitude
data
=
UNITS
.
Quantity
(
np
.
asarray
(
data
),
data
.
units
)
if
not
equivalent_units
(
data
.
units
,
units
):
units_converted
=
data
.
units
,
units
data
=
data
.
to
(
units
)
...
...
This diff is collapsed.
Click to expand it.
tests/data/test_tools.py
+
15
−
0
View file @
e95b9394
...
...
@@ -134,6 +134,14 @@ class TestDataTools(unittest.TestCase):
)
self
.
assertEqual
((
1
,
2
,
2
),
data
.
shape
)
data
=
finam
.
data
.
prepare
(
finam
.
UNITS
.
Quantity
(
1.0
,
"
m
"
),
finam
.
Info
(
time
,
grid
=
finam
.
NoGrid
(),
units
=
"
m
"
),
)
self
.
assertEqual
((
1
,),
data
.
shape
)
self
.
assertEqual
(
finam
.
UNITS
.
meter
,
data
.
units
)
with
self
.
assertRaises
(
finam
.
errors
.
FinamDataError
):
finam
.
data
.
prepare
(
np
.
asarray
([
1
,
2
]),
finam
.
Info
(
time
,
grid
=
finam
.
NoGrid
())
...
...
@@ -192,6 +200,13 @@ class TestDataTools(unittest.TestCase):
xdata
[
0
,
0
]
=
0
*
finam
.
UNITS
(
"
m
"
)
self
.
assertNotEqual
(
finam
.
data
.
get_magnitude
(
xdata2
[
0
,
0
]),
0.0
)
data
=
[
1.0
]
xdata2
=
finam
.
data
.
prepare
(
data
,
info_1
,
force_copy
=
True
)
self
.
assertEqual
(
1.0
*
finam
.
UNITS
.
meter
,
xdata2
[
0
])
xdata2
[
0
,
0
]
=
0
*
finam
.
UNITS
(
"
m
"
)
self
.
assertNotEqual
(
0.0
,
data
[
0
])
def
test_assert_type
(
self
):
finam
.
data
.
assert_type
(
self
,
"
A
"
,
1
,
[
int
,
float
])
...
...
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