Move conformance tests to per-version directories

Conformance tests now live in conformance/<version>/*.py and are checked
against the corresponding stubs in dist/<version>/. Auto-detection only
runs versions that have both stubs and test files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-27 15:17:01 +01:00
co-authored by Claude Opus 4.6
parent 441631d69a
commit 8879d14073
8 changed files with 17 additions and 8 deletions
@@ -0,0 +1,37 @@
import bpy
import gpu
from gpu_extras.batch import batch_for_shader
def test_1():
coords = [(1, 1, 1), (-2, 0, 0), (-2, -1, 3), (0, 1, 1)]
shader = gpu.shader.from_builtin("POINT_UNIFORM_COLOR")
batch = batch_for_shader(shader, "POINTS", {"pos": coords})
def draw():
shader.uniform_float("color", (1, 1, 0, 1))
gpu.state.point_size_set(4.5)
batch.draw(shader)
bpy.types.SpaceView3D.draw_handler_add(draw, (), "WINDOW", "POST_VIEW")
"""
3D Lines with Single Color
--------------------------
"""
def test_2():
coords = [(1, 1, 1), (-2, 0, 0), (-2, -1, 3), (0, 1, 1)]
shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
batch = batch_for_shader(shader, "LINES", {"pos": coords})
def draw():
shader.uniform_float("viewportSize", gpu.state.viewport_get()[2:])
shader.uniform_float("lineWidth", 4.5)
shader.uniform_float("color", (1, 1, 0, 1))
batch.draw(shader)
bpy.types.SpaceView3D.draw_handler_add(draw, (), "WINDOW", "POST_VIEW")
@@ -0,0 +1,42 @@
import bpy
import gpu
from gpu_extras.batch import batch_for_shader
vert_out = gpu.types.GPUStageInterfaceInfo("my_interface")
vert_out.smooth("VEC3", "pos")
shader_info = gpu.types.GPUShaderCreateInfo()
shader_info.push_constant("MAT4", "viewProjectionMatrix")
shader_info.push_constant("FLOAT", "brightness")
shader_info.vertex_in(0, "VEC3", "position")
shader_info.vertex_out(vert_out)
shader_info.fragment_out(0, "VEC4", "FragColor")
shader_info.vertex_source(
"void main()"
"{"
" pos = position;"
" gl_Position = viewProjectionMatrix * vec4(position, 1.0f);"
"}"
)
shader_info.fragment_source(
"void main()" "{" " FragColor = vec4(pos * brightness, 1.0);" "}"
)
shader = gpu.shader.create_from_info(shader_info)
del vert_out
del shader_info
coords = [(1, 1, 1), (2, 0, 0), (-2, -1, 3)]
batch = batch_for_shader(shader, "TRIS", {"position": coords})
def draw():
matrix = bpy.context.region_data.perspective_matrix
shader.uniform_float("viewProjectionMatrix", matrix)
shader.uniform_float("brightness", 0.5)
batch.draw(shader)
bpy.types.SpaceView3D.draw_handler_add(draw, (), "WINDOW", "POST_VIEW")
+18
View File
@@ -0,0 +1,18 @@
import mathutils
from math import radians
vec = mathutils.Vector((1.0, 2.0, 3.0))
mat_rot = mathutils.Matrix.Rotation(radians(90.0), 4, "X")
mat_trans = mathutils.Matrix.Translation(vec)
mat = mat_trans @ mat_rot
mat.invert()
mat3 = mat.to_3x3()
quat1 = mat.to_quaternion()
quat2 = mat3.to_quaternion()
quat_diff = quat1.rotation_difference(quat2)
print(quat_diff.angle)
+37
View File
@@ -0,0 +1,37 @@
import mathutils
# Color values are represented as RGB values from 0 - 1, this is blue.
col = mathutils.Color((0.0, 0.0, 1.0))
# As well as r/g/b attribute access you can adjust them by h/s/v.
col.s *= 0.5
# You can access its components by attribute or index.
print("Color R:", col.r)
print("Color G:", col[1])
print("Color B:", col[-1])
print("Color HSV: {:.2f}, {:.2f}, {:.2f}".format(*col))
# Components of an existing color can be set.
col[:] = 0.0, 0.5, 1.0
# Components of an existing color can use slice notation to get a tuple.
print("Values: {:f}, {:f}, {:f}".format(*col))
# Colors can be added and subtracted.
col += mathutils.Color((0.25, 0.0, 0.0))
# Color can be multiplied, in this example color is scaled to 0-255
# can printed as integers.
print("Color: {:d}, {:d}, {:d}".format(*(int(c) for c in (col * 255.0))))
# This example prints the color as hexadecimal.
print(
"Hexadecimal: {:02x}{:02x}{:02x}".format(
int(col.r * 255), int(col.g * 255), int(col.b * 255)
)
)
# Direct buffer access is supported at runtime via C buffer protocol
# but not expressible in type stubs (requires Python 3.12+ __buffer__).
+35
View File
@@ -0,0 +1,35 @@
import mathutils
import math
# Create a location matrix.
mat_loc = mathutils.Matrix.Translation((2.0, 3.0, 4.0))
# Create an identity matrix.
mat_sca = mathutils.Matrix.Scale(0.5, 4, (0.0, 0.0, 1.0))
# Create a rotation matrix.
mat_rot = mathutils.Matrix.Rotation(math.radians(45.0), 4, "X")
# Combine transformations.
mat_out = mat_loc @ mat_rot @ mat_sca
print(mat_out)
# Extract components back out of the matrix as two vectors and a quaternion.
loc, rot, sca = mat_out.decompose()
print(loc, rot, sca)
# Recombine extracted components.
mat_out2 = mathutils.Matrix.LocRotScale(loc, rot, sca)
print(mat_out2)
# It can also be useful to access components of a matrix directly.
mat = mathutils.Matrix()
mat[0][0], mat[1][0], mat[2][0] = 0.0, 1.0, 2.0
mat[0][0:3] = 0.0, 1.0, 2.0
# Each item in a matrix is a vector so vector utility functions can be used.
mat[0].xyz = 0.0, 1.0, 2.0
# Direct buffer access is supported at runtime via C buffer protocol
# but not expressible in type stubs (requires Python 3.12+ __buffer__).
@@ -0,0 +1,40 @@
import mathutils
import math
# A new rotation 90 degrees about the Y axis.
quat_a = mathutils.Quaternion((0.7071068, 0.0, 0.7071068, 0.0))
# Passing values to Quaternion's directly can be confusing so axis, angle
# is supported for initializing too.
quat_b = mathutils.Quaternion((0.0, 1.0, 0.0), math.radians(90.0))
print("Check quaternions match", quat_a == quat_b)
# Like matrices, quaternions can be multiplied to accumulate rotational values.
quat_a = mathutils.Quaternion((0.0, 1.0, 0.0), math.radians(90.0))
quat_b = mathutils.Quaternion((0.0, 0.0, 1.0), math.radians(45.0))
quat_out = quat_a @ quat_b
# Print the quaternion, euler degrees for mere mortals and (axis, angle).
print("Final Rotation:")
print(quat_out)
print("{:.2f}, {:.2f}, {:.2f}".format(*(math.degrees(a) for a in quat_out.to_euler())))
print(
"({:.2f}, {:.2f}, {:.2f}), {:.2f}".format(
*quat_out.axis, math.degrees(quat_out.angle)
)
)
# Multiple rotations can be interpolated using the exponential map.
quat_c = mathutils.Quaternion((1.0, 0.0, 0.0), math.radians(15.0))
exp_avg = (
quat_a.to_exponential_map()
+ quat_b.to_exponential_map()
+ quat_c.to_exponential_map()
) / 3.0
quat_avg = mathutils.Quaternion(exp_avg)
print("Average rotation:")
print(quat_avg)
# Direct buffer access is supported at runtime via C buffer protocol
# but not expressible in type stubs (requires Python 3.12+ __buffer__).
+58
View File
@@ -0,0 +1,58 @@
import mathutils
# Zero length vector.
vec = mathutils.Vector((0.0, 0.0, 1.0))
# Unit length vector.
vec_a = vec.normalized()
vec_b = mathutils.Vector((0.0, 1.0, 2.0))
vec2d = mathutils.Vector((1.0, 2.0))
vec3d = mathutils.Vector((1.0, 0.0, 0.0))
vec4d = vec_a.to_4d()
# Other `mathutils` types.
quat = mathutils.Quaternion()
matrix = mathutils.Matrix()
# Comparison operators can be done on Vector classes:
# (In)equality operators == and != test component values, e.g. 1,2,3 != 3,2,1
vec_a == vec_b
vec_a != vec_b
# Ordering operators >, >=, > and <= test vector length.
vec_a > vec_b
vec_a >= vec_b
vec_a < vec_b
vec_a <= vec_b
# Math can be performed on Vector classes.
vec_a + vec_b
vec_a - vec_b
vec_a @ vec_b
vec_a * 10.0
matrix @ vec_a
quat @ vec_a
-vec_a
# You can access a vector object like a sequence.
x = vec_a[0]
len(vec)
vec_a[:] = vec_b
vec_a[:] = 1.0, 2.0, 3.0
vec2d[:] = vec3d[:2]
# Vectors support 'swizzle' operations.
# See https://en.wikipedia.org/wiki/Swizzling_(computer_graphics)
vec.xyz = vec.zyx
vec.xy = vec4d.zw
vec.xyz = vec4d.wzz
vec4d.wxyz = vec.yxyx
# Direct buffer access is supported at runtime via C buffer protocol
# but not expressible in type stubs (requires Python 3.12+ __buffer__).