Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Add more contributors and refine several docstrings #836

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
./README.md:thanks
--8<--

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

<style>
.avatar {
Expand All @@ -216,32 +216,7 @@
transform:translateY(-10px);
}
</style>
<a href="https://github.com/Asthestarsfalll"><img class="avatar" src="https://avatars.githubusercontent.com/Asthestarsfalll" alt="avatar" /></a>
<a href="https://github.com/co63oc"><img class="avatar" src="https://avatars.githubusercontent.com/co63oc" alt="avatar" /></a>
<a href="https://github.com/MayYouBeProsperous"><img class="avatar" src="https://avatars.githubusercontent.com/MayYouBeProsperous" alt="avatar" /></a>
<a href="https://github.com/AndPuQing"><img class="avatar" src="https://avatars.githubusercontent.com/AndPuQing" alt="avatar" /></a>
<a href="https://github.com/lknt"><img class="avatar" src="https://avatars.githubusercontent.com/lknt" alt="avatar" /></a>
<a href="https://github.com/mrcangye"><img class="avatar" src="https://avatars.githubusercontent.com/mrcangye" alt="avatar" /></a>
<a href="https://github.com/yangguohao"><img class="avatar" src="https://avatars.githubusercontent.com/yangguohao" alt="avatar" /></a>
<a href="https://github.com/ooooo-create"><img class="avatar" src="https://avatars.githubusercontent.com/ooooo-create" alt="avatar" /></a>
<a href="https://github.com/megemini"><img class="avatar" src="https://avatars.githubusercontent.com/megemini" alt="avatar" /></a>
<a href="https://github.com/DUCH714"><img class="avatar" src="https://avatars.githubusercontent.com/DUCH714" alt="avatar" /></a>
<a href="https://github.com/zlynna"><img class="avatar" src="https://avatars.githubusercontent.com/zlynna" alt="avatar" /></a>
<a href="https://github.com/jjyaoao"><img class="avatar" src="https://avatars.githubusercontent.com/jjyaoao" alt="avatar" /></a>
<a href="https://github.com/jiamingkong"><img class="avatar" src="https://avatars.githubusercontent.com/jiamingkong" alt="avatar" /></a>
<a href="https://github.com/Liyulingyue"><img class="avatar" src="https://avatars.githubusercontent.com/Liyulingyue" alt="avatar" /></a>
<a href="https://github.com/DrRyanHuang"><img class="avatar" src="https://avatars.githubusercontent.com/DrRyanHuang" alt="avatar" /></a>
<a href="https://github.com/zbt78"><img class="avatar" src="https://avatars.githubusercontent.com/zbt78" alt="avatar" /></a>
<a href="https://github.com/Gxinhu"><img class="avatar" src="https://avatars.githubusercontent.com/Gxinhu" alt="avatar" /></a>
<a href="https://github.com/XYM-1"><img class="avatar" src="https://avatars.githubusercontent.com/XYM-1" alt="avatar" /></a>
<a href="https://github.com/xusuyong"><img class="avatar" src="https://avatars.githubusercontent.com/xusuyong" alt="avatar" /></a>
<a href="https://github.com/DrownFish19"><img class="avatar" src="https://avatars.githubusercontent.com/DrownFish19" alt="avatar" /></a>
<a href="https://github.com/NKNaN"><img class="avatar" src="https://avatars.githubusercontent.com/NKNaN" alt="avatar" /></a>
<a href="https://github.com/ruoyunbai"><img class="avatar" src="https://avatars.githubusercontent.com/ruoyunbai" alt="avatar" /></a>
<a href="https://github.com/sanbuphy"><img class="avatar" src="https://avatars.githubusercontent.com/sanbuphy" alt="avatar" /></a>
<a href="https://github.com/ccsuzzh"><img class="avatar" src="https://avatars.githubusercontent.com/ccsuzzh" alt="avatar" /></a>
<a href="https://github.com/enkilee"><img class="avatar" src="https://avatars.githubusercontent.com/enkilee" alt="avatar" /></a>
<a href="https://github.com/GreatV"><img class="avatar" src="https://avatars.githubusercontent.com/GreatV" alt="avatar" /></a>
<div id="contributors"></div>

## 🤝合作单位

Expand Down
26 changes: 26 additions & 0 deletions docs/javascripts/contributors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const owner = 'PaddlePaddle';
const repo = 'PaddleScience';

fetch(`https://api.github.com/repos/${owner}/${repo}/contributors?per_page=65&page=1`, {
headers: {
"Accept": "application/vnd.github.v3+json"
}
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
const contributorsDiv = document.getElementById('contributors');
data.forEach(contributor => {
const a = document.createElement('a');
a.href = `https://github.com/${contributor.login}`;
a.innerHTML = `<img class="avatar" src="${contributor.avatar_url}" alt="avatar" />`;
contributorsDiv.appendChild(a);
});
})
.catch((error) => {
console.error('Fetching contributors failed:', error);
});
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ markdown_extensions:
extra_javascript:
- javascripts/bd_statistics.js
- javascripts/mathjax.js
- javascripts/contributors.js
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

Expand Down
14 changes: 5 additions & 9 deletions ppsci/equation/pde/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ def add_equation(self, name: str, equation: Callable):
def parameters(self) -> List[paddle.Tensor]:
"""Return learnable parameters contained in PDE.

Args:
None

Returns:
List[Tensor]: A list of learnable parameters.

Expand All @@ -106,9 +103,6 @@ def parameters(self) -> List[paddle.Tensor]:
def state_dict(self) -> Dict[str, paddle.Tensor]:
"""Return named learnable parameters in dict.

Args:
None

Returns:
Dict[str, Tensor]: A dict of states(str) and learnable parameters(Tensor).

Expand All @@ -125,14 +119,16 @@ def state_dict(self) -> Dict[str, paddle.Tensor]:

return self.learnable_parameters.state_dict()

def set_state_dict(self, state_dict: Dict[str, paddle.Tensor]):
def set_state_dict(
self, state_dict: Dict[str, paddle.Tensor]
) -> Tuple[List[str], List[str]]:
"""Set state dict from dict.

Args:
state_dict (Dict[str, paddle.Tensor]): The state dict to be set.

Returns:
None
Tuple[List[str], List[str]]: List of missing_keys and unexpected_keys.

Examples:
>>> import paddle
Expand All @@ -148,7 +144,7 @@ def set_state_dict(self, state_dict: Dict[str, paddle.Tensor]):
Tensor(shape=[], dtype=float64, place=Place(gpu:0), stop_gradient=False,
0.))])
"""
self.learnable_parameters.set_state_dict(state_dict)
return self.learnable_parameters.set_state_dict(state_dict)

def __str__(self):
return ", ".join(
Expand Down
5 changes: 1 addition & 4 deletions ppsci/geometry/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,11 +659,8 @@ def __and__(self, other: "Geometry") -> "Geometry":
def __str__(self) -> str:
"""Return the name of class.

Args:
None.

Returns:
str: The name of class.
str: Meta information of geometry.

Examples:
>>> import ppsci
Expand Down
24 changes: 14 additions & 10 deletions ppsci/geometry/timedomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ def __init__(
elif timestamps is not None:
self.num_timestamps = len(timestamps)

def on_initial(self, t: np.ndarray):
def on_initial(self, t: np.ndarray) -> np.ndarray:
"""Check if a specific time is on the initial time point.

Args:
t (np.ndarray): The time to be checked.

Returns:
bool: True or False for whether the specific time is on the initial time point.
np.ndarray: Bool numpy array of whether the specific time is on the initial time point.

Examples:
>>> import paddle
Expand Down Expand Up @@ -132,7 +132,7 @@ def boundary_normal(self, x):
normal = self.geometry.boundary_normal(x[:, 1:])
return np.hstack((x[:, :1], normal))

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

def random_points(
self, n: int, random: str = "pseudo", criteria: Optional[Callable] = None
):
) -> np.ndarray:
"""Generate random points on the spatial-temporal domain.

Args:
Expand Down Expand Up @@ -347,7 +347,9 @@ def random_points(
t = np.random.permutation(t)
return np.hstack((t, x))

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

def random_boundary_points(
self, n: int, random: str = "pseudo", criteria: Optional[Callable] = None
):
) -> np.ndarray:
"""Random boundary points on the spatial-temporal domain.

Args:
Expand Down Expand Up @@ -621,7 +623,7 @@ def random_boundary_points(
else:
return t_x

def uniform_initial_points(self, n: int):
def uniform_initial_points(self, n: int) -> np.ndarray:
"""Generate evenly distributed point coordinates on the spatial-temporal domain at the initial moment.

Args:
Expand All @@ -645,7 +647,7 @@ def uniform_initial_points(self, n: int):
x = x[:n]
return np.hstack((np.full([n, 1], t, dtype=paddle.get_default_dtype()), x))

def random_initial_points(self, n: int, random: str = "pseudo"):
def random_initial_points(self, n: int, random: str = "pseudo") -> np.ndarray:
"""Generate randomly distributed point coordinates on the spatial-temporal domain at the initial moment.

Args:
Expand All @@ -668,7 +670,9 @@ def random_initial_points(self, n: int, random: str = "pseudo"):
t = self.timedomain.t0
return np.hstack((np.full([n, 1], t, dtype=paddle.get_default_dtype()), x))

def periodic_point(self, x: Dict[str, np.ndarray], component: int):
def periodic_point(
self, x: Dict[str, np.ndarray], component: int
) -> Dict[str, np.ndarray]:
"""process given point coordinates to satisfy the periodic boundary conditions of the geometry.

Args:
Expand Down Expand Up @@ -704,7 +708,7 @@ def sample_initial_interior(
criteria: Optional[Callable] = None,
evenly: bool = False,
compute_sdf_derivatives: bool = False,
):
) -> Dict[str, np.ndarray]:
"""Sample random points in the time-geometry and return those meet criteria.

Args:
Expand Down