• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

peekxc / splex / 9978389681

17 Jul 2024 05:02PM UTC coverage: 84.772% (-0.2%) from 84.929%
9978389681

push

github

peekxc
v0.3.2

20 of 22 new or added lines in 5 files covered. (90.91%)

17 existing lines in 4 files now uncovered.

835 of 985 relevant lines covered (84.77%)

2.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.75
/src/splex/complexes.py
1
import numpy as np
3✔
2
from typing import Iterable
3✔
3
from .meta import SimplexConvertible, SimplexLike
3✔
4
from .generics import dim, faces
3✔
5
from .complex_abcs import * 
3✔
6
from .RankComplex import RankComplex
3✔
7
from .SetComplex import SetComplex
3✔
8
from .Simplex import Simplex
3✔
9

10
def simplicial_complex(simplices: Iterable[SimplexConvertible] = None, form: str = "default"):
3✔
11
  """Abstract simplicial complex constructor.
12
  
13
  Parameters:
14
    simplices: Iterable of SimplexConvertible objects. 
15
    form: one of ['set', 'tree', 'rank']. Defaults to 'set'. 
16

17
  Returns:
18
    sc: a _ComplexLike_ structure whose structure depends on _form_.
19
  """ 
20
  if form is None or isinstance(form, str) and form == "default":
3✔
21
    form = "rank"
3✔
22
  assert isinstance(form, str), f"Invalid form argument of type '{type(form)}'; must be string."
3✔
23
  form = form.strip().lower()
3✔
24
  if form == "tree":
3✔
25
    from simplextree import SimplexTree
3✔
26
    sc = SimplexTree(simplices)
3✔
27
  elif form == "rank":
3✔
28
    sc = RankComplex(simplices)
3✔
29
  elif form == "set":
3✔
30
    sc = SetComplex(simplices)
3✔
31
  else: 
UNCOV
32
    raise ValueError(f"Invalid form '{form}'.")
×
33
  return sc 
3✔
34

35
def print_complex(S: ComplexLike, **kwargs):
3✔
36
  assert is_complex_like(S), "Must a complex-like input."
×
37
  ST = np.zeros(shape=(len(S), dim(S)+1), dtype='<U15')
×
38
  ST.fill(' ')
×
39
  for i,s in enumerate(S):
×
40
    ST[i,:len(s)] = str(Simplex(s))[1:-1].split(',')
×
41
  SC = np.apply_along_axis(lambda x: ' '.join(x), axis=0, arr=ST)
×
42
  for i, s in enumerate(SC): 
×
43
    ending = '\n' if i != (len(SC)-1) else ''
×
UNCOV
44
    print(s, sep='', end=ending, **kwargs)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc