Skip to content

Commit

Permalink
Pull request #111: HYP-177 update tests suite for entityset
Browse files Browse the repository at this point in the history
Merge in HYP/hypernetx from HYP-177-update-tests-suite-for-entityset to develop

* commit 'a249417bb8efe6d14e91e18b617a4af460f77d70': (27 commits)
  HYP-177 Reorg entityset tests
  HYP-353 Add deprecation warnings for property column args
  HYP-353 Remove option to customize misc cell props col
  HYP-353 Remove option to customize misc props column
  HYP-356 Add deprecate warnings to certain ES methods
  HYP-177 Update tox.ini script test deps
  HYP-177 Return none when property not found; update tests
  HYP-177 Refactor and fix set_cell_property
  HYP-177 Cleanup tests
  HYP-177 Modify helper method
  HYP-177 Update pytest and tox config
  HYP-177 Reorganize tests; cleanup fixtures
  HYP-177 Add tests for elements_by_column
  HYP-177 Add tests for collapse_identical_elements
  HYP-177 Update test config for CI
  HYP-177 Add tests for level method
  HYP-177 Fix set_cell_property bug
  HYP-177 Minor cleanup on assign_properties
  Add tests for assign_cell_properties
  HYP-177 Add tests for assign_properties, update docs
  ...
  • Loading branch information
bonicim committed Oct 26, 2023
2 parents 2b7425e + a249417 commit 7da6b3f
Show file tree
Hide file tree
Showing 16 changed files with 926 additions and 433 deletions.
6 changes: 5 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[run]
omit = */tests/*
omit =
*/tests/*
*/utils/toys/*
*/utils/log.py

[report]
exclude_lines =
_log
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dist/
*.egg-info*
.tox/
venv*
.coverage
.coverage*
.idea
*env*
.venv*
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include hypernetx/utils/toys/HarryPotter_Characters.csv
13 changes: 4 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,22 @@ test: test-deps
@$(PYTHON3) -m tox

test-ci: test-deps
@$(PYTHON3) -m pip install 'pytest-github-actions-annotate-failures>=0.1.7'
pre-commit install
pre-commit run --all-files
@$(PYTHON3) -m tox -e py38 -r
@$(PYTHON3) -m tox

test-ci-github: test-deps
@$(PYTHON3) -m pip install 'pytest-github-actions-annotate-failures>=0.1.7'
@$(PYTHON3) -m tox

test-coverage: test-deps
coverage run --source=hypernetx -m pytest
coverage html

.PHONY: test, test-ci, test-ci-github, test-coverage
.PHONY: test, test-ci, test-ci-github

## Continuous Deployment
## Assumes that scripts are run on a container or test server VM

### Publish to PyPi
publish-deps:
@$(PYTHON3) -m pip install -e .'[packaging]'
@$(PYTHON3) -m pip install -e .'[packaging]' --use-pep517

build-dist: publish-deps clean
@$(PYTHON3) -m build --wheel --sdist
Expand All @@ -48,7 +43,7 @@ publish-to-pypi: publish-deps build-dist
### Update version

version-deps:
@$(PYTHON3) -m pip install .'[releases]'
@$(PYTHON3) -m pip install .'[releases]' --use-pep517

.PHONY: version-deps

Expand Down
85 changes: 76 additions & 9 deletions hypernetx/classes/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import numpy as np

from hypernetx import Hypergraph, HarryPotter, EntitySet, LesMis as LM
from hypernetx.classes.helpers import create_dataframe

from collections import OrderedDict, defaultdict


Expand Down Expand Up @@ -40,31 +42,33 @@ def __init__(self, static=False):
)
self.labels = OrderedDict(
[
("edges", ["P", "R", "S", "L", "O", "I"]),
("nodes", ["A", "C", "E", "K", "T1", "T2", "V"]),
("edges", [p, r, s, l, o, i]),
("nodes", [a, c, e, k, t1, t2, v]),
]
)

self.data = np.array(
[
[0, 0],
[0, 1],
[0, 2],
[0, 3],
[1, 0],
[1, 2],
[1, 3],
[2, 0],
[2, 2],
[2, 4],
[2, 3],
[2, 5],
[2, 6],
[3, 1],
[3, 3],
[3, 2],
[4, 4],
[4, 5],
[4, 6],
[5, 0],
[5, 3],
[5, 5],
]
)

self.dataframe = create_dataframe(self.edgedict)


class TriLoop:
"""Example hypergraph with 2 two 1-cells and 1 2-cell forming a loop"""
Expand Down Expand Up @@ -100,6 +104,8 @@ def __init__(self):
]
)

self.dataframe = create_dataframe(self.edgedict)


class LesMis:
def __init__(self):
Expand Down Expand Up @@ -146,11 +152,66 @@ def __init__(self, n1, n2):
self.left, self.right = nx.bipartite.sets(self.g)


@pytest.fixture
def props_dataframe():
multi_index = pd.MultiIndex.from_tuples([(0, "P")], names=["level", "id"])
data = {
"properties": [{"prop1": "propval1", "prop2": "propval2"}],
}
return pd.DataFrame(data, index=multi_index)


@pytest.fixture
def cell_props_dataframe_multidx():
multi_index = pd.MultiIndex.from_tuples([("P", "A"), ("P", "C")], names=[0, 1])
data = {
"cell_properties": [
{"prop1": "propval1", "prop2": "propval2"},
{"prop1": "propval1", "prop2": "propval2"},
]
}

return pd.DataFrame(data, index=multi_index)


@pytest.fixture
def cell_props_dataframe():
data = {
0: ["P", "P"],
1: ["A", "C"],
"cell_properties": [
{"prop1": "propval1", "prop2": "propval2"},
{"prop1": "propval1", "prop2": "propval2"},
],
}
return pd.DataFrame(data)


@pytest.fixture
def sbs():
return SevenBySix()


@pytest.fixture
def sbs_dataframe(sbs):
return sbs.dataframe


@pytest.fixture
def sbs_dict(sbs):
return sbs.edgedict


@pytest.fixture
def sbs_data(sbs):
return np.asarray(sbs.data)


@pytest.fixture
def sbs_labels(sbs):
return sbs.labels


@pytest.fixture
def triloop():
return TriLoop()
Expand All @@ -176,6 +237,11 @@ def sbs_graph(sbs):
return G


@pytest.fixture
def sbsd():
return SBSDupes()


@pytest.fixture
def sbsd_hypergraph():
sbsd = SBSDupes()
Expand Down Expand Up @@ -217,6 +283,7 @@ def dataframe():

@pytest.fixture
def dataframe_example():
"""NOTE: Do not use this dataframe as an input for 'entity' when creating an EntitySet object"""
M = np.array([[1, 1, 0, 0], [0, 1, 1, 0], [1, 0, 1, 0]])
index = ["A", "B", "C"]
columns = ["a", "b", "c", "d"]
Expand Down
Loading

0 comments on commit 7da6b3f

Please sign in to comment.