Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
Routhleck and sourcery-ai[bot] authored Jan 20, 2025
1 parent e7a43d4 commit cb26bb9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions brainunit/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def get(key: str, default: Any = _NOT_PROVIDE, desc: str = None):
item: Any
The default computation environment.
"""
if key in DEFAULT.contexts:
if len(DEFAULT.contexts[key]) > 0:
return DEFAULT.contexts[key][-1]
if key in DEFAULT.contexts and len(DEFAULT.contexts[key]) > 0:
return DEFAULT.contexts[key][-1]

if key in DEFAULT.settings:
return DEFAULT.settings[key]

Expand Down Expand Up @@ -142,7 +142,7 @@ def all() -> dict:
r: dict
The current default computation environment.
"""
r = dict()
r = {}
for k, v in DEFAULT.contexts.items():
if v:
r[k] = v[-1]
Expand Down Expand Up @@ -177,7 +177,10 @@ def set(
The default compute mode. Default is computing in 'si'.
"""
if compute_mode is not None:
assert compute_mode in ['si', 'non_si'], f"compute_mode must be 'si' or 'non_si'. Got: {compute_mode}"
assert compute_mode in {
'si',
'non_si',
}, f"compute_mode must be 'si' or 'non_si'. Got: {compute_mode}"
kwargs['compute_mode'] = compute_mode

# set default environment
Expand Down

0 comments on commit cb26bb9

Please sign in to comment.