CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
test_weight_vector.py26 linesDownload Raw Back to tests
1import numpy as np
2import pytest
3
4from sklearn.utils._weight_vector import (
5    WeightVector32,
6    WeightVector64,
7)
8
9
10@pytest.mark.parametrize(
11    "dtype, WeightVector",
12    [
13        (np.float32, WeightVector32),
14        (np.float64, WeightVector64),
15    ],
16)
17def test_type_invariance(dtype, WeightVector):
18    """Check the `dtype` consistency of `WeightVector`."""
19    weights = np.random.rand(100).astype(dtype)
20    average_weights = np.random.rand(100).astype(dtype)
21
22    weight_vector = WeightVector(weights, average_weights)
23
24    assert np.asarray(weight_vector.w).dtype is np.dtype(dtype)
25    assert np.asarray(weight_vector.aw).dtype is np.dtype(dtype)
26 
Aluode/PerceptionLabPortable · CoolFace