Here are the examples of the python api numpy.find_common_type taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : matfuncs.py
Copyright MIT License
Author : luckystarufo
Copyright MIT License
Author : luckystarufo
def __init__(self, *args, **kwargs):
self._structure = kwargs.get('structure', None)
for A in args:
if len(A.shape) != 2 or A.shape[0] != A.shape[1]:
raise ValueError(
'For now, the ProductOperator implementation is '
'limited to the product of multiple square matrices.')
if args:
n = args[0].shape[0]
for A in args:
for d in A.shape:
if d != n:
raise ValueError(
'The square matrices of the ProductOperator '
'must all have the same shape.')
self.shape = (n, n)
self.ndim = len(self.shape)
self.dtype = np.find_common_type([x.dtype for x in args], [])
self._operator_sequence = args
3
View Complete Implementation : matfuncs.py
Copyright MIT License
Author : alvarob96
Copyright MIT License
Author : alvarob96
def __init__(self, *args, **kwargs):
self._structure = kwargs.get('structure', None)
for A in args:
if len(A.shape) != 2 or A.shape[0] != A.shape[1]:
raise ValueError(
'For now, the ProductOperator implementation is '
'limited to the product of multiple square matrices.')
if args:
n = args[0].shape[0]
for A in args:
for d in A.shape:
if d != n:
raise ValueError(
'The square matrices of the ProductOperator '
'must all have the same shape.')
self.shape = (n, n)
self.ndim = len(self.shape)
self.dtype = np.find_common_type([x.dtype for x in args], [])
self._operator_sequence = args
3
View Complete Implementation : matfuncs.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def __init__(self, *args, **kwargs):
self._structure = kwargs.get('structure', None)
for A in args:
if len(A.shape) != 2 or A.shape[0] != A.shape[1]:
raise ValueError(
'For now, the ProductOperator implementation is '
'limited to the product of multiple square matrices.')
if args:
n = args[0].shape[0]
for A in args:
for d in A.shape:
if d != n:
raise ValueError(
'The square matrices of the ProductOperator '
'must all have the same shape.')
self.shape = (n, n)
self.ndim = len(self.shape)
self.dtype = np.find_common_type([x.dtype for x in args], [])
self._operator_sequence = args
3
View Complete Implementation : matfuncs.py
Copyright MIT License
Author : Relph1119
Copyright MIT License
Author : Relph1119
def __init__(self, *args, **kwargs):
self._structure = kwargs.get('structure', None)
for A in args:
if len(A.shape) != 2 or A.shape[0] != A.shape[1]:
raise ValueError(
'For now, the ProductOperator implementation is '
'limited to the product of multiple square matrices.')
if args:
n = args[0].shape[0]
for A in args:
for d in A.shape:
if d != n:
raise ValueError(
'The square matrices of the ProductOperator '
'must all have the same shape.')
self.shape = (n, n)
self.ndim = len(self.shape)
self.dtype = np.find_common_type([x.dtype for x in args], [])
self._operator_sequence = args
3
View Complete Implementation : matmul.py
Copyright MIT License
Author : cemoody
Copyright MIT License
Author : cemoody
def forward_cpu(self, x):
a, b = x
batch_size = a.shape[0]
shape = self._output_shape(a, b)
ret_dtype = numpy.find_common_type([a.dtype, b.dtype], [])
ret = numpy.empty(shape, dtype=ret_dtype)
for i in six.moves.range(batch_size):
ret[i] = _matmul(
a[i], b[i], transa=self.transa, transb=self.transb)
return ret,
3
View Complete Implementation : interface.py
Copyright MIT License
Author : luckystarufo
Copyright MIT License
Author : luckystarufo
def _get_dtype(operators, dtypes=None):
if dtypes is None:
dtypes = []
for obj in operators:
if obj is not None and hasattr(obj, 'dtype'):
dtypes.append(obj.dtype)
return np.find_common_type(dtypes, [])
3
View Complete Implementation : interface.py
Copyright MIT License
Author : Relph1119
Copyright MIT License
Author : Relph1119
def _get_dtype(operators, dtypes=None):
if dtypes is None:
dtypes = []
for obj in operators:
if obj is not None and hasattr(obj, 'dtype'):
dtypes.append(obj.dtype)
return np.find_common_type(dtypes, [])
3
View Complete Implementation : interface.py
Copyright MIT License
Author : alvarob96
Copyright MIT License
Author : alvarob96
def _get_dtype(operators, dtypes=None):
if dtypes is None:
dtypes = []
for obj in operators:
if obj is not None and hasattr(obj, 'dtype'):
dtypes.append(obj.dtype)
return np.find_common_type(dtypes, [])
3
View Complete Implementation : interface.py
Copyright MIT License
Author : jgagneastro
Copyright MIT License
Author : jgagneastro
def _get_dtype(operators, dtypes=None):
if dtypes is None:
dtypes = []
for obj in operators:
if obj is not None and hasattr(obj, 'dtype'):
dtypes.append(obj.dtype)
return np.find_common_type(dtypes, [])
0
View Complete Implementation : test_numerictypes.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def test_scalar_wins3(self): # doesn't go up to 'f16' on purpose
res = np.find_common_type(['u8', 'i8', 'i8'], ['f8'])
astert_(res == 'f8')