From 986a8598ae72d769095b4fb08bc74978c5089197 Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Fri, 16 Aug 2024 16:50:53 -0600 Subject: [PATCH 01/15] Generated directory + module tree for unit tests --- polymerist/tests/test_analysis/__init__.py | 1 + polymerist/tests/test_genutils/__init__.py | 1 + polymerist/tests/test_genutils/test_decorators/__init__.py | 1 + polymerist/tests/test_genutils/test_fileutils/__init__.py | 1 + .../tests/test_genutils/test_fileutils/test_jsonio/__init__.py | 1 + polymerist/tests/test_genutils/test_logutils/__init__.py | 1 + polymerist/tests/test_genutils/test_sequences/__init__.py | 1 + .../test_genutils/test_sequences/test_discernment/__init__.py | 1 + .../test_genutils/test_sequences/test_similarity/__init__.py | 1 + polymerist/tests/test_genutils/test_textual/__init__.py | 1 + polymerist/tests/test_genutils/test_treetools/__init__.py | 1 + polymerist/tests/test_genutils/test_typetools/__init__.py | 1 + polymerist/tests/test_graphics/__init__.py | 1 + polymerist/tests/test_maths/__init__.py | 1 + polymerist/tests/test_maths/test_combinatorics/__init__.py | 1 + polymerist/tests/test_maths/test_fractions/__init__.py | 1 + polymerist/tests/test_maths/test_greek/__init__.py | 1 + polymerist/tests/test_maths/test_lattices/__init__.py | 1 + polymerist/tests/test_maths/test_linearalg/__init__.py | 1 + polymerist/tests/test_maths/test_numbersys/__init__.py | 1 + polymerist/tests/test_mdtools/__init__.py | 1 + polymerist/tests/test_mdtools/test_lammpstools/__init__.py | 1 + polymerist/tests/test_mdtools/test_openfftools/__init__.py | 1 + .../test_mdtools/test_openfftools/test_partialcharge/__init__.py | 1 + .../test_partialcharge/test_rescharge/__init__.py | 1 + .../test_mdtools/test_openfftools/test_solvation/__init__.py | 1 + .../test_openfftools/test_solvation/test_solvents/__init__.py | 1 + polymerist/tests/test_mdtools/test_openmmtools/__init__.py | 1 + polymerist/tests/test_polymers/__init__.py | 1 + polymerist/tests/test_polymers/test_monomers/__init__.py | 1 + polymerist/tests/test_polymers/test_smidgelib/__init__.py | 1 + polymerist/tests/test_rdutils/__init__.py | 1 + polymerist/tests/test_rdutils/test_bonding/__init__.py | 1 + polymerist/tests/test_rdutils/test_labeling/__init__.py | 1 + polymerist/tests/test_rdutils/test_rdcoords/__init__.py | 1 + polymerist/tests/test_rdutils/test_reactions/__init__.py | 1 + polymerist/tests/test_smileslib/__init__.py | 1 + polymerist/tests/test_smileslib/test_functgroups/__init__.py | 1 + polymerist/tests/test_tests/__init__.py | 1 + polymerist/tests/test_unitutils/__init__.py | 1 + 40 files changed, 40 insertions(+) create mode 100644 polymerist/tests/test_analysis/__init__.py create mode 100644 polymerist/tests/test_genutils/__init__.py create mode 100644 polymerist/tests/test_genutils/test_decorators/__init__.py create mode 100644 polymerist/tests/test_genutils/test_fileutils/__init__.py create mode 100644 polymerist/tests/test_genutils/test_fileutils/test_jsonio/__init__.py create mode 100644 polymerist/tests/test_genutils/test_logutils/__init__.py create mode 100644 polymerist/tests/test_genutils/test_sequences/__init__.py create mode 100644 polymerist/tests/test_genutils/test_sequences/test_discernment/__init__.py create mode 100644 polymerist/tests/test_genutils/test_sequences/test_similarity/__init__.py create mode 100644 polymerist/tests/test_genutils/test_textual/__init__.py create mode 100644 polymerist/tests/test_genutils/test_treetools/__init__.py create mode 100644 polymerist/tests/test_genutils/test_typetools/__init__.py create mode 100644 polymerist/tests/test_graphics/__init__.py create mode 100644 polymerist/tests/test_maths/__init__.py create mode 100644 polymerist/tests/test_maths/test_combinatorics/__init__.py create mode 100644 polymerist/tests/test_maths/test_fractions/__init__.py create mode 100644 polymerist/tests/test_maths/test_greek/__init__.py create mode 100644 polymerist/tests/test_maths/test_lattices/__init__.py create mode 100644 polymerist/tests/test_maths/test_linearalg/__init__.py create mode 100644 polymerist/tests/test_maths/test_numbersys/__init__.py create mode 100644 polymerist/tests/test_mdtools/__init__.py create mode 100644 polymerist/tests/test_mdtools/test_lammpstools/__init__.py create mode 100644 polymerist/tests/test_mdtools/test_openfftools/__init__.py create mode 100644 polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/__init__.py create mode 100644 polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/test_rescharge/__init__.py create mode 100644 polymerist/tests/test_mdtools/test_openfftools/test_solvation/__init__.py create mode 100644 polymerist/tests/test_mdtools/test_openfftools/test_solvation/test_solvents/__init__.py create mode 100644 polymerist/tests/test_mdtools/test_openmmtools/__init__.py create mode 100644 polymerist/tests/test_polymers/__init__.py create mode 100644 polymerist/tests/test_polymers/test_monomers/__init__.py create mode 100644 polymerist/tests/test_polymers/test_smidgelib/__init__.py create mode 100644 polymerist/tests/test_rdutils/__init__.py create mode 100644 polymerist/tests/test_rdutils/test_bonding/__init__.py create mode 100644 polymerist/tests/test_rdutils/test_labeling/__init__.py create mode 100644 polymerist/tests/test_rdutils/test_rdcoords/__init__.py create mode 100644 polymerist/tests/test_rdutils/test_reactions/__init__.py create mode 100644 polymerist/tests/test_smileslib/__init__.py create mode 100644 polymerist/tests/test_smileslib/test_functgroups/__init__.py create mode 100644 polymerist/tests/test_tests/__init__.py create mode 100644 polymerist/tests/test_unitutils/__init__.py diff --git a/polymerist/tests/test_analysis/__init__.py b/polymerist/tests/test_analysis/__init__.py new file mode 100644 index 0000000..ba40be5 --- /dev/null +++ b/polymerist/tests/test_analysis/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `analysis` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/__init__.py b/polymerist/tests/test_genutils/__init__.py new file mode 100644 index 0000000..954d19f --- /dev/null +++ b/polymerist/tests/test_genutils/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `genutils` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/test_decorators/__init__.py b/polymerist/tests/test_genutils/test_decorators/__init__.py new file mode 100644 index 0000000..1573261 --- /dev/null +++ b/polymerist/tests/test_genutils/test_decorators/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `decorators` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/test_fileutils/__init__.py b/polymerist/tests/test_genutils/test_fileutils/__init__.py new file mode 100644 index 0000000..7f49e8c --- /dev/null +++ b/polymerist/tests/test_genutils/test_fileutils/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `fileutils` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/test_fileutils/test_jsonio/__init__.py b/polymerist/tests/test_genutils/test_fileutils/test_jsonio/__init__.py new file mode 100644 index 0000000..6bf0714 --- /dev/null +++ b/polymerist/tests/test_genutils/test_fileutils/test_jsonio/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `jsonio` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/test_logutils/__init__.py b/polymerist/tests/test_genutils/test_logutils/__init__.py new file mode 100644 index 0000000..88e053e --- /dev/null +++ b/polymerist/tests/test_genutils/test_logutils/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `logutils` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/test_sequences/__init__.py b/polymerist/tests/test_genutils/test_sequences/__init__.py new file mode 100644 index 0000000..c754f33 --- /dev/null +++ b/polymerist/tests/test_genutils/test_sequences/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `sequences` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/test_sequences/test_discernment/__init__.py b/polymerist/tests/test_genutils/test_sequences/test_discernment/__init__.py new file mode 100644 index 0000000..6cee0a6 --- /dev/null +++ b/polymerist/tests/test_genutils/test_sequences/test_discernment/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `discernment` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/test_sequences/test_similarity/__init__.py b/polymerist/tests/test_genutils/test_sequences/test_similarity/__init__.py new file mode 100644 index 0000000..dea3ddf --- /dev/null +++ b/polymerist/tests/test_genutils/test_sequences/test_similarity/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `similarity` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/test_textual/__init__.py b/polymerist/tests/test_genutils/test_textual/__init__.py new file mode 100644 index 0000000..08f7241 --- /dev/null +++ b/polymerist/tests/test_genutils/test_textual/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `textual` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/test_treetools/__init__.py b/polymerist/tests/test_genutils/test_treetools/__init__.py new file mode 100644 index 0000000..55230fd --- /dev/null +++ b/polymerist/tests/test_genutils/test_treetools/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `treetools` package''' \ No newline at end of file diff --git a/polymerist/tests/test_genutils/test_typetools/__init__.py b/polymerist/tests/test_genutils/test_typetools/__init__.py new file mode 100644 index 0000000..30fee19 --- /dev/null +++ b/polymerist/tests/test_genutils/test_typetools/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `typetools` package''' \ No newline at end of file diff --git a/polymerist/tests/test_graphics/__init__.py b/polymerist/tests/test_graphics/__init__.py new file mode 100644 index 0000000..245b172 --- /dev/null +++ b/polymerist/tests/test_graphics/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `graphics` package''' \ No newline at end of file diff --git a/polymerist/tests/test_maths/__init__.py b/polymerist/tests/test_maths/__init__.py new file mode 100644 index 0000000..3a4fe3d --- /dev/null +++ b/polymerist/tests/test_maths/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `maths` package''' \ No newline at end of file diff --git a/polymerist/tests/test_maths/test_combinatorics/__init__.py b/polymerist/tests/test_maths/test_combinatorics/__init__.py new file mode 100644 index 0000000..cd69607 --- /dev/null +++ b/polymerist/tests/test_maths/test_combinatorics/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `combinatorics` package''' \ No newline at end of file diff --git a/polymerist/tests/test_maths/test_fractions/__init__.py b/polymerist/tests/test_maths/test_fractions/__init__.py new file mode 100644 index 0000000..6f0d592 --- /dev/null +++ b/polymerist/tests/test_maths/test_fractions/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `fractions` package''' \ No newline at end of file diff --git a/polymerist/tests/test_maths/test_greek/__init__.py b/polymerist/tests/test_maths/test_greek/__init__.py new file mode 100644 index 0000000..2abe4a8 --- /dev/null +++ b/polymerist/tests/test_maths/test_greek/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `greek` package''' \ No newline at end of file diff --git a/polymerist/tests/test_maths/test_lattices/__init__.py b/polymerist/tests/test_maths/test_lattices/__init__.py new file mode 100644 index 0000000..d23663d --- /dev/null +++ b/polymerist/tests/test_maths/test_lattices/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `lattices` package''' \ No newline at end of file diff --git a/polymerist/tests/test_maths/test_linearalg/__init__.py b/polymerist/tests/test_maths/test_linearalg/__init__.py new file mode 100644 index 0000000..79f09b2 --- /dev/null +++ b/polymerist/tests/test_maths/test_linearalg/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `linearalg` package''' \ No newline at end of file diff --git a/polymerist/tests/test_maths/test_numbersys/__init__.py b/polymerist/tests/test_maths/test_numbersys/__init__.py new file mode 100644 index 0000000..3c95aa1 --- /dev/null +++ b/polymerist/tests/test_maths/test_numbersys/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `numbersys` package''' \ No newline at end of file diff --git a/polymerist/tests/test_mdtools/__init__.py b/polymerist/tests/test_mdtools/__init__.py new file mode 100644 index 0000000..88e220b --- /dev/null +++ b/polymerist/tests/test_mdtools/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `mdtools` package''' \ No newline at end of file diff --git a/polymerist/tests/test_mdtools/test_lammpstools/__init__.py b/polymerist/tests/test_mdtools/test_lammpstools/__init__.py new file mode 100644 index 0000000..f105c90 --- /dev/null +++ b/polymerist/tests/test_mdtools/test_lammpstools/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `lammpstools` package''' \ No newline at end of file diff --git a/polymerist/tests/test_mdtools/test_openfftools/__init__.py b/polymerist/tests/test_mdtools/test_openfftools/__init__.py new file mode 100644 index 0000000..d2e4e9d --- /dev/null +++ b/polymerist/tests/test_mdtools/test_openfftools/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `openfftools` package''' \ No newline at end of file diff --git a/polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/__init__.py b/polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/__init__.py new file mode 100644 index 0000000..837792d --- /dev/null +++ b/polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `partialcharge` package''' \ No newline at end of file diff --git a/polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/test_rescharge/__init__.py b/polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/test_rescharge/__init__.py new file mode 100644 index 0000000..af9bb9f --- /dev/null +++ b/polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/test_rescharge/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `rescharge` package''' \ No newline at end of file diff --git a/polymerist/tests/test_mdtools/test_openfftools/test_solvation/__init__.py b/polymerist/tests/test_mdtools/test_openfftools/test_solvation/__init__.py new file mode 100644 index 0000000..6f5bcbc --- /dev/null +++ b/polymerist/tests/test_mdtools/test_openfftools/test_solvation/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `solvation` package''' \ No newline at end of file diff --git a/polymerist/tests/test_mdtools/test_openfftools/test_solvation/test_solvents/__init__.py b/polymerist/tests/test_mdtools/test_openfftools/test_solvation/test_solvents/__init__.py new file mode 100644 index 0000000..e7e7c7b --- /dev/null +++ b/polymerist/tests/test_mdtools/test_openfftools/test_solvation/test_solvents/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `solvents` package''' \ No newline at end of file diff --git a/polymerist/tests/test_mdtools/test_openmmtools/__init__.py b/polymerist/tests/test_mdtools/test_openmmtools/__init__.py new file mode 100644 index 0000000..44b2ca5 --- /dev/null +++ b/polymerist/tests/test_mdtools/test_openmmtools/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `openmmtools` package''' \ No newline at end of file diff --git a/polymerist/tests/test_polymers/__init__.py b/polymerist/tests/test_polymers/__init__.py new file mode 100644 index 0000000..7622def --- /dev/null +++ b/polymerist/tests/test_polymers/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `polymers` package''' \ No newline at end of file diff --git a/polymerist/tests/test_polymers/test_monomers/__init__.py b/polymerist/tests/test_polymers/test_monomers/__init__.py new file mode 100644 index 0000000..c8f2d69 --- /dev/null +++ b/polymerist/tests/test_polymers/test_monomers/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `monomers` package''' \ No newline at end of file diff --git a/polymerist/tests/test_polymers/test_smidgelib/__init__.py b/polymerist/tests/test_polymers/test_smidgelib/__init__.py new file mode 100644 index 0000000..a66a8af --- /dev/null +++ b/polymerist/tests/test_polymers/test_smidgelib/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `smidgelib` package''' \ No newline at end of file diff --git a/polymerist/tests/test_rdutils/__init__.py b/polymerist/tests/test_rdutils/__init__.py new file mode 100644 index 0000000..c518ab5 --- /dev/null +++ b/polymerist/tests/test_rdutils/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `rdutils` package''' \ No newline at end of file diff --git a/polymerist/tests/test_rdutils/test_bonding/__init__.py b/polymerist/tests/test_rdutils/test_bonding/__init__.py new file mode 100644 index 0000000..8ce1af8 --- /dev/null +++ b/polymerist/tests/test_rdutils/test_bonding/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `bonding` package''' \ No newline at end of file diff --git a/polymerist/tests/test_rdutils/test_labeling/__init__.py b/polymerist/tests/test_rdutils/test_labeling/__init__.py new file mode 100644 index 0000000..049964f --- /dev/null +++ b/polymerist/tests/test_rdutils/test_labeling/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `labeling` package''' \ No newline at end of file diff --git a/polymerist/tests/test_rdutils/test_rdcoords/__init__.py b/polymerist/tests/test_rdutils/test_rdcoords/__init__.py new file mode 100644 index 0000000..9adead5 --- /dev/null +++ b/polymerist/tests/test_rdutils/test_rdcoords/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `rdcoords` package''' \ No newline at end of file diff --git a/polymerist/tests/test_rdutils/test_reactions/__init__.py b/polymerist/tests/test_rdutils/test_reactions/__init__.py new file mode 100644 index 0000000..413d674 --- /dev/null +++ b/polymerist/tests/test_rdutils/test_reactions/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `reactions` package''' \ No newline at end of file diff --git a/polymerist/tests/test_smileslib/__init__.py b/polymerist/tests/test_smileslib/__init__.py new file mode 100644 index 0000000..b9c1d21 --- /dev/null +++ b/polymerist/tests/test_smileslib/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `smileslib` package''' \ No newline at end of file diff --git a/polymerist/tests/test_smileslib/test_functgroups/__init__.py b/polymerist/tests/test_smileslib/test_functgroups/__init__.py new file mode 100644 index 0000000..2d5efe7 --- /dev/null +++ b/polymerist/tests/test_smileslib/test_functgroups/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `functgroups` package''' \ No newline at end of file diff --git a/polymerist/tests/test_tests/__init__.py b/polymerist/tests/test_tests/__init__.py new file mode 100644 index 0000000..b2f1110 --- /dev/null +++ b/polymerist/tests/test_tests/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `tests` package''' \ No newline at end of file diff --git a/polymerist/tests/test_unitutils/__init__.py b/polymerist/tests/test_unitutils/__init__.py new file mode 100644 index 0000000..a222fa9 --- /dev/null +++ b/polymerist/tests/test_unitutils/__init__.py @@ -0,0 +1 @@ +'''Unit tests for `unitutils` package''' \ No newline at end of file From 0a45a5108a4bb9bec8ceef08f2e03b662c60ffc0 Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Fri, 16 Aug 2024 16:58:42 -0600 Subject: [PATCH 02/15] Removed "test_" prefixes from test filetree names (will reserve this for leaf module-level files) --- polymerist/tests/{test_analysis => analysis}/__init__.py | 0 polymerist/tests/{test_genutils => genutils}/__init__.py | 0 .../test_decorators => genutils/decorators}/__init__.py | 0 .../test_fileutils => genutils/fileutils}/__init__.py | 0 .../test_jsonio => genutils/fileutils/jsonio}/__init__.py | 0 .../test_logutils => genutils/logutils}/__init__.py | 0 .../test_sequences => genutils/sequences}/__init__.py | 0 .../sequences/discernment}/__init__.py | 0 .../sequences/similarity}/__init__.py | 0 .../{test_genutils/test_textual => genutils/textual}/__init__.py | 0 .../test_treetools => genutils/treetools}/__init__.py | 0 .../test_typetools => genutils/typetools}/__init__.py | 0 polymerist/tests/{test_graphics => graphics}/__init__.py | 0 polymerist/tests/{test_maths => maths}/__init__.py | 0 .../test_combinatorics => maths/combinatorics}/__init__.py | 0 .../{test_maths/test_fractions => maths/fractions}/__init__.py | 0 .../tests/{test_maths/test_greek => maths/greek}/__init__.py | 0 .../{test_maths/test_lattices => maths/lattices}/__init__.py | 0 .../{test_maths/test_linearalg => maths/linearalg}/__init__.py | 0 .../{test_maths/test_numbersys => maths/numbersys}/__init__.py | 0 polymerist/tests/{test_mdtools => mdtools}/__init__.py | 0 .../test_lammpstools => mdtools/lammpstools}/__init__.py | 0 .../test_openfftools => mdtools/openfftools}/__init__.py | 0 .../openfftools/partialcharge}/__init__.py | 0 .../openfftools/partialcharge/rescharge}/__init__.py | 0 .../test_solvation => mdtools/openfftools/solvation}/__init__.py | 0 .../openfftools/solvation/solvents}/__init__.py | 0 .../test_openmmtools => mdtools/openmmtools}/__init__.py | 0 polymerist/tests/{test_polymers => polymers}/__init__.py | 0 .../test_monomers => polymers/monomers}/__init__.py | 0 .../test_smidgelib => polymers/smidgelib}/__init__.py | 0 polymerist/tests/{test_rdutils => rdutils}/__init__.py | 0 .../{test_rdutils/test_bonding => rdutils/bonding}/__init__.py | 0 .../{test_rdutils/test_labeling => rdutils/labeling}/__init__.py | 0 .../{test_rdutils/test_rdcoords => rdutils/rdcoords}/__init__.py | 0 .../test_reactions => rdutils/reactions}/__init__.py | 0 polymerist/tests/{test_smileslib => smileslib}/__init__.py | 0 .../test_functgroups => smileslib/functgroups}/__init__.py | 0 polymerist/tests/test_tests/__init__.py | 1 - polymerist/tests/{test_unitutils => unitutils}/__init__.py | 0 40 files changed, 1 deletion(-) rename polymerist/tests/{test_analysis => analysis}/__init__.py (100%) rename polymerist/tests/{test_genutils => genutils}/__init__.py (100%) rename polymerist/tests/{test_genutils/test_decorators => genutils/decorators}/__init__.py (100%) rename polymerist/tests/{test_genutils/test_fileutils => genutils/fileutils}/__init__.py (100%) rename polymerist/tests/{test_genutils/test_fileutils/test_jsonio => genutils/fileutils/jsonio}/__init__.py (100%) rename polymerist/tests/{test_genutils/test_logutils => genutils/logutils}/__init__.py (100%) rename polymerist/tests/{test_genutils/test_sequences => genutils/sequences}/__init__.py (100%) rename polymerist/tests/{test_genutils/test_sequences/test_discernment => genutils/sequences/discernment}/__init__.py (100%) rename polymerist/tests/{test_genutils/test_sequences/test_similarity => genutils/sequences/similarity}/__init__.py (100%) rename polymerist/tests/{test_genutils/test_textual => genutils/textual}/__init__.py (100%) rename polymerist/tests/{test_genutils/test_treetools => genutils/treetools}/__init__.py (100%) rename polymerist/tests/{test_genutils/test_typetools => genutils/typetools}/__init__.py (100%) rename polymerist/tests/{test_graphics => graphics}/__init__.py (100%) rename polymerist/tests/{test_maths => maths}/__init__.py (100%) rename polymerist/tests/{test_maths/test_combinatorics => maths/combinatorics}/__init__.py (100%) rename polymerist/tests/{test_maths/test_fractions => maths/fractions}/__init__.py (100%) rename polymerist/tests/{test_maths/test_greek => maths/greek}/__init__.py (100%) rename polymerist/tests/{test_maths/test_lattices => maths/lattices}/__init__.py (100%) rename polymerist/tests/{test_maths/test_linearalg => maths/linearalg}/__init__.py (100%) rename polymerist/tests/{test_maths/test_numbersys => maths/numbersys}/__init__.py (100%) rename polymerist/tests/{test_mdtools => mdtools}/__init__.py (100%) rename polymerist/tests/{test_mdtools/test_lammpstools => mdtools/lammpstools}/__init__.py (100%) rename polymerist/tests/{test_mdtools/test_openfftools => mdtools/openfftools}/__init__.py (100%) rename polymerist/tests/{test_mdtools/test_openfftools/test_partialcharge => mdtools/openfftools/partialcharge}/__init__.py (100%) rename polymerist/tests/{test_mdtools/test_openfftools/test_partialcharge/test_rescharge => mdtools/openfftools/partialcharge/rescharge}/__init__.py (100%) rename polymerist/tests/{test_mdtools/test_openfftools/test_solvation => mdtools/openfftools/solvation}/__init__.py (100%) rename polymerist/tests/{test_mdtools/test_openfftools/test_solvation/test_solvents => mdtools/openfftools/solvation/solvents}/__init__.py (100%) rename polymerist/tests/{test_mdtools/test_openmmtools => mdtools/openmmtools}/__init__.py (100%) rename polymerist/tests/{test_polymers => polymers}/__init__.py (100%) rename polymerist/tests/{test_polymers/test_monomers => polymers/monomers}/__init__.py (100%) rename polymerist/tests/{test_polymers/test_smidgelib => polymers/smidgelib}/__init__.py (100%) rename polymerist/tests/{test_rdutils => rdutils}/__init__.py (100%) rename polymerist/tests/{test_rdutils/test_bonding => rdutils/bonding}/__init__.py (100%) rename polymerist/tests/{test_rdutils/test_labeling => rdutils/labeling}/__init__.py (100%) rename polymerist/tests/{test_rdutils/test_rdcoords => rdutils/rdcoords}/__init__.py (100%) rename polymerist/tests/{test_rdutils/test_reactions => rdutils/reactions}/__init__.py (100%) rename polymerist/tests/{test_smileslib => smileslib}/__init__.py (100%) rename polymerist/tests/{test_smileslib/test_functgroups => smileslib/functgroups}/__init__.py (100%) delete mode 100644 polymerist/tests/test_tests/__init__.py rename polymerist/tests/{test_unitutils => unitutils}/__init__.py (100%) diff --git a/polymerist/tests/test_analysis/__init__.py b/polymerist/tests/analysis/__init__.py similarity index 100% rename from polymerist/tests/test_analysis/__init__.py rename to polymerist/tests/analysis/__init__.py diff --git a/polymerist/tests/test_genutils/__init__.py b/polymerist/tests/genutils/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/__init__.py rename to polymerist/tests/genutils/__init__.py diff --git a/polymerist/tests/test_genutils/test_decorators/__init__.py b/polymerist/tests/genutils/decorators/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/test_decorators/__init__.py rename to polymerist/tests/genutils/decorators/__init__.py diff --git a/polymerist/tests/test_genutils/test_fileutils/__init__.py b/polymerist/tests/genutils/fileutils/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/test_fileutils/__init__.py rename to polymerist/tests/genutils/fileutils/__init__.py diff --git a/polymerist/tests/test_genutils/test_fileutils/test_jsonio/__init__.py b/polymerist/tests/genutils/fileutils/jsonio/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/test_fileutils/test_jsonio/__init__.py rename to polymerist/tests/genutils/fileutils/jsonio/__init__.py diff --git a/polymerist/tests/test_genutils/test_logutils/__init__.py b/polymerist/tests/genutils/logutils/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/test_logutils/__init__.py rename to polymerist/tests/genutils/logutils/__init__.py diff --git a/polymerist/tests/test_genutils/test_sequences/__init__.py b/polymerist/tests/genutils/sequences/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/test_sequences/__init__.py rename to polymerist/tests/genutils/sequences/__init__.py diff --git a/polymerist/tests/test_genutils/test_sequences/test_discernment/__init__.py b/polymerist/tests/genutils/sequences/discernment/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/test_sequences/test_discernment/__init__.py rename to polymerist/tests/genutils/sequences/discernment/__init__.py diff --git a/polymerist/tests/test_genutils/test_sequences/test_similarity/__init__.py b/polymerist/tests/genutils/sequences/similarity/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/test_sequences/test_similarity/__init__.py rename to polymerist/tests/genutils/sequences/similarity/__init__.py diff --git a/polymerist/tests/test_genutils/test_textual/__init__.py b/polymerist/tests/genutils/textual/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/test_textual/__init__.py rename to polymerist/tests/genutils/textual/__init__.py diff --git a/polymerist/tests/test_genutils/test_treetools/__init__.py b/polymerist/tests/genutils/treetools/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/test_treetools/__init__.py rename to polymerist/tests/genutils/treetools/__init__.py diff --git a/polymerist/tests/test_genutils/test_typetools/__init__.py b/polymerist/tests/genutils/typetools/__init__.py similarity index 100% rename from polymerist/tests/test_genutils/test_typetools/__init__.py rename to polymerist/tests/genutils/typetools/__init__.py diff --git a/polymerist/tests/test_graphics/__init__.py b/polymerist/tests/graphics/__init__.py similarity index 100% rename from polymerist/tests/test_graphics/__init__.py rename to polymerist/tests/graphics/__init__.py diff --git a/polymerist/tests/test_maths/__init__.py b/polymerist/tests/maths/__init__.py similarity index 100% rename from polymerist/tests/test_maths/__init__.py rename to polymerist/tests/maths/__init__.py diff --git a/polymerist/tests/test_maths/test_combinatorics/__init__.py b/polymerist/tests/maths/combinatorics/__init__.py similarity index 100% rename from polymerist/tests/test_maths/test_combinatorics/__init__.py rename to polymerist/tests/maths/combinatorics/__init__.py diff --git a/polymerist/tests/test_maths/test_fractions/__init__.py b/polymerist/tests/maths/fractions/__init__.py similarity index 100% rename from polymerist/tests/test_maths/test_fractions/__init__.py rename to polymerist/tests/maths/fractions/__init__.py diff --git a/polymerist/tests/test_maths/test_greek/__init__.py b/polymerist/tests/maths/greek/__init__.py similarity index 100% rename from polymerist/tests/test_maths/test_greek/__init__.py rename to polymerist/tests/maths/greek/__init__.py diff --git a/polymerist/tests/test_maths/test_lattices/__init__.py b/polymerist/tests/maths/lattices/__init__.py similarity index 100% rename from polymerist/tests/test_maths/test_lattices/__init__.py rename to polymerist/tests/maths/lattices/__init__.py diff --git a/polymerist/tests/test_maths/test_linearalg/__init__.py b/polymerist/tests/maths/linearalg/__init__.py similarity index 100% rename from polymerist/tests/test_maths/test_linearalg/__init__.py rename to polymerist/tests/maths/linearalg/__init__.py diff --git a/polymerist/tests/test_maths/test_numbersys/__init__.py b/polymerist/tests/maths/numbersys/__init__.py similarity index 100% rename from polymerist/tests/test_maths/test_numbersys/__init__.py rename to polymerist/tests/maths/numbersys/__init__.py diff --git a/polymerist/tests/test_mdtools/__init__.py b/polymerist/tests/mdtools/__init__.py similarity index 100% rename from polymerist/tests/test_mdtools/__init__.py rename to polymerist/tests/mdtools/__init__.py diff --git a/polymerist/tests/test_mdtools/test_lammpstools/__init__.py b/polymerist/tests/mdtools/lammpstools/__init__.py similarity index 100% rename from polymerist/tests/test_mdtools/test_lammpstools/__init__.py rename to polymerist/tests/mdtools/lammpstools/__init__.py diff --git a/polymerist/tests/test_mdtools/test_openfftools/__init__.py b/polymerist/tests/mdtools/openfftools/__init__.py similarity index 100% rename from polymerist/tests/test_mdtools/test_openfftools/__init__.py rename to polymerist/tests/mdtools/openfftools/__init__.py diff --git a/polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/__init__.py b/polymerist/tests/mdtools/openfftools/partialcharge/__init__.py similarity index 100% rename from polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/__init__.py rename to polymerist/tests/mdtools/openfftools/partialcharge/__init__.py diff --git a/polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/test_rescharge/__init__.py b/polymerist/tests/mdtools/openfftools/partialcharge/rescharge/__init__.py similarity index 100% rename from polymerist/tests/test_mdtools/test_openfftools/test_partialcharge/test_rescharge/__init__.py rename to polymerist/tests/mdtools/openfftools/partialcharge/rescharge/__init__.py diff --git a/polymerist/tests/test_mdtools/test_openfftools/test_solvation/__init__.py b/polymerist/tests/mdtools/openfftools/solvation/__init__.py similarity index 100% rename from polymerist/tests/test_mdtools/test_openfftools/test_solvation/__init__.py rename to polymerist/tests/mdtools/openfftools/solvation/__init__.py diff --git a/polymerist/tests/test_mdtools/test_openfftools/test_solvation/test_solvents/__init__.py b/polymerist/tests/mdtools/openfftools/solvation/solvents/__init__.py similarity index 100% rename from polymerist/tests/test_mdtools/test_openfftools/test_solvation/test_solvents/__init__.py rename to polymerist/tests/mdtools/openfftools/solvation/solvents/__init__.py diff --git a/polymerist/tests/test_mdtools/test_openmmtools/__init__.py b/polymerist/tests/mdtools/openmmtools/__init__.py similarity index 100% rename from polymerist/tests/test_mdtools/test_openmmtools/__init__.py rename to polymerist/tests/mdtools/openmmtools/__init__.py diff --git a/polymerist/tests/test_polymers/__init__.py b/polymerist/tests/polymers/__init__.py similarity index 100% rename from polymerist/tests/test_polymers/__init__.py rename to polymerist/tests/polymers/__init__.py diff --git a/polymerist/tests/test_polymers/test_monomers/__init__.py b/polymerist/tests/polymers/monomers/__init__.py similarity index 100% rename from polymerist/tests/test_polymers/test_monomers/__init__.py rename to polymerist/tests/polymers/monomers/__init__.py diff --git a/polymerist/tests/test_polymers/test_smidgelib/__init__.py b/polymerist/tests/polymers/smidgelib/__init__.py similarity index 100% rename from polymerist/tests/test_polymers/test_smidgelib/__init__.py rename to polymerist/tests/polymers/smidgelib/__init__.py diff --git a/polymerist/tests/test_rdutils/__init__.py b/polymerist/tests/rdutils/__init__.py similarity index 100% rename from polymerist/tests/test_rdutils/__init__.py rename to polymerist/tests/rdutils/__init__.py diff --git a/polymerist/tests/test_rdutils/test_bonding/__init__.py b/polymerist/tests/rdutils/bonding/__init__.py similarity index 100% rename from polymerist/tests/test_rdutils/test_bonding/__init__.py rename to polymerist/tests/rdutils/bonding/__init__.py diff --git a/polymerist/tests/test_rdutils/test_labeling/__init__.py b/polymerist/tests/rdutils/labeling/__init__.py similarity index 100% rename from polymerist/tests/test_rdutils/test_labeling/__init__.py rename to polymerist/tests/rdutils/labeling/__init__.py diff --git a/polymerist/tests/test_rdutils/test_rdcoords/__init__.py b/polymerist/tests/rdutils/rdcoords/__init__.py similarity index 100% rename from polymerist/tests/test_rdutils/test_rdcoords/__init__.py rename to polymerist/tests/rdutils/rdcoords/__init__.py diff --git a/polymerist/tests/test_rdutils/test_reactions/__init__.py b/polymerist/tests/rdutils/reactions/__init__.py similarity index 100% rename from polymerist/tests/test_rdutils/test_reactions/__init__.py rename to polymerist/tests/rdutils/reactions/__init__.py diff --git a/polymerist/tests/test_smileslib/__init__.py b/polymerist/tests/smileslib/__init__.py similarity index 100% rename from polymerist/tests/test_smileslib/__init__.py rename to polymerist/tests/smileslib/__init__.py diff --git a/polymerist/tests/test_smileslib/test_functgroups/__init__.py b/polymerist/tests/smileslib/functgroups/__init__.py similarity index 100% rename from polymerist/tests/test_smileslib/test_functgroups/__init__.py rename to polymerist/tests/smileslib/functgroups/__init__.py diff --git a/polymerist/tests/test_tests/__init__.py b/polymerist/tests/test_tests/__init__.py deleted file mode 100644 index b2f1110..0000000 --- a/polymerist/tests/test_tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -'''Unit tests for `tests` package''' \ No newline at end of file diff --git a/polymerist/tests/test_unitutils/__init__.py b/polymerist/tests/unitutils/__init__.py similarity index 100% rename from polymerist/tests/test_unitutils/__init__.py rename to polymerist/tests/unitutils/__init__.py From 4b93b0ef457e88e67a1941601b53f48fad1006d3 Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Fri, 16 Aug 2024 17:36:14 -0600 Subject: [PATCH 03/15] Added sample data file to test whether unit test data is shipped/accessed properly --- polymerist/tests/data/fake.dat | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 polymerist/tests/data/fake.dat diff --git a/polymerist/tests/data/fake.dat b/polymerist/tests/data/fake.dat new file mode 100644 index 0000000..e69de29 From 2c7109bdcd1620204cc99c5515ae18727ab3cd58 Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Fri, 16 Aug 2024 18:18:52 -0600 Subject: [PATCH 04/15] Added namespace header __init__.py files to data dirs to allow pyproject.toml builds with data --- polymerist/data/__init__.py | 1 + polymerist/tests/data/__init__.py | 1 + 2 files changed, 2 insertions(+) create mode 100644 polymerist/data/__init__.py create mode 100644 polymerist/tests/data/__init__.py diff --git a/polymerist/data/__init__.py b/polymerist/data/__init__.py new file mode 100644 index 0000000..309d669 --- /dev/null +++ b/polymerist/data/__init__.py @@ -0,0 +1 @@ +'''Additional data shipped along with polymerist source code''' \ No newline at end of file diff --git a/polymerist/tests/data/__init__.py b/polymerist/tests/data/__init__.py new file mode 100644 index 0000000..b591267 --- /dev/null +++ b/polymerist/tests/data/__init__.py @@ -0,0 +1 @@ +'''Reference data used to load or verify unit tests''' \ No newline at end of file From 89e3e0e6e146470a769f1d41e5b04ac0ba0df55a Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Fri, 16 Aug 2024 18:19:29 -0600 Subject: [PATCH 05/15] Updated pyproject.toml to include data bundled with polymerist.tests (commented out polymerist.data for now) --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 63d0541..f645349 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,6 +65,12 @@ where = ["."] polymerist = [ "py.typed" ] +# "polymerist.data" = [ +# "look_and_say.dat" +# ] +"polymerist.tests.data" = [ + "*.*", # include any data files shipped in tests.data +] [tool.versioningit] default-version = "1+unknown" From 4e2501052840537ed3e9e42b01656cbd15d2ab89 Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Fri, 16 Aug 2024 19:44:29 -0600 Subject: [PATCH 06/15] Added module for low-level Python package inspection --- polymerist/genutils/pkginspect.py | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 polymerist/genutils/pkginspect.py diff --git a/polymerist/genutils/pkginspect.py b/polymerist/genutils/pkginspect.py new file mode 100644 index 0000000..a160ff0 --- /dev/null +++ b/polymerist/genutils/pkginspect.py @@ -0,0 +1,57 @@ +'''For checking whether object are valid Python modules and packages, and if so for gathering info from within them''' + +from typing import Union +from pathlib import Path + +from importlib.resources import ( + Package, + files as get_package_path +) +from importlib.resources._common import get_package, from_package, resolve + + +def is_module(module : Package) -> bool: + '''Determine whether a given Package-like (i.e. str or ModuleType) is a valid Python module + This will return True for packages, bottom-level modules (i.e. *.py) and Python scripts''' + try: + resolve(module) + return True + except ModuleNotFoundError: + return False + +def is_package(package : Package) -> bool: + '''Determine whether a given Package-like (i.e. str or ModuleType) is a valid Python package''' + try: + get_package(package) + return True + except (ModuleNotFoundError, TypeError): + return False + + +def get_resource_path_within_package(relative_path : Union[str, Path], package : Package) -> Path: + '''Get the Path to a resource (i.e. either a directory or a file) which lives within a Python package''' + package_path : Path = get_package_path(package) # will also implicitly check that the provided package exists as a module + resource_path = package_path / relative_path # concat to Path here means string inputs for relative_path are valid without explicit conversion + + if not resource_path.exists(): # if this block is reached, it means "package" is a real module and resource path is DEFINED relative to package's path, so the below message is valid + raise ValueError(f'{resolve(package).__name__} contains no resource "{relative_path}"') + + return resource_path + +def get_dir_path_within_package(relative_path : Union[str, Path], package : Package) -> Path: + '''Get the Path to a directory which lives within a Python package''' + dir_path : Path = get_resource_path_within_package(package=package, relative_path=relative_path) # performs all check associated with getting the resource + + if not dir_path.is_dir(): + raise NotADirectoryError(f'{resolve(package).__name__} contains "{dir_path}", but it is not a directory') + + return dir_path + +def get_file_path_within_package(relative_path : Union[str, Path], package : Package) -> Path: + '''Get the Path to a (non-directory) file which lives within a Python package''' + file_path : Path = get_resource_path_within_package(package=package, relative_path=relative_path) # performs all check associated with getting the resource + + if not file_path.is_file(): + raise FileNotFoundError(f'{resolve(package).__name__} contains no file "{file_path}"') + + return file_path \ No newline at end of file From 61e34e0dc271c93903643105e35e86ffbf4a9b2f Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Fri, 16 Aug 2024 20:18:43 -0600 Subject: [PATCH 07/15] Moved discernment unit tests to tests submodule, set up basic pytest fixtures for correct solution read --- .../data}/correct_discernment_solution.json | 0 .../discernment/test_discernment.py} | 44 ++++++++++++------- 2 files changed, 27 insertions(+), 17 deletions(-) rename polymerist/{genutils/sequences/discernment => tests/data}/correct_discernment_solution.json (100%) rename polymerist/{genutils/sequences/discernment/_tests.py => tests/genutils/sequences/discernment/test_discernment.py} (58%) diff --git a/polymerist/genutils/sequences/discernment/correct_discernment_solution.json b/polymerist/tests/data/correct_discernment_solution.json similarity index 100% rename from polymerist/genutils/sequences/discernment/correct_discernment_solution.json rename to polymerist/tests/data/correct_discernment_solution.json diff --git a/polymerist/genutils/sequences/discernment/_tests.py b/polymerist/tests/genutils/sequences/discernment/test_discernment.py similarity index 58% rename from polymerist/genutils/sequences/discernment/_tests.py rename to polymerist/tests/genutils/sequences/discernment/test_discernment.py index ab11d36..fad5fb5 100644 --- a/polymerist/genutils/sequences/discernment/_tests.py +++ b/polymerist/tests/genutils/sequences/discernment/test_discernment.py @@ -1,33 +1,43 @@ '''Unit tests for DISCERNMENT-related functionality''' -# TODO: add logging +import pytest +from polymerist.genutils.pkginspect import get_file_path_within_package +from polymerist.tests import data as testdata import json from pathlib import Path -from .inventory import SymbolInventory -from .strategies import DISCERNMENTStrategy +from polymerist.genutils.sequences.discernment.inventory import SymbolInventory +from polymerist.genutils.sequences.discernment.strategies import DISCERNMENTStrategy -class DISCERNMENTIncosistencyError(Exception): +class DISCERNMENTInconsistencyError(Exception): '''Custom Exception for indicating inconsistencies between DISCERNMENT Strategy implementations''' pass -def check_discernment_algorithm_consistency(ignore_multiplicities : bool=False, unique_bins : bool=False) -> None: + +@pytest.fixture(scope='module') +def solution_path(): + return get_file_path_within_package('correct_discernment_solution.json', testdata) + +@pytest.fixture(scope='module') +def correct_solution(solution_path): + with solution_path.open('r') as file: + solution = set( + tuple(indices) + for indices in json.load(file) + ) + return solution + + +def test_discernment_algorithm_consistency(correct_solution : set[tuple[int, ...]], ignore_multiplicities : bool=False, unique_bins : bool=False) -> None: '''Check to ensure that all implementations of DISCERNMENT solution strageties yield the same outputs and don't modify a provided symbol inventory Raises failure-specific Exception if inconsistency is detected, terminates silently (no Exception, returns None) otherwise''' # hard-code inputs and expected solution WORD = 'accg' CHOICE_BINS = ('bbc','aced','bad','daea','fccce','g','abcd','fggegc') - LOCAL_DIR = Path(__file__).parent - SOLUTION_PATH = LOCAL_DIR / 'correct_discernment_solution.json' - - with SOLUTION_PATH.open('r') as file: - CORRECT_SOLUTION = set( - tuple(indices) - for indices in json.load(file) - ) + print(correct_solution) sym_inv = SymbolInventory.from_bins(CHOICE_BINS) orig_sym_inv = sym_inv.deepcopy() @@ -46,14 +56,14 @@ def check_discernment_algorithm_consistency(ignore_multiplicities : bool=False, unique_bins=unique_bins ) ) - if solution != CORRECT_SOLUTION: # check that answer produces is accurate - raise DISCERNMENTIncosistencyError(f'Algorithm {method_name} does not produce to correct enumeration of bin labels') + if solution != correct_solution: # check that answer produces is accurate + raise DISCERNMENTInconsistencyError(f'Algorithm {method_name} does not produce to correct enumeration of bin labels') if sym_inv != orig_sym_inv: # check that the symbol inventory is unmodified - raise DISCERNMENTIncosistencyError(f'Algorithm {method_name} does not return symbol inventory to original state after completion') + raise DISCERNMENTInconsistencyError(f'Algorithm {method_name} does not return symbol inventory to original state after completion') for other_method_name, other_solution in all_results.items(): # check against all other methods PRIOR TO INSERTION (minimal number of checks guaranteed to verify all pairwise checks) # print(method_name, other_method_name) if (solution - other_solution != set()) or (other_solution - solution != set()): # check both symmetric differences to make sure none are - raise DISCERNMENTIncosistencyError(f'Algorithms {method_name} and {other_method_name} produce inconsistent solutions') + raise DISCERNMENTInconsistencyError(f'Algorithms {method_name} and {other_method_name} produce inconsistent solutions') # implicit else all_results[method_name] = solution \ No newline at end of file From 31f379e4c03925eca7fc58f62c1539745f0ab09d Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Fri, 16 Aug 2024 21:23:06 -0600 Subject: [PATCH 08/15] Broke monolithic DISCERNMENT test into test class with mutliple tests in a crude manner --- .../sequences/discernment/test_discernment.py | 94 ++++++++++++------- 1 file changed, 61 insertions(+), 33 deletions(-) diff --git a/polymerist/tests/genutils/sequences/discernment/test_discernment.py b/polymerist/tests/genutils/sequences/discernment/test_discernment.py index fad5fb5..3e9d347 100644 --- a/polymerist/tests/genutils/sequences/discernment/test_discernment.py +++ b/polymerist/tests/genutils/sequences/discernment/test_discernment.py @@ -11,17 +11,25 @@ from polymerist.genutils.sequences.discernment.strategies import DISCERNMENTStrategy -class DISCERNMENTInconsistencyError(Exception): - '''Custom Exception for indicating inconsistencies between DISCERNMENT Strategy implementations''' - pass +# DEFINE/LOAD HARD-CODED INPUTS AND EXPECTED OUTPUTS TO A PARTICULAR DISCERNMENT PROBLEM +@pytest.fixture(scope='module') +def word() -> str: + return 'accg' +@pytest.fixture(scope='module') +def choice_bins() -> str: + return ('bbc','aced','bad','daea','fccce','g','abcd','fggegc') @pytest.fixture(scope='module') -def solution_path(): - return get_file_path_within_package('correct_discernment_solution.json', testdata) +def symbol_inventory(choice_bins) -> SymbolInventory: + return SymbolInventory.from_bins(choice_bins) @pytest.fixture(scope='module') -def correct_solution(solution_path): +def solution_path() -> Path: + return get_file_path_within_package('correct_discernment_solution.json', testdata) + +@pytest.fixture(scope='module') +def correct_solution(solution_path) -> set[tuple[int, ...]]: with solution_path.open('r') as file: solution = set( tuple(indices) @@ -30,40 +38,60 @@ def correct_solution(solution_path): return solution -def test_discernment_algorithm_consistency(correct_solution : set[tuple[int, ...]], ignore_multiplicities : bool=False, unique_bins : bool=False) -> None: - '''Check to ensure that all implementations of DISCERNMENT solution strageties yield the same outputs and don't modify a provided symbol inventory - Raises failure-specific Exception if inconsistency is detected, terminates silently (no Exception, returns None) otherwise''' - # hard-code inputs and expected solution - WORD = 'accg' - CHOICE_BINS = ('bbc','aced','bad','daea','fccce','g','abcd','fggegc') - - print(correct_solution) +@pytest.mark.parametrize("ignore_multiplicities,unique_bins,DSClass", [(False, False, DSClass) for DSClass in DISCERNMENTStrategy.__subclasses__()]) # TODO: produce solutions with unique bins AND ignored multiplicities to fully test +class TestDISCERNMENTStrategies: + all_results : dict[str, set[int]] = {} # cache solutions to avoid tedoius recalculations + def test_preserves_symbol_inventory( + self, + word : str, + symbol_inventory : SymbolInventory, + correct_solution : set[tuple[int, ...]], + ignore_multiplicities : bool, + unique_bins : bool, + DSClass : type[DISCERNMENTStrategy], + ) -> None: + '''Check to ensure that all implementations of DISCERNMENT solution strageties yield the same outputs and don't modify a provided symbol inventory + Raises failure-specific Exception if inconsistency is detected, terminates silently (no Exception, returns None) otherwise''' + mod_sym_inv = symbol_inventory.deepcopy() # create a copy of the symbol inventory to ensure any errant modifications do not affect other tests - sym_inv = SymbolInventory.from_bins(CHOICE_BINS) - orig_sym_inv = sym_inv.deepcopy() - - all_results : dict[str, set[int]] = {} - for DSClass in DISCERNMENTStrategy.__subclasses__(): method_name = DSClass.__name__ ds_strat = DSClass() - - solution = set( + proposed_solution = set( idxs for idxs in ds_strat.enumerate_choice_labels( - WORD, - sym_inv, + word, + mod_sym_inv, ignore_multiplicities=ignore_multiplicities, unique_bins=unique_bins ) ) - if solution != correct_solution: # check that answer produces is accurate - raise DISCERNMENTInconsistencyError(f'Algorithm {method_name} does not produce to correct enumeration of bin labels') - if sym_inv != orig_sym_inv: # check that the symbol inventory is unmodified - raise DISCERNMENTInconsistencyError(f'Algorithm {method_name} does not return symbol inventory to original state after completion') - for other_method_name, other_solution in all_results.items(): # check against all other methods PRIOR TO INSERTION (minimal number of checks guaranteed to verify all pairwise checks) - # print(method_name, other_method_name) - if (solution - other_solution != set()) or (other_solution - solution != set()): # check both symmetric differences to make sure none are - raise DISCERNMENTInconsistencyError(f'Algorithms {method_name} and {other_method_name} produce inconsistent solutions') + self.all_results[method_name] = proposed_solution # cache for comparison in later tests + assert (mod_sym_inv == symbol_inventory), f'Algorithm {method_name} does not produce to correct enumeration of bin labels' + + def test_solution_is_correct( + self, + word : str, + symbol_inventory : SymbolInventory, + correct_solution : set[tuple[int, ...]], + ignore_multiplicities : bool, + unique_bins : bool, + DSClass : type[DISCERNMENTStrategy], + ) -> None: + method_name = DSClass.__name__ + assert (self.all_results[method_name] == correct_solution), f'Algorithm {method_name} does not return symbol inventory to original state after completion' + + def test_solution_strategies_are_consistent( + self, + word : str, + symbol_inventory : SymbolInventory, + correct_solution : set[tuple[int, ...]], + ignore_multiplicities : bool, + unique_bins : bool, + DSClass : type[DISCERNMENTStrategy], + ) -> None: + method_name = DSClass.__name__ + proposed_solution = self.all_results[method_name] - # implicit else - all_results[method_name] = solution \ No newline at end of file + for other_method_name, other_solution in self.all_results.items(): # check against all other methods PRIOR TO INSERTION (minimal number of checks guaranteed to verify all pairwise checks) + # check both symmetric differences to make sure no solution sequences are unique to either method + assert (proposed_solution - other_solution == set()) and (other_solution - proposed_solution == set()), f'Algorithms {method_name} and {other_method_name} produce inconsistent solutions' From 84d808947c752e9ca3305a963d58de021b0fbaac Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Wed, 28 Aug 2024 17:20:59 -0600 Subject: [PATCH 09/15] Added unit tests location for pkginspect --- polymerist/tests/genutils/test_pkginspect.py | 55 ++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 polymerist/tests/genutils/test_pkginspect.py diff --git a/polymerist/tests/genutils/test_pkginspect.py b/polymerist/tests/genutils/test_pkginspect.py new file mode 100644 index 0000000..136d8a4 --- /dev/null +++ b/polymerist/tests/genutils/test_pkginspect.py @@ -0,0 +1,55 @@ +'''Unit tests for package inspection utilities''' + +from types import ModuleType + +import pytest +import math, json # use these as test cases, since they are pretty stable in stdlib + +from polymerist import polymerist # this is a dummy toplevel module, and NOt the entire polymerist package +from polymerist import genutils +from polymerist.genutils import pkginspect +from polymerist.tests import data as test_data + + + +# TABULATED EXPECTED TESTS OUTPUTS +are_modules = [ + ('--not_a_module--', False), # deliberately weird to ensure this never accidentally clashes with a legit module name + (math, True), + ('math', True), # test that the string -> module resolver also works as intended + (json, True), + ('json', True), + (json.decoder, True), + ('json.decoder', True), + (polymerist, True), + ('polymerist.polymerist', True), + (genutils, True), + ('polymerist.genutils', True), +] + +are_packages = [ + ('--not_a_package--', False), # deliberately weird to ensure this never accidentally clashes with a legit module name + (math, False), + ('math', False), # test that the string -> module resolver also works as intended + (json, True), + ('json', True), + (json.decoder, False), + ('json.decoder', False), + (polymerist, False), + ('polymerist.polymerist', False), + (genutils, True), + ('polymerist.genutils', True), +] + + +# UNIT TESTS +@pytest.mark.parametrize('module, expected_output', are_modules) +def test_is_module(module : ModuleType, expected_output : bool) -> None: + '''See if Python module perception behaves as expected''' + assert pkginspect.is_module(module) == expected_output + +@pytest.mark.parametrize('module, expected_output', are_packages) +def test_is_package(module : ModuleType, expected_output : bool) -> None: + '''See if Python package perception behaves as expected''' + assert pkginspect.is_package(module) == expected_output + From 161f84aa1d5c68503cd72c1b2e1396df8f0f3f23 Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Wed, 28 Aug 2024 17:23:11 -0600 Subject: [PATCH 10/15] Renamed "fake.dat" to "sample.dat" to avoid confusion, added dummy text data --- polymerist/tests/data/fake.dat | 0 polymerist/tests/data/sample.dat | 1 + 2 files changed, 1 insertion(+) delete mode 100644 polymerist/tests/data/fake.dat create mode 100644 polymerist/tests/data/sample.dat diff --git a/polymerist/tests/data/fake.dat b/polymerist/tests/data/fake.dat deleted file mode 100644 index e69de29..0000000 diff --git a/polymerist/tests/data/sample.dat b/polymerist/tests/data/sample.dat new file mode 100644 index 0000000..3ed2e08 --- /dev/null +++ b/polymerist/tests/data/sample.dat @@ -0,0 +1 @@ +I contain pointless sample text for debugging purposes! \ No newline at end of file From ca907fe7fb008552d66f83869724bbff3a3307cf Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Wed, 28 Aug 2024 17:50:53 -0600 Subject: [PATCH 11/15] Added expected-fail tests to exnsure obviously non-module types fail when passed to is_module and _is_package --- polymerist/tests/genutils/test_pkginspect.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/polymerist/tests/genutils/test_pkginspect.py b/polymerist/tests/genutils/test_pkginspect.py index 136d8a4..7aa4209 100644 --- a/polymerist/tests/genutils/test_pkginspect.py +++ b/polymerist/tests/genutils/test_pkginspect.py @@ -3,16 +3,21 @@ from types import ModuleType import pytest +from pathlib import Path import math, json # use these as test cases, since they are pretty stable in stdlib from polymerist import polymerist # this is a dummy toplevel module, and NOt the entire polymerist package from polymerist import genutils from polymerist.genutils import pkginspect -from polymerist.tests import data as test_data +from polymerist import tests # TABULATED EXPECTED TESTS OUTPUTS +non_module_types = [ # types that are obviously not modules OR packages, and which should fail + bool, int, float, complex, tuple, list, dict, set, # str, Path # str and Path need to be tested separately +] + are_modules = [ ('--not_a_module--', False), # deliberately weird to ensure this never accidentally clashes with a legit module name (math, True), @@ -48,8 +53,21 @@ def test_is_module(module : ModuleType, expected_output : bool) -> None: '''See if Python module perception behaves as expected''' assert pkginspect.is_module(module) == expected_output +@pytest.mark.parametrize('non_module_type', non_module_types) +def test_is_module_fail_on_invalid_types(non_module_type : type) -> None: + '''check that module perception fails on invalid inputs''' + with pytest.raises(AttributeError) as err_info: + instance = non_module_type() # create a default instance + _ = pkginspect.is_module(instance) + @pytest.mark.parametrize('module, expected_output', are_packages) def test_is_package(module : ModuleType, expected_output : bool) -> None: '''See if Python package perception behaves as expected''' assert pkginspect.is_package(module) == expected_output +@pytest.mark.parametrize('non_module_type', non_module_types) # NOTE: these args are in fact deliberately NOT renamed to ".*package" from ".*module" +def test_is_module_fail_on_invalid_types(non_module_type : type) -> None: + '''check that package perception fails on invalid inputs''' + with pytest.raises(AttributeError) as err_info: + instance = non_module_type() # create a default instance + _ = pkginspect.is_package(instance) From f5472c8098748aa5794a109422fae7cdd6781b86 Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Wed, 28 Aug 2024 18:26:34 -0600 Subject: [PATCH 12/15] Added test for get_resource_path_within_package() --- polymerist/tests/genutils/test_pkginspect.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/polymerist/tests/genutils/test_pkginspect.py b/polymerist/tests/genutils/test_pkginspect.py index 7aa4209..12dde7d 100644 --- a/polymerist/tests/genutils/test_pkginspect.py +++ b/polymerist/tests/genutils/test_pkginspect.py @@ -47,7 +47,7 @@ ] -# UNIT TESTS +# MODULE AND PACKAGE PERCEPTION @pytest.mark.parametrize('module, expected_output', are_modules) def test_is_module(module : ModuleType, expected_output : bool) -> None: '''See if Python module perception behaves as expected''' @@ -71,3 +71,19 @@ def test_is_module_fail_on_invalid_types(non_module_type : type) -> None: with pytest.raises(AttributeError) as err_info: instance = non_module_type() # create a default instance _ = pkginspect.is_package(instance) + +# FETCHING DATA FROM PACKAGES +@pytest.mark.parametrize( + 'rel_path, module', + [ + ('data', tests), + ('data/sample.dat', tests), + pytest.param('daata/simple.dat', tests, marks=pytest.mark.xfail(raises=ValueError, reason="This isn't a real file")), + ('pkginspect.py', genutils), + pytest.param('fake/whatever.txt', pkginspect, marks=pytest.mark.xfail(raises=TypeError, reason="Module is not a package and therefore cannot contain resources")), + ] +) +def test_get_resource_path(rel_path : str, module : ModuleType) -> None: + '''Test that fetching a resource (i.e. file OR dir) from a package''' + resource_path = pkginspect.get_resource_path_within_package(rel_path, module) + assert isinstance(resource_path, Path) \ No newline at end of file From 5ef9833144b5232dc9dca7cf4e9159fc696036ef Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Wed, 28 Aug 2024 18:30:42 -0600 Subject: [PATCH 13/15] Added test for get_file_path_within_package() --- polymerist/tests/genutils/test_pkginspect.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/polymerist/tests/genutils/test_pkginspect.py b/polymerist/tests/genutils/test_pkginspect.py index 12dde7d..9f98fc0 100644 --- a/polymerist/tests/genutils/test_pkginspect.py +++ b/polymerist/tests/genutils/test_pkginspect.py @@ -84,6 +84,21 @@ def test_is_module_fail_on_invalid_types(non_module_type : type) -> None: ] ) def test_get_resource_path(rel_path : str, module : ModuleType) -> None: - '''Test that fetching a resource (i.e. file OR dir) from a package''' + '''Test fetching a resource (i.e. file OR dir) from a package''' resource_path = pkginspect.get_resource_path_within_package(rel_path, module) + assert isinstance(resource_path, Path) + +@pytest.mark.parametrize( + 'rel_path, module', + [ + pytest.param('data', tests, marks=pytest.mark.xfail(raises=FileNotFoundError, reason="This is a directory, NOT a file")), + ('data/sample.dat', tests), + pytest.param('daata/simple.dat', tests, marks=pytest.mark.xfail(raises=ValueError, reason="This isn't a real file")), + ('pkginspect.py', genutils), + pytest.param('fake/whatever.txt', pkginspect, marks=pytest.mark.xfail(raises=TypeError, reason="Module is not a package and therefore cannot contain resources")), + ] +) +def test_get_file_path(rel_path : str, module : ModuleType) -> None: + '''Test fetching a file (i.e. NOT a dir) from a package''' + resource_path = pkginspect.get_file_path_within_package(rel_path, module) assert isinstance(resource_path, Path) \ No newline at end of file From 8208c9710c17405df0f9398558cf3b21e9ee770f Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Wed, 28 Aug 2024 18:44:20 -0600 Subject: [PATCH 14/15] Added test for get_dir_path_within_package() --- polymerist/tests/genutils/test_pkginspect.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/polymerist/tests/genutils/test_pkginspect.py b/polymerist/tests/genutils/test_pkginspect.py index 9f98fc0..85fb6aa 100644 --- a/polymerist/tests/genutils/test_pkginspect.py +++ b/polymerist/tests/genutils/test_pkginspect.py @@ -101,4 +101,19 @@ def test_get_resource_path(rel_path : str, module : ModuleType) -> None: def test_get_file_path(rel_path : str, module : ModuleType) -> None: '''Test fetching a file (i.e. NOT a dir) from a package''' resource_path = pkginspect.get_file_path_within_package(rel_path, module) + assert isinstance(resource_path, Path) + +@pytest.mark.parametrize( + 'rel_path, module', + [ + ('data', tests), + pytest.param('data/sample.dat', tests, marks=pytest.mark.xfail(raises=NotADirectoryError, reason='This IS a real file, but not a directory')), + pytest.param('daata/simple.dat', tests, marks=pytest.mark.xfail(raises=ValueError, reason="This isn't a real file")), + pytest.param('pkginspect.py', genutils, marks=pytest.mark.xfail(raises=NotADirectoryError, reason='This IS a real file, but not a directory')), + pytest.param('fake/whatever.txt', pkginspect, marks=pytest.mark.xfail(raises=TypeError, reason="Module is not a package and therefore cannot contain resources")), + ] +) +def test_get_dir_path(rel_path : str, module : ModuleType) -> None: + '''Test fetching a dir (i.e. NOT a file) from a package''' + resource_path = pkginspect.get_dir_path_within_package(rel_path, module) assert isinstance(resource_path, Path) \ No newline at end of file From 5dafd0e800ef9a4dc3b8adb5d1d7ddcdccd11624 Mon Sep 17 00:00:00 2001 From: Timotej Bernat Date: Wed, 28 Aug 2024 18:48:19 -0600 Subject: [PATCH 15/15] Made all xfails strict, so that an xpass in a package resource read is recorded as a failure --- polymerist/tests/genutils/test_pkginspect.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/polymerist/tests/genutils/test_pkginspect.py b/polymerist/tests/genutils/test_pkginspect.py index 85fb6aa..a8edbd9 100644 --- a/polymerist/tests/genutils/test_pkginspect.py +++ b/polymerist/tests/genutils/test_pkginspect.py @@ -78,9 +78,9 @@ def test_is_module_fail_on_invalid_types(non_module_type : type) -> None: [ ('data', tests), ('data/sample.dat', tests), - pytest.param('daata/simple.dat', tests, marks=pytest.mark.xfail(raises=ValueError, reason="This isn't a real file")), + pytest.param('daata/simple.dat', tests, marks=pytest.mark.xfail(raises=ValueError, reason="This isn't a real file", strict=True)), ('pkginspect.py', genutils), - pytest.param('fake/whatever.txt', pkginspect, marks=pytest.mark.xfail(raises=TypeError, reason="Module is not a package and therefore cannot contain resources")), + pytest.param('fake/whatever.txt', pkginspect, marks=pytest.mark.xfail(raises=TypeError, reason="Module is not a package and therefore cannot contain resources", strict=True)), ] ) def test_get_resource_path(rel_path : str, module : ModuleType) -> None: @@ -91,11 +91,11 @@ def test_get_resource_path(rel_path : str, module : ModuleType) -> None: @pytest.mark.parametrize( 'rel_path, module', [ - pytest.param('data', tests, marks=pytest.mark.xfail(raises=FileNotFoundError, reason="This is a directory, NOT a file")), + pytest.param('data', tests, marks=pytest.mark.xfail(raises=FileNotFoundError, reason="This is a directory, NOT a file", strict=True)), ('data/sample.dat', tests), - pytest.param('daata/simple.dat', tests, marks=pytest.mark.xfail(raises=ValueError, reason="This isn't a real file")), + pytest.param('daata/simple.dat', tests, marks=pytest.mark.xfail(raises=ValueError, reason="This isn't a real file", strict=True)), ('pkginspect.py', genutils), - pytest.param('fake/whatever.txt', pkginspect, marks=pytest.mark.xfail(raises=TypeError, reason="Module is not a package and therefore cannot contain resources")), + pytest.param('fake/whatever.txt', pkginspect, marks=pytest.mark.xfail(raises=TypeError, reason="Module is not a package and therefore cannot contain resources", strict=True)), ] ) def test_get_file_path(rel_path : str, module : ModuleType) -> None: @@ -107,10 +107,10 @@ def test_get_file_path(rel_path : str, module : ModuleType) -> None: 'rel_path, module', [ ('data', tests), - pytest.param('data/sample.dat', tests, marks=pytest.mark.xfail(raises=NotADirectoryError, reason='This IS a real file, but not a directory')), - pytest.param('daata/simple.dat', tests, marks=pytest.mark.xfail(raises=ValueError, reason="This isn't a real file")), - pytest.param('pkginspect.py', genutils, marks=pytest.mark.xfail(raises=NotADirectoryError, reason='This IS a real file, but not a directory')), - pytest.param('fake/whatever.txt', pkginspect, marks=pytest.mark.xfail(raises=TypeError, reason="Module is not a package and therefore cannot contain resources")), + pytest.param('data/sample.dat', tests, marks=pytest.mark.xfail(raises=NotADirectoryError, reason='This IS a real file, but not a directory', strict=True)), + pytest.param('daata/simple.dat', tests, marks=pytest.mark.xfail(raises=ValueError, reason="This isn't a real file", strict=True)), + pytest.param('pkginspect.py', genutils, marks=pytest.mark.xfail(raises=NotADirectoryError, reason='This IS a real file, but not a directory', strict=True)), + pytest.param('fake/whatever.txt', pkginspect, marks=pytest.mark.xfail(raises=TypeError, reason="Module is not a package and therefore cannot contain resources", strict=True)), ] ) def test_get_dir_path(rel_path : str, module : ModuleType) -> None: