Page MenuHome

numpy.arctan2 returns wrong value with x<0 and y>0 in windows builds
Closed, ResolvedPublic

Description

System Information

Blender 2.77 (sub 0) System Information

Blender:

version: 2.77 (sub 0), branch: master, commit date: 2016-03-18 12:34, hash: 22a2853, type:
build date: Fri 03/18/2016, 04:16 PM
platform: Windows
binary path: 'C:\\Program Files\\Blender Foundation\\Blender\\blender-app.exe'
build cflags: /W3 /w34062 /wd4018 /wd4146 /wd4065 /wd4127 /wd4181 /wd4200 /wd4244 /wd4267 /wd4305 /wd4800 /we4013 /we4431 /DWIN32 /D_WINDOWS /W3 /nologo /J /Gd /MP /openmp
build cxxflags: /W3 /w34062 /wd4018 /wd4146 /wd4065 /wd4127 /wd4181 /wd4200 /wd4244 /wd4267 /wd4305 /wd4800 /we4013 /we4431 /DWIN32 /D_WINDOWS /W3 /GR /EHsc /nologo /J /Gd /MP /EHsc /openmp
build linkflags: /MACHINE:X64 /OPT:NOREF /SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib /ignore:4049 /ignore:4217 /ignore:4221
build system: CMake

Python:

version: 3.5.1 (default, Feb 17 2016, 17:09:19) [MSC v.1800 64 bit (AMD64)]
paths:
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\scripts\\addons_contrib'
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\scripts\\addons'
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\scripts\\startup'
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\scripts\\modules'
'C:\\Program Files\\Blender Foundation\\Blender\\python35.zip'
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\python\\DLLs'
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\python\\lib'
'C:\\Program Files\\Blender Foundation\\Blender'
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\python'
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\python\\lib\\site-packages'
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\scripts\\freestyle\\modules'
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\scripts\\addons\\modules'
'C:\\Users\\Tet Woo Lee\\AppData\\Roaming\\Blender Foundation\\Blender\\2.77\\scripts\\addons\\modules'

Python (External Binary):

binary path: 'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\python\\bin\\python.EXE'
version: Python 3.5.1

Directories:

scripts:
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\scripts\\modules'
'C:\\Program Files\\Blender Foundation\\Blender\\2.77\\scripts'
user scripts: 'C:\\Users\\Tet Woo Lee\\AppData\\Roaming\\Blender Foundation\\Blender\\2.77\\scripts'
pref scripts: None
datafiles: 'C:\\Users\\Tet Woo Lee\\AppData\\Roaming\\Blender Foundation\\Blender\\2.77\\datafiles\\'
config: 'C:\\Users\\Tet Woo Lee\\AppData\\Roaming\\Blender Foundation\\Blender\\2.77\\config\\'
scripts : 'C:\\Users\\Tet Woo Lee\\AppData\\Roaming\\Blender Foundation\\Blender\\2.77\\scripts\\'
autosave: 'C:\\Users\\Tet Woo Lee\\AppData\\Roaming\\Blender Foundation\\Blender\\2.77\\autosave\\'
tempdir: 'C:\\Users\\TETWOO~1\\AppData\\Local\\Temp\\blender_a15044\\'

FFmpeg:

avcodec: '55, 39, 101'
avdevice: '55, 5, 100'
avformat: '55, 19, 104'
avutil: '52, 48, 101'
swscale: ' 2, 5, 101'

SDL:

Version: 2.0.4
Loading method: linked (WITH_SDL_DYNLOAD=OFF)

Other Libraries:

OpenColorIO: 1, 0, 9
OpenImageIO: 1, 6, 9
OpenShadingLanguage: 1, 7, 1
OpenVDB: 3, 1, 0

OpenGL:

renderer: 'Intel(R) HD Graphics Family'
vendor: 'Intel'
version: '3.1.0 - Build 8.15.10.2993'
extensions:
GL_3DFX_texture_compression_FXT1
GL_ARB_color_buffer_float
GL_ARB_compatibility
GL_ARB_copy_buffer
GL_ARB_depth_buffer_float
GL_ARB_depth_clamp
GL_ARB_depth_texture
GL_ARB_draw_buffers
GL_ARB_draw_elements_base_vertex
GL_ARB_draw_instanced
GL_ARB_fragment_coord_conventions
GL_ARB_fragment_program
GL_ARB_fragment_program_shadow
GL_ARB_fragment_shader
GL_ARB_framebuffer_object
GL_ARB_framebuffer_sRGB
GL_ARB_half_float_pixel
GL_ARB_half_float_vertex
GL_ARB_map_buffer_range
GL_ARB_multisample
GL_ARB_multitexture
GL_ARB_occlusion_query
GL_ARB_pixel_buffer_object
GL_ARB_point_parameters
GL_ARB_point_sprite
GL_ARB_sampler_objects
GL_ARB_seamless_cube_map
GL_ARB_shader_objects
GL_ARB_shading_language_100
GL_ARB_shadow
GL_ARB_sync
GL_ARB_texture_border_clamp
GL_ARB_texture_compression
GL_ARB_texture_compression_rgtc
GL_ARB_texture_cube_map
GL_ARB_texture_env_add
GL_ARB_texture_env_combine
GL_ARB_texture_env_crossbar
GL_ARB_texture_env_dot3
GL_ARB_texture_float
GL_ARB_texture_non_power_of_two
GL_ARB_texture_rectangle
GL_ARB_texture_rg
GL_ARB_transpose_matrix
GL_ARB_uniform_buffer_object
GL_ARB_vertex_array_bgra
GL_ARB_vertex_array_object
GL_ARB_vertex_buffer_object
GL_ARB_vertex_program
GL_ARB_vertex_shader
GL_ARB_window_pos
GL_ATI_separate_stencil
GL_EXT_abgr
GL_EXT_bgra
GL_EXT_blend_color
GL_EXT_blend_equation_separate
GL_EXT_blend_func_separate
GL_EXT_blend_minmax
GL_EXT_blend_subtract
GL_EXT_clip_volume_hint
GL_EXT_compiled_vertex_array
GL_EXT_draw_buffers2
GL_EXT_draw_range_elements
GL_EXT_fog_coord
GL_EXT_framebuffer_blit
GL_EXT_framebuffer_multisample
GL_EXT_framebuffer_object
GL_EXT_gpu_program_parameters
GL_EXT_multi_draw_arrays
GL_EXT_packed_depth_stencil
GL_EXT_packed_float
GL_EXT_packed_pixels
GL_EXT_rescale_normal
GL_EXT_secondary_color
GL_EXT_separate_specular_color
GL_EXT_shadow_funcs
GL_EXT_stencil_two_side
GL_EXT_stencil_wrap
GL_EXT_texture3D
GL_EXT_texture_array
GL_EXT_texture_compression_s3tc
GL_EXT_texture_edge_clamp
GL_EXT_texture_env_add
GL_EXT_texture_env_combine
GL_EXT_texture_filter_anisotropic
GL_EXT_texture_integer
GL_EXT_texture_lod_bias
GL_EXT_texture_rectangle
GL_EXT_texture_sRGB
GL_EXT_texture_shared_exponent
GL_EXT_texture_snorm
GL_EXT_texture_swizzle
GL_EXT_transform_feedback
GL_IBM_texture_mirrored_repeat
GL_INTEL_performance_queries
GL_NV_blend_square
GL_NV_conditional_render
GL_NV_primitive_restart
GL_NV_texgen_reflection
GL_SGIS_generate_mipmap
GL_SGIS_texture_edge_clamp
GL_SGIS_texture_lod
GL_WIN_swap_hint

Implementation Dependent OpenGL Limits:

Maximum Fixed Function Texture Units: 8
Maximum DrawElements Vertices: 1200
Maximum DrawElements Indices: 1200

GLSL:
Maximum Varying Floats: 41
Maximum Vertex Attributes: 16
Maximum Vertex Uniform Components: 512
Maximum Fragment Uniform Components: 1024
Maximum Vertex Image Units: 16
Maximum Fragment Image Units: 16
Maximum Pipeline Image Units: 16

Cycles:

CPU device capabilities: SSE2 SSE3 SSE41 AVX

OpenCL device capabilities:
Number of platforms: 1
Platform #0
Platform Name: AMD Accelerated Parallel Processing
Platform Vendor: Advanced Micro Devices, Inc.
Platform Version: OpenCL 1.2 AMD-APP (1445.5)
Platform Profile: FULL_PROFILE
Platform Extensions: cl_khr_icd cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_khr_dx9_media_sharing cl_amd_event_callback cl_amd_offline_devices cl_amd_hsa
Number of devices: 1

		Device: #0
			Device Name:       Intel(R) Core(TM) i7-2720QM CPU @ 2.20GHz
			Device Vendor: GenuineIntel
			Device OpenCL C Version: OpenCL C 1.2 
			Device Profile: FULL_PROFILE
			Device Version: OpenCL 1.2 AMD-APP (1445.5)
			Device Extensions: cl_khr_fp64 cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_gl_sharing cl_ext_device_fission cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf cl_amd_media_ops cl_amd_media_ops2 cl_amd_popcnt cl_khr_d3d10_sharing cl_khr_spir cl_amd_svm cl_khr_gl_event

Blender Version
Broken: 2.76b, 2.77
Worked: (optional)

Short description of error
The numpy library supplied with Blender/python returns the value with x<0 and y>0. e.g. numpy.arctan2(+1,-1) should return +135 degrees, but instead returns -135 degrees

Exact steps for others to reproduce the error
Run the following commands in the Python console:

import numpy as np
x = np.array([-1, +1, +1, -1])
y = np.array([-1, -1, +1, +1])
np.arctan2(y, x) * 180 / np.pi

Excerpt from http://docs.scipy.org/doc/numpy-1.9.1/reference/generated/numpy.arctan2.html indicates correct result should be array([-135., -45., 45., 135.]):
`>>> x = np.array([-1, +1, +1, -1])

y = np.array([-1, -1, +1, +1])
np.arctan2(y, x) * 180 / np.pi

array([-135., -45., 45., 135.])`
Result with Blender 2.76b:
`PYTHON INTERACTIVE CONSOLE 3.4.2 (default, Dec 7 2014, 18:21:18) [MSC v.1800 64 bit (AMD64)]

Command History: Up/Down Arrow
Cursor: Left/Right Home/End
Remove: Backspace/Delete
Execute: Enter
Autocomplete: Ctrl-Space
Zoom: Ctrl +/-, Ctrl-Wheel
Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils
Convenience Imports: from mathutils import *; from math import *
Convenience Variables: C = bpy.context, D = bpy.data

import numpy as np
np.version.version

'1.9.1'

x = np.array([-1, +1, +1, -1])
y = np.array([-1, -1, +1, +1])
np.arctan2(y, x) * 180 / np.pi

array([-135., -45., 45., -135.])`
Result with Blender 2.77:
`PYTHON INTERACTIVE CONSOLE 3.5.1 (default, Feb 17 2016, 17:09:19) [MSC v.1800 64 bit (AMD64)]

Command History: Up/Down Arrow
Cursor: Left/Right Home/End
Remove: Backspace/Delete
Execute: Enter
Autocomplete: Ctrl-Space
Zoom: Ctrl +/-, Ctrl-Wheel
Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils
Convenience Imports: from mathutils import *; from math import *
Convenience Variables: C = bpy.context, D = bpy.data

import numpy as np
np.version.version

'1.9.1'

x = np.array([-1, +1, +1, -1])
y = np.array([-1, -1, +1, +1])
np.arctan2(y, x) * 180 / np.pi

array([-135., -45., 45., -135.])`

Details

Type
Bug

Event Timeline

T Lee (moofromnz) raised the priority of this task from to Needs Triage by Developer.
T Lee (moofromnz) updated the task description. (Show Details)
T Lee (moofromnz) added a project: BF Blender.
T Lee (moofromnz) set Type to Bug.
Bastien Montagne (mont29) lowered the priority of this task from Needs Triage by Developer to Needs Information from User.Mar 25 2016, 2:12 PM

Please do not paste walls of text like that directly in reports/comments, such reports must be attached as text files instead.

And this totally sounds like numpy bug, did you check if a more recent version still has it or not? Only thing we could do here is updating the lib…

T Lee (moofromnz) added a comment.EditedMar 25 2016, 3:06 PM

Yes, this is definitely only to do with numpy.

I've tested it with numpy+mkl 1.10.4 on Python 2.7.10 and the bug does not exist.

I could find no trace of this bug in the numpy issue tracker, so it may be related to the particular build of the numpy library used with Blender rather than the version of numpy.

In any case, updating the lib is the solution I had in mine.

Bastien Montagne (mont29) raised the priority of this task from Needs Information from User to Normal.Mar 25 2016, 5:54 PM

We are on numpy 1.9 afaik currently… Also, cannot, reproduce the issue on linux build (neither official 2.77 nor own build using debian's numpy).

@Martijn Berger (juicyfruit), this one sounds for you?

Bastien Montagne (mont29) renamed this task from numpy.arctan2 returns wrong value with x<0 and y>0 to numpy.arctan2 returns wrong value with x<0 and y>0 in windows builds.Mar 25 2016, 5:55 PM
LazyDodo (LazyDodo) closed this task as Resolved.Dec 7 2016, 3:31 AM

Fixed in last weekends lib upgrade.