← Back
Editing: _util.cpython-311.pyc
� d�c�_ � � � d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlZd dl Z d dl mZmZm Z mZ d dlZeeej f Zeeej ej f Ze rNeeeej j ej j f Z edeej j ej j f �� � Z d dlmZ n# e$ r G d� d � � ZY nw xY wd*d �Zd+d�Zeddfd �Z d� Z!d� Z"dedefd�Z#d� Z$ d,d�Z%d-d�Z& edg d�� � Z'd� Z( G d� d� � Z) G d� d� � Z* d.d �Z+ed/d"�� � Z,d0d#�Z-d$� Z.d1d%�Z/d2d'�Z0d-d(�Z1d)� Z2dS )3� )�contextmanagerN)� namedtuple)�Optional�Union� TYPE_CHECKING�TypeVar� GeneratorType)�bound)� Generatorc � � e Zd ZdS )r N)�__name__� __module__�__qualname__� � �2/usr/lib/python3/dist-packages/scipy/_lib/_util.pyr r s � � � � � ��r r c �L � � t j � � � � |�|�t d� � �t j }n|�t d� � �t j � g|�R � }|d |dd� c� }t � fd�|D � � � � }t j d� |D � � � � }t j t j |d � � ||�� � }t j |� ||� � � |�5t � fd �|D � � � � }t j |� ||� � � |S ) a� np.where(cond, x, fillvalue) always evaluates x even where cond is False. This one only evaluates f(arr1[cond], arr2[cond], ...). Examples -------- >>> import numpy as np >>> a, b = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8]) >>> def f(a, b): ... return a*b >>> _lazywhere(a > 2, (a, b), f, np.nan) array([ nan, nan, 21., 32.]) Notice, it assumes that all `arrays` are of the same shape, or can be broadcasted together. Nz%One of (fillvalue, f2) must be given.z)Only one of (fillvalue, f2) can be given.r � c 3 �B �K � | ]}t j �|� � V � �d S �N��np�extract��.0�arr�conds �r � <genexpr>z_lazywhere.<locals>.<genexpr>B s/ �� � � �9�9�3���D�#�&�&�9�9�9�9�9�9r c �&