Skip to content

Commit

Permalink
checkpoint before big surgery: recursive -> iterative
Browse files Browse the repository at this point in the history
  • Loading branch information
junipertcy committed Mar 1, 2021
1 parent 849d609 commit 4d5f8ad
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
simpliciality_test
==================

.. image:: https://img.shields.io/badge/python-3-blue.svg?style=flat
.. image:: https://img.shields.io/badge/python-3.8-blue.svg?style=flat
:target: https://github.com/junipertcy/simpliciality_test/blob/master/COPYING
:alt: python
.. image:: https://img.shields.io/badge/license-LGPL-green.svg?style=flat
Expand Down
4 changes: 2 additions & 2 deletions docs/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/bash
make html

#aws s3 sync ./_build/html s3://docs.netscied.tw/simplicialTest --acl public-read
#aws cloudfront create-invalidation --distribution-id EJWRA9WAFT3AG --paths /simplicialTest/*
#aws s3 sync ./_build/html s3://docs.netscied.tw/simplicial-test --acl public-read
#aws cloudfront create-invalidation --distribution-id EJWRA9WAFT3AG --paths /simplicial-test/*

1 change: 1 addition & 0 deletions simplicial_test/Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def __init__(self, degree_list, size_list, blocked_sets=None, verbose=False, **k
self.blocked_sets = []
else:
self.blocked_sets = simplify_blocked_sets(blocked_sets)
# self.blocked_sets = [_ for _ in simplify_blocked_sets(blocked_sets) if len(_) >= min(degree_list[np.nonzero(degree_list)])]

self.s_depot = kwargs.pop("s_depot", SimplicialDepot(self.DEGREE_LIST, self.SIZE_LIST))
self.s_depot.cutoff = kwargs.pop("cutoff", np.infty)
Expand Down
2 changes: 2 additions & 0 deletions simplicial_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"NoMoreBalls",
"draw_landscape",
"draw_block",
"read_hyperedge_list",
"simplify_blocked_sets",
"__author__",
"__URL__",
"__version__",
Expand Down
25 changes: 25 additions & 0 deletions simplicial_test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
from .custom_exceptions import NonSimplicialSignal
from collections import defaultdict, Counter
from functools import partial
from typing import List


@dataclass
class SimplicialDepot:
degree_list: np.ndarray
size_list: np.ndarray
depths: List = field(repr=False, default_factory=list)
conv_time: int = field(repr=False, default=0)
cutoff: int = field(repr=False, init=False)

Expand Down Expand Up @@ -62,6 +64,7 @@ def compute_level_map(self, level, mapping2shrinked):
def add_to_time_counter(self, level):
self.time[level] += 1
self.conv_time += 1
self.depths += [level]
if self.conv_time >= self.cutoff:
raise NonSimplicialSignal

Expand Down Expand Up @@ -309,6 +312,28 @@ def get_partition(n=1, sortby="asc"):
return partitions
else:
return sorted(partitions, key=lambda x: max(x) - len(x), reverse=True)


def read_hyperedge_list(path, delimiter=","):
with open(path, 'r') as f:
edge_list = set()
for line in f:
if not line.lstrip().startswith("%"):
e = line.strip().split(delimiter)
_edge_list = list()
for _e in e:
_edge_list += [int(_e) - 1]
edge_list.add(tuple(_edge_list))
return list(edge_list)


def write_simplicial_list(el, path):
with open(path, 'w') as f:
for _el in el:
for __el in _el:
f.write(str(__el) + " ")
f.write("\n")

# return sorted(partitions, key=lambda x: [Counter(x)[1], max(x) - len(x)] + list(x), reverse=True)

# def get_slimmest_d(s):
Expand Down

0 comments on commit 4d5f8ad

Please sign in to comment.