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

Num results fix #1608

Merged
Merged
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
2 changes: 1 addition & 1 deletion jwql/website/apps/jwql/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class JwqlQueryForm(BaseForm):
num_choices = [(50, 50), (100, 100), (200, 200), (500, 500)]
num_per_page = forms.ChoiceField(
required=True,
choices=num_choices, initial=num_choices[1],
choices=num_choices, initial=num_choices[3],
widget=forms.RadioSelect)

# instrument specific parameters
Expand Down
1 change: 1 addition & 0 deletions jwql/website/apps/jwql/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def jwql_query(request):
parameters[QueryConfigKeys.DATE_RANGE] = form.cleaned_data['date_range']
parameters[QueryConfigKeys.PROPOSAL_CATEGORY] = form.cleaned_data['proposal_category']
parameters[QueryConfigKeys.SORT_TYPE] = form.cleaned_data['sort_type']
parameters[QueryConfigKeys.NUM_PER_PAGE] = form.cleaned_data['num_per_page']
parameters[QueryConfigKeys.ANOMALIES] = all_anomalies
parameters[QueryConfigKeys.APERTURES] = all_apers
parameters[QueryConfigKeys.FILTERS] = all_filters
Expand Down
36 changes: 13 additions & 23 deletions style_guide/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

# Global variables should be avoided, but if used should be named with
# all-caps
A_GLOBAL_VARIABLE = 'foo' # type: str
A_GLOBAL_VARIABLE = "foo" # type: str
BradleySappington marked this conversation as resolved.
Show resolved Hide resolved


@log_fail
Expand All @@ -92,14 +92,14 @@ def my_main_function(path: str, filter: str) -> None:
The filter to process (e.g. "F606W").
"""

logging.info('Using {} as an input file'.format(path))
logging.info("Using {} as an input file".format(path))

an_int = 1 # type: int
a_float = 3.14 # type: float
a_bool = True # type: bool
a_list = ['Dog', 'Cat', 'Turtle', False, 7] # type: List[Union[str, bool, int]]
a_tuple = ('Dog', 'Cat', 'Turtle', False, 7) # type: Tuple[str, str, str, bool, int]
a_dict = {'key1': 'value1', 'key2': 'value2'} # type: Dict[str, str]
a_list = ["Dog", "Cat", "Turtle", False, 7] # type: List[Union[str, bool, int]]
a_tuple = ("Dog", "Cat", "Turtle", False, 7) # type: Tuple[str, str, str, bool, int]
a_dict = {"key1": "value1", "key2": "value2"} # type: Dict[str, str]
an_obj = object() # type: object

result = some_other_function(an_int, a_float, a_bool, a_list, a_tuple, a_dict, an_obj) # type: Optional[int]
Expand All @@ -117,21 +117,13 @@ def parse_args() -> argparse.Namespace:
"""

# Create help strings
path_help = 'The path to the input file.' # type: str
path_help = "The path to the input file." # type: str
filter_help = 'The filter to process (e.g. "F606W").' # type: str

# Add arguments
parser = argparse.ArgumentParser() # type: argparse.ArgumentParser
parser.add_argument('path',
type=str,
default=os.getcwd(),
help=path_help)
parser.add_argument('-f --filter',
dest='filter',
type=str,
required=False,
default='F606W',
help=filter_help)
parser.add_argument("path", type=str, default=os.getcwd(), help=path_help)
parser.add_argument("-f --filter", dest="filter", type=str, required=False, default="F606W", help=filter_help)

# Parse args
args = parser.parse_args() # type: argparse.Namespace
Expand All @@ -140,8 +132,7 @@ def parse_args() -> argparse.Namespace:


@log_timing
def some_other_function(an_int: int, a_float: float, a_bool: bool, a_list: List[Any],
a_tuple: Tuple[Any], a_dict: Dict[Any, Any], an_obj: object) -> int:
def some_other_function(an_int: int, a_float: float, a_bool: bool, a_list: List[Any], a_tuple: Tuple[Any], a_dict: Dict[Any, Any], an_obj: object) -> int:
"""This function just does a bunch of nonsense.

But it serves as a decent example of some things.
Expand Down Expand Up @@ -170,19 +161,18 @@ def some_other_function(an_int: int, a_float: float, a_bool: bool, a_list: List[
"""

# File I/O should be handeled with 'with open' when possible
with open('my_file', 'w') as f:
f.write('My favorite integer is {}'.format(an_int))
with open("my_file", "w") as f:
f.write("My favorite integer is {}".format(an_int))

# Operators should be separated by spaces
logging.info(a_float + a_float)

return an_int


if __name__ == '__main__':

if __name__ == "__main__":
# Configure logging
module = os.path.basename(__file__).strip('.py')
module = os.path.basename(__file__).strip(".py")
configure_logging(module)

args = parse_args() # type: argparse.Namespace
Expand Down
9 changes: 4 additions & 5 deletions style_guide/typing_demo/typing_demo_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"""

import sys
from typing import (List, Set, Dict, Tuple, Union, Optional, Callable,
Iterable, Any)
from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Union

assert sys.version_info >= (3, 6) # PEP 526 added variable annotations

Expand All @@ -18,7 +17,7 @@
a_string: str = "jwql"
a_list: List[int] = [1]
a_set: Set[int] = {1, 2, 3}
a_dict: Dict[str, bool] = {'jwql': True} # Have to specify both keys and values
a_dict: Dict[str, bool] = {"jwql": True} # Have to specify both keys and values

# For python versions prior to 3.6, the variable annotation syntax uses comments:
# annotated_variable = 1 # type: int
Expand Down Expand Up @@ -68,6 +67,7 @@ def a_generator() -> Iterable[int]:
# Type annotations are stored in __annotations__, either as a local variable
# or as an object attribute.


def print_annotations(arg: Any) -> bool:
if not hasattr(arg, "__annotations__"):
print("Sorry, that argument doesn't have its own __annotations__.")
Expand All @@ -76,8 +76,7 @@ def print_annotations(arg: Any) -> bool:
return bool(arg.__annotations__)


for name in ["an_integer", "a_generic_function", "two_arg_function",
"func_alias", "anon_func", "a_generator"]:
for name in ["an_integer", "a_generic_function", "two_arg_function", "func_alias", "anon_func", "a_generator"]:
var = locals()[name]
print(f"Annotations for {name}:")
if not print_annotations(var):
Expand Down
Loading