Skip to content

Commit

Permalink
gh-pages branch for docs (Sai); Dvine one set empty
Browse files Browse the repository at this point in the history
  • Loading branch information
TY-Cheng committed Oct 16, 2024
1 parent 9385803 commit aaf91f2
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 23 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ Visit the [`./examples/`](https://github.com/TY-Cheng/torchvinecopulib/tree/main

- Or visit [html-preview.github.io](https://html-preview.github.io/?url=https%3A%2F%2Fgithub.com%2FTY-Cheng%2Ftorchvinecopulib%2Fblob%2Fmain%2Fdocs%2F_build%2Fhtml%2Findex.html)

- Or (locally) visit the `./docs/_build/html` subfolder for static `html` made with `Sphinx`

- Or build by yourself (need [`Sphinx`](https://github.com/sphinx-doc/sphinx), theme [`furo`](https://github.com/pradyunsg/furo) and [the GNU `make`](https://www.gnu.org/software/make/))

```bash
Expand Down
28 changes: 22 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import sys

from sphinx_pyproject import SphinxConfig

sys.path.append('.')

config = SphinxConfig('../pyproject.toml', globalns=globals(), style = 'poetry' )
# * load the pyproject.toml file using SphinxConfig
# * using Path for better cross-platform compatibility
try:
config = SphinxConfig("../pyproject.toml", globalns=globals(), style="poetry")
except FileNotFoundError as err:
raise FileNotFoundError("pyproject.toml not found") from err

# * project metadata
project = config.name
author = config.author
copyright = "2024-, Tuoyuan Cheng, Kan Chen"
version = release = config.version
documentation_summary = config.description
extensions = config["extensions"]
html_theme = 'furo'
extensions = config.get("extensions", [])
html_theme = config.get("html_theme", "furo")
html_title = f"{project} v{version}"
html_theme_options = {
"sidebar_hide_name": True,
# "light_logo": "../torchvinecopulib.png",
# "dark_logo": "../torchvinecopulib.png",
# "sticky_navigation": True,
"navigation_with_keys": True,
# "footer_text": f"© {copyright}",
# "navigation_depth": 4,
# "titles_only": False,
}
autosummary_generate = True
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ https://github.com/TY-Cheng/torchvinecopulib
============================================

.. toctree::
:maxdepth: 2
:maxdepth: 3
:caption: Contents

torchvinecopulib.vinecop
Expand Down
32 changes: 30 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ license = "GNU GPLv3"
name = "torchvinecopulib"
version = "2024.10.0"
description = "yet another vine copula library for PyTorch."
authors = ["Tuoyuan Cheng <cty120120@gmail.com>"]
authors = ["Tuoyuan Cheng <tuoyuan.cheng@nus.edu.sg>"]
maintainers = ["Xiaosheng You <e1204754@u.nus.edu>"]
readme = "README.md"
# homepage = ""
Expand All @@ -25,13 +25,38 @@ classifiers = [
extensions = [
"sphinx.ext.githubpages",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon"
"sphinx.ext.napoleon",
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.sphinx-pyproject.build]
source-dir = "docs"
build-dir = "docs/_build"
all_files = true
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.extlinks",
"sphinx.ext.githubpages",
"sphinx.ext.graphviz",
"sphinx.ext.ifconfig",
"sphinx.ext.imgconverter",
"sphinx.ext.inheritance_diagram",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
html_theme = "furo"


[tool.poetry.urls]
"Bug Tracker" = "https://github.com/TY-Cheng/torchvinecopulib/issues/new"

Expand Down Expand Up @@ -91,6 +116,7 @@ pytest = { version = "*" }
pyvinecopulib = { version = "0.6.6" }
scikit-learn = { version = "*" }
sphinx = { version = "*" }
sphinx_pyproject = { version = "*" }
tokenize-rt = { version = "*" }
yfinance = { version = "*" }

Expand All @@ -110,6 +136,7 @@ dev_cpu = [
"pyvinecopulib",
"scikit-learn",
"sphinx",
"sphinx_pyproject",
"tokenize-rt",
"yfinance",
]
Expand All @@ -128,6 +155,7 @@ dev_cuda = [
"pyvinecopulib",
"scikit-learn",
"sphinx",
"sphinx_pyproject",
"tokenize-rt",
"yfinance",
]
19 changes: 7 additions & 12 deletions torchvinecopulib/vinecop/_factory_vcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,20 +201,15 @@ def _edges_from_tsp(tsp: list) -> set:
# ! one set is empty or singleton: global TSP
tsp = threshold_accepting_tsp(graph_nx, init_cycle="greedy")
mst = []
heap_cost_non_first = []
tmp_cost, tmp_drop = -math.inf, None
for idx in range(1, len(tsp)):
v_lr = tuple(sorted((tsp[idx], tsp[idx - 1])))
if set(v_lr) <= set(s_first):
# * an edge with both vertices in s_first
mst.append(v_lr)
else:
# * an edge with at least one vertex in s_rest
# ! min heap, by -cost in ASCENDING order
heapq.heappush(heap_cost_non_first, (-dct_cost[v_lr], v_lr))
# ! drop the edge with max cost and one vertex not in s_first
heapq.heappop(heap_cost_non_first)
# * append others
mst.extend([key for _, key in heap_cost_non_first])
v_lr_cost = dct_cost[v_lr]
mst.append(v_lr)
# ! drop the edge with max cost and (at least) one vertex not in s_first
if (set(v_lr) - s_first) and (v_lr_cost > tmp_cost):
tmp_cost, tmp_drop = v_lr_cost, v_lr
mst.remove(tmp_drop)
else:
# ! both sets have more than two vertices, TSP with precedence constraints (clustered TSP)
tsp_first = threshold_accepting_tsp(graph_nx.subgraph(s_first), init_cycle="greedy")
Expand Down

0 comments on commit aaf91f2

Please sign in to comment.