本文整理汇总了Python中numpy.fmod方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.fmod方法的具体用法?Python numpy.fmod怎么用?Python numpy.fmod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块numpy的用法示例。

在下文中一共展示了numpy.fmod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_NotImplemented_not_returned

点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def test_NotImplemented_not_returned(self):

# See gh-5964 and gh-2091. Some of these functions are not operator

# related and were fixed for other reasons in the past.

binary_funcs = [

np.power, np.add, np.subtract, np.multiply, np.divide,

np.true_divide, np.floor_divide, np.bitwise_and, np.bitwise_or,

np.bitwise_xor, np.left_shift, np.right_shift, np.fmax,

np.fmin, np.fmod, np.hypot, np.logaddexp, np.logaddexp2,

np.logical_and, np.logical_or, np.logical_xor, np.maximum,

np.minimum, np.mod,

np.greater, np.greater_equal, np.less, np.less_equal,

np.equal, np.not_equal]

a = np.array('1')

b = 1

c = np.array([1., 2.])

for f in binary_funcs:

assert_raises(TypeError, f, a, b)

assert_raises(TypeError, f, c, a)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,

示例2: test_NotImplemented_not_returned

点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def test_NotImplemented_not_returned(self):

# See gh-5964 and gh-2091. Some of these functions are not operator

# related and were fixed for other reasons in the past.

binary_funcs = [

np.power, np.add, np.subtract, np.multiply, np.divide,

np.true_divide, np.floor_divide, np.bitwise_and, np.bitwise_or,

np.bitwise_xor, np.left_shift, np.right_shift, np.fmax,

np.fmin, np.fmod, np.hypot, np.logaddexp, np.logaddexp2,

np.logical_and, np.logical_or, np.logical_xor, np.maximum,

np.minimum, np.mod

]

# These functions still return NotImplemented. Will be fixed in

# future.

# bad = [np.greater, np.greater_equal, np.less, np.less_equal, np.not_equal]

a = np.array('1')

b = 1

for f in binary_funcs:

assert_raises(TypeError, f, a, b)

开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:22,

示例3: test_vectorized_intrin2

点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def test_vectorized_intrin2(dtype="float32"):

c2 = tvm.tir.const(2, dtype=dtype)

test_funcs = [

(tvm.tir.power, lambda x : np.power(x, 2.0)),

(tvm.tir.fmod, lambda x : np.fmod(x, 2.0))

]

def run_test(tvm_intrin, np_func):

if not tvm.gpu(0).exist or not tvm.runtime.enabled("cuda"):

print("skip because cuda is not enabled..")

return

n = 128

A = te.placeholder((n,), dtype=dtype, name='A')

B = te.compute((n,), lambda i: tvm_intrin(A[i], c2), name='B')

s = sched(B)

f = tvm.build(s, [A, B], "cuda")

ctx = tvm.gpu(0)

a = tvm.nd.array(np.random.uniform(0, 1, size=n).astype(A.dtype), ctx)

b = tvm.nd.array(np.zeros(shape=(n,)).astype(A.dtype), ctx)

f(a, b)

tvm.testing.assert_allclose(b.asnumpy(), np_func(a.asnumpy()), atol=1e-3, rtol=1e-3)

for func in test_funcs:

run_test(*func)

开发者ID:apache,项目名称:incubator-tvm,代码行数:26,

示例4: test_mod

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def test_mod(self):

if legacy_opset_pre_ver(10):

raise unittest.SkipTest("ONNX version {} doesn't support Mod.".format(

defs.onnx_opset_version()))

x = self._get_rnd_float32(shape=[5, 5])

y = self._get_rnd_float32(shape=[5, 5])

node_def = helper.make_node("Mod", ["X", "Y"], ["Z"], fmod=0)

output = run_node(node_def, [x, y])

np.testing.assert_almost_equal(output["Z"], np.mod(x, y))

node_def = helper.make_node("Mod", ["X", "Y"], ["Z"], fmod=1)

output = run_node(node_def, [x, y])

np.testing.assert_almost_equal(output["Z"], np.fmod(x, y))

开发者ID:onnx,项目名称:onnx-tensorflow,代码行数:14,

示例5: __setattr__

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def __setattr__(self, key, value):

"""Set attributes with conversion to ndarray where needed."""

is_set = hasattr(self, key) # == False in constructor

# parameter canonicalization and some validation via reshaping

if value is None:

# TODO: maybe forbid for some fields

pass

elif key == 'translation':

value = np.array(value, dtype=np.float32).reshape(3, 1)

elif key == 'rotation':

value = np.array(value, dtype=np.float32).reshape(4)

value[0] = np.fmod(value[0], 2.0 * np.pi)

if value[0] < 0.0:

value[0] += 2.0 * np.pi

value[0] = np.cos(value[0] / 2)

norm = np.linalg.norm(value[1:4])

needed_norm = np.sqrt(1 - value[0] * value[0])

if abs(norm - needed_norm) > _epsilon:

if norm < _epsilon:

raise ValueError('Norm of (x, y, z) part of quaternion too close to zero')

value[1:4] = value[1:4] / norm * needed_norm

# assert abs(np.linalg.norm(value) - 1.0) < _epsilon

elif key == 'scaling':

value = np.array(value, dtype=np.float32).reshape(3)

elif key in ['parent_matrix', 'custom_matrix', 'model_matrix']:

value = np.array(value, dtype=np.float32).reshape((4, 4))

super(Transform, self).__setattr__(key, value)

if is_set and key != 'model_matrix':

self._recompute_matrix()

self._notify_dependants()

开发者ID:K3D-tools,项目名称:K3D-jupyter,代码行数:38,

示例6: __init__

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def __init__(self, input_grid, pitch, apodization, orientation=0, even_grid=False):

'''An even asphere micro-lens array.

Parameters

----------

input_grid : Grid

The grid on which the periodic optical element is evaluated.

pitch : scalar

The pitch of the periodic optical element.

apodization : Apodizer

The apodizer that will be evaluated on the periodic grid.

orientation : scalar

The orientation of the periodic optical element.

even_grid : bool

This determines whether zero is in between two elements or if it is the center of an element.

'''

self.input_grid = input_grid.copy()

self.input_grid = self.input_grid.rotated(orientation)

if even_grid:

xf = (np.fmod(abs(self.input_grid.x), pitch) - pitch / 2) * np.sign(self.input_grid.x)

yf = (np.fmod(abs(self.input_grid.y), pitch) - pitch / 2) * np.sign(self.input_grid.y)

else:

xf = (np.fmod(abs(self.input_grid.x) + pitch / 2, pitch) - pitch / 2) * np.sign(self.input_grid.x)

yf = (np.fmod(abs(self.input_grid.y) + pitch / 2, pitch) - pitch / 2) * np.sign(self.input_grid.y)

periodic_grid = CartesianGrid(UnstructuredCoords((xf, yf)))

self.apodization = apodization(periodic_grid)

开发者ID:ehpor,项目名称:hcipy,代码行数:30,

示例7: forward

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def forward(self, inputs, device):

x, divisor = inputs

y = functions.fmod(x, divisor)

return y,

开发者ID:chainer,项目名称:chainer,代码行数:6,

示例8: forward_expected

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def forward_expected(self, inputs):

x, divisor = inputs

expected = numpy.fmod(x, divisor)

expected = numpy.asarray(expected)

return expected,

开发者ID:chainer,项目名称:chainer,代码行数:7,

示例9: testFloat

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def testFloat(self):

x = [0.5, 0.7, 0.3]

for dtype in [np.float32, np.double]:

# Test scalar and vector versions.

for denom in [x[0], [x[0]] * 3]:

x_np = np.array(x, dtype=dtype)

with self.test_session(use_gpu=True):

x_tf = constant_op.constant(x_np, shape=x_np.shape)

y_tf = math_ops.mod(x_tf, denom)

y_tf_np = y_tf.eval()

y_np = np.fmod(x_np, denom)

self.assertAllClose(y_tf_np, y_np, atol=1e-2)

开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:14,

示例10: testTruncateModInt

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def testTruncateModInt(self):

nums, divs = self.intTestData()

with self.test_session():

tf_result = math_ops.truncatemod(nums, divs).eval()

np_result = np.fmod(nums, divs)

self.assertAllEqual(tf_result, np_result)

开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:8,

示例11: testTruncateModFloat

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def testTruncateModFloat(self):

nums, divs = self.floatTestData()

with self.test_session():

tf_result = math_ops.truncatemod(nums, divs).eval()

np_result = np.fmod(nums, divs)

self.assertAllEqual(tf_result, np_result)

开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:8,

示例12: wrap_180

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def wrap_180(self, angle):

if (angle > 3*np.pi or angle < -3*np.pi):

angle = np.fmod(angle,2*np.pi)

if (angle > np.pi):

angle = angle - 2*np.pi

if (angle < - np.pi):

angle = angle + 2*np.pi

return angle;

开发者ID:purdue-biorobotics,项目名称:flappy,代码行数:10,

示例13: _periodic_boundary

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def _periodic_boundary(self,x,bound):

return np.fmod(x,bound)-np.trunc(x/bound)*bound

开发者ID:qkitgroup,项目名称:qkit,代码行数:4,

示例14: myProj

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def myProj(x):

angle = torch.norm(x, 2, 1, True)

axis = F.normalize(x)

angle = torch.fmod(angle, 2*np.pi)

return angle*axis

# my model for pose estimation: feature model + 1layer pose model x 12

开发者ID:JHUVisionLab,项目名称:multi-modal-regression,代码行数:10,

示例15: test_fmod

点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import fmod [as 别名]

def test_fmod(self):

A, A_rdd = self.make_dense_rdd((8, 3))

B, B_rdd = self.make_dense_rdd((1, 3))

np_res = np.fmod(A, B)

assert_array_equal(

A_rdd.fmod(B).toarray(), np_res

)

开发者ID:lensacom,项目名称:sparkit-learn,代码行数:9,

注:本文中的numpy.fmod方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

fmod函数python_python fmod函数_Python numpy.fmod方法代码示例相关推荐

  1. python iteritems函数_Python six.iteritems方法代码示例

    本文整理汇总了Python中sklearn.externals.six.iteritems方法的典型用法代码示例.如果您正苦于以下问题:Python six.iteritems方法的具体用法?Pyth ...

  2. python label函数_Python pyplot.clabel方法代码示例

    本文整理汇总了Python中matplotlib.pyplot.clabel方法的典型用法代码示例.如果您正苦于以下问题:Python pyplot.clabel方法的具体用法?Python pypl ...

  3. python中config命令_Python config.config方法代码示例

    本文整理汇总了Python中config.config方法的典型用法代码示例.如果您正苦于以下问题:Python config.config方法的具体用法?Python config.config怎么 ...

  4. doc python 颜色_Python wordcloud.ImageColorGenerator方法代码示例

    本文整理汇总了Python中wordcloud.ImageColorGenerator方法的典型用法代码示例.如果您正苦于以下问题:Python wordcloud.ImageColorGenerat ...

  5. pythoninterp error_Python numpy.interp方法代码示例

    本文整理汇总了Python中numpy.interp方法的典型用法代码示例.如果您正苦于以下问题:Python numpy.interp方法的具体用法?Python numpy.interp怎么用?P ...

  6. scipy库 signal 导入_Python scipy.signal方法代码示例

    本文整理汇总了Python中scipy.signal方法的典型用法代码示例.如果您正苦于以下问题:Python scipy.signal方法的具体用法?Python scipy.signal怎么用?P ...

  7. python中np zeros_Python numpy.zeros方法代码示例

    本文整理汇总了Python中numpy.zeros方法的典型用法代码示例.如果您正苦于以下问题:Python numpy.zeros方法的具体用法?Python numpy.zeros怎么用?Pyth ...

  8. python 求 gamma 分布_Python stats.gamma方法代码示例

    本文整理汇总了Python中scipy.stats.gamma方法的典型用法代码示例.如果您正苦于以下问题:Python stats.gamma方法的具体用法?Python stats.gamma怎么 ...

  9. python安装mlab库_Python mlab.normpdf方法代码示例

    本文整理汇总了Python中matplotlib.mlab.normpdf方法的典型用法代码示例.如果您正苦于以下问题:Python mlab.normpdf方法的具体用法?Python mlab.n ...

  10. python fsolve说明_Python optimize.fsolve方法代码示例

    本文整理汇总了Python中scipy.optimize.fsolve方法的典型用法代码示例.如果您正苦于以下问题:Python optimize.fsolve方法的具体用法?Python optim ...

最新文章

  1. 全球第三位艾滋病痊愈者出现,靠脐带血干细胞新疗法抵抗病毒,此前已患病9年...
  2. 求一个指定点对的路径上的最大边权或最小边权(转)
  3. 循环中 动态参数 传div 层_【转载】黄学杰等:铌元素在锂离子电池中的应用
  4. 用Python爬一爬那些年你硬盘存过的老师
  5. (day 21 - 辅助栈加模拟)剑指 Offer 31. 栈的压入、弹出序列
  6. 计算机图形学完整笔记(六):三维图形变换
  7. h5页面自定义字体_H5页面字体设置
  8. csdn积分c币获取方法
  9. 开源漫画服务器Mango
  10. mac版百度网盘客户端
  11. 三维扫描仪用于无人机壳体扫描与精密装配
  12. OA系统项目实施的难点和解决办法
  13. 彩色空间HSV|RGB|灰度图的理解与OpenCV中的转换【DataWhale琐碎知识点】
  14. python3文件的编码类型是_Python3.x环境创建Python脚本文件时,需要将文件编码格式设置为...
  15. 第六章、面向对象基础--中(续)构造器、this、包、eclipse的使用
  16. 蓝桥杯,我劝你不要参加的8个完美理由
  17. 程序员人人都会遇到的“画饼”,一招教你破解
  18. Mac上好用的连接服务器的工具(Termius)
  19. 边缘发光材质unity_Unity Shader Graph 小功能实现(一)边缘发光
  20. dwcs5这么写php,如何备份Dreamweaver CS5的人个设置信息

热门文章

  1. 绍兴一中模拟赛3.19——时光流转
  2. 译(五十一)-Pytorch的unsqueeze有什么用
  3. 中小型网站站长需要怎样的广告联盟
  4. 一文搞懂图的存储与遍历
  5. helm 的 values.yaml 配置语法说明
  6. 中等收入群体疲于应付生活压力 透支半生财富
  7. Linux虚拟机安装gcc(解决依赖)
  8. 身份证,联系电话,邮箱,网址,邮编,传真号码,MSN,国籍和身份证,QQ和电话校验
  9. 【JDBC技术】终于知道Java底层是如何连接数据库了!——(1)JDBC概述
  10. 6岁男童乞讨养残疾父亲 遭商家空头支票(图)