Skip to content

Commit

Permalink
Added writeOut and giveVal methods in vector data type
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaHobbyist committed Jun 7, 2024
1 parent f408b4d commit 716db54
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions manual_tests/test_pyvnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# test for KeyData and Foam classes

key1 = KeyData('solver', prop1, prop2)
print(key1.giveVal())
# print(key1.giveVal())
head = Foam("test_head",None, None)

# head.appendDict(args)
Expand All @@ -33,7 +33,7 @@
# key1 = KeyData('solver', prop1)
# print(key1)

writeTo(head, 'testFile.txt')
# writeTo(head, 'testFile.txt')



15 changes: 15 additions & 0 deletions pyvnt/Reference/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,20 @@ def normalise(self, tol: PropertyFloat) -> Self:
self.setProperties(self._ValueProperty__name, PropertyFloat(self._ValueProperty__name + "_x", self.__x.giveVal()/s), PropertyFloat(self._ValueProperty__name + "_y", self.__y.giveVal()/s), PropertyFloat(self._ValueProperty__name + "_z", self.__z.giveVal()/s))
return self

def giveVal(self):
'''
Returns the vector value
'''

res = (self.__x.giveVal(), self.__y.giveVal(), self.__z.giveVal())

return res

def writeOut(self, file):
'''
Returns the vector value in a string format
'''
file.write( f"({self.__x.giveVal()} {self.__y.giveVal()} {self.__z.giveVal()})")

def __repr__(self):
return f"PropertyVector(name = {self._ValueProperty__name}, x = {self.__x.giveVal()}, y = {self.__y.giveVal()}, z = {self.__z.giveVal()})"
17 changes: 0 additions & 17 deletions testFile.txt

This file was deleted.

6 changes: 5 additions & 1 deletion tests/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ def test_vector_normalise(self):
self.vprop1.normalise(PropertyFloat('tol', 0.1))
assert self.vprop1.x() == 1/14**0.5
assert self.vprop1.y() == 2/14**0.5
assert self.vprop1.z() == 3/14**0.5
assert self.vprop1.z() == 3/14**0.5

def test_vector_giveVal(self):
assert self.vprop1.giveVal() == (1, 2, 3)
assert self.vprop2.giveVal() == (4, 5, 6)

0 comments on commit 716db54

Please sign in to comment.