diff --git a/pymathzone/vector.py b/pymathzone/vector.py new file mode 100644 index 0000000..f6ed2fb --- /dev/null +++ b/pymathzone/vector.py @@ -0,0 +1,25 @@ +class Vector: + """ + Vector class representing a vector in n-dimensional space. + + Attributes: + components: A tuple containing the vector's components. + + Methods: + __init__(self, components): Initializes the vector with components. + __str__(self): Returns a human-readable string representation. + __add__(self, other): Adds two vectors element-wise. + __sub__(self, other): Subtracts two vectors element-wise. + __mul__(self, scalar): Multiplies the vector by a scalar. + magnitude(self): Calculates the magnitude (length) of the vector. + """ + + def __init__(self, components=None): + """ + Initialize a vector with a tuple + :param components: a tuple contain vector's components. + """ + if not isinstance(components, tuple): + raise ValueError("components must be a tuple") + + self.components = components diff --git a/tests/test_vector.py b/tests/test_vector.py new file mode 100644 index 0000000..651c3ff --- /dev/null +++ b/tests/test_vector.py @@ -0,0 +1,10 @@ +import unittest + + +class TestVector(unittest.TestCase): + def test_something(self): + self.assertEqual(True, False) # add assertion here + + +if __name__ == '__main__': + unittest.main()