From e31797cdac3492f44f9055ac0cc4f48752045c7a Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Tue, 25 Nov 2025 11:53:01 +0800 Subject: [PATCH 1/3] Rename python package name to apyds. --- CMakeLists.txt | 2 +- {pyds => apyds}/.gitignore | 0 {pyds => apyds}/__init__.py | 0 {pyds => apyds}/buffer_size.py | 0 {pyds => apyds}/common.py | 0 {pyds => apyds}/ds.cc | 0 {pyds => apyds}/ds.py | 0 {pyds => apyds}/item_t.py | 0 {pyds => apyds}/list_t.py | 0 {pyds => apyds}/rule_t.py | 0 {pyds => apyds}/search_t.py | 0 {pyds => apyds}/string_t.py | 0 {pyds => apyds}/term_t.py | 0 {pyds => apyds}/variable_t.py | 0 {pyds => apyds}/version.py | 0 examples/main.py | 10 +++--- pyproject.toml | 4 +-- tests/test_item.py | 36 +++++++++++----------- tests/test_list.py | 34 ++++++++++----------- tests/test_rule.py | 56 +++++++++++++++++----------------- tests/test_search.py | 34 ++++++++++----------- tests/test_string.py | 34 ++++++++++----------- tests/test_term.py | 50 +++++++++++++++--------------- tests/test_variable.py | 36 +++++++++++----------- 24 files changed, 147 insertions(+), 149 deletions(-) rename {pyds => apyds}/.gitignore (100%) rename {pyds => apyds}/__init__.py (100%) rename {pyds => apyds}/buffer_size.py (100%) rename {pyds => apyds}/common.py (100%) rename {pyds => apyds}/ds.cc (100%) rename {pyds => apyds}/ds.py (100%) rename {pyds => apyds}/item_t.py (100%) rename {pyds => apyds}/list_t.py (100%) rename {pyds => apyds}/rule_t.py (100%) rename {pyds => apyds}/search_t.py (100%) rename {pyds => apyds}/string_t.py (100%) rename {pyds => apyds}/term_t.py (100%) rename {pyds => apyds}/variable_t.py (100%) rename {pyds => apyds}/version.py (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a2288d..ceb1059 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ endforeach() find_package(pybind11) if(pybind11_FOUND) - pybind11_add_module(pyds ${CMAKE_CURRENT_SOURCE_DIR}/pyds/ds.cc) + pybind11_add_module(pyds ${CMAKE_CURRENT_SOURCE_DIR}/apyds/ds.cc) target_link_libraries(pyds PRIVATE ${PROJECT_NAME}) set_property(TARGET pyds PROPERTY INTERPROCEDURAL_OPTIMIZATION True) set_target_properties(pyds PROPERTIES OUTPUT_NAME _ds) diff --git a/pyds/.gitignore b/apyds/.gitignore similarity index 100% rename from pyds/.gitignore rename to apyds/.gitignore diff --git a/pyds/__init__.py b/apyds/__init__.py similarity index 100% rename from pyds/__init__.py rename to apyds/__init__.py diff --git a/pyds/buffer_size.py b/apyds/buffer_size.py similarity index 100% rename from pyds/buffer_size.py rename to apyds/buffer_size.py diff --git a/pyds/common.py b/apyds/common.py similarity index 100% rename from pyds/common.py rename to apyds/common.py diff --git a/pyds/ds.cc b/apyds/ds.cc similarity index 100% rename from pyds/ds.cc rename to apyds/ds.cc diff --git a/pyds/ds.py b/apyds/ds.py similarity index 100% rename from pyds/ds.py rename to apyds/ds.py diff --git a/pyds/item_t.py b/apyds/item_t.py similarity index 100% rename from pyds/item_t.py rename to apyds/item_t.py diff --git a/pyds/list_t.py b/apyds/list_t.py similarity index 100% rename from pyds/list_t.py rename to apyds/list_t.py diff --git a/pyds/rule_t.py b/apyds/rule_t.py similarity index 100% rename from pyds/rule_t.py rename to apyds/rule_t.py diff --git a/pyds/search_t.py b/apyds/search_t.py similarity index 100% rename from pyds/search_t.py rename to apyds/search_t.py diff --git a/pyds/string_t.py b/apyds/string_t.py similarity index 100% rename from pyds/string_t.py rename to apyds/string_t.py diff --git a/pyds/term_t.py b/apyds/term_t.py similarity index 100% rename from pyds/term_t.py rename to apyds/term_t.py diff --git a/pyds/variable_t.py b/apyds/variable_t.py similarity index 100% rename from pyds/variable_t.py rename to apyds/variable_t.py diff --git a/pyds/version.py b/apyds/version.py similarity index 100% rename from pyds/version.py rename to apyds/version.py diff --git a/examples/main.py b/examples/main.py index 5c89153..98249fd 100644 --- a/examples/main.py +++ b/examples/main.py @@ -1,5 +1,5 @@ import time -import pyds +import apyds def main(): @@ -7,8 +7,8 @@ def main(): temp_text_size = 1000 single_result_size = 10000 - pyds.buffer_size(temp_text_size) - search = pyds.Search(temp_data_size, single_result_size) + apyds.buffer_size(temp_text_size) + search = apyds.Search(temp_data_size, single_result_size) # P -> Q, P |- Q search.add("(`P -> `Q) `P `Q") @@ -22,12 +22,12 @@ def main(): # premise search.add("(! (! X))") - target = pyds.Rule("X") + target = apyds.Rule("X") while True: success = False - def callback(candidate: pyds.Rule) -> bool: + def callback(candidate: apyds.Rule) -> bool: if candidate == target: print("Found!") print(candidate) diff --git a/pyproject.toml b/pyproject.toml index dcefe24..179b9f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,13 +20,11 @@ license = "GPL-3.0-or-later" Repository = "https://github.com/USTC-KnowledgeComputingLab/ds.git" [tool.setuptools_scm] -version_file = "pyds/_version.py" +version_file = "apyds/_version.py" version_scheme = "no-guess-dev" fallback_version = "0.0.0" [tool.scikit-build] -wheel.packages = ["pyds"] -wheel.exclude = [".gitignore", "ds.cc"] metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" build.verbose = true diff --git a/tests/test_item.py b/tests/test_item.py index fb61847..e425393 100644 --- a/tests/test_item.py +++ b/tests/test_item.py @@ -1,64 +1,64 @@ import pytest import copy -import pyds +import apyds @pytest.fixture -def i() -> pyds.Item: - return pyds.Item("item") +def i() -> apyds.Item: + return apyds.Item("item") -def test_str(i: pyds.Item) -> None: +def test_str(i: apyds.Item) -> None: assert str(i) == "item" - with pyds.scoped_buffer_size(4): + with apyds.scoped_buffer_size(4): with pytest.raises(ValueError): str(i) -def test_repr(i: pyds.Item) -> None: +def test_repr(i: apyds.Item) -> None: assert repr(i) == "Item[item]" -def test_copy_hash_and_equality(i: pyds.Item) -> None: +def test_copy_hash_and_equality(i: apyds.Item) -> None: other = copy.copy(i) assert other == i assert hash(other) == hash(i) assert 1 != i -def test_create_from_same(i: pyds.Item) -> None: - item = pyds.Item(i) +def test_create_from_same(i: apyds.Item) -> None: + item = apyds.Item(i) assert str(item) == "item" with pytest.raises(ValueError): - item = pyds.Item(i, 100) + item = apyds.Item(i, 100) -def test_create_from_base(i: pyds.Item) -> None: - item = pyds.Item(i.value) +def test_create_from_base(i: apyds.Item) -> None: + item = apyds.Item(i.value) assert str(item) == "item" def test_create_from_text() -> None: - item = pyds.Item("item") + item = apyds.Item("item") assert str(item) == "item" # item never fails -def test_create_from_bytes(i: pyds.Item) -> None: - item = pyds.Item(i.data()) +def test_create_from_bytes(i: apyds.Item) -> None: + item = apyds.Item(i.data()) assert str(item) == "item" with pytest.raises(ValueError): - item = pyds.Item(i.data(), 100) + item = apyds.Item(i.data(), 100) def test_create_fail() -> None: with pytest.raises(TypeError): - item = pyds.Item(100) + item = apyds.Item(100) -def test_name(i: pyds.Item) -> None: +def test_name(i: apyds.Item) -> None: assert str(i.name) == "item" diff --git a/tests/test_list.py b/tests/test_list.py index 0affadf..03eab1f 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -1,63 +1,63 @@ import pytest import copy -import pyds +import apyds @pytest.fixture -def l() -> pyds.List: - return pyds.List("(a b c)") +def l() -> apyds.List: + return apyds.List("(a b c)") -def test_str(l: pyds.List) -> None: +def test_str(l: apyds.List) -> None: assert str(l) == "(a b c)" - with pyds.scoped_buffer_size(4): + with apyds.scoped_buffer_size(4): with pytest.raises(ValueError): str(l) -def test_repr(l: pyds.List) -> None: +def test_repr(l: apyds.List) -> None: assert repr(l) == "List[(a b c)]" -def test_copy_hash_and_equality(l: pyds.List) -> None: +def test_copy_hash_and_equality(l: apyds.List) -> None: other = copy.copy(l) assert other == l assert hash(other) == hash(l) assert 1 != l -def test_create_from_same(l: pyds.List) -> None: - list = pyds.List(l) +def test_create_from_same(l: apyds.List) -> None: + list = apyds.List(l) assert str(list) == "(a b c)" with pytest.raises(ValueError): - list = pyds.List(l, 100) + list = apyds.List(l, 100) -def test_create_from_base(l: pyds.List) -> None: - list = pyds.List(l.value) +def test_create_from_base(l: apyds.List) -> None: + list = apyds.List(l.value) assert str(list) == "(a b c)" def test_create_from_text() -> None: - list = pyds.List("(a b c)") + list = apyds.List("(a b c)") assert str(list) == "(a b c)" # list never fails -def test_create_from_bytes(l: pyds.List) -> None: - list = pyds.List(l.data()) +def test_create_from_bytes(l: apyds.List) -> None: + list = apyds.List(l.data()) assert str(list) == "(a b c)" with pytest.raises(ValueError): - list = pyds.List(l.data(), 100) + list = apyds.List(l.data(), 100) def test_create_fail() -> None: with pytest.raises(TypeError): - list = pyds.List(100) + list = apyds.List(100) def test_len(l) -> None: diff --git a/tests/test_rule.py b/tests/test_rule.py index f3dbf37..163015a 100644 --- a/tests/test_rule.py +++ b/tests/test_rule.py @@ -1,72 +1,72 @@ import pytest import copy -import pyds +import apyds @pytest.fixture -def r() -> pyds.Rule: - return pyds.Rule("(a b c)") +def r() -> apyds.Rule: + return apyds.Rule("(a b c)") -def test_str(r: pyds.Rule) -> None: +def test_str(r: apyds.Rule) -> None: assert str(r) == "----\n(a b c)\n" - with pyds.scoped_buffer_size(4): + with apyds.scoped_buffer_size(4): with pytest.raises(ValueError): str(r) -def test_repr(r: pyds.Rule) -> None: +def test_repr(r: apyds.Rule) -> None: assert repr(r) == "Rule[\n----\n(a b c)\n]" -def test_copy_hash_and_equality(r: pyds.Rule) -> None: +def test_copy_hash_and_equality(r: apyds.Rule) -> None: other = copy.copy(r) assert other == r assert hash(other) == hash(r) assert 1 != r -def test_create_from_same(r: pyds.Rule) -> None: - rule = pyds.Rule(r) +def test_create_from_same(r: apyds.Rule) -> None: + rule = apyds.Rule(r) assert str(rule) == "----\n(a b c)\n" with pytest.raises(ValueError): - rule = pyds.Rule(r, 100) + rule = apyds.Rule(r, 100) -def test_create_from_base(r: pyds.Rule) -> None: - rule = pyds.Rule(r.value) +def test_create_from_base(r: apyds.Rule) -> None: + rule = apyds.Rule(r.value) assert str(rule) == "----\n(a b c)\n" def test_create_from_text() -> None: - rule = pyds.Rule("(a b c)") + rule = apyds.Rule("(a b c)") assert str(rule) == "----\n(a b c)\n" # rule never fails -def test_create_from_bytes(r: pyds.Rule) -> None: - rule = pyds.Rule(r.data()) +def test_create_from_bytes(r: apyds.Rule) -> None: + rule = apyds.Rule(r.data()) assert str(rule) == "----\n(a b c)\n" with pytest.raises(ValueError): - rule = pyds.Rule(r.data(), 100) + rule = apyds.Rule(r.data(), 100) def test_create_fail() -> None: with pytest.raises(TypeError): - rule = pyds.Rule(100) + rule = apyds.Rule(100) def test_len() -> None: - r = pyds.Rule("(p -> q)\np\nq\n") + r = apyds.Rule("(p -> q)\np\nq\n") assert len(r) == 2 def test_getitem() -> None: - r = pyds.Rule("(p -> q)\np\nq\n") + r = apyds.Rule("(p -> q)\np\nq\n") assert str(r[0]) == "(p -> q)" assert str(r[1]) == "p" @@ -78,28 +78,28 @@ def test_getitem() -> None: def test_conclusion() -> None: - r = pyds.Rule("(p -> q)\np\nq\n") + r = apyds.Rule("(p -> q)\np\nq\n") assert str(r.conclusion) == "q" def test_ground_simple() -> None: - a = pyds.Rule("`a") - b = pyds.Rule("((`a b))") + a = apyds.Rule("`a") + b = apyds.Rule("((`a b))") assert str(a // b) == "----\nb\n" - assert a // pyds.Rule("((`a b c d e))") is None + assert a // apyds.Rule("((`a b c d e))") is None def test_ground_scope() -> None: - a = pyds.Rule("`a") - b = pyds.Rule("((x y `a `b) (y x `b `c))") + a = apyds.Rule("`a") + b = apyds.Rule("((x y `a `b) (y x `b `c))") assert str(a.ground(b, "x")) == "----\n`c\n" def test_match() -> None: - mp = pyds.Rule("(`p -> `q)\n`p\n`q\n") - pq = pyds.Rule("((! (! `x)) -> `x)") + mp = apyds.Rule("(`p -> `q)\n`p\n`q\n") + pq = apyds.Rule("((! (! `x)) -> `x)") assert str(mp @ pq) == "(! (! `x))\n----------\n`x\n" - fail = pyds.Rule("`q <- `p") + fail = apyds.Rule("`q <- `p") assert mp @ fail is None diff --git a/tests/test_search.py b/tests/test_search.py index a60fe46..a2d76cc 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -1,35 +1,35 @@ import pytest -import pyds +import apyds @pytest.fixture -def search() -> pyds.Search: - return pyds.Search(100, 1000) +def search() -> apyds.Search: + return apyds.Search(100, 1000) -def test_reset_parameters(search: pyds.Search) -> None: +def test_reset_parameters(search: apyds.Search) -> None: search.set_limit_size(50) search.set_buffer_size(500) search.reset() -def test_add_rule_and_fact(search: pyds.Search) -> None: +def test_add_rule_and_fact(search: apyds.Search) -> None: assert search.add("test rule") assert search.add("fact") -def test_add_fail(search: pyds.Search) -> None: +def test_add_fail(search: apyds.Search) -> None: search.set_limit_size(10) assert not search.add("a-long-facts-that-exceeds-limit") -def test_execute_single(search: pyds.Search) -> None: +def test_execute_single(search: apyds.Search) -> None: search.add("p q") search.add("p") - target = pyds.Rule("q") + target = apyds.Rule("q") success = False - def callback(rule: pyds.Rule) -> bool: + def callback(rule: apyds.Rule) -> bool: nonlocal success if rule == target: success = True @@ -41,22 +41,22 @@ def callback(rule: pyds.Rule) -> bool: assert success -def test_execute_long(search: pyds.Search) -> None: +def test_execute_long(search: apyds.Search) -> None: search.add("p q r") search.add("p") search.add("q") - target1 = pyds.Rule("q r") - target2 = pyds.Rule("r") + target1 = apyds.Rule("q r") + target2 = apyds.Rule("r") success1 = False success2 = False - def callback1(rule: pyds.Rule) -> bool: + def callback1(rule: apyds.Rule) -> bool: if rule == target1: nonlocal success1 success1 = True return False - def callback2(rule: pyds.Rule) -> bool: + def callback2(rule: apyds.Rule) -> bool: if rule == target2: nonlocal success2 success2 = True @@ -70,7 +70,7 @@ def callback2(rule: pyds.Rule) -> bool: assert success2 -def test_execute_duplicated_fact(search: pyds.Search) -> None: +def test_execute_duplicated_fact(search: apyds.Search) -> None: search.add("p r") search.add("q r") search.add("p") @@ -79,7 +79,7 @@ def test_execute_duplicated_fact(search: pyds.Search) -> None: assert count == 1 -def test_execute_duplicate_rule(search: pyds.Search) -> None: +def test_execute_duplicate_rule(search: apyds.Search) -> None: search.add("p r s") search.add("p r s") search.add("p") @@ -88,7 +88,7 @@ def test_execute_duplicate_rule(search: pyds.Search) -> None: assert count == 1 -def test_execute_exceed(search: pyds.Search) -> None: +def test_execute_exceed(search: apyds.Search) -> None: search.set_limit_size(100) assert search.add("(2 `x) (`x `x`)") assert search.add("(2 a-very-long-fact-that-exceeds-half-of-the-limit-size)") diff --git a/tests/test_string.py b/tests/test_string.py index 7f384ae..8d8d3c2 100644 --- a/tests/test_string.py +++ b/tests/test_string.py @@ -1,60 +1,60 @@ import pytest import copy -import pyds +import apyds @pytest.fixture -def s() -> pyds.String: - return pyds.String("string") +def s() -> apyds.String: + return apyds.String("string") -def test_str(s: pyds.String) -> None: +def test_str(s: apyds.String) -> None: assert str(s) == "string" - with pyds.scoped_buffer_size(4): + with apyds.scoped_buffer_size(4): with pytest.raises(ValueError): str(s) -def test_repr(s: pyds.String) -> None: +def test_repr(s: apyds.String) -> None: assert repr(s) == "String[string]" -def test_copy_hash_and_equality(s: pyds.String) -> None: +def test_copy_hash_and_equality(s: apyds.String) -> None: other = copy.copy(s) assert other == s assert hash(other) == hash(s) assert 1 != s -def test_create_from_same(s: pyds.String) -> None: - string = pyds.String(s) +def test_create_from_same(s: apyds.String) -> None: + string = apyds.String(s) assert str(string) == "string" with pytest.raises(ValueError): - string = pyds.String(s, 100) + string = apyds.String(s, 100) -def test_create_from_base(s: pyds.String) -> None: - string = pyds.String(s.value) +def test_create_from_base(s: apyds.String) -> None: + string = apyds.String(s.value) assert str(string) == "string" def test_create_from_text() -> None: - string = pyds.String("string") + string = apyds.String("string") assert str(string) == "string" # string never fails -def test_create_from_bytes(s: pyds.String) -> None: - string = pyds.String(s.data()) +def test_create_from_bytes(s: apyds.String) -> None: + string = apyds.String(s.data()) assert str(string) == "string" with pytest.raises(ValueError): - string = pyds.String(s.data(), 100) + string = apyds.String(s.data(), 100) def test_create_fail() -> None: with pytest.raises(TypeError): - string = pyds.String(100) + string = apyds.String(100) diff --git a/tests/test_term.py b/tests/test_term.py index f65e9ae..858caaf 100644 --- a/tests/test_term.py +++ b/tests/test_term.py @@ -1,82 +1,82 @@ import pytest import copy -import pyds +import apyds @pytest.fixture -def t() -> pyds.Term: - return pyds.Term("(a b c)") +def t() -> apyds.Term: + return apyds.Term("(a b c)") -def test_str(t: pyds.Term) -> None: +def test_str(t: apyds.Term) -> None: assert str(t) == "(a b c)" - with pyds.scoped_buffer_size(4): + with apyds.scoped_buffer_size(4): with pytest.raises(ValueError): str(t) -def test_repr(t: pyds.Term) -> None: +def test_repr(t: apyds.Term) -> None: assert repr(t) == "Term[(a b c)]" -def test_copy_hash_and_equality(t: pyds.Term) -> None: +def test_copy_hash_and_equality(t: apyds.Term) -> None: other = copy.copy(t) assert other == t assert hash(other) == hash(t) assert 1 != t -def test_create_from_same(t: pyds.Term) -> None: - term = pyds.Term(t) +def test_create_from_same(t: apyds.Term) -> None: + term = apyds.Term(t) assert str(term) == "(a b c)" with pytest.raises(ValueError): - term = pyds.Term(t, 100) + term = apyds.Term(t, 100) -def test_create_from_base(t: pyds.Term) -> None: - term = pyds.Term(t.value) +def test_create_from_base(t: apyds.Term) -> None: + term = apyds.Term(t.value) assert str(term) == "(a b c)" def test_create_from_text() -> None: - term = pyds.Term("(a b c)") + term = apyds.Term("(a b c)") assert str(term) == "(a b c)" # term never fails -def test_create_from_bytes(t: pyds.Term) -> None: - term = pyds.Term(t.data()) +def test_create_from_bytes(t: apyds.Term) -> None: + term = apyds.Term(t.data()) assert str(term) == "(a b c)" with pytest.raises(ValueError): - term = pyds.Term(t.data(), 100) + term = apyds.Term(t.data(), 100) def test_create_fail() -> None: with pytest.raises(TypeError): - term = pyds.Term(100) + term = apyds.Term(100) def test_term() -> None: - assert isinstance(pyds.Term("()").term, pyds.List) - assert isinstance(pyds.Term("a").term, pyds.Item) - assert isinstance(pyds.Term("`a").term, pyds.Variable) + assert isinstance(apyds.Term("()").term, apyds.List) + assert isinstance(apyds.Term("a").term, apyds.Item) + assert isinstance(apyds.Term("`a").term, apyds.Variable) # it is hard to create a invalid term def test_ground_simple() -> None: - a = pyds.Term("`a") - b = pyds.Term("((`a b))") + a = apyds.Term("`a") + b = apyds.Term("((`a b))") assert str(a // b) == "b" - assert a // pyds.Term("((`a b c d e))") is None + assert a // apyds.Term("((`a b c d e))") is None def test_ground_scope() -> None: - a = pyds.Term("`a") - b = pyds.Term("((x y `a `b) (y x `b `c))") + a = apyds.Term("`a") + b = apyds.Term("((x y `a `b) (y x `b `c))") assert str(a.ground(b, "x")) == "`c" diff --git a/tests/test_variable.py b/tests/test_variable.py index f5028cb..b4cbe07 100644 --- a/tests/test_variable.py +++ b/tests/test_variable.py @@ -1,64 +1,64 @@ import pytest import copy -import pyds +import apyds @pytest.fixture -def v() -> pyds.Variable: - return pyds.Variable("`variable") +def v() -> apyds.Variable: + return apyds.Variable("`variable") -def test_str(v: pyds.Variable) -> None: +def test_str(v: apyds.Variable) -> None: assert str(v) == "`variable" - with pyds.scoped_buffer_size(4): + with apyds.scoped_buffer_size(4): with pytest.raises(ValueError): str(v) -def test_repr(v: pyds.Variable) -> None: +def test_repr(v: apyds.Variable) -> None: assert repr(v) == "Variable[`variable]" -def test_copy_hash_and_equality(v: pyds.Variable) -> None: +def test_copy_hash_and_equality(v: apyds.Variable) -> None: other = copy.copy(v) assert other == v assert hash(other) == hash(v) assert 1 != v -def test_create_from_same(v: pyds.Variable) -> None: - variable = pyds.Variable(v) +def test_create_from_same(v: apyds.Variable) -> None: + variable = apyds.Variable(v) assert str(variable) == "`variable" with pytest.raises(ValueError): - variable = pyds.Variable(v, 100) + variable = apyds.Variable(v, 100) -def test_create_from_base(v: pyds.Variable) -> None: - variable = pyds.Variable(v.value) +def test_create_from_base(v: apyds.Variable) -> None: + variable = apyds.Variable(v.value) assert str(variable) == "`variable" def test_create_from_text() -> None: - variable = pyds.Variable("`variable") + variable = apyds.Variable("`variable") assert str(variable) == "`variable" # variable never fails -def test_create_from_bytes(v: pyds.Variable) -> None: - variable = pyds.Variable(v.data()) +def test_create_from_bytes(v: apyds.Variable) -> None: + variable = apyds.Variable(v.data()) assert str(variable) == "`variable" with pytest.raises(ValueError): - variable = pyds.Variable(v.data(), 100) + variable = apyds.Variable(v.data(), 100) def test_create_fail() -> None: with pytest.raises(TypeError): - variable = pyds.Variable(100) + variable = apyds.Variable(100) -def test_name(v: pyds.Variable) -> None: +def test_name(v: apyds.Variable) -> None: assert str(v.name) == "variable" From 827367341f216e06faefc9c91c72bf48608512ac Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Tue, 25 Nov 2025 11:54:01 +0800 Subject: [PATCH 2/3] Update README for apyds. --- README.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1cf03ee..05edfca 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A deductive system for logical inference, implemented in C++. The library provid ## Architecture - **C++ Core**: The core implementation in `src/` and `include/ds/` provides the fundamental data structures and algorithms -- **Python Bindings**: Built with pybind11, wrapping the C++ core (see `pyds/`) +- **Python Bindings**: Built with pybind11, wrapping the C++ core (see `apyds/`) - **TypeScript/JavaScript Bindings**: Built with Emscripten, compiling C++ to WebAssembly (see `tsds/`) ## Features @@ -38,12 +38,6 @@ The Python package wraps the C++ core via pybind11. pip install apyds ``` -Then import as `pyds`: - -```python -import pyds -``` - Requires Python 3.10-3.14. ### C++ (Core Library) @@ -102,10 +96,10 @@ while (true) { ### Python Example ```python -import pyds +import apyds # Create a search engine -search = pyds.Search(1000, 10000) +search = apyds.Search(1000, 10000) # Modus ponens: P -> Q, P |- Q search.add("(`P -> `Q) `P `Q") @@ -120,7 +114,7 @@ search.add("(((! `p) -> (! `q)) -> (`q -> `p))") search.add("(! (! X))") # Target: X (double negation elimination) -target = pyds.Rule("X") +target = apyds.Rule("X") # Execute search until target is found while True: From 0b4d5804a2d2c1ee746cdd7664e4ae719daf3a02 Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Tue, 25 Nov 2025 11:55:39 +0800 Subject: [PATCH 3/3] Fix cmake for renaming of python package. --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ceb1059..b02fd18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,11 +18,11 @@ endforeach() find_package(pybind11) if(pybind11_FOUND) - pybind11_add_module(pyds ${CMAKE_CURRENT_SOURCE_DIR}/apyds/ds.cc) - target_link_libraries(pyds PRIVATE ${PROJECT_NAME}) - set_property(TARGET pyds PROPERTY INTERPROCEDURAL_OPTIMIZATION True) - set_target_properties(pyds PROPERTIES OUTPUT_NAME _ds) - install(TARGETS pyds DESTINATION pyds) + pybind11_add_module(apyds ${CMAKE_CURRENT_SOURCE_DIR}/apyds/ds.cc) + target_link_libraries(apyds PRIVATE ${PROJECT_NAME}) + set_property(TARGET apyds PROPERTY INTERPROCEDURAL_OPTIMIZATION True) + set_target_properties(apyds PROPERTIES OUTPUT_NAME _ds) + install(TARGETS apyds DESTINATION apyds) else() message(STATUS "pybind11 not found, Python bindings will not be built.") endif()