<s> from __future__ import absolute_import <EOL> try : <EOL> import unittest2 as unittest <EOL> except : <EOL> import unittest <EOL> import numpy as np <EOL> from pyrr . objects . matrix33 import Matrix33 <EOL> from pyrr . objects . matrix44 import Matrix44 <EOL> from pyrr . objects . quaternion import Quaternion <EOL> from pyrr . objects . vector3 import Vector3 <EOL> from pyrr . objects . vector4 import Vector4 <EOL> from pyrr import matrix33 <EOL> from pyrr import matrix44 <EOL> from pyrr import quaternion <EOL> class test_object_matrix33 ( unittest . TestCase ) : <EOL> _shape = ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> _size = np . multiply . reduce ( _shape ) <EOL> def test_imports ( self ) : <EOL> import pyrr <EOL> pyrr . Matrix33 ( ) <EOL> pyrr . matrix33 . Matrix33 ( ) <EOL> pyrr . objects . matrix33 . Matrix33 ( ) <EOL> from pyrr import Matrix33 <EOL> from pyrr . objects import Matrix33 <EOL> from pyrr . objects . matrix33 import Matrix33 <EOL> def test_create ( self ) : <EOL> m = Matrix33 ( ) <EOL> self . assertTrue ( np . array_equal ( m , np . zeros ( self . _shape ) ) ) <EOL> self . assertEqual ( m . shape , self . _shape ) <EOL> m = Matrix33 ( np . arange ( self . _size ) ) <EOL> self . assertEqual ( m . shape , self . _shape ) <EOL> m = Matrix33 ( [ [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , [ <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] ] ) <EOL> self . assertEqual ( m . shape , self . _shape ) <EOL> m = Matrix33 ( Matrix33 ( ) ) <EOL> self . assertTrue ( np . array_equal ( m , np . zeros ( self . _shape ) ) ) <EOL> self . assertEqual ( m . shape , self . _shape ) <EOL> def test_identity ( self ) : <EOL> m = Matrix33 . identity ( ) <EOL> self . assertTrue ( np . array_equal ( m , np . eye ( <NUM_LIT:3> ) ) ) <EOL> @ unittest . skip ( '<STR_LIT>' ) <EOL> def test_perspective_projection ( self ) : <EOL> pass <EOL> @ unittest . skip ( '<STR_LIT>' ) <EOL> def test_perspective_projection_bounds ( self ) : <EOL> pass <EOL> @ unittest . skip ( '<STR_LIT>' ) <EOL> def test_orthogonal_projection ( self ) : <EOL> pass <EOL> @ unittest . skip ( '<STR_LIT>' ) <EOL> def test_from_translation ( self ) : <EOL> pass <EOL> def test_create_from_matrix44 ( self ) : <EOL> m1 = Matrix44 . identity ( ) <EOL> m = Matrix33 . from_matrix44 ( m1 ) <EOL> self . assertTrue ( np . array_equal ( m , np . eye ( <NUM_LIT:3> ) ) ) <EOL> m = Matrix33 ( m1 ) <EOL> self . assertTrue ( np . array_equal ( m , np . eye ( <NUM_LIT:3> ) ) ) <EOL> def test_create_from_scale ( self ) : <EOL> v = Vector3 ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> m = Matrix33 . from_scale ( v ) <EOL> self . assertTrue ( np . array_equal ( m , np . diag ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) ) ) <EOL> def test_create_from_eulers ( self ) : <EOL> e = Vector3 ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> m = Matrix33 . from_eulers ( e ) <EOL> self . assertTrue ( np . array_equal ( m , matrix33 . create_from_eulers ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) ) ) <EOL> def test_create_from_quaternion ( self ) : <EOL> q = Quaternion ( ) <EOL> m = Matrix33 . from_quaternion ( q ) <EOL> self . assertTrue ( np . array_equal ( m , np . eye ( <NUM_LIT:3> ) ) ) <EOL> self . assertTrue ( np . array_equal ( m . quaternion , q ) ) <EOL> m = Matrix33 ( q ) <EOL> self . assertTrue ( np . array_equal ( m , np . eye ( <NUM_LIT:3> ) ) ) <EOL> def test_create_from_inverse_quaternion ( self ) : <EOL> q = Quaternion . from_x_rotation ( <NUM_LIT:0.5> ) <EOL> m = Matrix33 . from_inverse_of_quaternion ( q ) <EOL> expected = matrix33 . create_from_quaternion ( quaternion . inverse ( quaternion . create_from_x_rotation ( <NUM_LIT:0.5> ) ) ) <EOL> np . testing . assert_almost_equal ( np . array ( m ) , expected , decimal = <NUM_LIT:5> ) <EOL> def test_multiply ( self ) : <EOL> m1 = Matrix33 ( np . arange ( self . _size ) ) <EOL> m2 = Matrix33 ( np . arange ( self . _size ) [ : : - <NUM_LIT:1> ] ) <EOL> m = m1 * m2 <EOL> self . assertTrue ( np . array_equal ( m , matrix33 . multiply ( m1 , m2 ) ) ) <EOL> m1 = Matrix33 ( np . arange ( self . _size ) ) <EOL> m2 = Matrix44 ( np . arange ( <NUM_LIT:16> ) ) <EOL> m = m1 * m2 <EOL> self . assertTrue ( np . array_equal ( m , matrix33 . multiply ( m1 , matrix33 . create_from_matrix44 ( m2 ) ) ) ) <EOL> def test_inverse ( self ) : <EOL> m1 = Matrix33 . identity ( ) * Matrix33 . from_x_rotation ( <NUM_LIT:0.5> ) <EOL> m = m1 . inverse <EOL> self . assertTrue ( np . array_equal ( m , matrix33 . inverse ( m1 ) ) ) <EOL> def test_matrix33 ( self ) : <EOL> m1 = Matrix33 . identity ( ) * Matrix33 . from_x_rotation ( <NUM_LIT:0.5> ) <EOL> m = m1 . matrix33 <EOL> self . assertTrue ( m1 is m ) <EOL> def test_matrix44 ( self ) : <EOL> m1 = Matrix33 . identity ( ) * Matrix33 . from_x_rotation ( <NUM_LIT:0.5> ) <EOL> m = m1 . matrix44 <EOL> self . assertTrue ( np . array_equal ( m , matrix44 . create_from_matrix33 ( m1 ) ) ) <EOL> def test_operators_matrix33 ( self ) : <EOL> m1 = Matrix33 . identity ( ) <EOL> m2 = Matrix33 . from_x_rotation ( <NUM_LIT:0.5> ) <EOL> self . assertTrue ( np . array_equal ( m1 + m2 , matrix33 . create_identity ( ) + matrix33 . create_from_x_rotation ( <NUM_LIT:0.5> ) ) ) <EOL> self . assertTrue ( np . array_equal ( m1 - m2 , matrix33 . create_identity ( ) - matrix33 . create_from_x_rotation ( <NUM_LIT:0.5> ) ) ) <EOL> self . assertTrue ( np . array_equal ( m1 * m2 , matrix33 . multiply ( matrix33 . create_identity ( ) , matrix33 . create_from_x_rotation ( <NUM_LIT:0.5> ) ) ) ) <EOL> self . assertRaises ( ValueError , lambda : m1 / m2 ) <EOL> self . assertTrue ( np . array_equal ( ~ m2 , matrix33 . inverse ( matrix33 . create_from_x_rotation ( <NUM_LIT:0.5> ) ) ) ) <EOL> def test_operators_matrix44 ( self ) : <EOL> m1 = Matrix33 . identity ( ) <EOL> m2 = Matrix44 . from_x_rotation ( <NUM_LIT:0.5> ) <EOL> self . assertTrue ( np . array_equal ( m1 + m2 , matrix33 . create_identity ( ) + matrix33 . create_from_x_rotation ( <NUM_LIT:0.5> ) ) ) <EOL> self . assertTrue ( np . array_equal ( m1 - m2 , matrix33 . create_identity ( ) - matrix33 . create_from_x_rotation ( <NUM_LIT:0.5> ) ) ) <EOL> self . assertTrue ( np . array_equal ( m1 * m2 , matrix33 . multiply ( matrix33 . create_identity ( ) , matrix33 . create_from_x_rotation ( <NUM_LIT:0.5> ) ) ) ) <EOL> self . assertRaises ( ValueError , lambda : m1 / m2 ) <EOL> def test_operators_quaternion ( self ) : <EOL> m = Matrix33 . identity ( ) <EOL> q = Quaternion . from_x_rotation ( <NUM_LIT> ) <EOL> self . assertRaises ( ValueError , lambda : m + q ) <EOL> self . assertRaises ( ValueError , lambda : m - q ) <EOL> self . assertTrue ( np . array_equal ( m * q , matrix33 . multiply ( matrix33 . create_identity ( ) , matrix33 . create_from_quaternion ( quaternion . create_from_x_rotation ( <NUM_LIT> ) ) ) ) ) <EOL> self . assertRaises ( ValueError , lambda : m / q ) <EOL> def test_operators_vector3 ( self ) : <EOL> m = Matrix33 . identity ( ) <EOL> v = Vector3 ( [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> self . assertRaises ( ValueError , lambda : m + v ) <EOL> self . assertRaises ( ValueError , lambda : m - v ) <EOL> self . assertTrue ( np . array_equal ( m * v , matrix33 . apply_to_vector ( matrix33 . create_identity ( ) , [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) ) ) <EOL> self . assertRaises ( ValueError , lambda : m / v ) <EOL> def test_operators_vector4 ( self ) : <EOL> m = Matrix33 . identity ( ) <EOL> v = Vector4 ( [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> self . assertRaises ( ValueError , lambda : m + v ) <EOL> self . assertRaises ( ValueError , lambda : m - v ) <EOL> self . assertTrue ( ValueError , lambda : m * v ) <EOL> self . assertRaises ( ValueError , lambda : m / v ) <EOL> def test_operators_number ( self ) : <EOL> m = Matrix33 . identity ( ) <EOL> fv = np . empty ( ( <NUM_LIT:1> , ) , dtype = [ ( '<STR_LIT:i>' , np . int16 , <NUM_LIT:1> ) , ( '<STR_LIT:f>' , np . float32 , <NUM_LIT:1> ) ] ) <EOL> fv [ <NUM_LIT:0> ] = ( <NUM_LIT:2> , <NUM_LIT> ) <EOL> self . assertTrue ( np . array_equal ( m + <NUM_LIT:1.0> , matrix33 . create_identity ( ) [ : ] + <NUM_LIT:1.0> ) ) <EOL> self . assertTrue ( np . array_equal ( m + <NUM_LIT:1> , matrix33 . create_identity ( ) [ : ] + <NUM_LIT:1.0> ) ) <EOL> self . assertTrue ( np . array_equal ( m + np . float ( <NUM_LIT:1.> ) , matrix33 . create_identity ( ) [ : ] + <NUM_LIT:1.0> ) ) <EOL> self . assertTrue ( np . array_equal ( m + fv [ <NUM_LIT:0> ] [ '<STR_LIT:f>' ] , matrix33 . create_identity ( ) [ : ] + <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m + fv [ <NUM_LIT:0> ] [ '<STR_LIT:i>' ] , matrix33 . create_identity ( ) [ : ] + <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m - <NUM_LIT:1.0> , matrix33 . create_identity ( ) [ : ] - <NUM_LIT:1.0> ) ) <EOL> self . assertTrue ( np . array_equal ( m - <NUM_LIT:1> , matrix33 . create_identity ( ) [ : ] - <NUM_LIT:1.0> ) ) <EOL> self . assertTrue ( np . array_equal ( m - np . float ( <NUM_LIT:1.> ) , matrix33 . create_identity ( ) [ : ] - <NUM_LIT:1.0> ) ) <EOL> self . assertTrue ( np . array_equal ( m - fv [ <NUM_LIT:0> ] [ '<STR_LIT:f>' ] , matrix33 . create_identity ( ) [ : ] - <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m - fv [ <NUM_LIT:0> ] [ '<STR_LIT:i>' ] , matrix33 . create_identity ( ) [ : ] - <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m * <NUM_LIT> , matrix33 . create_identity ( ) [ : ] * <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m * <NUM_LIT:2> , matrix33 . create_identity ( ) [ : ] * <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m * np . float ( <NUM_LIT> ) , matrix33 . create_identity ( ) [ : ] * <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m * fv [ <NUM_LIT:0> ] [ '<STR_LIT:f>' ] , matrix33 . create_identity ( ) [ : ] * <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m * fv [ <NUM_LIT:0> ] [ '<STR_LIT:i>' ] , matrix33 . create_identity ( ) [ : ] * <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m / <NUM_LIT> , matrix33 . create_identity ( ) [ : ] / <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m / <NUM_LIT:2> , matrix33 . create_identity ( ) [ : ] / <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m / np . float ( <NUM_LIT> ) , matrix33 . create_identity ( ) [ : ] / <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m / fv [ <NUM_LIT:0> ] [ '<STR_LIT:f>' ] , matrix33 . create_identity ( ) [ : ] / <NUM_LIT> ) ) <EOL> self . assertTrue ( np . array_equal ( m / fv [ <NUM_LIT:0> ] [ '<STR_LIT:i>' ] , matrix33 . create_identity ( ) [ : ] / <NUM_LIT> ) ) <EOL> def test_accessors ( self ) : <EOL> m = Matrix33 ( np . arange ( self . _size ) ) <EOL> self . assertTrue ( np . array_equal ( m . m1 , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] ) ) <EOL> self . assertTrue ( np . array_equal ( m . m2 , [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] ) ) <EOL> self . assertTrue ( np . array_equal ( m . m3 , [ <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> ] ) ) <EOL> self . assertTrue ( np . array_equal ( m . r1 , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] ) ) <EOL> self . assertTrue ( np . array_equal ( m . r2 , [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] ) ) <EOL> self . assertTrue ( np . array_equal ( m . r3 , [ <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> ] ) ) <EOL> self . assertTrue ( np . array_equal ( m . c1 , [ <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:6> ] ) ) <EOL> self . assertTrue ( np . array_equal ( m . c2 , [ <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:7> ] ) ) <EOL> self . assertTrue ( np . array_equal ( m . c3 , [ <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:8> ] ) ) <EOL> self . assertEqual ( m . m11 , <NUM_LIT:0> ) <EOL> self . assertEqual ( m . m12 , <NUM_LIT:1> ) <EOL> self . assertEqual ( m . m13 , <NUM_LIT:2> ) <EOL> self . assertEqual ( m . m21 , <NUM_LIT:3> ) <EOL> self . assertEqual ( m . m22 , <NUM_LIT:4> ) <EOL> self . assertEqual ( m . m23 , <NUM_LIT:5> ) <EOL> self . assertEqual ( m . m31 , <NUM_LIT:6> ) <EOL> self . assertEqual ( m . m32 , <NUM_LIT:7> ) <EOL> self . assertEqual ( m . m33 , <NUM_LIT:8> ) <EOL> m . m11 = <NUM_LIT:1> <EOL> self . assertEqual ( m . m11 , <NUM_LIT:1> ) <EOL> self . assertEqual ( m [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> m . m11 += <NUM_LIT:1> <EOL> self . assertEqual ( m . m11 , <NUM_LIT:2> ) <EOL> self . assertEqual ( m [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:2> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
