Commit d6e5806af53d2933fedbcccd24b79d9112c2e8cd
1 parent
0342a0fa
misc fixes, add codefactor badge
Showing
5 changed files
with
15 additions
and
16 deletions
Show diff stats
.travis.yml
@@ -8,7 +8,7 @@ python: | @@ -8,7 +8,7 @@ python: | ||
8 | matrix: | 8 | matrix: |
9 | include: | 9 | include: |
10 | - name: "Python 3.7.1 on Xenial Linux" | 10 | - name: "Python 3.7.1 on Xenial Linux" |
11 | - python: 3.7 | 11 | + python: 3.7 |
12 | dist: xenial | 12 | dist: xenial |
13 | script: py.test --cov-report=xml --cov=./ | 13 | script: py.test --cov-report=xml --cov=./ |
14 | after_success: | 14 | after_success: |
README.md
1 | 1 | ||
2 | -[](https://travis-ci.com/Anthex/LO53FP) [](https://codecov.io/gh/Anthex/LO53FP) [](https://opensource.org/licenses/MIT) | 2 | +[](https://travis-ci.com/Anthex/LO53FP) [](https://codecov.io/gh/Anthex/LO53FP) [](https://www.codefactor.io/repository/github/anthex/lo53fp) [](https://opensource.org/licenses/MIT) |
3 | 3 | ||
4 | 4 | ||
5 | 5 |
main.py
@@ -54,8 +54,9 @@ def main(): | @@ -54,8 +54,9 @@ def main(): | ||
54 | print("\r\nPERCENTAGES : \r\n") | 54 | print("\r\nPERCENTAGES : \r\n") |
55 | MM.printPercentages() | 55 | MM.printPercentages() |
56 | print("\r\ncurrent cell is \033[0;32;40m#" + str(MM.previousCell) + "\033[1;37;40m , most likely next cell is \033[1;32;40m#" + str(MM.getMostLikely()) + "\033[1;37;40m which is located at \033[1;32;40m" + str(Location.fromID(MM.getMostLikely()).toString()) + "\033[1;37;40m") | 56 | print("\r\ncurrent cell is \033[0;32;40m#" + str(MM.previousCell) + "\033[1;37;40m , most likely next cell is \033[1;32;40m#" + str(MM.getMostLikely()) + "\033[1;37;40m which is located at \033[1;32;40m" + str(Location.fromID(MM.getMostLikely()).toString()) + "\033[1;37;40m") |
57 | - else: | 57 | + else: |
58 | print("invalid ID") | 58 | print("invalid ID") |
59 | + break | ||
59 | 60 | ||
60 | if __name__ == '__main__': | 61 | if __name__ == '__main__': |
61 | - main() | ||
62 | \ No newline at end of file | 62 | \ No newline at end of file |
63 | + main() |
structure.py
@@ -26,10 +26,8 @@ class Location(): | @@ -26,10 +26,8 @@ class Location(): | ||
26 | self.z = z | 26 | self.z = z |
27 | 27 | ||
28 | def __eq__(self, loc2): | 28 | def __eq__(self, loc2): |
29 | - if self.x == loc2.x and self.y == loc2.y and self.z == loc2.z: | ||
30 | - return True | ||
31 | - else: | ||
32 | - return False | 29 | + return bool(self.x == loc2.x and self.y == loc2.y and self.z == loc2.z) |
30 | + | ||
33 | 31 | ||
34 | def __mul__(self, multiplier): | 32 | def __mul__(self, multiplier): |
35 | returnValue = Location(self.x, self.y, self.z) | 33 | returnValue = Location(self.x, self.y, self.z) |
@@ -72,15 +70,15 @@ class Location(): | @@ -72,15 +70,15 @@ class Location(): | ||
72 | return floor((temp.x * arraySize + temp.y)/2) | 70 | return floor((temp.x * arraySize + temp.y)/2) |
73 | 71 | ||
74 | @staticmethod | 72 | @staticmethod |
75 | - def fromID(id, arraySize=3): | 73 | + def fromID(origin_id, arraySize=3): |
76 | ''' | 74 | ''' |
77 | Returns the Location of a fingerprint of known ID | 75 | Returns the Location of a fingerprint of known ID |
78 | :param: ID to resolve | 76 | :param: ID to resolve |
79 | :param arraySize: (Optional) dimension of the array | 77 | :param arraySize: (Optional) dimension of the array |
80 | ''' | 78 | ''' |
81 | - id -= 1 | ||
82 | - y=id % 3 | ||
83 | - x=floor((id - y) / 3) | 79 | + origin_id -= 1 |
80 | + y=origin_id % 3 | ||
81 | + x=floor((origin_id - y) / 3) | ||
84 | returnValue = Location(x, y) | 82 | returnValue = Location(x, y) |
85 | returnValue *= 2 | 83 | returnValue *= 2 |
86 | returnValue += Location(1,1) | 84 | returnValue += Location(1,1) |
@@ -204,11 +202,11 @@ class MarkovModel(): | @@ -204,11 +202,11 @@ class MarkovModel(): | ||
204 | :param currentCell: ID of the last cell | 202 | :param currentCell: ID of the last cell |
205 | :return: ID of the most likely next location | 203 | :return: ID of the most likely next location |
206 | ''' | 204 | ''' |
207 | - max=0 | 205 | + max_value=0 |
208 | max_id=0 | 206 | max_id=0 |
209 | for k in range(1,10): | 207 | for k in range(1,10): |
210 | - if self.MarkovValues[k][currentCell].nb > max: | ||
211 | - max = self.MarkovValues[k][currentCell].nb | 208 | + if self.MarkovValues[k][currentCell].nb > max_value: |
209 | + max_value = self.MarkovValues[k][currentCell].nb | ||
212 | max_id = k | 210 | max_id = k |
213 | return max_id | 211 | return max_id |
214 | 212 |
test_structure.py
@@ -118,4 +118,4 @@ class OutputBuffer(object): | @@ -118,4 +118,4 @@ class OutputBuffer(object): | ||
118 | 118 | ||
119 | @property | 119 | @property |
120 | def err(self): | 120 | def err(self): |
121 | - return self.stderr.getvalue() | ||
122 | \ No newline at end of file | 121 | \ No newline at end of file |
122 | + return self.stderr.getvalue() |