All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.improbable.keanu.tensor.validate.DebugTensorValidator Maven / Gradle / Ivy

package io.improbable.keanu.tensor.validate;

import io.improbable.keanu.tensor.Tensor;
import io.improbable.keanu.tensor.bool.BooleanTensor;

public class DebugTensorValidator> implements TensorValidator {
    private final TensorValidator delegate;
    private boolean debugMode = false;

    public DebugTensorValidator(TensorValidator delegate) {
        this.delegate = delegate;
    }

    @Override
    public TENSOR validate(TENSOR tensor) {
        if (debugMode) {
            return delegate.validate(tensor);
        } else {
            return tensor;
        }
    }

    @Override
    public BooleanTensor check(TENSOR tensor) {
        if (debugMode) {
            return delegate.check(tensor);
        } else {
            return BooleanTensor.trues(tensor.getShape());

        }
    }

    public void enable() {
        debugMode = true;
    }

    public void disable() {
        debugMode = false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy