Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FreeForestML
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Benjamin Paul Jaeger
FreeForestML
Commits
24550d78
Verified
Commit
24550d78
authored
5 years ago
by
Frank Sauerburger
Browse files
Options
Downloads
Patches
Plain Diff
Add Cut copy constructor
parent
e38b6ed8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nnfwtbn/cut.py
+6
-2
6 additions, 2 deletions
nnfwtbn/cut.py
nnfwtbn/tests/test_cut.py
+27
-0
27 additions, 0 deletions
nnfwtbn/tests/test_cut.py
with
33 additions
and
2 deletions
nnfwtbn/cut.py
+
6
−
2
View file @
24550d78
...
...
@@ -74,8 +74,12 @@ class Cut:
the optional function is omitted, Every row in the dataframe is
accepted by this cut.
"""
self
.
func
=
func
self
.
label
=
label
if
isinstance
(
func
,
Cut
):
self
.
func
=
func
.
func
self
.
label
=
label
or
func
.
label
else
:
self
.
func
=
func
self
.
label
=
label
def
__call__
(
self
,
dataframe
):
"""
...
...
This diff is collapsed.
Click to expand it.
nnfwtbn/tests/test_cut.py
+
27
−
0
View file @
24550d78
...
...
@@ -261,3 +261,30 @@ class CutTestCase(unittest.TestCase):
high_sale
=
Cut
(
lambda
df
:
df
.
sale
>
4
,
label
=
"
High sales volume
"
)
self
.
assertEqual
(
high_sale
.
label
,
"
High sales volume
"
)
def
test_init_cut
(
self
):
"""
Check that a cut can be passed to the constructor.
"""
high_sale
=
Cut
(
lambda
df
:
df
.
sale
>
4
)
high_sale2
=
Cut
(
high_sale
)
self
.
assertEqual
(
len
(
high_sale2
(
self
.
df
)),
4
)
self
.
assertEqual
(
len
(
high_sale2
.
idx_array
(
self
.
df
)),
8
)
def
test_init_cut_name_inherit
(
self
):
"""
Check that the name of a cut passed to the constructor is inherited.
"""
high_sale
=
Cut
(
lambda
df
:
df
.
sale
>
4
,
label
=
"
High sales volume
"
)
high_sale2
=
Cut
(
high_sale
)
self
.
assertEqual
(
high_sale2
.
label
,
"
High sales volume
"
)
def
test_init_cut_name_inherit_precedence
(
self
):
"""
Check that the name argument has precedence over the given cut.
"""
high_sale
=
Cut
(
lambda
df
:
df
.
sale
>
4
,
label
=
"
High sales volume
"
)
high_sale2
=
Cut
(
high_sale
,
label
=
"
Other label
"
)
self
.
assertEqual
(
high_sale2
.
label
,
"
Other label
"
)
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