<commit_before>/**
 * Copyright (c) 2014 European Organisation for Nuclear Research (CERN), All Rights Reserved.
 */

package org.tensorics.core.tensorbacked;

/**
 * Contains (public) utility methods for tensor backed objects.
 * 
 * @author kfuchsbe
 */
public final class Tensorbackeds {

    /**
     * Private constructor to avoid instantiation.
     */
    private Tensorbackeds() {
        /* Only static methods */
    }

    /**
     * Creates a new builder for the given tensor backed class. The builder will allow to add content to the tensor
     * backed object and construct it at the end. Only coordinates wich are compatible with the dimensions as annotated
     * in the tensor backed class are allowed.
     * 
     * @param tensorbackedClass the type of tensor backed object to be created.
     * @return a builder for the tensor backed object
     */
    public static <V, TB extends Tensorbacked<V>> TensorbackedBuilder<V, TB> builderFor(Class<TB> tensorbackedClass) {
        return new TensorbackedBuilder<>(tensorbackedClass);
    }

    /**
     * A convenience method to retrieve the size (number of entries) of a tensor backed object. This is nothing else
     * than a shortcut to the size of the underlaying tensor.
     * 
     * @param tensorbacked the tensor backed object for which to retrieve the size
     * @return the size (number of entries) of the object
     */
    public static <TB extends Tensorbacked<?>> int sizeOf(TB tensorbacked) {
        return tensorbacked.tensor().shape().size();
    }

    /**
     * A convenience method to retrieve the number of dimensions of a tensor backed object. This is a shortcut to
     * retrieving the dimensionality of the underlaying tensor of the tensor backed object.
     * 
     * @param tensorbacked the tensor backed object from which to retrieve the dimensions
     * @return the number of dimensions of the tensor backed object
     */
    public static <TB extends Tensorbacked<?>> int dimensionalityOf(TB tensorbacked) {
        return tensorbacked.tensor().shape().dimensionality();
    }

}<commit_msg>new methods to simplify tensorbacked createions<commit_after>/**
 * Copyright (c) 2014 European Organisation for Nuclear Research (CERN), All Rights Reserved.
 */

package org.tensorics.core.tensorbacked;

/**
 * Contains (public) utility methods for tensor backed objects.
 * 
 * @author kfuchsbe
 */
public final class Tensorbackeds {

    /**
     * Private constructor to avoid instantiation.
     */
    private Tensorbackeds() {
        /* Only static methods */
    }

    /**
     * Creates a new builder for the given tensor backed class. The builder will allow to add content to the tensor
     * backed object and construct it at the end. Only coordinates wich are compatible with the dimensions as annotated
     * in the tensor backed class are allowed.
     * 
     * @param tensorbackedClass the type of tensor backed object to be created.
     * @return a builder for the tensor backed object
     */
    public static <V, TB extends Tensorbacked<V>> TensorbackedBuilder<V, TB> builderFor(Class<TB> tensorbackedClass) {
        return new TensorbackedBuilder<>(tensorbackedClass);
    }

    /**
     * A convenience method to retrieve the size (number of entries) of a tensor backed object. This is nothing else
     * than a shortcut to the size of the underlaying tensor.
     * 
     * @param tensorbacked the tensor backed object for which to retrieve the size
     * @return the size (number of entries) of the object
     */
    public static <TB extends Tensorbacked<?>> int sizeOf(TB tensorbacked) {
        return tensorbacked.tensor().shape().size();
    }

    /**
     * A convenience method to retrieve the number of dimensions of a tensor backed object. This is a shortcut to
     * retrieving the dimensionality of the underlaying tensor of the tensor backed object.
     * 
     * @param tensorbacked the tensor backed object from which to retrieve the dimensions
     * @return the number of dimensions of the tensor backed object
     */
    public static <TB extends Tensorbacked<?>> int dimensionalityOf(TB tensorbacked) {
        return tensorbacked.tensor().shape().dimensionality();
    }

    /**
     * Creates a new empty instance of a tensorbacked class of the given type. This is simply a convenience method for
     * calling {@link TensorbackedBuilder#build()} on an empty builder.
     * 
     * @param tensorbackedClass the class of the tensor backed object to create
     * @return a new empty instance of the tensorbacked object.
     */
    public static <V, TB extends Tensorbacked<V>> TB empty(Class<TB> tensorbackedClass) {
        return builderFor(tensorbackedClass).build();
    }

    /*
     * TODO:<p> <ul> <li> singleton </ul>
     */

}
{'fraction_non_alphanumeric': 0.07527105921601335, 'fraction_numerical': 0.0016680567139282735, 'mean_word_length': 3.0209555741827328, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '826103', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1157, 'n_words': 546}