Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace match with if/else logic to restore compatiibility with earlier Python versions #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions pygdsm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,18 @@ def init_gsm(gsm_name: str='gsm08'):
sky_model (various): Corresponding sky model
"""
gsm_name = gsm_name.lower().strip()
match gsm_name:
case 'gsm': # Shorthand for GSM08
return GlobalSkyModel()
case 'gsm08':
return GlobalSkyModel()
case 'gsm16':
return GlobalSkyModel16()
case 'lfsm':
return LowFrequencySkyModel()
case 'haslam':
return HaslamSkyModel()
if gsm_name == 'gsm': # Shorthand for GSM08
return GlobalSkyModel()
elif gsm_name == 'gsm08':
return GlobalSkyModel()
elif gsm_name == 'gsm16':
return GlobalSkyModel16()
elif gsm_name == 'lfsm':
return LowFrequencySkyModel()
elif gsm_name == 'haslam':
return HaslamSkyModel()
else:
raise ValueError(f'Invalid model specification "{gsm_name}"')


def init_observer(gsm_name: str='gsm08'):
Expand All @@ -68,14 +69,16 @@ def init_observer(gsm_name: str='gsm08'):
observer (various): Corresponding sky model observer
"""
gsm_name = gsm_name.lower().strip()
match gsm_name:
case 'gsm': # Shorthand for GSM08
return GSMObserver()
case 'gsm08':
return GSMObserver()
case 'gsm16':
return GSMObserver16()
case 'lfsm':
return LFSMObserver()
case 'haslam':
return HaslamObserver()

if gsm_name == 'gsm': # Shorthand for GSM08
return GSMObserver()
elif gsm_name == 'gsm08':
return GSMObserver()
elif gsm_name == 'gsm16':
return GSMObserver16()
elif gsm_name == 'lfsm':
return LFSMObserver()
elif gsm_name == 'haslam':
return HaslamObserver()
else:
raise ValueError(f'Invalid model specification "{gsm_name}"')
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ universal=1
[metadata]
description_file=README.md

[options]
python_requires = >=3.6

[aliases]
test=pytest

Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
Expand Down