Skip to content

Commit 07b440f

Browse files
[Doc] Add more contributors and refine several docstrings (#836)
* auto generate contributors instead of adding manually * refine return type of docstrings
1 parent 58ad0b3 commit 07b440f

File tree

6 files changed

+49
-50
lines changed

6 files changed

+49
-50
lines changed

docs/index.md

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
./README.md:thanks
201201
--8<--
202202

203-
- PaddleScience 的部分代码由以下优秀社区开发者贡献(按 [Contributors](https://github.com/PaddlePaddle/PaddleScience/graphs/contributors) 排序):
203+
- PaddleScience 的部分代码由以下优秀开发者贡献(按 [Contributors](https://github.com/PaddlePaddle/PaddleScience/graphs/contributors) 排序):
204204

205205
<style>
206206
.avatar {
@@ -216,32 +216,7 @@
216216
transform:translateY(-10px);
217217
}
218218
</style>
219-
<a href="https://github.com/Asthestarsfalll"><img class="avatar" src="https://avatars.githubusercontent.com/Asthestarsfalll" alt="avatar" /></a>
220-
<a href="https://github.com/co63oc"><img class="avatar" src="https://avatars.githubusercontent.com/co63oc" alt="avatar" /></a>
221-
<a href="https://github.com/MayYouBeProsperous"><img class="avatar" src="https://avatars.githubusercontent.com/MayYouBeProsperous" alt="avatar" /></a>
222-
<a href="https://github.com/AndPuQing"><img class="avatar" src="https://avatars.githubusercontent.com/AndPuQing" alt="avatar" /></a>
223-
<a href="https://github.com/lknt"><img class="avatar" src="https://avatars.githubusercontent.com/lknt" alt="avatar" /></a>
224-
<a href="https://github.com/mrcangye"><img class="avatar" src="https://avatars.githubusercontent.com/mrcangye" alt="avatar" /></a>
225-
<a href="https://github.com/yangguohao"><img class="avatar" src="https://avatars.githubusercontent.com/yangguohao" alt="avatar" /></a>
226-
<a href="https://github.com/ooooo-create"><img class="avatar" src="https://avatars.githubusercontent.com/ooooo-create" alt="avatar" /></a>
227-
<a href="https://github.com/megemini"><img class="avatar" src="https://avatars.githubusercontent.com/megemini" alt="avatar" /></a>
228-
<a href="https://github.com/DUCH714"><img class="avatar" src="https://avatars.githubusercontent.com/DUCH714" alt="avatar" /></a>
229-
<a href="https://github.com/zlynna"><img class="avatar" src="https://avatars.githubusercontent.com/zlynna" alt="avatar" /></a>
230-
<a href="https://github.com/jjyaoao"><img class="avatar" src="https://avatars.githubusercontent.com/jjyaoao" alt="avatar" /></a>
231-
<a href="https://github.com/jiamingkong"><img class="avatar" src="https://avatars.githubusercontent.com/jiamingkong" alt="avatar" /></a>
232-
<a href="https://github.com/Liyulingyue"><img class="avatar" src="https://avatars.githubusercontent.com/Liyulingyue" alt="avatar" /></a>
233-
<a href="https://github.com/DrRyanHuang"><img class="avatar" src="https://avatars.githubusercontent.com/DrRyanHuang" alt="avatar" /></a>
234-
<a href="https://github.com/zbt78"><img class="avatar" src="https://avatars.githubusercontent.com/zbt78" alt="avatar" /></a>
235-
<a href="https://github.com/Gxinhu"><img class="avatar" src="https://avatars.githubusercontent.com/Gxinhu" alt="avatar" /></a>
236-
<a href="https://github.com/XYM-1"><img class="avatar" src="https://avatars.githubusercontent.com/XYM-1" alt="avatar" /></a>
237-
<a href="https://github.com/xusuyong"><img class="avatar" src="https://avatars.githubusercontent.com/xusuyong" alt="avatar" /></a>
238-
<a href="https://github.com/DrownFish19"><img class="avatar" src="https://avatars.githubusercontent.com/DrownFish19" alt="avatar" /></a>
239-
<a href="https://github.com/NKNaN"><img class="avatar" src="https://avatars.githubusercontent.com/NKNaN" alt="avatar" /></a>
240-
<a href="https://github.com/ruoyunbai"><img class="avatar" src="https://avatars.githubusercontent.com/ruoyunbai" alt="avatar" /></a>
241-
<a href="https://github.com/sanbuphy"><img class="avatar" src="https://avatars.githubusercontent.com/sanbuphy" alt="avatar" /></a>
242-
<a href="https://github.com/ccsuzzh"><img class="avatar" src="https://avatars.githubusercontent.com/ccsuzzh" alt="avatar" /></a>
243-
<a href="https://github.com/enkilee"><img class="avatar" src="https://avatars.githubusercontent.com/enkilee" alt="avatar" /></a>
244-
<a href="https://github.com/GreatV"><img class="avatar" src="https://avatars.githubusercontent.com/GreatV" alt="avatar" /></a>
219+
<div id="contributors"></div>
245220

246221
## 🤝合作单位
247222

docs/javascripts/contributors.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const owner = 'PaddlePaddle';
2+
const repo = 'PaddleScience';
3+
4+
fetch(`https://api.github.com/repos/${owner}/${repo}/contributors?per_page=65&page=1`, {
5+
headers: {
6+
"Accept": "application/vnd.github.v3+json"
7+
}
8+
})
9+
.then(response => {
10+
if (!response.ok) {
11+
throw new Error(`HTTP error! status: ${response.status}`);
12+
}
13+
return response.json();
14+
})
15+
.then(data => {
16+
const contributorsDiv = document.getElementById('contributors');
17+
data.forEach(contributor => {
18+
const a = document.createElement('a');
19+
a.href = `https://github.com/${contributor.login}`;
20+
a.innerHTML = `<img class="avatar" src="${contributor.avatar_url}" alt="avatar" />`;
21+
contributorsDiv.appendChild(a);
22+
});
23+
})
24+
.catch((error) => {
25+
console.error('Fetching contributors failed:', error);
26+
});

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ markdown_extensions:
211211
extra_javascript:
212212
- javascripts/bd_statistics.js
213213
- javascripts/mathjax.js
214+
- javascripts/contributors.js
214215
- https://polyfill.io/v3/polyfill.min.js?features=es6
215216
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
216217

ppsci/equation/pde/base.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ def add_equation(self, name: str, equation: Callable):
8585
def parameters(self) -> List[paddle.Tensor]:
8686
"""Return learnable parameters contained in PDE.
8787
88-
Args:
89-
None
90-
9188
Returns:
9289
List[Tensor]: A list of learnable parameters.
9390
@@ -106,9 +103,6 @@ def parameters(self) -> List[paddle.Tensor]:
106103
def state_dict(self) -> Dict[str, paddle.Tensor]:
107104
"""Return named learnable parameters in dict.
108105
109-
Args:
110-
None
111-
112106
Returns:
113107
Dict[str, Tensor]: A dict of states(str) and learnable parameters(Tensor).
114108
@@ -125,14 +119,16 @@ def state_dict(self) -> Dict[str, paddle.Tensor]:
125119

126120
return self.learnable_parameters.state_dict()
127121

128-
def set_state_dict(self, state_dict: Dict[str, paddle.Tensor]):
122+
def set_state_dict(
123+
self, state_dict: Dict[str, paddle.Tensor]
124+
) -> Tuple[List[str], List[str]]:
129125
"""Set state dict from dict.
130126
131127
Args:
132128
state_dict (Dict[str, paddle.Tensor]): The state dict to be set.
133129
134130
Returns:
135-
None
131+
Tuple[List[str], List[str]]: List of missing_keys and unexpected_keys.
136132
137133
Examples:
138134
>>> import paddle
@@ -148,7 +144,7 @@ def set_state_dict(self, state_dict: Dict[str, paddle.Tensor]):
148144
Tensor(shape=[], dtype=float64, place=Place(gpu:0), stop_gradient=False,
149145
0.))])
150146
"""
151-
self.learnable_parameters.set_state_dict(state_dict)
147+
return self.learnable_parameters.set_state_dict(state_dict)
152148

153149
def __str__(self):
154150
return ", ".join(

ppsci/geometry/geometry.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,11 +659,8 @@ def __and__(self, other: "Geometry") -> "Geometry":
659659
def __str__(self) -> str:
660660
"""Return the name of class.
661661
662-
Args:
663-
None.
664-
665662
Returns:
666-
str: The name of class.
663+
str: Meta information of geometry.
667664
668665
Examples:
669666
>>> import ppsci

ppsci/geometry/timedomain.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ def __init__(
7575
elif timestamps is not None:
7676
self.num_timestamps = len(timestamps)
7777

78-
def on_initial(self, t: np.ndarray):
78+
def on_initial(self, t: np.ndarray) -> np.ndarray:
7979
"""Check if a specific time is on the initial time point.
8080
8181
Args:
8282
t (np.ndarray): The time to be checked.
8383
8484
Returns:
85-
bool: True or False for whether the specific time is on the initial time point.
85+
np.ndarray: Bool numpy array of whether the specific time is on the initial time point.
8686
8787
Examples:
8888
>>> import paddle
@@ -132,7 +132,7 @@ def boundary_normal(self, x):
132132
normal = self.geometry.boundary_normal(x[:, 1:])
133133
return np.hstack((x[:, :1], normal))
134134

135-
def uniform_points(self, n: int, boundary: bool = True):
135+
def uniform_points(self, n: int, boundary: bool = True) -> np.ndarray:
136136
"""Uniform points on the spatial-temporal domain.
137137
Geometry volume ~ bbox.
138138
Time volume ~ diam.
@@ -202,7 +202,7 @@ def uniform_points(self, n: int, boundary: bool = True):
202202

203203
def random_points(
204204
self, n: int, random: str = "pseudo", criteria: Optional[Callable] = None
205-
):
205+
) -> np.ndarray:
206206
"""Generate random points on the spatial-temporal domain.
207207
208208
Args:
@@ -347,7 +347,9 @@ def random_points(
347347
t = np.random.permutation(t)
348348
return np.hstack((t, x))
349349

350-
def uniform_boundary_points(self, n: int, criteria: Optional[Callable] = None):
350+
def uniform_boundary_points(
351+
self, n: int, criteria: Optional[Callable] = None
352+
) -> np.ndarray:
351353
"""Uniform boundary points on the spatial-temporal domain.
352354
Geometry surface area ~ bbox.
353355
Time surface area ~ diam.
@@ -427,7 +429,7 @@ def uniform_boundary_points(self, n: int, criteria: Optional[Callable] = None):
427429

428430
def random_boundary_points(
429431
self, n: int, random: str = "pseudo", criteria: Optional[Callable] = None
430-
):
432+
) -> np.ndarray:
431433
"""Random boundary points on the spatial-temporal domain.
432434
433435
Args:
@@ -621,7 +623,7 @@ def random_boundary_points(
621623
else:
622624
return t_x
623625

624-
def uniform_initial_points(self, n: int):
626+
def uniform_initial_points(self, n: int) -> np.ndarray:
625627
"""Generate evenly distributed point coordinates on the spatial-temporal domain at the initial moment.
626628
627629
Args:
@@ -645,7 +647,7 @@ def uniform_initial_points(self, n: int):
645647
x = x[:n]
646648
return np.hstack((np.full([n, 1], t, dtype=paddle.get_default_dtype()), x))
647649

648-
def random_initial_points(self, n: int, random: str = "pseudo"):
650+
def random_initial_points(self, n: int, random: str = "pseudo") -> np.ndarray:
649651
"""Generate randomly distributed point coordinates on the spatial-temporal domain at the initial moment.
650652
651653
Args:
@@ -668,7 +670,9 @@ def random_initial_points(self, n: int, random: str = "pseudo"):
668670
t = self.timedomain.t0
669671
return np.hstack((np.full([n, 1], t, dtype=paddle.get_default_dtype()), x))
670672

671-
def periodic_point(self, x: Dict[str, np.ndarray], component: int):
673+
def periodic_point(
674+
self, x: Dict[str, np.ndarray], component: int
675+
) -> Dict[str, np.ndarray]:
672676
"""process given point coordinates to satisfy the periodic boundary conditions of the geometry.
673677
674678
Args:
@@ -704,7 +708,7 @@ def sample_initial_interior(
704708
criteria: Optional[Callable] = None,
705709
evenly: bool = False,
706710
compute_sdf_derivatives: bool = False,
707-
):
711+
) -> Dict[str, np.ndarray]:
708712
"""Sample random points in the time-geometry and return those meet criteria.
709713
710714
Args:

0 commit comments

Comments
 (0)