Esempio n. 1
0
    def test_that_equality_operator_returns_false_for_none(self):
        lhs = Vec3([1, 0, 0])
        rhs = None

        current = lhs == rhs
        expects = False

        assert current == expects
Esempio n. 2
0
    def test_pow_operator_with_scalar(self):
        lhs = Vec3([1, 1, 1])
        rhs = 2

        current = lhs**rhs
        expects = np.dot(lhs, lhs)

        assert np.allclose(current, expects)
Esempio n. 3
0
    def test_that_vec3_string_gets_three_digits_when_vec2dd_settings_is_false(self):
        settings["vec2dd"] = False

        vec = Vec3([1, 2, 3])

        current = str(vec)
        expects = "V(1.000, 2.000, 3.000)"

        assert current == expects
Esempio n. 4
0
    def test_that_vec3_string_gets_dip_and_dir_when_vec2dd_settings_is_true(self):
        settings["vec2dd"] = True

        vec = Vec3([1, 2, 3])

        current = str(vec)
        expects = "V:63/53"

        assert current == expects

        settings["vec2dd"] = False
Esempio n. 5
0
 def min_at(self):
     return Vec3(self.dcgrid[self.values.argmin()]).aslin
Esempio n. 6
0
    def test_that_equality_operator_is_symetric(self):
        u = Vec3([1, 2, 3])
        v = Vec3([1, 2, 3])

        assert u == v and v == u
Esempio n. 7
0
 def test_that_vector_is_hashable(self, helpers):
     assert helpers.is_hashable(Vec3([1, 2, 3]))
Esempio n. 8
0
    def test_length_method(self):
        w = Vec3([1, 2, 3])

        assert len(w) == 3
Esempio n. 9
0
 def y(self):
     return Vec3([0, 1, 0])
Esempio n. 10
0
    def test_rotation_by_360_degrees_around_axis(self, z):
        v = Vec3([1, 1, 1])
        current = v.rotate(z, 360)
        expects = Vec3([1, 1, 1])

        assert current == expects
Esempio n. 11
0
    def test_absolute_value(self):
        current = abs(Vec3([1, 2, 3]))
        expects = 3.7416573867739413

        assert current == expects
Esempio n. 12
0
    def test_that_vector_is_flipped(self):
        current = Vec3([0, 0, 1]).flip
        expects = Vec3([0, 0, -1])

        assert current == expects
Esempio n. 13
0
    def test_that_vector_is_not_upper(self):
        vec = Vec3([0, 0, 1])

        assert not vec.upper
Esempio n. 14
0
    def test_that_vector_is_upper(self):
        vec = Vec3([0, 0, -1])

        assert vec.upper
Esempio n. 15
0
    def test_that_hash_is_not_same_for_different_vectors(self):
        lhs = Vec3([1, 2, 3])
        rhs = Vec3([3, 2, 1])

        assert not hash(lhs) == hash(rhs)
Esempio n. 16
0
    def test_scalar_product_of_same_vectors(self):
        i = Vec3([1, 2, 3])

        assert np.allclose(i.dot(i), abs(i)**2)
Esempio n. 17
0
    def test_scalar_product_of_orthonornal_vectors(self):
        i = Vec3([1, 0, 0])
        j = Vec3([0, 1, 0])

        assert i.dot(j) == 0
Esempio n. 18
0
    def test_that_vector_is_normalized(self):
        current = Vec3([1, 2, 3]).uv
        expects = Vec3(
            [0.26726124191242442, 0.5345224838248488, 0.8017837257372732])

        assert current == expects
Esempio n. 19
0
    def test_projection_of_xy_onto(self, z):
        xz = Vec3([1, 0, 1])
        current = xz.proj(z)
        expects = Vec3([0, 0, 1])

        assert current == expects
Esempio n. 20
0
 def test_aslin_conversion(self):
     assert str(Vec3([1, 1, 1]).aslin) == str(Lin(45, 35))  # `Vec` to `Lin`
     assert str(Vec3(Lin(110, 37)).aslin) == str(Lin(
         110, 37))  # `Lin` to `Vec` to `Lin`
Esempio n. 21
0
 def z(self):
     return Vec3([0, 0, 1])
Esempio n. 22
0
 def test_asfol_conversion(self):
     assert str(Vec3([1, 1, 1]).asfol) == str(Fol(225,
                                                  55))  # `Vec` to `Fol`
     assert str(Vec3(Fol(213, 52)).asfol) == str(Fol(
         213, 52))  # `Fol` to `Vec` to `Fol`
Esempio n. 23
0
    def test_getitem_operator(self):
        v = Vec3([1, 2, 3])

        assert all((v[0] == 1, v[1] == 2, v[2] == 3))
Esempio n. 24
0
 def test_asvec_conversion(self):
     assert str(Lin(120, 10).asvec3) == str(Vec3(120, 10, 1))
Esempio n. 25
0
    def test_that_equality_operator_is_reflexive(self):
        u = Vec3([1, 2, 3])

        assert u == u
Esempio n. 26
0
    def test_that_vector_product_is_anticommutative(self):
        lhs = Vec3([1, 0, 0])
        rhs = Vec3([0, 1, 0])

        assert lhs.cross(rhs) == -rhs.cross(lhs)
Esempio n. 27
0
    def test_that_equality_operator_is_transitive(self):
        u = Vec3([1, 2, 3])
        v = Vec3([1, 2, 3])
        w = Vec3([1, 2, 3])

        assert u == v and v == w and u == w
Esempio n. 28
0
    def test_that_vector_product_is_distributive_over_addition(self):
        a = Vec3([1, 0, 0])
        b = Vec3([0, 1, 0])
        c = Vec3([0, 0, 1])

        assert a.cross(b + c) == a.cross(b) + a.cross(c)
Esempio n. 29
0
 def max_at(self):
     return Vec3(self.dcgrid[self.values.argmax()]).aslin
Esempio n. 30
0
 def x(self):
     return Vec3([1, 0, 0])