Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
36
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
rdm-software
SaQC
Commits
12a648b0
Commit
12a648b0
authored
4 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
refactored nr->pos; simplyfied/fixed _insert
parent
e83023c1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!218
Flags
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/flagger/history.py
+10
-18
10 additions, 18 deletions
saqc/flagger/history.py
with
10 additions
and
18 deletions
saqc/flagger/history.py
+
10
−
18
View file @
12a648b0
...
...
@@ -127,7 +127,7 @@ class History:
# but self.hist could have -> see pd.DataFrame.empty
return
self
.
mask
.
empty
def
_insert
(
self
,
s
:
pd
.
Series
,
nr
:
int
,
force
=
False
)
->
History
:
def
_insert
(
self
,
s
:
pd
.
Series
,
pos
:
int
,
force
=
False
)
->
History
:
"""
Insert data at an arbitrary position in the FH.
...
...
@@ -138,11 +138,12 @@ class History:
s : pd.Series
the series to insert
nr
: int
pos
: int
the position to insert
force : bool, default False
if True the internal mask is updated accordingly
if True the internal mask is updated accordingly that the values overwrite
any earlier values in the FH.
Returns
-------
...
...
@@ -150,25 +151,16 @@ class History:
"""
# internal detail:
# ensure continuous increasing columns
assert
0
<=
nr
<=
len
(
self
)
assert
0
<=
pos
<=
len
(
self
)
# we dont care about force on first insert
if
self
.
empty
:
assert
nr
==
0
self
.
mask
[
nr
]
=
pd
.
Series
(
True
,
index
=
s
.
index
,
dtype
=
bool
)
self
.
hist
[
nr
]
=
s
return
self
if
pos
==
len
(
self
):
# append
self
.
mask
[
pos
]
=
pd
.
Series
(
True
,
index
=
s
.
index
,
dtype
=
bool
)
if
force
:
touched
=
np
.
isfinite
(
s
)
self
.
mask
.
iloc
[
touched
,
:
nr
]
=
False
# a column is appended
if
nr
==
len
(
self
):
self
.
mask
[
nr
]
=
True
self
.
mask
.
iloc
[
touched
,
:
pos
]
=
False
self
.
hist
[
nr
]
=
s
self
.
hist
[
pos
]
=
s
return
self
...
...
@@ -205,7 +197,7 @@ class History:
if
not
self
.
empty
and
not
s
.
index
.
equals
(
self
.
index
):
raise
ValueError
(
"
Index must be equal to FH
'
s index
"
)
self
.
_insert
(
value
,
nr
=
len
(
self
),
force
=
force
)
self
.
_insert
(
value
,
pos
=
len
(
self
),
force
=
force
)
return
self
def
squeeze
(
self
,
n
:
int
)
->
History
:
...
...
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