Datasets:

repository
stringclasses
11 values
repo_id
stringlengths
1
3
target_module_path
stringlengths
16
72
prompt
stringlengths
298
21.7k
relavent_test_path
stringlengths
50
99
full_function
stringlengths
336
33.8k
function_name
stringlengths
2
51
content_class
stringclasses
3 values
external_dependencies
stringclasses
2 values
flask
23
src/flask/config.py
def from_file( self, filename: str | os.PathLike[str], load: t.Callable[[t.IO[t.Any]], t.Mapping[str, t.Any]], silent: bool = False, text: bool = True, ) -> bool: """Update the values in the config from a file that is loaded using the ``load`` parameter. T...
/usr/src/app/target_test_cases/failed_tests_config.Config.from_file.txt
def from_file( self, filename: str | os.PathLike[str], load: t.Callable[[t.IO[t.Any]], t.Mapping[str, t.Any]], silent: bool = False, text: bool = True, ) -> bool: """Update the values in the config from a file that is loaded using the ``load`` parameter. T...
config.Config.from_file
file-level
external
flask
24
src/flask/config.py
def from_object(self, obj: object | str) -> None: """Updates the values from the given object. An object can be of one of the following two types: - a string: in this case the object with that name will be imported - an actual object reference: that object is used directly ...
/usr/src/app/target_test_cases/failed_tests_config.Config.from_object.txt
def from_object(self, obj: object | str) -> None: """Updates the values from the given object. An object can be of one of the following two types: - a string: in this case the object with that name will be imported - an actual object reference: that object is used directly ...
config.Config.from_object
file-level
non_external
flask
25
src/flask/config.py
def from_prefixed_env( self, prefix: str = "FLASK", *, loads: t.Callable[[str], t.Any] = json.loads ) -> bool: """Load any environment variables that start with ``FLASK_``, dropping the prefix from the env key for the config key. Values are passed through a loading function to at...
/usr/src/app/target_test_cases/failed_tests_config.Config.from_prefixed_env.txt
def from_prefixed_env( self, prefix: str = "FLASK", *, loads: t.Callable[[str], t.Any] = json.loads ) -> bool: """Load any environment variables that start with ``FLASK_``, dropping the prefix from the env key for the config key. Values are passed through a loading function to at...
config.Config.from_prefixed_env
file-level
external
flask
26
src/flask/config.py
def from_pyfile( self, filename: str | os.PathLike[str], silent: bool = False ) -> bool: """Updates the values in the config from a Python file. This function behaves as if the file was imported as module with the :meth:`from_object` function. :param filename: the filen...
/usr/src/app/target_test_cases/failed_tests_config.Config.from_pyfile.txt
def from_pyfile( self, filename: str | os.PathLike[str], silent: bool = False ) -> bool: """Updates the values in the config from a Python file. This function behaves as if the file was imported as module with the :meth:`from_object` function. :param filename: the filen...
config.Config.from_pyfile
file-level
external
flask
27
src/flask/config.py
def get_namespace( self, namespace: str, lowercase: bool = True, trim_namespace: bool = True ) -> dict[str, t.Any]: """Returns a dictionary containing a subset of configuration options that match the specified namespace/prefix. Example usage:: app.config['IMAGE_STORE_TYPE'] ...
/usr/src/app/target_test_cases/failed_tests_config.Config.get_namespace.txt
def get_namespace( self, namespace: str, lowercase: bool = True, trim_namespace: bool = True ) -> dict[str, t.Any]: """Returns a dictionary containing a subset of configuration options that match the specified namespace/prefix. Example usage:: app.config['IMAGE_STORE_TYPE'] ...
config.Config.get_namespace
file-level
external
flask
28
src/flask/ctx.py
def after_this_request( f: ft.AfterRequestCallable[t.Any], ) -> ft.AfterRequestCallable[t.Any]: """Executes a function after this request. This is useful to modify response objects. The function is passed the response object and has to return the same or a new one. Example:: @app.route('...
/usr/src/app/target_test_cases/failed_tests_ctx.after_this_request.txt
def after_this_request( f: ft.AfterRequestCallable[t.Any], ) -> ft.AfterRequestCallable[t.Any]: """Executes a function after this request. This is useful to modify response objects. The function is passed the response object and has to return the same or a new one. Example:: @app.route('...
ctx.after_this_request
repository-level
external
flask
29
src/flask/ctx.py
def has_request_context() -> bool: """If you have code that wants to test if a request context is there or not this function can be used. For instance, you may want to take advantage of request information if the request object is available, but fail silently if it is unavailable. :: clas...
/usr/src/app/target_test_cases/failed_tests_ctx.has_request_context.txt
def has_request_context() -> bool: """If you have code that wants to test if a request context is there or not this function can be used. For instance, you may want to take advantage of request information if the request object is available, but fail silently if it is unavailable. :: clas...
ctx.has_request_context
repository-level
non_external
flask
30
src/flask/helpers.py
def abort(code: int | BaseResponse, *args: t.Any, **kwargs: t.Any) -> t.NoReturn: """Raise an :exc:`~werkzeug.exceptions.HTTPException` for the given status code. If :data:`~flask.current_app` is available, it will call its :attr:`~flask.Flask.aborter` object, otherwise it will use :func:`werkzeug....
/usr/src/app/target_test_cases/failed_tests_helpers.abort.txt
def abort(code: int | BaseResponse, *args: t.Any, **kwargs: t.Any) -> t.NoReturn: """Raise an :exc:`~werkzeug.exceptions.HTTPException` for the given status code. If :data:`~flask.current_app` is available, it will call its :attr:`~flask.Flask.aborter` object, otherwise it will use :func:`werkzeug....
helpers.abort
repository-level
external
flask
31
src/flask/helpers.py
def flash(message: str, category: str = "message") -> None: """Flashes a message to the next request. In order to remove the flashed message from the session and to display it to the user, the template has to call :func:`get_flashed_messages`. .. versionchanged:: 0.3 `category` parameter added....
/usr/src/app/target_test_cases/failed_tests_helpers.flash.txt
def flash(message: str, category: str = "message") -> None: """Flashes a message to the next request. In order to remove the flashed message from the session and to display it to the user, the template has to call :func:`get_flashed_messages`. .. versionchanged:: 0.3 `category` parameter added....
helpers.flash
repository-level
non_external
flask
32
src/flask/helpers.py
def get_flashed_messages( with_categories: bool = False, category_filter: t.Iterable[str] = () ) -> list[str] | list[tuple[str, str]]: """Pulls all flashed messages from the session and returns them. Further calls in the same request to the function will return the same messages. By default just the me...
/usr/src/app/target_test_cases/failed_tests_helpers.get_flashed_messages.txt
def get_flashed_messages( with_categories: bool = False, category_filter: t.Iterable[str] = () ) -> list[str] | list[tuple[str, str]]: """Pulls all flashed messages from the session and returns them. Further calls in the same request to the function will return the same messages. By default just the me...
helpers.get_flashed_messages
repository-level
external
flask
33
src/flask/helpers.py
def get_template_attribute(template_name: str, attribute: str) -> t.Any: """Loads a macro (or variable) a template exports. This can be used to invoke a macro from within Python code. If you for example have a template named :file:`_cider.html` with the following contents: .. sourcecode:: html+jinja ...
/usr/src/app/target_test_cases/failed_tests_helpers.get_template_attribute.txt
def get_template_attribute(template_name: str, attribute: str) -> t.Any: """Loads a macro (or variable) a template exports. This can be used to invoke a macro from within Python code. If you for example have a template named :file:`_cider.html` with the following contents: .. sourcecode:: html+jinja ...
helpers.get_template_attribute
repository-level
external
flask
34
src/flask/helpers.py
def make_response(*args: t.Any) -> Response: """Sometimes it is necessary to set additional headers in a view. Because views do not have to return response objects but can return a value that is converted into a response object by Flask itself, it becomes tricky to add headers to it. This function can...
/usr/src/app/target_test_cases/failed_tests_helpers.make_response.txt
def make_response(*args: t.Any) -> Response: """Sometimes it is necessary to set additional headers in a view. Because views do not have to return response objects but can return a value that is converted into a response object by Flask itself, it becomes tricky to add headers to it. This function can...
helpers.make_response
repository-level
external
flask
35
src/flask/helpers.py
def redirect( location: str, code: int = 302, Response: type[BaseResponse] | None = None ) -> BaseResponse: """Create a redirect response object. If :data:`~flask.current_app` is available, it will use its :meth:`~flask.Flask.redirect` method, otherwise it will use :func:`werkzeug.utils.redirect`. ...
/usr/src/app/target_test_cases/failed_tests_helpers.redirect.txt
def redirect( location: str, code: int = 302, Response: type[BaseResponse] | None = None ) -> BaseResponse: """Create a redirect response object. If :data:`~flask.current_app` is available, it will use its :meth:`~flask.Flask.redirect` method, otherwise it will use :func:`werkzeug.utils.redirect`. ...
helpers.redirect
repository-level
non_external
flask
36
src/flask/helpers.py
def send_file( path_or_file: os.PathLike[t.AnyStr] | str | t.BinaryIO, mimetype: str | None = None, as_attachment: bool = False, download_name: str | None = None, conditional: bool = True, etag: bool | str = True, last_modified: datetime | int | float | None = None, max_age: None | (int ...
/usr/src/app/target_test_cases/failed_tests_helpers.send_file.txt
def send_file( path_or_file: os.PathLike[t.AnyStr] | str | t.BinaryIO, mimetype: str | None = None, as_attachment: bool = False, download_name: str | None = None, conditional: bool = True, etag: bool | str = True, last_modified: datetime | int | float | None = None, max_age: None | (int ...
helpers.send_file
repository-level
external
flask
37
src/flask/helpers.py
def send_from_directory( directory: os.PathLike[str] | str, path: os.PathLike[str] | str, **kwargs: t.Any, ) -> Response: """Send a file from within a directory using :func:`send_file`. .. code-block:: python @app.route("/uploads/<path:name>") def download_file(name): r...
/usr/src/app/target_test_cases/failed_tests_helpers.send_from_directory.txt
def send_from_directory( directory: os.PathLike[str] | str, path: os.PathLike[str] | str, **kwargs: t.Any, ) -> Response: """Send a file from within a directory using :func:`send_file`. .. code-block:: python @app.route("/uploads/<path:name>") def download_file(name): r...
helpers.send_from_directory
repository-level
external
flask
38
src/flask/helpers.py
def url_for( endpoint: str, *, _anchor: str | None = None, _method: str | None = None, _scheme: str | None = None, _external: bool | None = None, **values: t.Any, ) -> str: """Generate a URL to the given endpoint with the given values. This requires an active request or application ...
/usr/src/app/target_test_cases/failed_tests_helpers.url_for.txt
def url_for( endpoint: str, *, _anchor: str | None = None, _method: str | None = None, _scheme: str | None = None, _external: bool | None = None, **values: t.Any, ) -> str: """Generate a URL to the given endpoint with the given values. This requires an active request or application ...
helpers.url_for
repository-level
external
flask
39
src/flask/json/provider.py
def response(self, *args: t.Any, **kwargs: t.Any) -> Response: """Serialize the given arguments as JSON, and return a :class:`~flask.Response` object with it. The response mimetype will be "application/json" and can be changed with :attr:`mimetype`. If :attr:`compact` is ``F...
/usr/src/app/target_test_cases/failed_tests_provider.DefaultJSONProvider.response.txt
def response(self, *args: t.Any, **kwargs: t.Any) -> Response: """Serialize the given arguments as JSON, and return a :class:`~flask.Response` object with it. The response mimetype will be "application/json" and can be changed with :attr:`mimetype`. If :attr:`compact` is ``F...
provider.DefaultJSONProvider.response
file-level
external
flask
40
src/flask/testing.py
def invoke( # type: ignore self, cli: t.Any = None, args: t.Any = None, **kwargs: t.Any ) -> t.Any: """Invokes a CLI command in an isolated environment. See :meth:`CliRunner.invoke <click.testing.CliRunner.invoke>` for full method documentation. See :ref:`testing-cli` for exampl...
/usr/src/app/target_test_cases/failed_tests_testing.FlaskCliRunner.invoke.txt
def invoke( # type: ignore self, cli: t.Any = None, args: t.Any = None, **kwargs: t.Any ) -> t.Any: """Invokes a CLI command in an isolated environment. See :meth:`CliRunner.invoke <click.testing.CliRunner.invoke>` for full method documentation. See :ref:`testing-cli` for exampl...
testing.FlaskCliRunner.invoke
repository-level
external
flask
41
src/flask/testing.py
def session_transaction( self, *args: t.Any, **kwargs: t.Any ) -> t.Iterator[SessionMixin]: """When used in combination with a ``with`` statement this opens a session transaction. This can be used to modify the session that the test client uses. Once the ``with`` block is left ...
/usr/src/app/target_test_cases/failed_tests_testing.session_transaction.txt
def session_transaction( self, *args: t.Any, **kwargs: t.Any ) -> t.Iterator[SessionMixin]: """When used in combination with a ``with`` statement this opens a session transaction. This can be used to modify the session that the test client uses. Once the ``with`` block is left ...
testing.session_transaction
repository-level
external
flask
42
src/flask/views.py
def as_view( cls, name: str, *class_args: t.Any, **class_kwargs: t.Any ) -> ft.RouteCallable: """Convert the class into a view function that can be registered for a route. By default, the generated view will create a new instance of the view class for every request and c...
/usr/src/app/target_test_cases/failed_tests_views.as_view.txt
def as_view( cls, name: str, *class_args: t.Any, **class_kwargs: t.Any ) -> ft.RouteCallable: """Convert the class into a view function that can be registered for a route. By default, the generated view will create a new instance of the view class for every request and c...
views.as_view
repository-level
external
more-itertools
0
more_itertools/more.py
def adjacent(predicate, iterable, distance=1): """Return an iterable over `(bool, item)` tuples where the `item` is drawn from *iterable* and the `bool` indicates whether that item satisfies the *predicate* or is adjacent to an item that does. For example, to find whether items are adjacent to a ``3``:...
/usr/src/app/target_test_cases/failed_tests_more.adjacent.txt
def adjacent(predicate, iterable, distance=1): """Return an iterable over `(bool, item)` tuples where the `item` is drawn from *iterable* and the `bool` indicates whether that item satisfies the *predicate* or is adjacent to an item that does. For example, to find whether items are adjacent to a ``3``:...
more.adjacent
file-level
non_external
more-itertools
1
more_itertools/more.py
def all_unique(iterable, key=None): """ Returns ``True`` if all the elements of *iterable* are unique (no two elements are equal). >>> all_unique('ABCB') False If a *key* function is specified, it will be used to make comparisons. >>> all_unique('ABCb') True >>...
/usr/src/app/target_test_cases/failed_tests_more.all_unique.txt
def all_unique(iterable, key=None): """ Returns ``True`` if all the elements of *iterable* are unique (no two elements are equal). >>> all_unique('ABCB') False If a *key* function is specified, it will be used to make comparisons. >>> all_unique('ABCb') True >>...
more.all_unique
self-contained
non_external
more-itertools
2
more_itertools/more.py
def always_iterable(obj, base_type=(str, bytes)): """If *obj* is iterable, return an iterator over its items:: >>> obj = (1, 2, 3) >>> list(always_iterable(obj)) [1, 2, 3] If *obj* is not iterable, return a one-item iterable containing *obj*:: >>> obj = 1 >>> list(alwa...
/usr/src/app/target_test_cases/failed_tests_more.always_iterable.txt
def always_iterable(obj, base_type=(str, bytes)): """If *obj* is iterable, return an iterator over its items:: >>> obj = (1, 2, 3) >>> list(always_iterable(obj)) [1, 2, 3] If *obj* is not iterable, return a one-item iterable containing *obj*:: >>> obj = 1 >>> list(alwa...
more.always_iterable
self-contained
non_external
more-itertools
3
more_itertools/more.py
def chunked(iterable, n, strict=False): """Break *iterable* into lists of length *n*: >>> list(chunked([1, 2, 3, 4, 5, 6], 3)) [[1, 2, 3], [4, 5, 6]] By the default, the last yielded list will have fewer than *n* elements if the length of *iterable* is not divisible by *n*: >>> li...
/usr/src/app/target_test_cases/failed_tests_more.chunked.txt
def chunked(iterable, n, strict=False): """Break *iterable* into lists of length *n*: >>> list(chunked([1, 2, 3, 4, 5, 6], 3)) [[1, 2, 3], [4, 5, 6]] By the default, the last yielded list will have fewer than *n* elements if the length of *iterable* is not divisible by *n*: >>> li...
more.chunked
repository-level
external
more-itertools
4
more_itertools/more.py
def chunked_even(iterable, n): """Break *iterable* into lists of approximately length *n*. Items are distributed such the lengths of the lists differ by at most 1 item. >>> iterable = [1, 2, 3, 4, 5, 6, 7] >>> n = 3 >>> list(chunked_even(iterable, n)) # List lengths: 3, 2, 2 [[1, 2, 3], [4...
/usr/src/app/target_test_cases/failed_tests_more.chunked_even.txt
def chunked_even(iterable, n): """Break *iterable* into lists of approximately length *n*. Items are distributed such the lengths of the lists differ by at most 1 item. >>> iterable = [1, 2, 3, 4, 5, 6, 7] >>> n = 3 >>> list(chunked_even(iterable, n)) # List lengths: 3, 2, 2 [[1, 2, 3], [4...
more.chunked_even
self-contained
non_external
more-itertools
5
more_itertools/more.py
def circular_shifts(iterable, steps=1): """Yield the circular shifts of *iterable*. >>> list(circular_shifts(range(4))) [(0, 1, 2, 3), (1, 2, 3, 0), (2, 3, 0, 1), (3, 0, 1, 2)] Set *steps* to the number of places to rotate to the left (or to the right if negative). Defaults to 1. >>> list(ci...
/usr/src/app/target_test_cases/failed_tests_more.circular_shifts.txt
def circular_shifts(iterable, steps=1): """Yield the circular shifts of *iterable*. >>> list(circular_shifts(range(4))) [(0, 1, 2, 3), (1, 2, 3, 0), (2, 3, 0, 1), (3, 0, 1, 2)] Set *steps* to the number of places to rotate to the left (or to the right if negative). Defaults to 1. >>> list(ci...
more.circular_shifts
self-contained
external
more-itertools
6
more_itertools/more.py
def classify_unique(iterable, key=None): """Classify each element in terms of its uniqueness. For each element in the input iterable, return a 3-tuple consisting of: 1. The element itself 2. ``False`` if the element is equal to the one preceding it in the input, ``True`` otherwise (i.e. the equ...
/usr/src/app/target_test_cases/failed_tests_more.classify_unique.txt
def classify_unique(iterable, key=None): """Classify each element in terms of its uniqueness. For each element in the input iterable, return a 3-tuple consisting of: 1. The element itself 2. ``False`` if the element is equal to the one preceding it in the input, ``True`` otherwise (i.e. the equ...
more.classify_unique
self-contained
non_external
more-itertools
7
more_itertools/more.py
def collapse(iterable, base_type=None, levels=None): """Flatten an iterable with multiple levels of nesting (e.g., a list of lists of tuples) into non-iterable types. >>> iterable = [(1, 2), ([3, 4], [[5], [6]])] >>> list(collapse(iterable)) [1, 2, 3, 4, 5, 6] Binary and text strin...
/usr/src/app/target_test_cases/failed_tests_more.collapse.txt
def collapse(iterable, base_type=None, levels=None): """Flatten an iterable with multiple levels of nesting (e.g., a list of lists of tuples) into non-iterable types. >>> iterable = [(1, 2), ([3, 4], [[5], [6]])] >>> list(collapse(iterable)) [1, 2, 3, 4, 5, 6] Binary and text strin...
more.collapse
self-contained
external
more-itertools
8
more_itertools/more.py
def combination_with_replacement_index(element, iterable): """Equivalent to ``list(combinations_with_replacement(iterable, r)).index(element)`` The subsequences with repetition of *iterable* that are of length *r* can be ordered lexicographically. :func:`combination_with_replacement_index` computes...
/usr/src/app/target_test_cases/failed_tests_more.combination_with_replacement_index.txt
def combination_with_replacement_index(element, iterable): """Equivalent to ``list(combinations_with_replacement(iterable, r)).index(element)`` The subsequences with repetition of *iterable* that are of length *r* can be ordered lexicographically. :func:`combination_with_replacement_index` computes...
more.combination_with_replacement_index
self-contained
non_external
more-itertools
9
more_itertools/more.py
def consecutive_groups(iterable, ordering=lambda x: x): """Yield groups of consecutive items using :func:`itertools.groupby`. The *ordering* function determines whether two items are adjacent by returning their position. By default, the ordering function is the identity function. This is suitable f...
/usr/src/app/target_test_cases/failed_tests_more.consecutive_groups.txt
def consecutive_groups(iterable, ordering=lambda x: x): """Yield groups of consecutive items using :func:`itertools.groupby`. The *ordering* function determines whether two items are adjacent by returning their position. By default, the ordering function is the identity function. This is suitable f...
more.consecutive_groups
file-level
external
more-itertools
10
more_itertools/more.py
def constrained_batches( iterable, max_size, max_count=None, get_len=len, strict=True ): """Yield batches of items from *iterable* with a combined size limited by *max_size*. >>> iterable = [b'12345', b'123', b'12345678', b'1', b'1', b'12', b'1'] >>> list(constrained_batches(iterable, 10)) [(b'...
/usr/src/app/target_test_cases/failed_tests_more.constrained_batches.txt
def constrained_batches( iterable, max_size, max_count=None, get_len=len, strict=True ): """Yield batches of items from *iterable* with a combined size limited by *max_size*. >>> iterable = [b'12345', b'123', b'12345678', b'1', b'1', b'12', b'1'] >>> list(constrained_batches(iterable, 10)) [(b'...
more.constrained_batches
self-contained
non_external
more-itertools
11
more_itertools/more.py
def consumer(func): """Decorator that automatically advances a PEP-342-style "reverse iterator" to its first yield point so you don't have to call ``next()`` on it manually. >>> @consumer ... def tally(): ... i = 0 ... while True: ... print('Thing num...
/usr/src/app/target_test_cases/failed_tests_more.consumer.txt
def consumer(func): """Decorator that automatically advances a PEP-342-style "reverse iterator" to its first yield point so you don't have to call ``next()`` on it manually. >>> @consumer ... def tally(): ... i = 0 ... while True: ... print('Thing num...
more.consumer
file-level
external
more-itertools
12
more_itertools/more.py
def difference(iterable, func=sub, *, initial=None): """This function is the inverse of :func:`itertools.accumulate`. By default it will compute the first difference of *iterable* using :func:`operator.sub`: >>> from itertools import accumulate >>> iterable = accumulate([0, 1, 2, 3, 4]) # ...
/usr/src/app/target_test_cases/failed_tests_more.difference.txt
def difference(iterable, func=sub, *, initial=None): """This function is the inverse of :func:`itertools.accumulate`. By default it will compute the first difference of *iterable* using :func:`operator.sub`: >>> from itertools import accumulate >>> iterable = accumulate([0, 1, 2, 3, 4]) # ...
more.difference
self-contained
external
more-itertools
13
more_itertools/more.py
def distinct_permutations(iterable, r=None): """Yield successive distinct permutations of the elements in *iterable*. >>> sorted(distinct_permutations([1, 0, 1])) [(0, 1, 1), (1, 0, 1), (1, 1, 0)] Equivalent to yielding from ``set(permutations(iterable))``, except duplicates are not genera...
/usr/src/app/target_test_cases/failed_tests_more.distinct_permutations.txt
def distinct_permutations(iterable, r=None): """Yield successive distinct permutations of the elements in *iterable*. >>> sorted(distinct_permutations([1, 0, 1])) [(0, 1, 1), (1, 0, 1), (1, 1, 0)] Equivalent to yielding from ``set(permutations(iterable))``, except duplicates are not genera...
more.distinct_permutations
file-level
external
more-itertools
14
more_itertools/more.py
def distribute(n, iterable): """Distribute the items from *iterable* among *n* smaller iterables. >>> group_1, group_2 = distribute(2, [1, 2, 3, 4, 5, 6]) >>> list(group_1) [1, 3, 5] >>> list(group_2) [2, 4, 6] If the length of *iterable* is not evenly divisible by *n*,...
/usr/src/app/target_test_cases/failed_tests_more.distribute.txt
def distribute(n, iterable): """Distribute the items from *iterable* among *n* smaller iterables. >>> group_1, group_2 = distribute(2, [1, 2, 3, 4, 5, 6]) >>> list(group_1) [1, 3, 5] >>> list(group_2) [2, 4, 6] If the length of *iterable* is not evenly divisible by *n*,...
more.distribute
self-contained
non_external
more-itertools
15
more_itertools/more.py
def divide(n, iterable): """Divide the elements from *iterable* into *n* parts, maintaining order. >>> group_1, group_2 = divide(2, [1, 2, 3, 4, 5, 6]) >>> list(group_1) [1, 2, 3] >>> list(group_2) [4, 5, 6] If the length of *iterable* is not evenly divisible by *n*...
/usr/src/app/target_test_cases/failed_tests_more.divide.txt
def divide(n, iterable): """Divide the elements from *iterable* into *n* parts, maintaining order. >>> group_1, group_2 = divide(2, [1, 2, 3, 4, 5, 6]) >>> list(group_1) [1, 2, 3] >>> list(group_2) [4, 5, 6] If the length of *iterable* is not evenly divisible by *n*...
more.divide
self-contained
non_external
more-itertools
16
more_itertools/more.py
def doublestarmap(func, iterable): """Apply *func* to every item of *iterable* by dictionary unpacking the item into *func*. The difference between :func:`itertools.starmap` and :func:`doublestarmap` parallels the distinction between ``func(*a)`` and ``func(**a)``. >>> iterable = [{'a': 1, 'b': 2}...
/usr/src/app/target_test_cases/failed_tests_more.doublestarmap.txt
def doublestarmap(func, iterable): """Apply *func* to every item of *iterable* by dictionary unpacking the item into *func*. The difference between :func:`itertools.starmap` and :func:`doublestarmap` parallels the distinction between ``func(*a)`` and ``func(**a)``. >>> iterable = [{'a': 1, 'b': 2}...
more.doublestarmap
self-contained
non_external
more-itertools
17
more_itertools/more.py
def exactly_n(iterable, n, predicate=bool): """Return ``True`` if exactly ``n`` items in the iterable are ``True`` according to the *predicate* function. >>> exactly_n([True, True, False], 2) True >>> exactly_n([True, True, False], 1) False >>> exactly_n([0, 1, 2, 3, 4, ...
/usr/src/app/target_test_cases/failed_tests_more.exactly_n.txt
def exactly_n(iterable, n, predicate=bool): """Return ``True`` if exactly ``n`` items in the iterable are ``True`` according to the *predicate* function. >>> exactly_n([True, True, False], 2) True >>> exactly_n([True, True, False], 1) False >>> exactly_n([0, 1, 2, 3, 4, ...
more.exactly_n
repository-level
non_external
more-itertools
18
more_itertools/more.py
def filter_except(validator, iterable, *exceptions): """Yield the items from *iterable* for which the *validator* function does not raise one of the specified *exceptions*. *validator* is called for each item in *iterable*. It should be a function that accepts one argument and raises an exception i...
/usr/src/app/target_test_cases/failed_tests_more.filter_except.txt
def filter_except(validator, iterable, *exceptions): """Yield the items from *iterable* for which the *validator* function does not raise one of the specified *exceptions*. *validator* is called for each item in *iterable*. It should be a function that accepts one argument and raises an exception i...
more.filter_except
self-contained
non_external
more-itertools
19
more_itertools/more.py
def first(iterable, default=_marker): """Return the first item of *iterable*, or *default* if *iterable* is empty. >>> first([0, 1, 2, 3]) 0 >>> first([], 'some default') 'some default' If *default* is not provided and there are no items in the iterable, raise ``ValueEr...
/usr/src/app/target_test_cases/failed_tests_more.first.txt
def first(iterable, default=_marker): """Return the first item of *iterable*, or *default* if *iterable* is empty. >>> first([0, 1, 2, 3]) 0 >>> first([], 'some default') 'some default' If *default* is not provided and there are no items in the iterable, raise ``ValueEr...
more.first
repository-level
non_external
more-itertools
20
more_itertools/more.py
def gray_product(*iterables): """Like :func:`itertools.product`, but return tuples in an order such that only one element in the generated tuple changes from one iteration to the next. >>> list(gray_product('AB','CD')) [('A', 'C'), ('B', 'C'), ('B', 'D'), ('A', 'D')] This function cons...
/usr/src/app/target_test_cases/failed_tests_more.gray_product.txt
def gray_product(*iterables): """Like :func:`itertools.product`, but return tuples in an order such that only one element in the generated tuple changes from one iteration to the next. >>> list(gray_product('AB','CD')) [('A', 'C'), ('B', 'C'), ('B', 'D'), ('A', 'D')] This function cons...
more.gray_product
self-contained
non_external
more-itertools
21
more_itertools/more.py
def groupby_transform(iterable, keyfunc=None, valuefunc=None, reducefunc=None): """An extension of :func:`itertools.groupby` that can apply transformations to the grouped data. * *keyfunc* is a function computing a key value for each item in *iterable* * *valuefunc* is a function that transforms the in...
/usr/src/app/target_test_cases/failed_tests_more.groupby_transform.txt
def groupby_transform(iterable, keyfunc=None, valuefunc=None, reducefunc=None): """An extension of :func:`itertools.groupby` that can apply transformations to the grouped data. * *keyfunc* is a function computing a key value for each item in *iterable* * *valuefunc* is a function that transforms the in...
more.groupby_transform
self-contained
non_external
more-itertools
22
more_itertools/more.py
def ichunked(iterable, n): """Break *iterable* into sub-iterables with *n* elements each. :func:`ichunked` is like :func:`chunked`, but it yields iterables instead of lists. If the sub-iterables are read in order, the elements of *iterable* won't be stored in memory. If they are read out of ord...
/usr/src/app/target_test_cases/failed_tests_more.ichunked.txt
def ichunked(iterable, n): """Break *iterable* into sub-iterables with *n* elements each. :func:`ichunked` is like :func:`chunked`, but it yields iterables instead of lists. If the sub-iterables are read in order, the elements of *iterable* won't be stored in memory. If they are read out of ord...
more.ichunked
file-level
non_external
more-itertools
23
more_itertools/more.py
def idft(Xarr): """Inverse Discrete Fourier Tranform. *Xarr* is a sequence of complex numbers. Yields the components of the corresponding inverse-transformed output vector. >>> import cmath >>> xarr = [1, 2-1j, -1j, -1+2j] >>> Xarr = [2, -2-2j, -2j, 4+4j] >>> all(map(cmath.isclose, idft(Xar...
/usr/src/app/target_test_cases/failed_tests_more.idft.txt
def idft(Xarr): """Inverse Discrete Fourier Tranform. *Xarr* is a sequence of complex numbers. Yields the components of the corresponding inverse-transformed output vector. >>> import cmath >>> xarr = [1, 2-1j, -1j, -1+2j] >>> Xarr = [2, -2-2j, -2j, 4+4j] >>> all(map(cmath.isclose, idft(Xar...
more.idft
file-level
non_external
more-itertools
24
more_itertools/more.py
def iequals(*iterables): """Return ``True`` if all given *iterables* are equal to each other, which means that they contain the same elements in the same order. The function is useful for comparing iterables of different data types or iterables that do not support equality checks. >>> iequals("abc...
/usr/src/app/target_test_cases/failed_tests_more.iequals.txt
def iequals(*iterables): """Return ``True`` if all given *iterables* are equal to each other, which means that they contain the same elements in the same order. The function is useful for comparing iterables of different data types or iterables that do not support equality checks. >>> iequals("abc...
more.iequals
repository-level
non_external
more-itertools
25
more_itertools/more.py
def interleave_evenly(iterables, lengths=None): """ Interleave multiple iterables so that their elements are evenly distributed throughout the output sequence. >>> iterables = [1, 2, 3, 4, 5], ['a', 'b'] >>> list(interleave_evenly(iterables)) [1, 2, 'a', 3, 4, 'b', 5] >>> iterables = [[1, ...
/usr/src/app/target_test_cases/failed_tests_more.interleave_evenly.txt
def interleave_evenly(iterables, lengths=None): """ Interleave multiple iterables so that their elements are evenly distributed throughout the output sequence. >>> iterables = [1, 2, 3, 4, 5], ['a', 'b'] >>> list(interleave_evenly(iterables)) [1, 2, 'a', 3, 4, 'b', 5] >>> iterables = [[1, ...
more.interleave_evenly
self-contained
non_external
more-itertools
26
more_itertools/more.py
def is_sorted(iterable, key=None, reverse=False, strict=False): """Returns ``True`` if the items of iterable are in sorted order, and ``False`` otherwise. *key* and *reverse* have the same meaning that they do in the built-in :func:`sorted` function. >>> is_sorted(['1', '2', '3', '4', '5'], key=int) ...
/usr/src/app/target_test_cases/failed_tests_more.is_sorted.txt
def is_sorted(iterable, key=None, reverse=False, strict=False): """Returns ``True`` if the items of iterable are in sorted order, and ``False`` otherwise. *key* and *reverse* have the same meaning that they do in the built-in :func:`sorted` function. >>> is_sorted(['1', '2', '3', '4', '5'], key=int) ...
more.is_sorted
self-contained
external
more-itertools
27
more_itertools/more.py
def iter_suppress(iterable, *exceptions): """Yield each of the items from *iterable*. If the iteration raises one of the specified *exceptions*, that exception will be suppressed and iteration will stop. >>> from itertools import chain >>> def breaks_at_five(x): ... while True: ... ...
/usr/src/app/target_test_cases/failed_tests_more.iter_suppress.txt
def iter_suppress(iterable, *exceptions): """Yield each of the items from *iterable*. If the iteration raises one of the specified *exceptions*, that exception will be suppressed and iteration will stop. >>> from itertools import chain >>> def breaks_at_five(x): ... while True: ... ...
more.iter_suppress
self-contained
non_external
more-itertools
28
more_itertools/more.py
def locate(iterable, pred=bool, window_size=None): """Yield the index of each item in *iterable* for which *pred* returns ``True``. *pred* defaults to :func:`bool`, which will select truthy items: >>> list(locate([0, 1, 1, 0, 1, 0, 0])) [1, 2, 4] Set *pred* to a custom function to, e....
/usr/src/app/target_test_cases/failed_tests_more.locate.txt
def locate(iterable, pred=bool, window_size=None): """Yield the index of each item in *iterable* for which *pred* returns ``True``. *pred* defaults to :func:`bool`, which will select truthy items: >>> list(locate([0, 1, 1, 0, 1, 0, 0])) [1, 2, 4] Set *pred* to a custom function to, e....
more.locate
repository-level
non_external
more-itertools
29
more_itertools/more.py
def lstrip(iterable, pred): """Yield the items from *iterable*, but strip any from the beginning for which *pred* returns ``True``. For example, to remove a set of items from the start of an iterable: >>> iterable = (None, False, None, 1, 2, None, 3, False, None) >>> pred = lambda x: x in ...
/usr/src/app/target_test_cases/failed_tests_more.lstrip.txt
def lstrip(iterable, pred): """Yield the items from *iterable*, but strip any from the beginning for which *pred* returns ``True``. For example, to remove a set of items from the start of an iterable: >>> iterable = (None, False, None, 1, 2, None, 3, False, None) >>> pred = lambda x: x in ...
more.lstrip
self-contained
non_external
more-itertools
30
more_itertools/more.py
def make_decorator(wrapping_func, result_index=0): """Return a decorator version of *wrapping_func*, which is a function that modifies an iterable. *result_index* is the position in that function's signature where the iterable goes. This lets you use itertools on the "production end," i.e. at function ...
/usr/src/app/target_test_cases/failed_tests_more.make_decorator.txt
def make_decorator(wrapping_func, result_index=0): """Return a decorator version of *wrapping_func*, which is a function that modifies an iterable. *result_index* is the position in that function's signature where the iterable goes. This lets you use itertools on the "production end," i.e. at function ...
more.make_decorator
file-level
non_external
more-itertools
31
more_itertools/more.py
def map_except(function, iterable, *exceptions): """Transform each item from *iterable* with *function* and yield the result, unless *function* raises one of the specified *exceptions*. *function* is called to transform each item in *iterable*. It should accept one argument. >>> iterable = ['1', '...
/usr/src/app/target_test_cases/failed_tests_more.map_except.txt
def map_except(function, iterable, *exceptions): """Transform each item from *iterable* with *function* and yield the result, unless *function* raises one of the specified *exceptions*. *function* is called to transform each item in *iterable*. It should accept one argument. >>> iterable = ['1', '...
more.map_except
self-contained
non_external
more-itertools
32
more_itertools/more.py
def map_if(iterable, pred, func, func_else=lambda x: x): """Evaluate each item from *iterable* using *pred*. If the result is equivalent to ``True``, transform the item with *func* and yield it. Otherwise, transform the item with *func_else* and yield it. *pred*, *func*, and *func_else* should each be ...
/usr/src/app/target_test_cases/failed_tests_more.map_if.txt
def map_if(iterable, pred, func, func_else=lambda x: x): """Evaluate each item from *iterable* using *pred*. If the result is equivalent to ``True``, transform the item with *func* and yield it. Otherwise, transform the item with *func_else* and yield it. *pred*, *func*, and *func_else* should each be ...
more.map_if
file-level
non_external
more-itertools
33
more_itertools/more.py
def map_reduce(iterable, keyfunc, valuefunc=None, reducefunc=None): """Return a dictionary that maps the items in *iterable* to categories defined by *keyfunc*, transforms them with *valuefunc*, and then summarizes them by category with *reducefunc*. *valuefunc* defaults to the identity function if it ...
/usr/src/app/target_test_cases/failed_tests_more.map_reduce.txt
def map_reduce(iterable, keyfunc, valuefunc=None, reducefunc=None): """Return a dictionary that maps the items in *iterable* to categories defined by *keyfunc*, transforms them with *valuefunc*, and then summarizes them by category with *reducefunc*. *valuefunc* defaults to the identity function if it ...
more.map_reduce
file-level
external
more-itertools
34
more_itertools/more.py
def mark_ends(iterable): """Yield 3-tuples of the form ``(is_first, is_last, item)``. >>> list(mark_ends('ABC')) [(True, False, 'A'), (False, False, 'B'), (False, True, 'C')] Use this when looping over an iterable to take special action on its first and/or last items: >>> iterable = ['Header'...
/usr/src/app/target_test_cases/failed_tests_more.mark_ends.txt
def mark_ends(iterable): """Yield 3-tuples of the form ``(is_first, is_last, item)``. >>> list(mark_ends('ABC')) [(True, False, 'A'), (False, False, 'B'), (False, True, 'C')] Use this when looping over an iterable to take special action on its first and/or last items: >>> iterable = ['Header'...
more.mark_ends
self-contained
non_external
more-itertools
35
more_itertools/more.py
def minmax(iterable_or_value, *others, key=None, default=_marker): """Returns both the smallest and largest items in an iterable or the largest of two or more arguments. >>> minmax([3, 1, 5]) (1, 5) >>> minmax(4, 2, 6) (2, 6) If a *key* function is provided, it will be use...
/usr/src/app/target_test_cases/failed_tests_more.minmax.txt
def minmax(iterable_or_value, *others, key=None, default=_marker): """Returns both the smallest and largest items in an iterable or the largest of two or more arguments. >>> minmax([3, 1, 5]) (1, 5) >>> minmax(4, 2, 6) (2, 6) If a *key* function is provided, it will be use...
more.minmax
repository-level
non_external
more-itertools
36
more_itertools/more.py
def nth_combination_with_replacement(iterable, r, index): """Equivalent to ``list(combinations_with_replacement(iterable, r))[index]``. The subsequences with repetition of *iterable* that are of length *r* can be ordered lexicographically. :func:`nth_combination_with_replacement` computes the subs...
/usr/src/app/target_test_cases/failed_tests_more.nth_combination_with_replacement.txt
def nth_combination_with_replacement(iterable, r, index): """Equivalent to ``list(combinations_with_replacement(iterable, r))[index]``. The subsequences with repetition of *iterable* that are of length *r* can be ordered lexicographically. :func:`nth_combination_with_replacement` computes the subs...
more.nth_combination_with_replacement
self-contained
non_external
more-itertools
37
more_itertools/more.py
def nth_or_last(iterable, n, default=_marker): """Return the nth or the last item of *iterable*, or *default* if *iterable* is empty. >>> nth_or_last([0, 1, 2, 3], 2) 2 >>> nth_or_last([0, 1], 2) 1 >>> nth_or_last([], 0, 'some default') 'some default' If *de...
/usr/src/app/target_test_cases/failed_tests_more.nth_or_last.txt
def nth_or_last(iterable, n, default=_marker): """Return the nth or the last item of *iterable*, or *default* if *iterable* is empty. >>> nth_or_last([0, 1, 2, 3], 2) 2 >>> nth_or_last([0, 1], 2) 1 >>> nth_or_last([], 0, 'some default') 'some default' If *de...
more.nth_or_last
repository-level
non_external
more-itertools
38
more_itertools/more.py
def nth_permutation(iterable, r, index): """Equivalent to ``list(permutations(iterable, r))[index]``` The subsequences of *iterable* that are of length *r* where order is important can be ordered lexicographically. :func:`nth_permutation` computes the subsequence at sort position *index* directly, with...
/usr/src/app/target_test_cases/failed_tests_more.nth_permutation.txt
def nth_permutation(iterable, r, index): """Equivalent to ``list(permutations(iterable, r))[index]``` The subsequences of *iterable* that are of length *r* where order is important can be ordered lexicographically. :func:`nth_permutation` computes the subsequence at sort position *index* directly, with...
more.nth_permutation
self-contained
non_external
more-itertools
39
more_itertools/more.py
def one(iterable, too_short=None, too_long=None): """Return the first item from *iterable*, which is expected to contain only that item. Raise an exception if *iterable* is empty or has more than one item. :func:`one` is useful for ensuring that an iterable contains only one item. For example, it c...
/usr/src/app/target_test_cases/failed_tests_more.one.txt
def one(iterable, too_short=None, too_long=None): """Return the first item from *iterable*, which is expected to contain only that item. Raise an exception if *iterable* is empty or has more than one item. :func:`one` is useful for ensuring that an iterable contains only one item. For example, it c...
more.one
self-contained
non_external
more-itertools
40
more_itertools/more.py
def only(iterable, default=None, too_long=None): """If *iterable* has only one item, return it. If it has zero items, return *default*. If it has more than one item, raise the exception given by *too_long*, which is ``ValueError`` by default. >>> only([], default='missing') 'missing' >>> on...
/usr/src/app/target_test_cases/failed_tests_more.only.txt
def only(iterable, default=None, too_long=None): """If *iterable* has only one item, return it. If it has zero items, return *default*. If it has more than one item, raise the exception given by *too_long*, which is ``ValueError`` by default. >>> only([], default='missing') 'missing' >>> on...
more.only
self-contained
non_external
more-itertools
41
more_itertools/more.py
def outer_product(func, xs, ys, *args, **kwargs): """A generalized outer product that applies a binary function to all pairs of items. Returns a 2D matrix with ``len(xs)`` rows and ``len(ys)`` columns. Also accepts ``*args`` and ``**kwargs`` that are passed to ``func``. Multiplication table: >...
/usr/src/app/target_test_cases/failed_tests_more.outer_product.txt
def outer_product(func, xs, ys, *args, **kwargs): """A generalized outer product that applies a binary function to all pairs of items. Returns a 2D matrix with ``len(xs)`` rows and ``len(ys)`` columns. Also accepts ``*args`` and ``**kwargs`` that are passed to ``func``. Multiplication table: >...
more.outer_product
repository-level
non_external
more-itertools
42
more_itertools/more.py
def padded(iterable, fillvalue=None, n=None, next_multiple=False): """Yield the elements from *iterable*, followed by *fillvalue*, such that at least *n* items are emitted. >>> list(padded([1, 2, 3], '?', 5)) [1, 2, 3, '?', '?'] If *next_multiple* is ``True``, *fillvalue* will be emitted u...
/usr/src/app/target_test_cases/failed_tests_more.padded.txt
def padded(iterable, fillvalue=None, n=None, next_multiple=False): """Yield the elements from *iterable*, followed by *fillvalue*, such that at least *n* items are emitted. >>> list(padded([1, 2, 3], '?', 5)) [1, 2, 3, '?', '?'] If *next_multiple* is ``True``, *fillvalue* will be emitted u...
more.padded
file-level
non_external
more-itertools
43
more_itertools/more.py
def partitions(iterable): """Yield all possible order-preserving partitions of *iterable*. >>> iterable = 'abc' >>> for part in partitions(iterable): ... print([''.join(p) for p in part]) ['abc'] ['a', 'bc'] ['ab', 'c'] ['a', 'b', 'c'] This is unrelated to :func:`partition`. ...
/usr/src/app/target_test_cases/failed_tests_more.partitions.txt
def partitions(iterable): """Yield all possible order-preserving partitions of *iterable*. >>> iterable = 'abc' >>> for part in partitions(iterable): ... print([''.join(p) for p in part]) ['abc'] ['a', 'bc'] ['ab', 'c'] ['a', 'b', 'c'] This is unrelated to :func:`partition`. ...
more.partitions
repository-level
non_external
more-itertools
44
more_itertools/more.py
def prepend(self, *items): """Stack up items to be the next ones returned from ``next()`` or ``self.peek()``. The items will be returned in first in, first out order:: >>> p = peekable([1, 2, 3]) >>> p.prepend(10, 11, 12) >>> next(p) 10 ...
/usr/src/app/target_test_cases/failed_tests_more.peekable.prepend.txt
def prepend(self, *items): """Stack up items to be the next ones returned from ``next()`` or ``self.peek()``. The items will be returned in first in, first out order:: >>> p = peekable([1, 2, 3]) >>> p.prepend(10, 11, 12) >>> next(p) 10 ...
more.peekable.prepend
file-level
non_external
more-itertools
45
more_itertools/more.py
def permutation_index(element, iterable): """Equivalent to ``list(permutations(iterable, r)).index(element)``` The subsequences of *iterable* that are of length *r* where order is important can be ordered lexicographically. :func:`permutation_index` computes the index of the first *element* directly, w...
/usr/src/app/target_test_cases/failed_tests_more.permutation_index.txt
def permutation_index(element, iterable): """Equivalent to ``list(permutations(iterable, r)).index(element)``` The subsequences of *iterable* that are of length *r* where order is important can be ordered lexicographically. :func:`permutation_index` computes the index of the first *element* directly, w...
more.permutation_index
self-contained
non_external
more-itertools
46
more_itertools/more.py
def replace(iterable, pred, substitutes, count=None, window_size=1): """Yield the items from *iterable*, replacing the items for which *pred* returns ``True`` with the items from the iterable *substitutes*. >>> iterable = [1, 1, 0, 1, 1, 0, 1, 1] >>> pred = lambda x: x == 0 >>> substitu...
/usr/src/app/target_test_cases/failed_tests_more.replace.txt
def replace(iterable, pred, substitutes, count=None, window_size=1): """Yield the items from *iterable*, replacing the items for which *pred* returns ``True`` with the items from the iterable *substitutes*. >>> iterable = [1, 1, 0, 1, 1, 0, 1, 1] >>> pred = lambda x: x == 0 >>> substitu...
more.replace
repository-level
non_external
more-itertools
47
more_itertools/more.py
def rlocate(iterable, pred=bool, window_size=None): """Yield the index of each item in *iterable* for which *pred* returns ``True``, starting from the right and moving left. *pred* defaults to :func:`bool`, which will select truthy items: >>> list(rlocate([0, 1, 1, 0, 1, 0, 0])) # Truthy at 1, 2,...
/usr/src/app/target_test_cases/failed_tests_more.rlocate.txt
def rlocate(iterable, pred=bool, window_size=None): """Yield the index of each item in *iterable* for which *pred* returns ``True``, starting from the right and moving left. *pred* defaults to :func:`bool`, which will select truthy items: >>> list(rlocate([0, 1, 1, 0, 1, 0, 0])) # Truthy at 1, 2,...
more.rlocate
file-level
non_external
more-itertools
48
more_itertools/more.py
def sample(iterable, k, weights=None, *, counts=None, strict=False): """Return a *k*-length list of elements chosen (without replacement) from the *iterable*. Similar to :func:`random.sample`, but works on iterables of unknown length. >>> iterable = range(100) >>> sample(iterable, 5) # doctest: +S...
/usr/src/app/target_test_cases/failed_tests_more.sample.txt
def sample(iterable, k, weights=None, *, counts=None, strict=False): """Return a *k*-length list of elements chosen (without replacement) from the *iterable*. Similar to :func:`random.sample`, but works on iterables of unknown length. >>> iterable = range(100) >>> sample(iterable, 5) # doctest: +S...
more.sample
file-level
non_external
more-itertools
49
more_itertools/more.py
def set_partitions(iterable, k=None, min_size=None, max_size=None): """ Yield the set partitions of *iterable* into *k* parts. Set partitions are not order-preserving. >>> iterable = 'abc' >>> for part in set_partitions(iterable, 2): ... print([''.join(p) for p in part]) ['a', 'bc'] ...
/usr/src/app/target_test_cases/failed_tests_more.set_partitions.txt
def set_partitions(iterable, k=None, min_size=None, max_size=None): """ Yield the set partitions of *iterable* into *k* parts. Set partitions are not order-preserving. >>> iterable = 'abc' >>> for part in set_partitions(iterable, 2): ... print([''.join(p) for p in part]) ['a', 'bc'] ...
more.set_partitions
file-level
non_external
more-itertools
50
more_itertools/more.py
def side_effect(func, iterable, chunk_size=None, before=None, after=None): """Invoke *func* on each item in *iterable* (or on each *chunk_size* group of items) before yielding the item. `func` must be a function that takes a single argument. Its return value will be discarded. *before* and *after*...
/usr/src/app/target_test_cases/failed_tests_more.side_effect.txt
def side_effect(func, iterable, chunk_size=None, before=None, after=None): """Invoke *func* on each item in *iterable* (or on each *chunk_size* group of items) before yielding the item. `func` must be a function that takes a single argument. Its return value will be discarded. *before* and *after*...
more.side_effect
file-level
non_external
more-itertools
51
more_itertools/more.py
def sliced(seq, n, strict=False): """Yield slices of length *n* from the sequence *seq*. >>> list(sliced((1, 2, 3, 4, 5, 6), 3)) [(1, 2, 3), (4, 5, 6)] By the default, the last yielded slice will have fewer than *n* elements if the length of *seq* is not divisible by *n*: >>> list(sliced((1, ...
/usr/src/app/target_test_cases/failed_tests_more.sliced.txt
def sliced(seq, n, strict=False): """Yield slices of length *n* from the sequence *seq*. >>> list(sliced((1, 2, 3, 4, 5, 6), 3)) [(1, 2, 3), (4, 5, 6)] By the default, the last yielded slice will have fewer than *n* elements if the length of *seq* is not divisible by *n*: >>> list(sliced((1, ...
more.sliced
file-level
non_external
more-itertools
52
more_itertools/more.py
def sort_together( iterables, key_list=(0,), key=None, reverse=False, strict=False ): """Return the input iterables sorted together, with *key_list* as the priority for sorting. All iterables are trimmed to the length of the shortest one. This can be used like the sorting function in a spreadsheet....
/usr/src/app/target_test_cases/failed_tests_more.sort_together.txt
def sort_together( iterables, key_list=(0,), key=None, reverse=False, strict=False ): """Return the input iterables sorted together, with *key_list* as the priority for sorting. All iterables are trimmed to the length of the shortest one. This can be used like the sorting function in a spreadsheet....
more.sort_together
file-level
external
more-itertools
53
more_itertools/more.py
def split_after(iterable, pred, maxsplit=-1): """Yield lists of items from *iterable*, where each list ends with an item where callable *pred* returns ``True``: >>> list(split_after('one1two2', lambda s: s.isdigit())) [['o', 'n', 'e', '1'], ['t', 'w', 'o', '2']] >>> list(split_after(ra...
/usr/src/app/target_test_cases/failed_tests_more.split_after.txt
def split_after(iterable, pred, maxsplit=-1): """Yield lists of items from *iterable*, where each list ends with an item where callable *pred* returns ``True``: >>> list(split_after('one1two2', lambda s: s.isdigit())) [['o', 'n', 'e', '1'], ['t', 'w', 'o', '2']] >>> list(split_after(ra...
more.split_after
self-contained
non_external
more-itertools
54
more_itertools/more.py
def split_at(iterable, pred, maxsplit=-1, keep_separator=False): """Yield lists of items from *iterable*, where each list is delimited by an item where callable *pred* returns ``True``. >>> list(split_at('abcdcba', lambda x: x == 'b')) [['a'], ['c', 'd', 'c'], ['a']] >>> list(split_at(...
/usr/src/app/target_test_cases/failed_tests_more.split_at.txt
def split_at(iterable, pred, maxsplit=-1, keep_separator=False): """Yield lists of items from *iterable*, where each list is delimited by an item where callable *pred* returns ``True``. >>> list(split_at('abcdcba', lambda x: x == 'b')) [['a'], ['c', 'd', 'c'], ['a']] >>> list(split_at(...
more.split_at
self-contained
non_external
more-itertools
55
more_itertools/more.py
def split_before(iterable, pred, maxsplit=-1): """Yield lists of items from *iterable*, where each list ends just before an item for which callable *pred* returns ``True``: >>> list(split_before('OneTwo', lambda s: s.isupper())) [['O', 'n', 'e'], ['T', 'w', 'o']] >>> list(split_before(...
/usr/src/app/target_test_cases/failed_tests_more.split_before.txt
def split_before(iterable, pred, maxsplit=-1): """Yield lists of items from *iterable*, where each list ends just before an item for which callable *pred* returns ``True``: >>> list(split_before('OneTwo', lambda s: s.isupper())) [['O', 'n', 'e'], ['T', 'w', 'o']] >>> list(split_before(...
more.split_before
self-contained
non_external
more-itertools
56
more_itertools/more.py
def split_into(iterable, sizes): """Yield a list of sequential items from *iterable* of length 'n' for each integer 'n' in *sizes*. >>> list(split_into([1,2,3,4,5,6], [1,2,3])) [[1], [2, 3], [4, 5, 6]] If the sum of *sizes* is smaller than the length of *iterable*, then the remaining i...
/usr/src/app/target_test_cases/failed_tests_more.split_into.txt
def split_into(iterable, sizes): """Yield a list of sequential items from *iterable* of length 'n' for each integer 'n' in *sizes*. >>> list(split_into([1,2,3,4,5,6], [1,2,3])) [[1], [2, 3], [4, 5, 6]] If the sum of *sizes* is smaller than the length of *iterable*, then the remaining i...
more.split_into
self-contained
non_external
more-itertools
57
more_itertools/more.py
def split_when(iterable, pred, maxsplit=-1): """Split *iterable* into pieces based on the output of *pred*. *pred* should be a function that takes successive pairs of items and returns ``True`` if the iterable should be split in between them. For example, to find runs of increasing numbers, split the i...
/usr/src/app/target_test_cases/failed_tests_more.split_when.txt
def split_when(iterable, pred, maxsplit=-1): """Split *iterable* into pieces based on the output of *pred*. *pred* should be a function that takes successive pairs of items and returns ``True`` if the iterable should be split in between them. For example, to find runs of increasing numbers, split the i...
more.split_when
self-contained
non_external
more-itertools
58
more_itertools/more.py
def spy(iterable, n=1): """Return a 2-tuple with a list containing the first *n* elements of *iterable*, and an iterator with the same items as *iterable*. This allows you to "look ahead" at the items in the iterable without advancing it. There is one item in the list by default: >>> itera...
/usr/src/app/target_test_cases/failed_tests_more.spy.txt
def spy(iterable, n=1): """Return a 2-tuple with a list containing the first *n* elements of *iterable*, and an iterator with the same items as *iterable*. This allows you to "look ahead" at the items in the iterable without advancing it. There is one item in the list by default: >>> itera...
more.spy
repository-level
non_external
more-itertools
59
more_itertools/more.py
def stagger(iterable, offsets=(-1, 0, 1), longest=False, fillvalue=None): """Yield tuples whose elements are offset from *iterable*. The amount by which the `i`-th item in each tuple is offset is given by the `i`-th item in *offsets*. >>> list(stagger([0, 1, 2, 3])) [(None, 0, 1), (0, 1, 2)...
/usr/src/app/target_test_cases/failed_tests_more.stagger.txt
def stagger(iterable, offsets=(-1, 0, 1), longest=False, fillvalue=None): """Yield tuples whose elements are offset from *iterable*. The amount by which the `i`-th item in each tuple is offset is given by the `i`-th item in *offsets*. >>> list(stagger([0, 1, 2, 3])) [(None, 0, 1), (0, 1, 2)...
more.stagger
file-level
non_external
more-itertools
60
more_itertools/more.py
def strictly_n(iterable, n, too_short=None, too_long=None): """Validate that *iterable* has exactly *n* items and return them if it does. If it has fewer than *n* items, call function *too_short* with those items. If it has more than *n* items, call function *too_long* with the first ``n + 1`` items. ...
/usr/src/app/target_test_cases/failed_tests_more.strictly_n.txt
def strictly_n(iterable, n, too_short=None, too_long=None): """Validate that *iterable* has exactly *n* items and return them if it does. If it has fewer than *n* items, call function *too_short* with those items. If it has more than *n* items, call function *too_long* with the first ``n + 1`` items. ...
more.strictly_n
file-level
non_external
more-itertools
61
more_itertools/more.py
def substrings_indexes(seq, reverse=False): """Yield all substrings and their positions in *seq* The items yielded will be a tuple of the form ``(substr, i, j)``, where ``substr == seq[i:j]``. This function only works for iterables that support slicing, such as ``str`` objects. >>> for item i...
/usr/src/app/target_test_cases/failed_tests_more.substrings_indexes.txt
def substrings_indexes(seq, reverse=False): """Yield all substrings and their positions in *seq* The items yielded will be a tuple of the form ``(substr, i, j)``, where ``substr == seq[i:j]``. This function only works for iterables that support slicing, such as ``str`` objects. >>> for item i...
more.substrings_indexes
self-contained
non_external
more-itertools
62
more_itertools/more.py
def unique_in_window(iterable, n, key=None): """Yield the items from *iterable* that haven't been seen recently. *n* is the size of the lookback window. >>> iterable = [0, 1, 0, 2, 3, 0] >>> n = 3 >>> list(unique_in_window(iterable, n)) [0, 1, 2, 3, 0] The *key* function, i...
/usr/src/app/target_test_cases/failed_tests_more.unique_in_window.txt
def unique_in_window(iterable, n, key=None): """Yield the items from *iterable* that haven't been seen recently. *n* is the size of the lookback window. >>> iterable = [0, 1, 0, 2, 3, 0] >>> n = 3 >>> list(unique_in_window(iterable, n)) [0, 1, 2, 3, 0] The *key* function, i...
more.unique_in_window
self-contained
external
more-itertools
63
more_itertools/more.py
def unique_to_each(*iterables): """Return the elements from each of the input iterables that aren't in the other input iterables. For example, suppose you have a set of packages, each with a set of dependencies:: {'pkg_1': {'A', 'B'}, 'pkg_2': {'B', 'C'}, 'pkg_3': {'B', 'D'}} If you remov...
/usr/src/app/target_test_cases/failed_tests_more.unique_to_each.txt
def unique_to_each(*iterables): """Return the elements from each of the input iterables that aren't in the other input iterables. For example, suppose you have a set of packages, each with a set of dependencies:: {'pkg_1': {'A', 'B'}, 'pkg_2': {'B', 'C'}, 'pkg_3': {'B', 'D'}} If you remov...
more.unique_to_each
self-contained
external
more-itertools
64
more_itertools/more.py
def unzip(iterable): """The inverse of :func:`zip`, this function disaggregates the elements of the zipped *iterable*. The ``i``-th iterable contains the ``i``-th element from each element of the zipped iterable. The first element is used to determine the length of the remaining elements. ...
/usr/src/app/target_test_cases/failed_tests_more.unzip.txt
def unzip(iterable): """The inverse of :func:`zip`, this function disaggregates the elements of the zipped *iterable*. The ``i``-th iterable contains the ``i``-th element from each element of the zipped iterable. The first element is used to determine the length of the remaining elements. ...
more.unzip
file-level
non_external
more-itertools
65
more_itertools/more.py
def value_chain(*args): """Yield all arguments passed to the function in the same order in which they were passed. If an argument itself is iterable then iterate over its values. >>> list(value_chain(1, 2, 3, [4, 5, 6])) [1, 2, 3, 4, 5, 6] Binary and text strings are not considered ite...
/usr/src/app/target_test_cases/failed_tests_more.value_chain.txt
def value_chain(*args): """Yield all arguments passed to the function in the same order in which they were passed. If an argument itself is iterable then iterate over its values. >>> list(value_chain(1, 2, 3, [4, 5, 6])) [1, 2, 3, 4, 5, 6] Binary and text strings are not considered ite...
more.value_chain
self-contained
non_external
more-itertools
66
more_itertools/more.py
def windowed(seq, n, fillvalue=None, step=1): """Return a sliding window of width *n* over the given iterable. >>> all_windows = windowed([1, 2, 3, 4, 5], 3) >>> list(all_windows) [(1, 2, 3), (2, 3, 4), (3, 4, 5)] When the window is larger than the iterable, *fillvalue* is used in plac...
/usr/src/app/target_test_cases/failed_tests_more.windowed.txt
def windowed(seq, n, fillvalue=None, step=1): """Return a sliding window of width *n* over the given iterable. >>> all_windows = windowed([1, 2, 3, 4, 5], 3) >>> list(all_windows) [(1, 2, 3), (2, 3, 4), (3, 4, 5)] When the window is larger than the iterable, *fillvalue* is used in plac...
more.windowed
self-contained
external
more-itertools
67
more_itertools/more.py
def windowed_complete(iterable, n): """ Yield ``(beginning, middle, end)`` tuples, where: * Each ``middle`` has *n* items from *iterable* * Each ``beginning`` has the items before the ones in ``middle`` * Each ``end`` has the items after the ones in ``middle`` >>> iterable = range(7) >>> n...
/usr/src/app/target_test_cases/failed_tests_more.windowed_complete.txt
def windowed_complete(iterable, n): """ Yield ``(beginning, middle, end)`` tuples, where: * Each ``middle`` has *n* items from *iterable* * Each ``beginning`` has the items before the ones in ``middle`` * Each ``end`` has the items after the ones in ``middle`` >>> iterable = range(7) >>> n...
more.windowed_complete
self-contained
non_external
more-itertools
68
more_itertools/more.py
def zip_broadcast(*objects, scalar_types=(str, bytes), strict=False): """A version of :func:`zip` that "broadcasts" any scalar (i.e., non-iterable) items into output tuples. >>> iterable_1 = [1, 2, 3] >>> iterable_2 = ['a', 'b', 'c'] >>> scalar = '_' >>> list(zip_broadcast(iterable_1, iterable_...
/usr/src/app/target_test_cases/failed_tests_more.zip_broadcast.txt
def zip_broadcast(*objects, scalar_types=(str, bytes), strict=False): """A version of :func:`zip` that "broadcasts" any scalar (i.e., non-iterable) items into output tuples. >>> iterable_1 = [1, 2, 3] >>> iterable_2 = ['a', 'b', 'c'] >>> scalar = '_' >>> list(zip_broadcast(iterable_1, iterable_...
more.zip_broadcast
repository-level
non_external
more-itertools
69
more_itertools/more.py
def zip_equal(*iterables): """``zip`` the input *iterables* together, but raise ``UnequalIterablesError`` if they aren't all the same length. >>> it_1 = range(3) >>> it_2 = iter('abc') >>> list(zip_equal(it_1, it_2)) [(0, 'a'), (1, 'b'), (2, 'c')] >>> it_1 = range(3) ...
/usr/src/app/target_test_cases/failed_tests_more.zip_equal.txt
def zip_equal(*iterables): """``zip`` the input *iterables* together, but raise ``UnequalIterablesError`` if they aren't all the same length. >>> it_1 = range(3) >>> it_2 = iter('abc') >>> list(zip_equal(it_1, it_2)) [(0, 'a'), (1, 'b'), (2, 'c')] >>> it_1 = range(3) ...
more.zip_equal
repository-level
external
more-itertools
70
more_itertools/more.py
def zip_offset(*iterables, offsets, longest=False, fillvalue=None): """``zip`` the input *iterables* together, but offset the `i`-th iterable by the `i`-th item in *offsets*. >>> list(zip_offset('0123', 'abcdef', offsets=(0, 1))) [('0', 'b'), ('1', 'c'), ('2', 'd'), ('3', 'e')] This can be...
/usr/src/app/target_test_cases/failed_tests_more.zip_offset.txt
def zip_offset(*iterables, offsets, longest=False, fillvalue=None): """``zip`` the input *iterables* together, but offset the `i`-th iterable by the `i`-th item in *offsets*. >>> list(zip_offset('0123', 'abcdef', offsets=(0, 1))) [('0', 'b'), ('1', 'c'), ('2', 'd'), ('3', 'e')] This can be...
more.zip_offset
self-contained
non_external
more-itertools
71
more_itertools/recipes.py
def all_equal(iterable, key=None): """ Returns ``True`` if all the elements are equal to each other. >>> all_equal('aaaa') True >>> all_equal('aaab') False A function that accepts a single argument and returns a transformed version of each input item can be specified wi...
/usr/src/app/target_test_cases/failed_tests_recipes.all_equal.txt
def all_equal(iterable, key=None): """ Returns ``True`` if all the elements are equal to each other. >>> all_equal('aaaa') True >>> all_equal('aaab') False A function that accepts a single argument and returns a transformed version of each input item can be specified wi...
recipes.all_equal
self-contained
non_external
more-itertools
72
more_itertools/recipes.py
def before_and_after(predicate, it): """A variant of :func:`takewhile` that allows complete access to the remainder of the iterator. >>> it = iter('ABCdEfGhI') >>> all_upper, remainder = before_and_after(str.isupper, it) >>> ''.join(all_upper) 'ABC' >>> ''.join(rema...
/usr/src/app/target_test_cases/failed_tests_recipes.before_and_after.txt
def before_and_after(predicate, it): """A variant of :func:`takewhile` that allows complete access to the remainder of the iterator. >>> it = iter('ABCdEfGhI') >>> all_upper, remainder = before_and_after(str.isupper, it) >>> ''.join(all_upper) 'ABC' >>> ''.join(rema...
recipes.before_and_after
file-level
non_external
more-itertools
73
more_itertools/recipes.py
def consume(iterator, n=None): """Advance *iterable* by *n* steps. If *n* is ``None``, consume it entirely. Efficiently exhausts an iterator without returning values. Defaults to consuming the whole iterator, but an optional second argument may be provided to limit consumption. >>> i = (x ...
/usr/src/app/target_test_cases/failed_tests_recipes.consume.txt
def consume(iterator, n=None): """Advance *iterable* by *n* steps. If *n* is ``None``, consume it entirely. Efficiently exhausts an iterator without returning values. Defaults to consuming the whole iterator, but an optional second argument may be provided to limit consumption. >>> i = (x ...
recipes.consume
self-contained
external
more-itertools
74
more_itertools/recipes.py
def first_true(iterable, default=None, pred=None): """ Returns the first true value in the iterable. If no true value is found, returns *default* If *pred* is not None, returns the first item for which ``pred(item) == True`` . >>> first_true(range(10)) 1 >>> first_true(ran...
/usr/src/app/target_test_cases/failed_tests_recipes.first_true.txt
def first_true(iterable, default=None, pred=None): """ Returns the first true value in the iterable. If no true value is found, returns *default* If *pred* is not None, returns the first item for which ``pred(item) == True`` . >>> first_true(range(10)) 1 >>> first_true(ran...
recipes.first_true
self-contained
non_external
more-itertools
75
more_itertools/recipes.py
def grouper(iterable, n, incomplete='fill', fillvalue=None): """Group elements from *iterable* into fixed-length groups of length *n*. >>> list(grouper('ABCDEF', 3)) [('A', 'B', 'C'), ('D', 'E', 'F')] The keyword arguments *incomplete* and *fillvalue* control what happens for iterables whose lengt...
/usr/src/app/target_test_cases/failed_tests_recipes.grouper.txt
def grouper(iterable, n, incomplete='fill', fillvalue=None): """Group elements from *iterable* into fixed-length groups of length *n*. >>> list(grouper('ABCDEF', 3)) [('A', 'B', 'C'), ('D', 'E', 'F')] The keyword arguments *incomplete* and *fillvalue* control what happens for iterables whose lengt...
recipes.grouper
file-level
non_external
more-itertools
76
more_itertools/recipes.py
def iter_except(func, exception, first=None): """Yields results from a function repeatedly until an exception is raised. Converts a call-until-exception interface to an iterator interface. Like ``iter(func, sentinel)``, but uses an exception instead of a sentinel to end the loop. >>> l = [0, 1...
/usr/src/app/target_test_cases/failed_tests_recipes.iter_except.txt
def iter_except(func, exception, first=None): """Yields results from a function repeatedly until an exception is raised. Converts a call-until-exception interface to an iterator interface. Like ``iter(func, sentinel)``, but uses an exception instead of a sentinel to end the loop. >>> l = [0, 1...
recipes.iter_except
self-contained
non_external
more-itertools
77
more_itertools/recipes.py
def iter_index(iterable, value, start=0, stop=None): """Yield the index of each place in *iterable* that *value* occurs, beginning with index *start* and ending before index *stop*. >>> list(iter_index('AABCADEAF', 'A')) [0, 1, 4, 7] >>> list(iter_index('AABCADEAF', 'A', 1)) # start index is incl...
/usr/src/app/target_test_cases/failed_tests_recipes.iter_index.txt
def iter_index(iterable, value, start=0, stop=None): """Yield the index of each place in *iterable* that *value* occurs, beginning with index *start* and ending before index *stop*. >>> list(iter_index('AABCADEAF', 'A')) [0, 1, 4, 7] >>> list(iter_index('AABCADEAF', 'A', 1)) # start index is incl...
recipes.iter_index
self-contained
non_external
more-itertools
78
more_itertools/recipes.py
def nth_combination(iterable, r, index): """Equivalent to ``list(combinations(iterable, r))[index]``. The subsequences of *iterable* that are of length *r* can be ordered lexicographically. :func:`nth_combination` computes the subsequence at sort position *index* directly, without computing the previou...
/usr/src/app/target_test_cases/failed_tests_recipes.nth_combination.txt
def nth_combination(iterable, r, index): """Equivalent to ``list(combinations(iterable, r))[index]``. The subsequences of *iterable* that are of length *r* can be ordered lexicographically. :func:`nth_combination` computes the subsequence at sort position *index* directly, without computing the previou...
recipes.nth_combination
self-contained
non_external
more-itertools
79
more_itertools/recipes.py
def partition(pred, iterable): """ Returns a 2-tuple of iterables derived from the input iterable. The first yields the items that have ``pred(item) == False``. The second yields the items that have ``pred(item) == True``. >>> is_odd = lambda x: x % 2 != 0 >>> iterable = range(10) ...
/usr/src/app/target_test_cases/failed_tests_recipes.partition.txt
def partition(pred, iterable): """ Returns a 2-tuple of iterables derived from the input iterable. The first yields the items that have ``pred(item) == False``. The second yields the items that have ``pred(item) == True``. >>> is_odd = lambda x: x % 2 != 0 >>> iterable = range(10) ...
recipes.partition
self-contained
external