Skip to content

Commit

Permalink
fix test errors introduced by #35
Browse files Browse the repository at this point in the history
  • Loading branch information
Binh Vu committed Nov 8, 2023
1 parent 83f8c00 commit 27cc2e6
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 197 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
pip install dist/*cp38*.whl
pip install pytest
mv drepr drepr2
pytest -xvs python/tests
pytest -xvs tests
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -66,8 +66,8 @@ jobs:
# ls dist
# bash -c 'pwd; pip install dist/*cp38*.whl'
# pip install pytest
# mv python/drepr python/drepr2
# pytest -xvs python/tests
# mv drepr drepr2
# pytest -xvs tests
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -96,8 +96,8 @@ jobs:
run: |
pip install dist/*cp38*.whl
pip install pytest
mv python/drepr python/drepr2
pytest -xvs python/tests
mv drepr drepr2
pytest -xvs tests
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion drepr/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def complete_description(ds_model: DRepr) -> "CompleteDescription":
for n in sm.iter_class_nodes():
class_id = engine_model.sm_node_idmap[n.node_id]
aidx = extra_info["class2subj"][class_id]
if aidx == -1:
if aidx is None:
# just need to pick a random literal node
for e in sm.iter_outgoing_edges(n.node_id):
if isinstance(sm.nodes[e.target_id], LiteralNode):
Expand Down
18 changes: 16 additions & 2 deletions src/python/complete_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn complete_description(py: Python<'_>, args: &[u8]) -> PyResult<PyObject> {
} else {
ClassMapPlan::find_subject(&desc, class_id, &class2subj, &inference)
};
class2subj.push(subj);
class2subj[class_id] = subj;
}

// generate alignments between subject and other data attributes
Expand Down Expand Up @@ -68,7 +68,21 @@ pub fn complete_description(py: Python<'_>, args: &[u8]) -> PyResult<PyObject> {
}

let dict = PyDict::new(py);
dict.set_item("class2subj", class2subj).unwrap();
dict
.set_item(
"class2subj",
class2subj
.into_iter()
.map(|subj| {
if subj == desc.attributes.len() {
None
} else {
Some(subj)
}
})
.collect::<Vec<_>>(),
)
.unwrap();
dict.set_item("aligned_funcs", aligned_funcs).unwrap();
Ok(dict.into())
}
Expand Down
4 changes: 2 additions & 2 deletions tests/python/engine/test_complete_description.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Dict, Tuple, Callable, Any, Optional
from typing import Any, Callable, Dict, List, Optional, Tuple

from drepr import DRepr, outputs
from drepr.engine import complete_description
Expand All @@ -7,8 +7,8 @@
def test_complete_description(d_s04: DRepr):
model2subjects = {
"d_s04": {
("mint:Variable:2", "dnode:Albedo_inst"),
("mint:Variable:1", "dnode:Rainf_f_tavg"),
("mint:Variable:2", "dnode:Albedo_inst")
}
}

Expand Down
Loading

0 comments on commit 27cc2e6

Please sign in to comment.