Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
MLAir
Commits
982fc6f6
Commit
982fc6f6
authored
4 years ago
by
leufen1
Browse files
Options
Downloads
Patches
Plain Diff
helper to list can now transform sets to lists in addition
parent
7ce6cc81
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!226
Develop
,
!225
Resolve "release v1.2.0"
,
!198
Resolve "REFAC: "bad" stations do not report which variable is missing"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mlair/helpers/helpers.py
+5
-3
5 additions, 3 deletions
mlair/helpers/helpers.py
with
5 additions
and
3 deletions
mlair/helpers/helpers.py
+
5
−
3
View file @
982fc6f6
...
...
@@ -12,13 +12,15 @@ from typing import Dict, Callable, Union, List, Any
def
to_list
(
obj
:
Any
)
->
List
:
"""
Transform given object to list if obj is not already a list.
Transform given object to list if obj is not already a list.
Sets are also transformed to a list.
:param obj: object to transform to list
:return: list containing obj, or obj itself (if obj was already a list)
"""
if
not
isinstance
(
obj
,
list
):
if
isinstance
(
obj
,
set
):
obj
=
list
(
obj
)
elif
not
isinstance
(
obj
,
list
):
obj
=
[
obj
]
return
obj
...
...
@@ -99,7 +101,7 @@ def remove_items(obj: Union[List, Dict], items: Any):
raise
TypeError
(
f
"
{
inspect
.
stack
()[
0
][
3
]
}
does not support type
{
type
(
obj
)
}
.
"
)
def
select_from_dict
(
dict_obj
:
dict
,
sel_list
:
str
):
def
select_from_dict
(
dict_obj
:
dict
,
sel_list
:
Any
):
"""
Extract all key values pairs whose key is contained in the sel_list.
...
...
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