Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
A
alpha-mind
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dr.李
alpha-mind
Commits
4e1d09c0
Commit
4e1d09c0
authored
Feb 09, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added more universe functionality
parent
6bad1c21
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
6 deletions
+26
-6
api.py
alphamind/api.py
+2
-2
universe.py
alphamind/data/engines/universe.py
+10
-3
test_universe.py
alphamind/tests/data/engines/test_universe.py
+14
-1
No files found.
alphamind/api.py
View file @
4e1d09c0
...
...
@@ -43,7 +43,7 @@ from alphamind.model import load_model
from
alphamind.model.data_preparing
import
fetch_data_package
from
alphamind.model.data_preparing
import
fetch_train_phase
from
alphamind.model.data_preparing
import
fetch_predict_phase
from
alphamind.model.composer
import
Model
Composer
from
alphamind.model.composer
import
Composer
from
alphamind.model.composer
import
DataMeta
from
alphamind.model.composer
import
train_model
from
alphamind.model.composer
import
predict_by_model
...
...
@@ -83,7 +83,7 @@ __all__ = [
'fetch_data_package'
,
'fetch_train_phase'
,
'fetch_predict_phase'
,
'
Model
Composer'
,
'Composer'
,
'DataMeta'
,
'train_model'
,
'predict_by_model'
,
...
...
alphamind/data/engines/universe.py
View file @
4e1d09c0
...
...
@@ -7,6 +7,7 @@ Created on 2017-7-7
from
typing
import
Iterable
import
pandas
as
pd
from
simpleutils.miscellaneous
import
list_eq
from
sqlalchemy
import
and_
from
sqlalchemy
import
or_
from
sqlalchemy
import
select
...
...
@@ -30,11 +31,17 @@ class Universe(object):
special_codes
:
Iterable
=
None
,
filter_cond
=
None
):
self
.
name
=
name
self
.
base_universe
=
base_univers
e
self
.
exclude_universe
=
exclude_univers
e
self
.
special_codes
=
s
pecial_codes
self
.
base_universe
=
sorted
(
base_universe
)
if
base_universe
else
Non
e
self
.
exclude_universe
=
sorted
(
exclude_universe
)
if
exclude_universe
else
Non
e
self
.
special_codes
=
s
orted
(
special_codes
)
if
special_codes
else
None
self
.
filter_cond
=
filter_cond
def
__eq__
(
self
,
rhs
):
return
self
.
name
==
rhs
.
name
\
and
list_eq
(
self
.
base_universe
,
rhs
.
base_universe
)
\
and
list_eq
(
self
.
exclude_universe
,
rhs
.
exclude_universe
)
\
and
list_eq
(
self
.
special_codes
,
rhs
.
special_codes
)
@
property
def
is_filtered
(
self
):
return
True
if
self
.
filter_cond
is
not
None
else
False
...
...
alphamind/tests/data/engines/test_universe.py
View file @
4e1d09c0
...
...
@@ -12,6 +12,20 @@ from alphamind.data.engines.universe import Universe
class
TestUniverse
(
unittest
.
TestCase
):
def
test_universe_equal
(
self
):
universe1
=
Universe
(
'custom'
,
[
'zz500'
])
universe2
=
Universe
(
'custom'
,
[
'zz500'
])
self
.
assertEqual
(
universe1
,
universe2
)
universe1
=
Universe
(
'custom'
,
[
'zz500'
])
universe2
=
Universe
(
'custom'
,
[
'zz800'
])
self
.
assertNotEqual
(
universe1
,
universe2
)
filter_cond
=
LAST
(
'x'
)
>
1.
universe1
=
Universe
(
'custom'
,
[
'zz500'
],
filter_cond
=
filter_cond
)
universe2
=
Universe
(
'custom'
,
[
'zz500'
],
filter_cond
=
filter_cond
)
self
.
assertEqual
(
universe1
,
universe2
)
def
test_universe_persistence
(
self
):
universe
=
Universe
(
'custom'
,
[
'zz500'
])
univ_desc
=
universe
.
save
()
...
...
@@ -26,4 +40,3 @@ class TestUniverse(unittest.TestCase):
self
.
assertEqual
(
universe
.
name
,
loaded_universe
.
name
)
self
.
assertListEqual
(
universe
.
base_universe
,
loaded_universe
.
base_universe
)
self
.
assertEqual
(
universe
.
filter_cond
,
loaded_universe
.
filter_cond
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment