当前位置: 首页>>代码示例>>Python>>正文


Python numpy.alltrue方法代码示例

本文整理汇总了Python中numpy.alltrue方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.alltrue方法的具体用法?Python numpy.alltrue怎么用?Python numpy.alltrue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


在下文中一共展示了numpy.alltrue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_emg_eventrelated

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_emg_eventrelated():

    emg = nk.emg_simulate(duration=20, sampling_rate=1000, burst_number=3)
    emg_signals, info = nk.emg_process(emg, sampling_rate=1000)
    epochs = nk.epochs_create(
        emg_signals, events=[3000, 6000, 9000], sampling_rate=1000, epochs_start=-0.1, epochs_end=1.9
    )
    emg_eventrelated = nk.emg_eventrelated(epochs)

    # Test amplitude features
    no_activation = np.where(emg_eventrelated["EMG_Activation"] == 0)[0][0]
    assert int(pd.DataFrame(emg_eventrelated.values[no_activation]).isna().sum()) == 4

    assert np.alltrue(
        np.nansum(np.array(emg_eventrelated["EMG_Amplitude_Mean"]))
        < np.nansum(np.array(emg_eventrelated["EMG_Amplitude_Max"]))
    )

    assert len(emg_eventrelated["Label"]) == 3 
开发者ID:neuropsychology,项目名称:NeuroKit,代码行数:21,代码来源:tests_emg.py

示例2: test_rsp_eventrelated

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_rsp_eventrelated():

    rsp, info = nk.rsp_process(nk.rsp_simulate(duration=30, random_state=42))
    epochs = nk.epochs_create(rsp, events=[5000, 10000, 15000], epochs_start=-0.1, epochs_end=1.9)
    rsp_eventrelated = nk.rsp_eventrelated(epochs)

    # Test rate features
    assert np.alltrue(np.array(rsp_eventrelated["RSP_Rate_Min"]) < np.array(rsp_eventrelated["RSP_Rate_Mean"]))

    assert np.alltrue(np.array(rsp_eventrelated["RSP_Rate_Mean"]) < np.array(rsp_eventrelated["RSP_Rate_Max"]))

    # Test amplitude features
    assert np.alltrue(
        np.array(rsp_eventrelated["RSP_Amplitude_Min"]) < np.array(rsp_eventrelated["RSP_Amplitude_Mean"])
    )

    assert np.alltrue(
        np.array(rsp_eventrelated["RSP_Amplitude_Mean"]) < np.array(rsp_eventrelated["RSP_Amplitude_Max"])
    )

    assert len(rsp_eventrelated["Label"]) == 3 
开发者ID:neuropsychology,项目名称:NeuroKit,代码行数:23,代码来源:tests_rsp.py

示例3: run_prequential_supervised

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def run_prequential_supervised(stream, learner, max_samples, n_wait, y_expected=None):
    stream.restart()

    y_pred = np.zeros(max_samples // n_wait, dtype=np.int)
    y_true = np.zeros(max_samples // n_wait, dtype=np.int)
    j = 0

    for i in range(max_samples):
        X, y = stream.next_sample()
        # Test every n samples
        if i % n_wait == 0:
            y_pred[j] = int(learner.predict(X)[0])
            y_true[j] = (y[0])
            j += 1
        learner.partial_fit(X, y, classes=stream.target_values)

    assert type(learner.predict(X)) == np.ndarray

    if y_expected is not None:
        assert np.alltrue(y_pred == y_expected) 
开发者ID:scikit-multiflow,项目名称:scikit-multiflow,代码行数:22,代码来源:test_leverage_bagging.py

示例4: test_missing_values_cleaner

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_missing_values_cleaner(test_path):

    test_file = os.path.join(test_path, 'data_nan.npy')
    X_nan = np.load(test_file)
    X = copy(X_nan)

    cleaner = MissingValuesCleaner(missing_value=np.nan, strategy='zero')

    X_complete = cleaner.transform(X)

    test_file = os.path.join(test_path, 'data_complete.npy')
    X_expected = np.load(test_file)
    assert np.alltrue(X_complete == X_expected)

    expected_info = "MissingValuesCleaner(missing_value=[nan], new_value=1, strategy='zero',\n" \
                    "                     window_size=200)"
    assert cleaner.get_info() == expected_info

    assert cleaner._estimator_type == 'transform' 
开发者ID:scikit-multiflow,项目名称:scikit-multiflow,代码行数:21,代码来源:test_missing_values_cleaner.py

示例5: test_windowed_standard_scaler

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_windowed_standard_scaler(test_path):
    X_orig = np.array([[1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.]])
    X = copy(X_orig)

    cleaner = WindowedStandardScaler(window_size=20)

    X_complete = cleaner.transform(X)

    test_file = os.path.join(test_path, 'std_scaler.npy')
    X_expected = np.load(test_file)

    assert np.alltrue(X_complete == X_expected) 
开发者ID:scikit-multiflow,项目名称:scikit-multiflow,代码行数:24,代码来源:test_windowed_standard_scaler.py

示例6: test_windowed_minmax_scaler

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_windowed_minmax_scaler(test_path):
    X_orig = np.array([[1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.],
                       [1., 2., 3., 4.], [2., 3., 4., 5.], [3., 4., 5., 6.], [5., 4., 3., 2.], [4., 3., 2., 1.], [0., 1., 0., 1.], [3., 2., 3., 4.]])
    X = copy(X_orig)

    cleaner = WindowedMinmaxScaler(window_size=20)

    X_complete = cleaner.transform(X)

    test_file = os.path.join(test_path, 'minmax_scaler.npy')
    X_expected = np.load(test_file)

    assert np.alltrue(X_complete == X_expected) 
开发者ID:scikit-multiflow,项目名称:scikit-multiflow,代码行数:24,代码来源:test_windowed_minmax_scaler.py

示例7: test_regression_measurements

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_regression_measurements():
    y_true = np.sin(range(100))
    y_pred = np.sin(range(100)) + .05

    measurements = RegressionMeasurements()
    for i in range(len(y_true)):
        measurements.add_result(y_true[i], y_pred[i])

    expected_mse = 0.0025000000000000022
    assert np.isclose(expected_mse, measurements.get_mean_square_error())

    expected_ae = 0.049999999999999906
    assert np.isclose(expected_ae, measurements.get_average_error())

    expected_info = 'RegressionMeasurements: - sample_count: 100 - mean_square_error: 0.002500 ' \
                    '- mean_absolute_error: 0.050000'
    assert expected_info == measurements.get_info()

    expected_last = (-0.9992068341863537, -0.9492068341863537)
    assert np.alltrue(expected_last == measurements.get_last())

    measurements.reset()
    assert measurements.sample_count == 0 
开发者ID:scikit-multiflow,项目名称:scikit-multiflow,代码行数:25,代码来源:test_measure_collection.py

示例8: test_agrawal_drift

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_agrawal_drift(test_path):
    stream = AGRAWALGenerator(random_state=1)
    X, y = stream.next_sample(10)
    stream.generate_drift()
    X_drift, y_drift = stream.next_sample(10)

    # Load test data corresponding to first 10 instances
    test_file = os.path.join(test_path, 'agrawal_stream_drift.npz')
    data = np.load(test_file)
    X_expected = data['X']
    y_expected = data['y']

    X = np.concatenate((X, X_drift))
    y = np.concatenate((y, y_drift))
    assert np.alltrue(X == X_expected)
    assert np.alltrue(y == y_expected) 
开发者ID:scikit-multiflow,项目名称:scikit-multiflow,代码行数:18,代码来源:test_agrawal_generator.py

示例9: test_ecg_eventrelated

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_ecg_eventrelated():

    ecg, info = nk.ecg_process(nk.ecg_simulate(duration=20))
    epochs = nk.epochs_create(ecg, events=[5000, 10000, 15000], epochs_start=-0.1, epochs_end=1.9)
    ecg_eventrelated = nk.ecg_eventrelated(epochs)

    # Test rate features
    assert np.alltrue(np.array(ecg_eventrelated["ECG_Rate_Min"]) < np.array(ecg_eventrelated["ECG_Rate_Mean"]))

    assert np.alltrue(np.array(ecg_eventrelated["ECG_Rate_Mean"]) < np.array(ecg_eventrelated["ECG_Rate_Max"]))

    assert len(ecg_eventrelated["Label"]) == 3 
开发者ID:neuropsychology,项目名称:NeuroKit,代码行数:14,代码来源:tests_ecg.py

示例10: add_channels

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def add_channels(self, channels):
        if self.channels is None:
            self.channels = channels
        else:
            assert np.alltrue(channels == self.channels) 
开发者ID:MichaelHills,项目名称:seizure-prediction,代码行数:7,代码来源:mat_to_hdf5.py

示例11: test_nd

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_nd(self):
        y1 = [[0, 0, 1], [0, 1, 1], [1, 1, 1]]
        assert_(not np.all(y1))
        assert_array_equal(np.alltrue(y1, axis=0), [0, 0, 1])
        assert_array_equal(np.alltrue(y1, axis=1), [0, 0, 1]) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_function_base.py

示例12: fail_if_array_equal

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def fail_if_array_equal(x, y, err_msg='', verbose=True):
    """
    Raises an assertion error if two masked arrays are not equal elementwise.

    """
    def compare(x, y):
        return (not np.alltrue(approx(x, y)))
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
                         header='Arrays are not equal') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:11,代码来源:testutils.py

示例13: test_values

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_values(self):
        expected = np.array(list(self.makegen()))
        a = np.fromiter(self.makegen(), int)
        a20 = np.fromiter(self.makegen(), int, 20)
        assert_(np.alltrue(a == expected, axis=0))
        assert_(np.alltrue(a20 == expected[:20], axis=0)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_numeric.py

示例14: test_method_args

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_method_args(self):
        # Make sure methods and functions have same default axis
        # keyword and arguments
        funcs1 = ['argmax', 'argmin', 'sum', ('product', 'prod'),
                 ('sometrue', 'any'),
                 ('alltrue', 'all'), 'cumsum', ('cumproduct', 'cumprod'),
                 'ptp', 'cumprod', 'prod', 'std', 'var', 'mean',
                 'round', 'min', 'max', 'argsort', 'sort']
        funcs2 = ['compress', 'take', 'repeat']

        for func in funcs1:
            arr = np.random.rand(8, 7)
            arr2 = arr.copy()
            if isinstance(func, tuple):
                func_meth = func[1]
                func = func[0]
            else:
                func_meth = func
            res1 = getattr(arr, func_meth)()
            res2 = getattr(np, func)(arr2)
            if res1 is None:
                res1 = arr

            if res1.dtype.kind in 'uib':
                assert_((res1 == res2).all(), func)
            else:
                assert_(abs(res1-res2).max() < 1e-8, func)

        for func in funcs2:
            arr1 = np.random.rand(8, 7)
            arr2 = np.random.rand(8, 7)
            res1 = None
            if func == 'compress':
                arr1 = arr1.ravel()
                res1 = getattr(arr2, func)(arr1)
            else:
                arr2 = (15*arr2).astype(int).ravel()
            if res1 is None:
                res1 = getattr(arr1, func)(arr2)
            res2 = getattr(np, func)(arr1, arr2)
            assert_(abs(res1-res2).max() < 1e-8, func) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:43,代码来源:test_regression.py

示例15: test_fromiter_bytes

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import alltrue [as 别名]
def test_fromiter_bytes(self):
        # Ticket #1058
        a = np.fromiter(list(range(10)), dtype='b')
        b = np.fromiter(list(range(10)), dtype='B')
        assert_(np.alltrue(a == np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])))
        assert_(np.alltrue(b == np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_regression.py


注:本文中的numpy.alltrue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。