Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
fixes inconsistent parameterize documentation to use correct helper f…
Browse files Browse the repository at this point in the history
…unctions
  • Loading branch information
elijahbenizzy committed Sep 2, 2022
1 parent 37cf3c9 commit d70dd30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ business-logic reuse. The decorators we've defined are as follows

## @parameterize
Expands a single function into n, each of which correspond to a function in which the parameter value is replaced either by:
1. A specific value
2. An specific upstream node.
1. A specified value
2. The value from a specified upstream node.

Note that this can take the place of any of the `@parameterize` decorators below. In fact, they delegate to this!

Expand All @@ -31,8 +31,8 @@ also pass documentation. If you don't, it will use the parameterized docstring.

```python
@parameterize(
D_ELECTION_2016_shifted=(dict(n_off_date=upstream('D_ELECTION_2016'), shift_by=literal(3)), "D_ELECTION_2016 shifted by 3"),
SOME_OUTPUT_NAME=(dict(n_off_date=upstream('SOME_INPUT_NAME'), shift_by=literal(1)),"SOME_INPUT_NAME shifted by 1")
D_ELECTION_2016_shifted=(dict(n_off_date=source('D_ELECTION_2016'), shift_by=value(3)), "D_ELECTION_2016 shifted by 3"),
SOME_OUTPUT_NAME=(dict(n_off_date=source('SOME_INPUT_NAME'), shift_by=value(1)),"SOME_INPUT_NAME shifted by 1")
)
def date_shifter(n_off_date: pd.Series, shift_by: int=1) -> pd.Series:
"""{one_off_date} shifted by shift_by to create {output_name}"""
Expand Down
8 changes: 4 additions & 4 deletions hamilton/function_modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def __init__(
"""Creates a parameterize decorator. For example:
@parameterize(
replace_no_parameters=({}, 'fn with no parameters replaced'),
replace_just_upstream_parameter=({'upstream_parameter': upstream('foo_source')}, 'fn with upstream_parameter set to node foo'),
replace_just_literal_parameter=({'literal_parameter': literal('bar')}, 'fn with upstream_parameter set to node foo'),
replace_both_parameters=({'upstream_parameter': upstream('foo_source'), 'literal_parameter': literal('bar')}, 'fn with both parameters replaced')
replace_just_upstream_parameter=({'upstream_parameter': source('foo_source')}, 'fn with upstream_parameter set to node foo'),
replace_just_literal_parameter=({'literal_parameter': value('bar')}, 'fn with parameter literal_parameter set to value bar'),
replace_both_parameters=({'upstream_parameter': source('foo_source'), 'literal_parameter': value('bar')}, 'fn with both parameters replaced')
)
def concat(upstream_parameter: str, literal_parameter: str) -> Any:
return f'{upstream_parameter}{literal_parameter}'
Expand All @@ -127,7 +127,7 @@ def concat(upstream_parameter: str, literal_parameter: str) -> Any:
bad_values.append(value)
if bad_values:
raise InvalidDecoratorException(
f"@parameterize must specify a dependency type -- either upstream() or literal()."
f"@parameterize must specify a dependency type -- either source() or value()."
f"The following are not allowed: {bad_values}."
)
self.specified_docstrings = {
Expand Down

0 comments on commit d70dd30

Please sign in to comment.