Skip to content

Commit

Permalink
Add dynamic_ncols=True to all tqdm calls to make things cleaner.
Browse files Browse the repository at this point in the history
  • Loading branch information
kboone committed May 20, 2019
1 parent adba7b7 commit 090ba65
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion avocado/augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ def augment_dataset(self, augment_name, dataset, num_augments,
"""
augmented_objects = []

for reference_object in tqdm(dataset.objects, desc='Object'):
for reference_object in tqdm(dataset.objects, desc='Object',
dynamic_ncols=True):
if include_reference:
augmented_objects.append(reference_object)

Expand Down
3 changes: 2 additions & 1 deletion avocado/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ def predict(self, dataset):

predictions = 0

for classifier in tqdm(self.classifiers, desc='Classifier'):
for classifier in tqdm(self.classifiers, desc='Classifier',
dynamic_ncols=True):
fold_scores = classifier.predict_proba(
features, raw_score=True,
num_iteration=classifier.best_iteration_
Expand Down
2 changes: 1 addition & 1 deletion avocado/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def extract_raw_features(self, featurizer):
"""
list_raw_features = []
object_ids = []
for obj in tqdm(self.objects, desc='Object'):
for obj in tqdm(self.objects, desc='Object', dynamic_ncols=True):
obj_features = featurizer.extract_raw_features(obj)
list_raw_features.append(obj_features.values())
object_ids.append(obj.metadata['object_id'])
Expand Down
3 changes: 2 additions & 1 deletion scripts/avocado_augment
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ if __name__ == "__main__":
else:
# Process all chunks
print("Processing the dataset in %d chunks..." % args.num_chunks)
for chunk in tqdm(range(args.num_chunks), desc='Chunk'):
for chunk in tqdm(range(args.num_chunks), desc='Chunk',
dynamic_ncols=True):
process_chunk(augmentor, chunk, args, verbose=False)

print("Done!")
3 changes: 2 additions & 1 deletion scripts/avocado_download_plasticc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def update_plasticc_observations(observations):
def preprocess_observations(input_path, output_path, chunk_size=10**6):
"""Preprocess an observations table and write it out."""
for chunk in tqdm(pd.read_csv(input_path, chunksize=chunk_size),
desc=" %s" % os.path.basename(input_path)):
desc=" %s" % os.path.basename(input_path),
dynamic_ncols=True):
chunk = update_plasticc_observations(chunk)
avocado.utils.write_dataframe(output_path, chunk, 'observations',
append=True, index_chunk_column=False)
Expand Down
3 changes: 2 additions & 1 deletion scripts/avocado_featurize
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ if __name__ == "__main__":
else:
# Process all chunks
print("Processing the dataset in %d chunks..." % args.num_chunks)
for chunk in tqdm(range(args.num_chunks), desc='Chunk'):
for chunk in tqdm(range(args.num_chunks), desc='Chunk',
dynamic_ncols=True):
process_chunk(featurizer, chunk, args, verbose=False)

print("Done!")
3 changes: 2 additions & 1 deletion scripts/avocado_predict
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ if __name__ == "__main__":
else:
# Process all chunks
print("Processing the dataset in %d chunks..." % args.num_chunks)
for chunk in tqdm(range(args.num_chunks), desc='Chunk'):
for chunk in tqdm(range(args.num_chunks), desc='Chunk',
dynamic_ncols=True):
process_chunk(classifier, chunk, args, verbose=False)

print("Done!")

0 comments on commit 090ba65

Please sign in to comment.