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
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 | 54 | print("\r\nPERCENTAGES : \r\n") |
55 | 55 | MM.printPercentages() |
56 | 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 | 58 | print("invalid ID") |
59 | + break | |
59 | 60 | |
60 | 61 | if __name__ == '__main__': |
61 | - main() | |
62 | 62 | \ No newline at end of file |
63 | + main() | ... | ... |
structure.py
... | ... | @@ -26,10 +26,8 @@ class Location(): |
26 | 26 | self.z = z |
27 | 27 | |
28 | 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 | 32 | def __mul__(self, multiplier): |
35 | 33 | returnValue = Location(self.x, self.y, self.z) |
... | ... | @@ -72,15 +70,15 @@ class Location(): |
72 | 70 | return floor((temp.x * arraySize + temp.y)/2) |
73 | 71 | |
74 | 72 | @staticmethod |
75 | - def fromID(id, arraySize=3): | |
73 | + def fromID(origin_id, arraySize=3): | |
76 | 74 | ''' |
77 | 75 | Returns the Location of a fingerprint of known ID |
78 | 76 | :param: ID to resolve |
79 | 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 | 82 | returnValue = Location(x, y) |
85 | 83 | returnValue *= 2 |
86 | 84 | returnValue += Location(1,1) |
... | ... | @@ -204,11 +202,11 @@ class MarkovModel(): |
204 | 202 | :param currentCell: ID of the last cell |
205 | 203 | :return: ID of the most likely next location |
206 | 204 | ''' |
207 | - max=0 | |
205 | + max_value=0 | |
208 | 206 | max_id=0 |
209 | 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 | 210 | max_id = k |
213 | 211 | return max_id |
214 | 212 | ... | ... |