Skip to content

Commit

Permalink
Fix linter and doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
seignovert committed Nov 5, 2020
1 parent b4383f0 commit ceaa2cd
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 34 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
.eggs/
build/
dist/
venv/
htmlcov/
__pycache__/
AUTHORS
Changelog
docs/_build
docs/_build
coverage.xml
40 changes: 20 additions & 20 deletions docs/calculation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,33 @@ All WebGeoCalc calculation objects take their input attributes in
to the any Calculation parameters:

>>> Calculation(
api = 'ESA',
kernels = 6,
times = '2014-01-01T01:23:45.000',
calculation_type = 'STATE_VECTOR',
target = '67P/CHURYUMOV-GERASIMENKO (1969 R1)',
observer = 'ROSETTA ORBITER',
reference_frame = '67P/C-G_CK',
aberration_correction = 'NONE',
state_representation = 'LATITUDINAL',
).api
... api = 'ESA',
... kernels = 6,
... times = '2014-01-01T01:23:45.000',
... calculation_type = 'STATE_VECTOR',
... target = '67P/CHURYUMOV-GERASIMENKO (1969 R1)',
... observer = 'ROSETTA ORBITER',
... reference_frame = '67P/C-G_CK',
... aberration_correction = 'NONE',
... state_representation = 'LATITUDINAL',
... ).api
<Api> http://spice.esac.esa.int/webgeocalc/api

3-rd party WGC are also supported, either set :obj:`WGC_URL`
on your system (as mention before), or you can provide directly
its ``URL`` to the :py:attr:`api` parameter:

>>> Calculation(
api = 'https://wgc.obspm.fr/webgeocalc/api',
kernels = 6,
times = '2014-01-01T01:23:45.000',
calculation_type = 'STATE_VECTOR',
target = '67P/CHURYUMOV-GERASIMENKO (1969 R1)',
observer = 'ROSETTA ORBITER',
reference_frame = '67P/C-G_CK',
aberration_correction = 'NONE',
state_representation = 'LATITUDINAL',
).api
... api = 'https://wgc.obspm.fr/webgeocalc/api',
... kernels = 6,
... times = '2014-01-01T01:23:45.000',
... calculation_type = 'STATE_VECTOR',
... target = '67P/CHURYUMOV-GERASIMENKO (1969 R1)',
... observer = 'ROSETTA ORBITER',
... reference_frame = '67P/C-G_CK',
... aberration_correction = 'NONE',
... state_representation = 'LATITUDINAL',
... ).api
<Api> https://wgc.obspm.fr/webgeocalc/api

In each cases, every new API is cached to improve
Expand Down
11 changes: 2 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#!/usr/bin/env python
'''Packaging Webgeocalc.'''
"""Packaging Webgeocalc."""

# This will try to import setuptools. If not here, it fails with a message
try:
from setuptools import setup
except ImportError:
raise ImportError("This module could not be installed, probably because"
" setuptools is not installed on this computer."
"\nInstall ez_setup ([sudo] pip install ez_setup) and try again.")
from setuptools import setup

setup(
setup_requires=['pbr'],
Expand Down
5 changes: 3 additions & 2 deletions tests/test_calculation_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from webgeocalc.errors import (CalculationAlreadySubmitted, CalculationFailed,
CalculationNotCompleted, CalculationTimeOut,
ResultAttributeError)
from webgeocalc.vars import JPL_URL, ESA_URL
from webgeocalc.vars import ESA_URL, JPL_URL

@pytest.fixture
def params():
Expand Down Expand Up @@ -448,7 +448,8 @@ def test_state_vector_single_time_esa(requests_mock,

requests_mock.post(ESA_URL + '/calculation/new', json=response_sv_esa)
requests_mock.get(
ESA_URL + '/calculation/' + response_sv_esa['calculationId'], json=response_sv_esa)
ESA_URL + '/calculation/' + response_sv_esa['calculationId'],
json=response_sv_esa)
requests_mock.get(
ESA_URL + '/calculation/' + response_sv_esa['calculationId'] + '/results',
json=results_sv_esa)
Expand Down
4 changes: 2 additions & 2 deletions webgeocalc/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import time

from .api import Api, API, JPL_API, ESA_API
from .api import API, Api, ESA_API, JPL_API
from .errors import (CalculationAlreadySubmitted, CalculationConflictAttr,
CalculationFailed, CalculationIncompatibleAttr,
CalculationInvalidAttr, CalculationInvalidValue,
Expand Down Expand Up @@ -389,7 +389,7 @@ def run(self, timeout=30, sleep=1):
if self.columns is not None and self.values is not None:
return self.results

for i in range(int(timeout / sleep)):
for _ in range(int(timeout / sleep)):
self.update()

if self.phase == 'COMPLETE':
Expand Down
2 changes: 2 additions & 0 deletions webgeocalc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

class GetApi(argparse.Action):
"""Custom API from key action."""

def __call__(self, parser, args, values, option_string=None):
"""Select API based on the provided key."""
key = values.upper()
api = JPL_API if key == 'JPL' else ESA_API if key == 'ESA' else Api(key)
setattr(args, self.dest, api)
Expand Down

0 comments on commit ceaa2cd

Please sign in to comment.