-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"The aiida extension is already loaded. To reload it, use:\n", | ||
" %reload_ext aiida\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from aiida_aimall.controllers import G16FragController\n", | ||
"%load_ext aiida\n", | ||
"%aiida\n", | ||
"\n", | ||
"con = G16FragController(\n", | ||
" parent_group_label = \"foo\",\n", | ||
" group_label = \"fa\",\n", | ||
" code_label = \"foo\",\n", | ||
" max_concurrent = 1,\n", | ||
" g16_opt_params={}\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from aiida.orm import Group" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"g= Group(label = \"fi\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"True" | ||
] | ||
}, | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"g.is_stored" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<Group: 'fi' [type core], of user [email protected]>" | ||
] | ||
}, | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"g.store()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"f = Group(label=\"fi\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"False" | ||
] | ||
}, | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"g." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "aiida3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Tests for aiida_aimall.controllers""" | ||
import pytest | ||
from aiida.common.exceptions import NotExistent | ||
from aiida.orm import Group, Str | ||
|
||
# pylint:disable=no-name-in-module | ||
from aiida_aimall.controllers import G16FragController | ||
|
||
# pylint:disable=no-name-in-module | ||
from aiida_aimall.workchains import G16OptWorkchain # pylint:disable=no-name-in-module | ||
|
||
|
||
def test_unstored_parentgrouplabel_returns_error(): | ||
"""Test that error returns when groups are not defined""" | ||
with pytest.raises(NotExistent) as excinfo: | ||
G16FragController( | ||
parent_group_label="inp_frag", | ||
group_label="opt_workchain", | ||
max_concurrent=1, | ||
code_label="test.aimall.aimqb", | ||
g16_opt_params={}, | ||
) | ||
assert str(excinfo.value) == "No result was found" | ||
|
||
|
||
def test_g16frag_controller(): | ||
"""Test that error returns when groups are not defined""" | ||
gr = Group(label="opt_workchain") | ||
gr.store() | ||
gr = Group(label="inp_frag") | ||
gr.store() | ||
# with pytest.raises(NotExistent) as excinfo: | ||
con = G16FragController( | ||
parent_group_label="inp_frag", | ||
group_label="opt_workchain", | ||
max_concurrent=1, | ||
code_label="test.aimall.aimqb", | ||
g16_opt_params={}, | ||
) | ||
assert con.get_extra_unique_keys() == ("smiles",) | ||
struct = Str("C 0.0 0.0 0.0\nH -0.5,0.0,0.0\nC 0.5 0.0 0.0\n H 1.0, 0.0,0.0") | ||
struct.base.extras.set("smiles", "CtC") | ||
struct.store() | ||
ins, wfs = con.get_inputs_and_processclass_from_extras(extras_values="CtC") | ||
assert isinstance(ins, dict) | ||
assert "frag_label" in ins | ||
assert "fragment_dict" in ins | ||
assert "g16_code" in ins | ||
assert "g16_opt_params" in ins | ||
assert isinstance(wfs, G16OptWorkchain) |