Skip to content
Snippets Groups Projects
Commit 2068f36f authored by Markus Holzer's avatar Markus Holzer
Browse files

Merge branch 'fix_timestep_arg' into 'master'

Add sanity check to timestep arg of get_accessor

See merge request !154
parents cd1bc2f3 c3f2b691
1 merge request!154Add sanity check to timestep arg of get_accessor
Pipeline #55713 passed with stages
in 47 minutes and 17 seconds
...@@ -58,24 +58,27 @@ odd_accessors = { ...@@ -58,24 +58,27 @@ odd_accessors = {
} }
def is_inplace(streaming_pattern):
if streaming_pattern not in streaming_patterns:
raise ValueError('Invalid streaming pattern', streaming_pattern)
return streaming_pattern in ['aa', 'esotwist', 'esopull', 'esopush']
def get_accessor(streaming_pattern: str, timestep: Timestep) -> PdfFieldAccessor: def get_accessor(streaming_pattern: str, timestep: Timestep) -> PdfFieldAccessor:
if streaming_pattern not in streaming_patterns: if streaming_pattern not in streaming_patterns:
raise ValueError( raise ValueError(
"Invalid value of parameter 'streaming_pattern'.", streaming_pattern) "Invalid value of parameter 'streaming_pattern'.", streaming_pattern)
if is_inplace(streaming_pattern) and (timestep == Timestep.BOTH):
raise ValueError(f"Invalid timestep for streaming pattern {streaming_pattern}: {str(timestep)}")
if timestep == Timestep.EVEN: if timestep == Timestep.EVEN:
return even_accessors[streaming_pattern] return even_accessors[streaming_pattern]
else: else:
return odd_accessors[streaming_pattern] return odd_accessors[streaming_pattern]
def is_inplace(streaming_pattern):
if streaming_pattern not in streaming_patterns:
raise ValueError('Invalid streaming pattern', streaming_pattern)
return streaming_pattern in ['aa', 'esotwist', 'esopull', 'esopush']
def get_timesteps(streaming_pattern): def get_timesteps(streaming_pattern):
return (Timestep.EVEN, Timestep.ODD) if is_inplace(streaming_pattern) else (Timestep.BOTH, ) return (Timestep.EVEN, Timestep.ODD) if is_inplace(streaming_pattern) else (Timestep.BOTH, )
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment