Skip to content

Commit

Permalink
Pull request #115: HYP-353 remove option to customize prop cols
Browse files Browse the repository at this point in the history
Merge in HYP/hypernetx from HYP-345-remove-option-to-customize-prop-cols to HYP-177-update-tests-suite-for-entityset

* commit 'eb78a61815c909ed40c74fc8b2268ef0ba6c8256':
  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
  • Loading branch information
bonicim authored and brendapraggastis committed Oct 18, 2023
2 parents 6989ec5 + eb78a61 commit e8a3a89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
26 changes: 14 additions & 12 deletions hypernetx/classes/entityset.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,26 @@ def __init__(
weights: Optional[Sequence[float] | float | int | str] = 1,
aggregateby: Optional[str | dict] = "sum",
properties: Optional[pd.DataFrame | dict[int, dict[T, dict[Any, Any]]]] = None,
misc_props_col: str = "properties",
misc_props_col: Optional[str] = None,
level_col: str = "level",
id_col: str = "id",
cell_properties: Optional[
Sequence[T] | pd.DataFrame | dict[T, dict[T, dict[Any, Any]]]
] = None,
misc_cell_props_col: str = "cell_properties",
misc_cell_props_col: Optional[str] = None,
):
if misc_props_col or misc_cell_props_col:
warnings.warn(
"misc_props_col and misc_cell_props_col will be deprecated; all public references to these "
"arguments will be removed in a future release.",
DeprecationWarning,
)

self._uid = uid
self._static = static
self._state_dict = {}
self._misc_cell_props_col = misc_cell_props_col
self._misc_cell_props_col = "cell_properties"
self._misc_props_col = "properties"

# build initial dataframe
if isinstance(data, np.ndarray) and entity is None:
Expand Down Expand Up @@ -178,7 +186,7 @@ def __init__(
)

# create properties
self._create_properties(level_col, id_col, misc_props_col, properties)
self._create_properties(level_col, id_col, properties)

# create cell properties (From old EntitySet)
self._create_assign_cell_properties(cell_properties)
Expand Down Expand Up @@ -224,7 +232,6 @@ def _create_properties(
self,
level_col: str,
id_col: str,
misc_props_col: str,
properties: Optional[pd.DataFrame | dict[int, dict[T, dict[Any, Any]]]],
) -> None:
item_levels = [
Expand All @@ -235,9 +242,8 @@ def _create_properties(
index = pd.MultiIndex.from_tuples(item_levels, names=[level_col, id_col])
data = [(i, 1, {}) for i in range(len(index))]
self._properties = pd.DataFrame(
data=data, index=index, columns=["uid", "weight", misc_props_col]
data=data, index=index, columns=["uid", "weight", self._misc_props_col]
).sort_index()
self._misc_props_col = misc_props_col
self.assign_properties(properties)

def _create_assign_cell_properties(
Expand Down Expand Up @@ -1296,7 +1302,6 @@ def _restrict_to_levels(
data_cols=cols,
aggregateby=aggregateby,
properties=properties,
misc_props_col=self._misc_props_col,
level_col=level_col,
id_col=id_col,
**kwargs,
Expand Down Expand Up @@ -1329,9 +1334,7 @@ def restrict_to_indices(

for col in self._data_cols:
entity[col] = entity[col].cat.remove_unused_categories()
restricted = self.__class__(
entity=entity, misc_props_col=self._misc_props_col, **kwargs
)
restricted = self.__class__(entity=entity, **kwargs)

if not self.properties.empty:
prop_idx = [
Expand Down Expand Up @@ -2011,7 +2014,6 @@ def restrict_to_levels(
levels,
weights,
aggregateby,
misc_cell_props_col=self._misc_cell_props_col,
**kwargs,
)

Expand Down
1 change: 0 additions & 1 deletion hypernetx/classes/hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ def __init__(
### cell properties

if setsystem is None: #### Empty Case

self._edges = EntitySet({})
self._nodes = EntitySet({})
self._state_dict = {}
Expand Down

0 comments on commit e8a3a89

Please sign in to comment.