Skip to content

Commit

Permalink
Use more pythonic list comprehensions in some places
Browse files Browse the repository at this point in the history
Co-authored-by: Juan Miguel Carceller <[email protected]>
  • Loading branch information
tmadlener and jmcarcell authored Jul 21, 2023
1 parent bdf118e commit 31bafc4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/podio/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _determine_cpp_type(idx_and_type):

def _get_cpp_types(type_str):
"""Get all possible c++ types from the passed py_type string."""
types = list(filter(lambda t: type_str in t, SUPPORTED_PARAMETER_TYPES))
types = [t for t in SUPPORTED_PARAMETER_TYPES if type_str in t]
if not types:
raise ValueError(f'{type_str} cannot be mapped to a valid parameter type')

Expand All @@ -61,7 +61,7 @@ def _get_cpp_vector_types(type_str):
"""Get the possible std::vector<cpp_type> from the passed py_type string."""
# Gather a list of all types that match the type_str (c++ or python)
types = _get_cpp_types(type_str)
return [f'std::vector<{t}>' for t in map(lambda x: x[0], types)]
return [f'std::vector<{t[0]}>' for t in types]


def _is_collection_base(thing):
Expand Down Expand Up @@ -243,7 +243,7 @@ def put_parameter(self, key, value, as_type=None):

self._frame.putParameter[par_type](key, value)
else:
if as_type is not None:
if as_type:
cpp_types = _get_cpp_types(as_type)
if len(cpp_types) == 0:
raise ValueError(f"Cannot put a parameter of type {as_type} into a Frame")
Expand Down

0 comments on commit 31bafc4

Please sign in to comment.