1762cd0d2a62f55693774d655b0ae367008d7e2d,brian2/units/fundamentalunits.py,Quantity,prod,#Quantity#,1149

Before Change


        if not self.is_dimensionless():
            raise NotImplementedError("Product over array elements on quantities "
                                    "with dimensions is not implemented.")
        return Quantity(np.asarray(self).prod(*args, **kwds))

    def cumprod(self, *args, **kwds):
        if not self.is_dimensionless():
            raise NotImplementedError("Product over array elements on quantities "

After Change


    searchsorted.__doc__ = np.ndarray.searchsorted.__doc__

    def prod(self, *args, **kwds):
        prod_result = super(Quantity, self).prod(*args, **kwds)
        // Calculating the correct dimensions is not completly trivial (e.g.
        // like doing self.dim**self.size) because prod can be called on
        // multidimensional arrays along a certain axis. 
        // Our solution: Use a "dummy matrix" containing a 1 (without units) at
        // each entry and sum it, using the same keyword arguments as provided.
        // The result gives the exponent for the dimensions.
        // This relies on sum and prod having the same arguments, which is true
        // now and probably remains like this in the future 
        dim_exponent = np.ones_like(self).sum(*args, **kwds)
        // The result is possibly multidimensional but all entries should be
        // identical
        if dim_exponent.size > 1:
            dim_exponent = dim_exponent[0]
        return Quantity.with_dimensions(prod_result, self.dim ** dim_exponent)
    prod.__doc__ = np.ndarray.prod.__doc__        

    def cumprod(self, *args, **kwds):
        if not self.is_dimensionless():
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: brian-team/brian2
Commit Name: 1762cd0d2a62f55693774d655b0ae367008d7e2d
Time: 2012-09-12
Author: marcel.stimberg@ens.fr
File Name: brian2/units/fundamentalunits.py
Class Name: Quantity
Method Name: prod


Project Name: brian-team/brian2
Commit Name: 9ca7138d7ca7a43a56728017501c72f6f2095393
Time: 2016-03-09
Author: marcel.stimberg@inserm.fr
File Name: brian2/units/fundamentalunits.py
Class Name: Quantity
Method Name: _binary_operation


Project Name: brian-team/brian2
Commit Name: 4fc2fed2a6e3da28de4d77b4e3917952a0dfa562
Time: 2013-08-12
Author: marcel.stimberg@ens.fr
File Name: brian2/core/variables.py
Class Name: VariableView
Method Name: __repr__