Пример #1
0
        {"label": 1},
        {"label": 2},
        {"label": 0},
        {"label": 0},
        {"label": 0},
    ]
    assert ds[1].compute(label_name=True) == {"label": "blue"}
    assert ds[1].compute() == {"label": 2}
    assert ds[1:3].compute(label_name=True).tolist() == [
        {"label": "blue"},
        {"label": "red"},
    ]
    assert ds[1:3].compute().tolist() == [{"label": 2}, {"label": 0}]


@pytest.mark.skipif(not minio_creds_exist(), reason="requires minio credentials")
def test_minio_endpoint():
    token = {
        "aws_access_key_id": os.getenv("ACTIVELOOP_MINIO_KEY"),
        "aws_secret_access_key": os.getenv("ACTIVELOOP_MINIO_SECRET_ACCESS_KEY"),
        "endpoint_url": "https://play.min.io:9000",
        "region": "us-east-1",
    }

    schema = {"abc": Tensor((100, 100, 3))}
    ds = Dataset(
        "s3://bucket/random_dataset", token=token, shape=(10,), schema=schema, mode="w"
    )

    for i in range(10):
        ds["abc", i] = i * np.ones((100, 100, 3))
Пример #2
0
        assert isinstance(ex, ClassLabelValueError)
    try:
        ds[0:4]["label/b"] = np.array([0, 1, 2, 3, 7])
    except Exception as ex:
        assert isinstance(ex, ClassLabelValueError)
    try:
        ds["label", 4] = "name4"
    except Exception as ex:
        assert isinstance(ex, ClassLabelValueError)
    try:
        ds[0]["label/b"] = ["name"]
    except Exception as ex:
        assert isinstance(ex, ValueError)


@pytest.mark.skipif(not minio_creds_exist(),
                    reason="requires minio credentials")
def test_minio_endpoint():
    token = {
        "aws_access_key_id": os.getenv("ACTIVELOOP_MINIO_KEY"),
        "aws_secret_access_key":
        os.getenv("ACTIVELOOP_MINIO_SECRET_ACCESS_KEY"),
        "endpoint_url": "https://play.min.io:9000",
        "region": "us-east-1",
    }

    schema = {"abc": Tensor((100, 100, 3))}
    ds = Dataset("s3://bucket/random_dataset",
                 token=token,
                 shape=(10, ),
                 schema=schema,