Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: absolute value in queries #90

Open
eszter137 opened this issue Mar 16, 2020 · 5 comments
Open

Question: absolute value in queries #90

eszter137 opened this issue Mar 16, 2020 · 5 comments
Labels
doc Add documentation for this

Comments

@eszter137
Copy link

I'd like to be able to do something like:

abcd summary -q "ABS(E_MP2_3b)>0.01"  -p "E_MP2_3b"

This would be useful when checking for the large differences between 2 calculation methods.

(It could be also solved by the OR operator but I haven't figured out how to use this yet - the following didn't work:

$ abcd summary -q "E_MP2_3b<-0.01" OR "E_MP2_3b>0.01" -p "E_MP2_3b"
$ abcd summary -q "E_MP2_3b<-0.01 OR E_MP2_3b>0.01" -p "E_MP2_3b"

)

@gabor1
Copy link
Contributor

gabor1 commented Mar 16, 2020 via email

@eszter137
Copy link
Author

I think this is something similar to your example but not working:

$ abcd summary -q '"E_MP2_3b<-0.01" or "E_MP2_3b>0.01"' -p "E_MP2_3b"
Traceback (most recent call last):
  File "/home/es732/miniconda3/bin/abcd", line 8, in <module>
    sys.exit(main())
  File "/home/es732/miniconda3/lib/python3.7/site-packages/abcd/frontends/commandline/parser.py", line 121, in main
    callback_func(**kwargs)
  File "/home/es732/miniconda3/lib/python3.7/site-packages/abcd/frontends/commandline/decorators.py", line 15, in wrapper
    func(*args, config=config, **kwargs)
  File "/home/es732/miniconda3/lib/python3.7/site-packages/abcd/frontends/commandline/decorators.py", line 39, in wrapper
    query_list.append(parser(q))
  File "/home/es732/miniconda3/lib/python3.7/site-packages/abcd/parsers/queries.py", line 136, in __call__
    return self.transformer.transform(self.parse(string))
  File "/home/es732/miniconda3/lib/python3.7/site-packages/abcd/parsers/queries.py", line 133, in parse
    return self.parser.parse(string)
  File "/home/es732/miniconda3/lib/python3.7/site-packages/lark/lark.py", line 308, in parse
    return self.parser.parse(text, start=start)
  File "/home/es732/miniconda3/lib/python3.7/site-packages/lark/parser_frontends.py", line 193, in parse
    return self._parse(text, start)
  File "/home/es732/miniconda3/lib/python3.7/site-packages/lark/parser_frontends.py", line 54, in _parse
    return self.parser.parse(input, start, *args)
  File "/home/es732/miniconda3/lib/python3.7/site-packages/lark/parsers/earley.py", line 292, in parse
    to_scan = self._parse(stream, columns, to_scan, start_symbol)
  File "/home/es732/miniconda3/lib/python3.7/site-packages/lark/parsers/xearley.py", line 137, in _parse
    to_scan = scan(i, to_scan)
  File "/home/es732/miniconda3/lib/python3.7/site-packages/lark/parsers/xearley.py", line 114, in scan
    raise UnexpectedCharacters(stream, i, text_line, text_column, {item.expect.name for item in to_scan}, set(to_scan))
lark.exceptions.UnexpectedCharacters: No terminal defined for 'o' at line 1 col 18

"E_MP2_3b<-0.01" or "E_MP2_3b>0.01"
                 ^

Expecting: {'IN'}

When changing the place of the quotes, I don't get any results:

$ abcd summary -q 'E_MP2_3b<"-0.01" or E_MP2_3b>"0.01"' -p "E_MP2_3b"

though there are definitely structures with either of the queries:

$ abcd summary -q 'E_MP2_3b<-0.01' -p "E_MP2_3b"
E_MP2_3b  count: 340 min: -2.8904e-01 med: -2.2580e-02 max: -1.0002e-02 std:  2.7190e-02 var: 7.3930e-04
                                           1 [-2.8904e-01,     -0.2611)
                                           0 [-2.6114e-01,     -0.2332)
                                           1 [-2.3323e-01,     -0.2053)
                                           1 [-2.0533e-01,     -0.1774)
                                           0 [-1.7743e-01,     -0.1495)
                                           3 [-1.4952e-01,     -0.1216)
                                           3 [-1.2162e-01,     -0.0937)
▉                                          9 [-9.3714e-02,     -0.0658)
                                           7 [-6.5810e-02,     -0.0379)
▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 315 [-3.7906e-02,     -0.0100)
$ abcd summary -q 'E_MP2_3b>0.01' -p "E_MP2_3b"
E_MP2_3b  count: 151 min:  1.0022e-02 med:  1.9160e-02 max:  4.0975e-01 std:  3.3383e-02 var: 1.1144e-03
▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 148 [ 1.0022e-02,      0.0500)
                                           1 [ 4.9995e-02,      0.0900)
                                           1 [ 8.9968e-02,      0.1299)
                                           0 [ 1.2994e-01,      0.1699)
                                           0 [ 1.6991e-01,      0.2099)
                                           0 [ 2.0989e-01,      0.2499)
                                           0 [ 2.4986e-01,      0.2898)
                                           0 [ 2.8983e-01,      0.3298)
                                           0 [ 3.2981e-01,      0.3698)
                                           1 [ 3.6978e-01,      0.4098)

@eszter137
Copy link
Author

it seems it handles numbers within quotes as strings, this won't result in any structures again:

$ abcd summary -q 'E_MP2_3b<"-0.01"' -p "E_MP2_3b"

@eszter137
Copy link
Author

ok, this version is working finally when removing the internal quotes:

$ abcd summary -q 'E_MP2_3b<-0.01 or E_MP2_3b>0.01' -p "E_MP2_3b"
E_MP2_3b  count: 491 min: -2.8904e-01 med: -9.7434e-03 max:  4.0975e-01 std:  3.5010e-02 var: 1.2257e-03
                                           1 [-2.8904e-01,     -0.2192)
                                           2 [-2.1916e-01,     -0.1493)
▉                                         11 [-1.4928e-01,     -0.0794)
▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 326 [-7.9404e-02,     -0.0095)
▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉                       148 [-9.5247e-03,      0.0604)
                                           2 [ 6.0355e-02,      0.1302)
                                           0 [ 1.3023e-01,      0.2001)
                                           0 [ 2.0011e-01,      0.2700)
                                           0 [ 2.6999e-01,      0.3399)
                                           1 [ 3.3987e-01,      0.4098)

@gabor1
Copy link
Contributor

gabor1 commented Mar 16, 2020 via email

@gabor1 gabor1 added the doc Add documentation for this label Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Add documentation for this
Projects
None yet
Development

No branches or pull requests

2 participants