Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-pipeline
csst_proto
Commits
55300f36
Commit
55300f36
authored
Oct 28, 2023
by
BO ZHANG
🏀
Browse files
fix docstring and typing
parent
e5cef66b
Pipeline
#1427
failed with stage
in 0 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
csst_proto/config.py
View file @
55300f36
...
@@ -24,7 +24,7 @@ HERE: str = os.path.dirname(__file__)
...
@@ -24,7 +24,7 @@ HERE: str = os.path.dirname(__file__)
# 这个函数演示了如何利用随包数据
# 这个函数演示了如何利用随包数据
# 当config_path被指定时,会读取指定的config_path
# 当config_path被指定时,会读取指定的config_path
# 当config_path=None时,读取随包数据中的config/default_config.toml
# 当config_path=None时,读取随包数据中的config/default_config.toml
def
read_config
(
config_path
:
Optional
[
str
]
=
None
):
def
read_config
(
config_path
:
Optional
[
str
]
=
None
)
->
dict
:
"""
"""
Get config info from a toml file.
Get config info from a toml file.
...
...
csst_proto/demo.py
View file @
55300f36
...
@@ -11,7 +11,7 @@ Modified-History:
...
@@ -11,7 +11,7 @@ Modified-History:
from
typing
import
Any
from
typing
import
Any
def
demo_function
(
*
args
:
Any
):
def
demo_function
(
*
args
:
Any
)
->
int
:
"""
"""
A demo function.
A demo function.
...
@@ -66,9 +66,9 @@ class DemoClass:
...
@@ -66,9 +66,9 @@ class DemoClass:
>>> a.say_hello()
>>> a.say_hello()
"""
"""
def
__init__
(
self
,
first_name
,
last_name
):
def
__init__
(
self
,
first_name
,
last_name
)
->
None
:
self
.
first_name
=
first_name
self
.
first_name
=
first_name
self
.
last_name
=
last_name
self
.
last_name
=
last_name
def
say_hello
(
self
):
def
say_hello
(
self
)
->
None
:
print
(
"Hello, {} {}!"
.
format
(
self
.
first_name
,
self
.
last_name
))
print
(
"Hello, {} {}!"
.
format
(
self
.
first_name
,
self
.
last_name
))
csst_proto/flip_image.py
View file @
55300f36
...
@@ -61,7 +61,7 @@ def flip_image(image: np.ndarray, use_numpy: bool = False) -> np.ndarray:
...
@@ -61,7 +61,7 @@ def flip_image(image: np.ndarray, use_numpy: bool = False) -> np.ndarray:
# 此函数读取了随包数据中的test_image.txt
# 此函数读取了随包数据中的test_image.txt
def
read_default_image
():
def
read_default_image
()
->
np
.
ndarray
:
"""
"""
Read default image.
Read default image.
...
...
csst_proto/flip_image_in_parallel.py
View file @
55300f36
...
@@ -30,7 +30,8 @@ def flip_multiple_images_mp(images: list[np.ndarray], n_jobs: int) -> list[np.nd
...
@@ -30,7 +30,8 @@ def flip_multiple_images_mp(images: list[np.ndarray], n_jobs: int) -> list[np.nd
Returns
Returns
-------
-------
The flipped image list.
list[np.ndarray]
The flipped image list.
"""
"""
with
multiprocessing
.
Pool
(
n_jobs
)
as
p
:
with
multiprocessing
.
Pool
(
n_jobs
)
as
p
:
results
=
p
.
map
(
flip_image
,
images
)
results
=
p
.
map
(
flip_image
,
images
)
...
@@ -52,7 +53,8 @@ def flip_multiple_images_jl(images: list[np.ndarray], n_jobs: int) -> list[np.nd
...
@@ -52,7 +53,8 @@ def flip_multiple_images_jl(images: list[np.ndarray], n_jobs: int) -> list[np.nd
Returns
Returns
-------
-------
The flipped image list.
list[np.ndarray]
The flipped image list.
"""
"""
return
joblib
.
Parallel
(
n_jobs
=
n_jobs
,
backend
=
"multiprocessing"
)(
return
joblib
.
Parallel
(
n_jobs
=
n_jobs
,
backend
=
"multiprocessing"
)(
joblib
.
delayed
(
flip_image
)(
image
)
for
image
in
images
joblib
.
delayed
(
flip_image
)(
image
)
for
image
in
images
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment