Skip to content

Commit

Permalink
Correct way to pass extra args
Browse files Browse the repository at this point in the history
  • Loading branch information
aulemahal authored Feb 12, 2025
1 parent bef557c commit 9479f51
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/notebooks/customize.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"\n",
"The `is_missing` method should return a boolean mask, resampled at the `freq` frequency, the same as the indicator output (same as `count`), where True values are for elements that are considered missing and masked on the output.\n",
"\n",
"To add additional arguments, one should override the `__init__` (receiving those arguments) and the `validate` static method, which validates them. See example below and the docstrings in the module.\n",
"To add additional arguments, one should override the `__init__` (receiving those arguments) and the `validate` static method, which validates them. The options are then stored in the `options` property of the instance. See example below and the docstrings in the module.\n",
"\n",
"When registering the class with the `xclim.core.checks.register_missing_method` decorator, the keyword arguments will be registered as options for the missing method. "
]
Expand All @@ -185,9 +185,9 @@
" def __init__(self, max_n: int = 5):\n",
" super().__init__(max_n=max_n)\n",
"\n",
" def is_missing(self, null, count, freq, max_n=5):\n",
" def is_missing(self, null, count, freq):\n",
" \"\"\"Return a boolean mask where True values are for elements that are considered missing and masked on the output.\"\"\"\n",
" return null.resample(time=freq).map(longest_run, dim=\"time\") >= max_n\n",
" return null.resample(time=freq).map(longest_run, dim=\"time\") >= self.options['max_n']\n",
"\n",
" @staticmethod\n",
" def validate(max_n):\n",
Expand Down

0 comments on commit 9479f51

Please sign in to comment.