Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alibylite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Swain Lab
aliby
alibylite
Commits
ea4b7af6
Commit
ea4b7af6
authored
2 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
refactor(signal): apply minutification everywhere
parent
3164db4e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
io/signal.py
+29
-28
29 additions, 28 deletions
io/signal.py
with
29 additions
and
28 deletions
io/signal.py
+
29
−
28
View file @
ea4b7af6
...
@@ -40,7 +40,8 @@ class Signal(BridgeH5):
...
@@ -40,7 +40,8 @@ class Signal(BridgeH5):
for
dset
in
dsets
for
dset
in
dsets
]
]
return
self
.
cols_in_mins
(
self
.
add_name
(
df
,
dsets
))
# return self.cols_in_mins(self.add_name(df, dsets))
return
self
.
add_name
(
df
,
dsets
)
@staticmethod
@staticmethod
def
add_name
(
df
,
name
):
def
add_name
(
df
,
name
):
...
@@ -88,35 +89,32 @@ class Signal(BridgeH5):
...
@@ -88,35 +89,32 @@ class Signal(BridgeH5):
Apply modifier operations (picker, merger) to a given dataframe.
Apply modifier operations (picker, merger) to a given dataframe.
"""
"""
merges
=
self
.
get_merges
()
merges
=
self
.
get_merges
()
with
h5py
.
File
(
self
.
filename
,
"
r
"
)
as
f
:
df
=
self
.
get_raw
(
dataset
)
df
=
self
.
dset_to_df
(
f
,
dataset
)
merged
=
copy
(
df
)
if
merges
.
any
():
merged
=
df
# Split in two dfs, one with rows relevant for merging and one
if
merges
.
any
():
# without them
# Split in two dfs, one with rows relevant for merging and one
valid_merges
=
merges
[
# without them
(
valid_merges
=
merges
[
merges
[:,
:,
:,
None
]
(
==
np
.
array
(
list
(
df
.
index
)).
T
[:,
None
,
:]
merges
[:,
:,
:,
None
]
==
np
.
array
(
list
(
df
.
index
)).
T
[:,
None
,
:]
)
.
all
(
axis
=
(
1
,
2
))
.
any
(
axis
=
1
)
]
# Casting allows fast multiindexing
merged
=
self
.
apply_merge
(
df
.
loc
[
map
(
tuple
,
valid_merges
.
reshape
(
-
1
,
2
))],
valid_merges
,
)
)
.
all
(
axis
=
(
1
,
2
))
.
any
(
axis
=
1
)
]
# Casting allows fast multiindexing
nonmergeable_ids
=
df
.
index
.
difference
(
merged
=
self
.
apply_merge
(
valid_merges
.
reshape
(
-
1
,
2
)
df
.
loc
[
map
(
tuple
,
valid_merges
.
reshape
(
-
1
,
2
))],
)
valid_merges
,
)
merged
=
pd
.
concat
(
nonmergeable_ids
=
df
.
index
.
difference
(
valid_merges
.
reshape
(
-
1
,
2
))
(
merged
,
df
.
loc
[
nonmergeable_ids
]),
names
=
df
.
index
.
names
)
merged
=
pd
.
concat
(
(
merged
,
df
.
loc
[
nonmergeable_ids
]),
names
=
df
.
index
.
names
)
with
h5py
.
File
(
self
.
filename
,
"
r
"
)
as
f
:
if
"
modifiers/picks
"
in
f
and
not
skip_pick
:
if
"
modifiers/picks
"
in
f
and
not
skip_pick
:
picks
=
self
.
get_picks
(
names
=
merged
.
index
.
names
)
picks
=
self
.
get_picks
(
names
=
merged
.
index
.
names
)
# missing_cells = [i for i in picks if tuple(i) not in
# missing_cells = [i for i in picks if tuple(i) not in
...
@@ -208,11 +206,14 @@ class Signal(BridgeH5):
...
@@ -208,11 +206,14 @@ class Signal(BridgeH5):
return
df
return
df
def
get_raw
(
self
,
dataset
):
def
get_raw
(
self
,
dataset
,
in_minutes
=
True
):
try
:
try
:
if
isinstance
(
dataset
,
str
):
if
isinstance
(
dataset
,
str
):
with
h5py
.
File
(
self
.
filename
,
"
r
"
)
as
f
:
with
h5py
.
File
(
self
.
filename
,
"
r
"
)
as
f
:
return
self
.
dset_to_df
(
f
,
dataset
)
df
=
self
.
dset_to_df
(
f
,
dataset
)
if
in_minutes
:
df
=
self
.
cols_in_mins
(
df
)
return
df
elif
isinstance
(
dataset
,
list
):
elif
isinstance
(
dataset
,
list
):
return
[
self
.
get_raw
(
dset
)
for
dset
in
dataset
]
return
[
self
.
get_raw
(
dset
)
for
dset
in
dataset
]
except
Exception
as
e
:
except
Exception
as
e
:
...
...
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