Skip to content

Commit 65eb76e

Browse files
committed
Merge branch 'master' into pchou
2 parents 6e702c9 + 5749a52 commit 65eb76e

12 files changed

+92
-41
lines changed

.github/workflows/CI.yml

+10-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
os:
2424
- ubuntu-latest
2525
arch:
26-
- x64
2726
- x86
27+
- x64
2828

2929
steps:
3030
- uses: actions/checkout@v2
@@ -43,8 +43,13 @@ jobs:
4343
4444
- name: Run tests
4545
run: |
46-
export PYTHONPATH=src
47-
pytest --cov --cov-report=xml
46+
export RANK=0
47+
export LOCAL_RANK=0
48+
export WORLD_SIZE=1
49+
export MASTER_ADDR=localhost
50+
export MASTER_PORT=12345
51+
export PYTHONPATH=MCintegration
52+
pytest --cov --cov-report=xml --ignore=examples
4853
4954
- name: Upload coverage to Codecov
5055
uses: codecov/codecov-action@v4
@@ -68,8 +73,8 @@ jobs:
6873
- name: Build documentation
6974
run: |
7075
cd docs
71-
sphinx-apidoc -o source ../src ../src/*_test.py
72-
python ../clean_src_rst.py
76+
sphinx-apidoc -o source ../MCintegration ../MCintegration/*_test.py
77+
python ../clean_MCintegration_rst.py
7378
make html
7479
python ../clean_html_sidebar.py
7580

examples/mc_multicpu_test.py MCintegration/mc_multicpu_test.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import torch.distributed as dist
33
import torch.multiprocessing as mp
44
import os
5-
import MCintegration
6-
from MCintegration import MonteCarlo, MarkovChainMonteCarlo
5+
from integrators import MonteCarlo, MarkovChainMonteCarlo
76

87

98
def init_process(rank, world_size, fn, backend="gloo"):
@@ -53,7 +52,6 @@ def two_integrands(x, f):
5352
# Only rank 0 prints the result
5453
print("MarkovChainMonteCarlo Result:", mcmc_result)
5554

56-
57-
if __name__ == "__main__":
55+
def test_mcmc():
5856
world_size = 8 # Number of processes to launch
5957
mp.spawn(init_process, args=(world_size, run_mcmc), nprocs=world_size, join=True)

MCintegration/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def summary(self, weighted=None):
148148
Args:
149149
weighted (bool): Display weighted averages of results from different
150150
iterations if ``True``; otherwise show unweighted averages.
151-
Default behavior is determined by |vegas|.
151+
Default behavior is determined by vegas.
152152
"""
153153
if weighted is None:
154154
weighted = self.weighted

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# MCintegration
22
[![alpha](https://img.shields.io/badge/docs-alpha-blue.svg)](https://numericaleft.github.io/MCintegration.py/)
3+
[![Build Status](https://github.com/numericalEFT/MCIntegration.py/workflows/CI/badge.svg)](https://github.com/numericalEFT/MCIntegration.py/actions)
34
[![codecov](https://codecov.io/gh/numericalEFT/MCintegration.py/graph/badge.svg?token=851N2CNOTN)](https://codecov.io/gh/numericalEFT/MCintegration.py)

clean_MCintegration_rst.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import re
2+
3+
def remove_prefix_and_horizontal_lines(filename):
4+
with open(filename, 'r') as file:
5+
lines = file.readlines()
6+
7+
cleaned_lines = []
8+
9+
for i, line in enumerate(lines):
10+
if re.match(r"^[A-Za-z0-9._ ]+ module", line.strip()) and 'MCintegration.' in line:
11+
cleaned_lines.append(line.replace('MCintegration.', '').strip() + '\n')
12+
elif line.strip().startswith('.. automodule::'):
13+
cleaned_lines.append(line)
14+
else:
15+
cleaned_lines.append(line)
16+
17+
with open(filename, 'w') as file:
18+
file.writelines(cleaned_lines)
19+
20+
remove_prefix_and_horizontal_lines('./source/MCintegration.rst')

clean_html_sidebar.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@ def remove_class_prefix_from_sidebar(html_file):
66

77
soup = BeautifulSoup(content, 'html.parser')
88

9-
# 找 class="sphinxsidebarwrapper" 侧边栏
109
sidebar = soup.find('div', class_='sphinxsidebarwrapper')
1110

1211
if sidebar:
13-
# 找 class="pre" 的 span 标签
1412
for span in sidebar.find_all('span', class_='pre'):
1513
text = span.get_text()
16-
# 删除 '.' 之前的内容
1714
if '.' in text:
1815
method_name = text.split('.')[1]
19-
# 更新 <a> 标签,保证跳转有效
2016
for a_tag in sidebar.find_all('a', class_='reference internal'):
2117
if text in a_tag.get_text():
2218
href = a_tag['href']
@@ -36,5 +32,5 @@ def remove_class_prefix_from_sidebar(html_file):
3632
else:
3733
print("No sidebar found in the HTML.")
3834

39-
input_html = './build/html/src.html'
35+
input_html = './build/html/MCintegration.html'
4036
remove_class_prefix_from_sidebar(input_html)

clean_src_rst.py

-14
This file was deleted.

codecov.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
ignore:
2-
- "examples"
2+
- "examples/*"
3+
coverage:
4+
status:
5+
patch:
6+
default:
7+
target: 84%
8+
project:
9+
default:
10+
target: 84%

docs/source/conf.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
import sys
1010

11-
sys.path.insert(0, os.path.abspath('../../src'))
11+
sys.path.insert(0, os.path.abspath('../..'))
1212

1313
project = 'MCintegration'
1414
copyright = '2024, Authors'
@@ -25,11 +25,6 @@
2525
'sphinx.ext.autosummary'
2626
]
2727

28-
templates_path = ['_templates']
29-
exclude_patterns = []
30-
31-
32-
3328
# -- Options for HTML output -------------------------------------------------
3429
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3530

@@ -56,7 +51,5 @@
5651
napoleon_use_param = True
5752
napoleon_use_rtype = True
5853

59-
html_theme = 'sphinxdoc'
60-
html_theme = 'nature'
6154
html_theme = 'pyramid'
6255
html_static_path = ['_static']

docs/source/index.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
contain the root `toctree` directive.
55
66
MCintegration documentation
7-
===============
8-
7+
===========================
98

109
Contents:
1110

1211
.. toctree::
1312
:maxdepth: 2
14-
:caption: Contents:
13+
14+
test_result.rst
1515

1616
Indices and tables
1717
==================

docs/source/test_result.rst

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Table of test results
2+
=======================================
3+
4+
Multigpu Test
5+
---------------------------------------
6+
7+
eval = 400000
8+
9+
+---------------------------+---------------+-----------------+-----------------+
10+
| Configuration | Integration | eval*16/ngpu | eval*64/ngpu |
11+
+===========================+===============+=================+=================+
12+
| | mc | 3.14100 (64) | 3.14156 (32) |
13+
| | | | |
14+
| | | 20.02ms | 79.87ms |
15+
| 1DCU (1node, 8cpu cores) +---------------+-----------------+-----------------+
16+
| | mcmc | 3.14152 (65) | 3.14090 (33) |
17+
| | | | |
18+
| | | 58.57ms | 234ms |
19+
+---------------------------+---------------+-----------------+-----------------+
20+
| | mc | 3.14137 (65) | 3.14123 (33) |
21+
| | | | |
22+
| | | 11.33ms | 42.22ms |
23+
| 2DCU (1node, 16cpu cores) +---------------+-----------------+-----------------+
24+
| | mcmc | 3.14129 (65) | 3.14157 (32) |
25+
| | | | |
26+
| | | 32.18ms | 123ms |
27+
+---------------------------+---------------+-----------------+-----------------+
28+
| | mc | 3.14182 (65) | 3.14173 (32) |
29+
| | | | |
30+
| | | 6.08ms | 22.32ms |
31+
| 4DCU (1node, 32cpu cores) +---------------+-----------------+-----------------+
32+
| | mcmc | 3.14260 (65) | 3.14175 (33) |
33+
| | | | |
34+
| | | 17.34ms | 64.69ms |
35+
+---------------------------+---------------+-----------------+-----------------+
36+
| | mc | 3.14049 (65) | 3.14150 (32) |
37+
| | | | |
38+
| | | 3.73ms | 11.55ms |
39+
| 8DCU (2node, 64cpu cores) +---------------+-----------------+-----------------+
40+
| | mcmc | 3.14313 (65) | 3.14149 (33) |
41+
| | | | |
42+
| | | 10.47ms | 32.39ms |
43+
+---------------------------+---------------+-----------------+-----------------+

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ matplotlib
77
tqdm
88
absl-py
99
beautifulsoup4
10+
pandas

0 commit comments

Comments
 (0)