     public func index(before i: Int) -> Int {
         return i - 1
     }
-
 }
 
 public extension Tensor {
-
     public func reshaped(as newShape: TensorShape) -> Tensor? {
         guard self.shape.contiguousSize == newShape.contiguousSize else {
             return nil
         }
         return Tensor(shape: newShape, units: units)
     }
-
 }
 
 public extension Tensor {
-
     func withUnsafeBufferPointer<Result>
         (_ body: (UnsafeBufferPointer<UnitType>) throws -> Result) rethrows -> Result {
         return try units.withUnsafeBufferPointer { ptr in

            try body(&ptr)
        }
    }

}

extension Tensor : TextOutputStreamable {
    public func write<Target>(to target: inout Target) where Target : TextOutputStream {
        target.write(
            isScalar ?
                String(describing: units[0])
                     : "[\(map {"\($0)"}.joined(separator: ", "))]"
        )
    }
}

    public func unitsEqual(_ other: Tensor<UnitType>) -> Bool {
        return units.elementsEqual(other.units)
    }
}

public extension TensorProtocol {
    public func isSimilar(to other: Self) -> Bool {
        return shape ~ other.shape
    }
