Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions bin/CsvJoiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,7 @@
"ZWE":"716"
}

sedoc = {}
for k in codes:
sedoc[codes[k]] = k
sedoc = {codes[k]: k for k in codes}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 506-508 refactored with the following changes:

  • Convert for loop into dictionary comprehension (dict-comprehension)


def main(argv):
a = sys.argv[1]
Expand Down
4 changes: 2 additions & 2 deletions bin/avgRegistrationResponseTimes
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def registrationsFromFile(counter, arg):
line = f.readline()
if not line: break
numOf, timeOf = registrationsFromLine(counter, line.rstrip())
totalNumOf = totalNumOf + numOf
totalTimeOf = totalTimeOf + timeOf
totalNumOf += numOf
totalTimeOf += timeOf
Comment on lines -26 to +27
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function registrationsFromFile refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

return totalNumOf, totalTimeOf

# The "main"
Expand Down
14 changes: 4 additions & 10 deletions bin/drawDeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,9 @@
def nextOrder(modules, deps, ordered, unordered, fileName):
order = set()
for module in unordered:
isOrd = True
for (left, right) in deps:
if module == left:
if right not in ordered:
# It's not already ordered, so this is not this order
isOrd = False
isOrd = not any(module == left and right not in ordered
for (left, right) in deps)
Comment on lines -60 to +62
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function nextOrder refactored with the following changes:

  • Merge nested if conditions (merge-nested-ifs)
  • Use any() instead of for loop (use-any)

if isOrd:
order.add(module)

Expand All @@ -81,11 +78,8 @@ def nextOrder(modules, deps, ordered, unordered, fileName):
def nextGeneration(modules, deps, gened, ungened, fileName):
gen = set()
for module in ungened:
isGen = True
for (left, right) in deps:
if module == right:
if left not in gened:
isGen = False
isGen = not any(module == right and left not in gened
for (left, right) in deps)
Comment on lines -84 to +82
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function nextGeneration refactored with the following changes:

  • Merge nested if conditions (merge-nested-ifs)
  • Use any() instead of for loop (use-any)

if isGen:
gen.add(module)

Expand Down
4 changes: 1 addition & 3 deletions geo/CountryCodeToName.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,7 @@
"ZWE":"716"
}

sedoc = {}
for k in codes:
sedoc[codes[k]] = k
sedoc = {codes[k]: k for k in codes}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 506-508 refactored with the following changes:

  • Convert for loop into dictionary comprehension (dict-comprehension)


def main(argv):
a = sys.argv[1]
Expand Down
18 changes: 9 additions & 9 deletions geo/geohash.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ def _encode_i2c(lat,lon,lat_length,lon_length):
else:
a = lat
b = lon

boost = (0,1,4,5,16,17,20,21)
ret = ''
for i in range(precision):
for _ in range(precision):
ret+=_base32[(boost[a&7]+(boost[b&3]<<1))&0x1F]
t = a>>3
a = b>>2
b = t

Comment on lines -65 to +73
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _encode_i2c refactored with the following changes:

  • Replace unused for index with underscore (for-index-underscore)

return ret[::-1]

def encode(latitude, longitude, precision=12):
Expand Down Expand Up @@ -131,8 +131,8 @@ def _decode_c2i(hashcode):
for i in hashcode:
t = _base32_map[i]
if bit_length%2==0:
lon = lon<<3
lat = lat<<2
lon <<= 3
lat <<= 2
Comment on lines -134 to +135
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _decode_c2i refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

lon += (t>>2)&4
lat += (t>>2)&2
lon += (t>>1)&2
Expand All @@ -141,18 +141,18 @@ def _decode_c2i(hashcode):
lon_length+=3
lat_length+=2
else:
lon = lon<<2
lat = lat<<3
lon <<= 2
lat <<= 3
lat += (t>>2)&4
lon += (t>>2)&2
lat += (t>>1)&2
lon += (t>>1)&1
lat += t&1
lon_length+=2
lat_length+=3

bit_length+=5

return (lat,lon,lat_length,lon_length)

def decode(hashcode, delta=False):
Expand Down
2 changes: 1 addition & 1 deletion geo/ppidCounts2kml.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def run(self):
#print geohash.bbox("u27")
i = 0
for csv in self.csvs:
i = i + 1
i += 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PpidCounts2KML.run refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

place = self.processPlace(csv, i)
self.csvs[i - 1] = place
if i == 1001:
Expand Down