Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
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
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
caosdb
Software
caosdb-advanced-user-tools
Commits
25c6e3c0
Commit
25c6e3c0
authored
10 months ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Return empty dataframe in case of empty container
parent
73a52aea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!100
WIP: Filling XLSX: Seems to be working.
,
!99
FIX: `to_table` failed on lists
Pipeline
#50265
passed with warnings
10 months ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+3
-0
3 additions, 0 deletions
CHANGELOG.md
src/caosadvancedtools/table_converter.py
+1
-2
1 addition, 2 deletions
src/caosadvancedtools/table_converter.py
unittests/test_table_converter.py
+2
-1
2 additions, 1 deletion
unittests/test_table_converter.py
with
6 additions
and
3 deletions
CHANGELOG.md
+
3
−
0
View file @
25c6e3c0
...
...
@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ###
*
`table_converter.to_table`
now returns an empty DataFrame instead of raising a
ValueError when called with an empty container.
### Deprecated ###
### Removed ###
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/table_converter.py
+
1
−
2
View file @
25c6e3c0
...
...
@@ -52,8 +52,7 @@ def to_table(container):
"""
Create a table from the records in a container.
"""
if
len
(
container
)
==
0
:
raise
ValueError
(
"
Container is empty
"
)
# TODO Why not this? return pd.DataFrame()
return
pd
.
DataFrame
()
rts
=
{
p
.
name
for
p
in
container
[
0
].
parents
}
data
=
[]
...
...
This diff is collapsed.
Click to expand it.
unittests/test_table_converter.py
+
2
−
1
View file @
25c6e3c0
...
...
@@ -43,7 +43,8 @@ class TableTest(unittest.TestCase):
def
test_empty
(
self
):
c
=
db
.
Container
()
self
.
assertRaises
(
ValueError
,
to_table
,
c
)
df
=
to_table
(
c
)
assert
df
.
shape
==
(
0
,
0
)
def
test_different_props
(
self
):
r1
=
db
.
Record
()
...
...
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