libAtoms / abcd

1 stars 4 forks source link

BUG: summary -a option breaks when histogram is trying to be printed #82

Closed stenczelt closed 2 years ago

stenczelt commented 4 years ago

When summary with -a is called on a property that is not a list, but histogram is made then histogram bins are specified incorrectly:

$abcd summary -p "volume" -q "cell" -a

Traceback (most recent call last):
  File "/home/tks32/programs/miniconda3/envs/tum_test/lib/python3.7/site-packages/numpy/lib/histograms.py", line 412, in _get_bin_edges
    n_equal_bins = operator.index(bins)
TypeError: 'NoneType' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tks32/programs/miniconda3/envs/tum_test/bin/abcd", line 8, in <module>
    sys.exit(main())
  File "/home/tks32/programs/miniconda3/envs/tum_test/lib/python3.7/site-packages/abcd/frontends/commandline/parser.py", line 121, in main
    callback_func(**kwargs)
  File "/home/tks32/programs/miniconda3/envs/tum_test/lib/python3.7/site-packages/abcd/frontends/commandline/decorators.py", line 15, in wrapper
    func(*args, config=config, **kwargs)
  File "/home/tks32/programs/miniconda3/envs/tum_test/lib/python3.7/site-packages/abcd/frontends/commandline/decorators.py", line 48, in wrapper
    func(*args, db=db, query=query, **kwargs)
  File "/home/tks32/programs/miniconda3/envs/tum_test/lib/python3.7/site-packages/abcd/frontends/commandline/commands.py", line 138, in summary
    data = db.hist(p, query=query, bins=bins, truncate=truncate)
  File "/home/tks32/programs/miniconda3/envs/tum_test/lib/python3.7/site-packages/abcd/backends/atoms_pymongo.py", line 401, in hist
    return histogram(name, data, **kwargs)
  File "/home/tks32/programs/miniconda3/envs/tum_test/lib/python3.7/site-packages/abcd/backends/atoms_pymongo.py", line 452, in histogram
    return _hist_float(name, data, bins)
  File "/home/tks32/programs/miniconda3/envs/tum_test/lib/python3.7/site-packages/abcd/backends/atoms_pymongo.py", line 476, in _hist_float
    hist, bin_edges = np.histogram(data, bins=bins)
  File "<__array_function__ internals>", line 6, in histogram
  File "/home/tks32/programs/miniconda3/envs/tum_test/lib/python3.7/site-packages/numpy/lib/histograms.py", line 785, in histogram
    bin_edges, uniform_bins = _get_bin_edges(a, bins, range, weights)
  File "/home/tks32/programs/miniconda3/envs/tum_test/lib/python3.7/site-packages/numpy/lib/histograms.py", line 415, in _get_bin_edges
    '`bins` must be an integer, a string, or an array')
TypeError: `bins` must be an integer, a string, or an array
stenczelt commented 3 years ago

basically -a is not valid for hisogram, so should just not be an option for histograms

gabor1 commented 2 years ago

I think this has been fixed already.