Skip to content

Commit

Permalink
Adding OSM licenses; fixing choice creation
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverroick committed Feb 20, 2017
1 parent f3d09b6 commit 89918c9
Show file tree
Hide file tree
Showing 2 changed files with 15,011 additions and 15,003 deletions.
11 changes: 8 additions & 3 deletions cadasta/core/fixtures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def add_test_users(self):
for n in range(20):
if n < len(named_users):
users.append(UserFactory.create(
**named_users[n],
password='password',
email_verified=True,
last_login=datetime.now(tz=timezone.utc),
is_active=True,
**named_users[n]
))
else:
users.append(UserFactory.create(
Expand Down Expand Up @@ -408,15 +408,20 @@ def add_huge_project(self, num_records=4000):
)

spatial_units = []
choices = [c[0] for c in TYPE_CHOICES]

with open(os.path.join(os.path.dirname(__file__),
"londondata.txt"), "r") as ins:
for i, geometry in enumerate(ins):
for geometry in ins:
if not geometry.rstrip() or geometry.startswith('#'):
continue

i = len(spatial_units)

This comment has been minimized.

Copy link
@seav

seav Feb 20, 2017

Contributor

Just curious. Would initializing i to 0 and then incrementing it be more efficient than checking the array length? Also, since the variable is no longer tied to the loop definition, then it needs a better name like num_running_records (or num_records and then rename the existing parameter to max_num_records).

This comment has been minimized.

Copy link
@oliverroick

oliverroick Feb 20, 2017

Author Member

Internally, a list stores its current count so len is always a cheap operation. I agree on renaming the variable, will do that now.

if not i < num_records:
break

name = 'Spatial Unit #{}'.format(i)
type = random.choice([c[0] for c in TYPE_CHOICES])
type = random.choice(choices)

spatial_units.append({
'geometry': GEOSGeometry(geometry),
Expand Down
Loading

0 comments on commit 89918c9

Please sign in to comment.