Skip to content

Commit

Permalink
Merge pull request #100 from libAtoms/summary-fix
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
gabor1 authored Jan 27, 2021
2 parents d262fe8 + 5051861 commit ba82c6a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
- pip install -r requirements.txt
- pip install sphinx sphinx-rtd-theme
script:
- cd docs; make html
- cd docs_src; make html
deploy:
provider: pages
local_dir: docs/_build/html
local_dir: docs_src/_build/html
skip-cleanup: true
github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
keep-history: true
Expand Down
34 changes: 22 additions & 12 deletions abcd/frontends/commandline/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

@init_config
def login(*, config, name, url, **kwargs):
logger.info('login args: \nconfig:{}, name:{}, url:{}, kwargs:{}'.format(config, name, url, kwargs))
logger.info(
'login args: \nconfig:{}, name:{}, url:{}, kwargs:{}'.format(config, name, url, kwargs))
from abcd import ABCD

db = ABCD.from_url(url=url)
Expand Down Expand Up @@ -103,14 +104,17 @@ def summary(*, db, query, print_all, bins, truncate, props, **kwargs):

logging.info('property list: {}'.format(props_list))

total = db.count(query)
print('Total number of configurations: {}'.format(total))

if total == 0:
return

f = Formater()
if props_list is None:

total = db.count(query)
props = db.count_properties(query=query)

print('Total number of configurations: {}'.format(total))

labels, categories, dtypes, counts = [], [], [], []
for k in sorted(props, key=str.lower):
labels.append(k)
Expand Down Expand Up @@ -205,7 +209,8 @@ def key_delete(*, db, query, yes, keys, **kwargs):
query += keys

if not yes:
print('Please use --yes for deleting keys from {} configurations'.format(db.count(query=query)))
print('Please use --yes for deleting keys from {} configurations'.format(
db.count(query=query)))
exit(1)

for k in keys:
Expand All @@ -217,7 +222,8 @@ def key_delete(*, db, query, yes, keys, **kwargs):
@init_db
def execute(*, db, query, yes, python_code, **kwargs):
if not yes:
print('Please use --yes for executing code on {} configurations'.format(db.count(query=query)))
print('Please use --yes for executing code on {} configurations'.format(
db.count(query=query)))
exit(1)

db.exec(python_code, query)
Expand Down Expand Up @@ -248,15 +254,18 @@ def title(self, title):

def describe(self, data):
if data['type'] == 'hist_float':
print('{} count: {} min: {:11.4e} med: {:11.4e} max: {:11.4e} std: {:11.4e} var:{:11.4e}'.format(
data["name"], sum(data["counts"]),
data["min"], data["median"], data["max"],
data["std"], data["var"])
print(
'{} count: {} min: {:11.4e} med: {:11.4e} max: {:11.4e} std: {:11.4e} var:{'
':11.4e}'.format(
data["name"], sum(data["counts"]),
data["min"], data["median"], data["max"],
data["std"], data["var"])
)

elif data['type'] == 'hist_int':
print('{} count: {} '.format(data["name"], sum(data["counts"])),
'min: {:d} med: {:d} max: {:d} '.format(int(data["min"]), int(data["median"]), int(data["max"]))
'min: {:d} med: {:d} max: {:d} '.format(int(data["min"]), int(data["median"]),
int(data["max"]))
)

elif data['type'] == 'hist_str':
Expand Down Expand Up @@ -310,7 +319,8 @@ def hist_str(self, total, counts, labels, width_hist=40):
ratio = width_hist / max(counts)
for label, count in zip(labels, counts):
scale = int(ratio * count)
self.print('{:<{}} {:>{}d} {}'.format("▉" * scale, width_hist, count, width_count, label))
self.print(
'{:<{}} {:>{}d} {}'.format("▉" * scale, width_hist, count, width_count, label))

def hist_labels(self, counts, categories, dtypes, labels, width_hist=40):

Expand Down
2 changes: 1 addition & 1 deletion abcd/frontends/commandline/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
download_parser = subparsers.add_parser('download', help='download data from the database')
download_parser.set_defaults(callback_func=commands.download)
download_parser.add_argument('-q', '--query', action='append', help='Filtering extra quantities', default=[])
download_parser.add_argument('-f', '--format', help='Valid ASE file format (optional)', dest='fileformat', default='')
download_parser.add_argument('-f', '--format', help='Valid ASE file format (optional)', dest='fileformat', default='extxyz')
download_parser.add_argument(dest='filename', help='name of the file to store the configurations', nargs='?')

upload_parser = subparsers.add_parser('upload', help='upload any ase supported files to the database')
Expand Down
2 changes: 1 addition & 1 deletion tests/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_push(self):
Si 0.00000000 0.00000000 0.00000000
""")

atoms = read(xyz, format='xyz')
atoms = read(xyz, format='extxyz')
atoms.set_cell([1, 1, 1])

self.abcd.destroy()
Expand Down

0 comments on commit ba82c6a

Please sign in to comment.