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
87498047
Commit
87498047
authored
Aug 08, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added rank method
parent
54edf78f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
rank.py
alphamind/data/rank.py
+29
-0
test_rank.py
alphamind/tests/data/test_rank.py
+14
-0
No files found.
alphamind/data/rank.py
0 → 100644
View file @
87498047
# -*- coding: utf-8 -*-
"""
Created on 2017-8-8
@author: cheng.li
"""
from
typing
import
Optional
import
numpy
as
np
import
alphamind.utilities
as
utils
def
rank
(
x
:
np
.
ndarray
,
groups
:
Optional
[
np
.
ndarray
]
=
None
)
->
np
.
ndarray
:
if
x
.
ndim
==
1
:
x
=
x
.
reshape
((
-
1
,
1
))
if
groups
is
not
None
:
res
=
np
.
zeros
(
x
.
shape
,
dtype
=
int
)
index_diff
,
order
=
utils
.
groupby
(
groups
)
start
=
0
for
diff_loc
in
index_diff
:
curr_idx
=
order
[
start
:
diff_loc
+
1
]
res
[
curr_idx
]
=
x
[
curr_idx
]
.
argsort
(
axis
=
0
)
start
=
diff_loc
+
1
else
:
return
x
.
argsort
(
axis
=
0
)
\ No newline at end of file
alphamind/tests/data/test_rank.py
0 → 100644
View file @
87498047
# -*- coding: utf-8 -*-
"""
Created on 2017-8-8
@author: cheng.li
"""
import
unittest
class
TestRank
(
unittest
.
TestCase
):
def
test_rank
(
self
):
pass
\ 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