Skip to content

Commit

Permalink
DOC: Add docstring to string_like method
Browse files Browse the repository at this point in the history
Add docstring to string_like method
  • Loading branch information
tagomatech authored and bashtage committed Aug 18, 2020
1 parent 8d049b3 commit 9d900d6
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion statsmodels/tools/validation/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def array_like(
>>> a = array_like(pd.Series(x), 'x', ndim=1)
>>> a.shape
(4,)
>>> type(a.orig)
pandas.core.series.Series
Squeezes singleton dimensions when required
>>> x = np.array(x).reshape((4, 1))
>>> a = array_like(x, 'x', ndim=1)
Expand Down Expand Up @@ -395,6 +395,26 @@ def float_like(value, name, optional=False, strict=False):


def string_like(value, name, optional=False, options=None, lower=True):
"""
Check if object is string-like and raise if not
Parameters
----------
value : object
Value to verify
name : str
Variable name for exceptions
optional : bool
Flag indicating whether None is allowed
options : Sequence[str] or tuple[str]
Allowed values for input parameter `value`
lower : bool
Convert all case-based characters in `value` into lowercase
Returns
-------
validated : str
string_like
"""
if value is None:
return None
if not isinstance(value, str):
Expand Down

0 comments on commit 9d900d6

Please sign in to comment.