Skip to content

Commit 46a2009

Browse files
author
Uli Köhler
committed
Fix docstring linting errors in UliEngineering/Chemistry/ files
1 parent 2f2a55b commit 46a2009

2 files changed

Lines changed: 92 additions & 54 deletions

File tree

UliEngineering/Chemistry/Absorption.py

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ def absorption_length_from_absorption_coefficient(absorption_coefficient: Absorp
3636
"""
3737
Compute the absorption length (in meters) from the extinction coefficient (in 1/m).
3838
Absorption length is defined as the distance over which the intensity drops to 1/e.
39-
Formula: absorption_length = 1 / absorption_coefficient):
39+
Formula: absorption_length = 1 / absorption_coefficient.
4040
41-
NOTE: The absopriotn coefficient must bei in 1/m, not in 1/cm or any other unit.
41+
NOTE: The absorption coefficient must be in 1/m, not in 1/cm or any other unit.
4242
43-
Parameters:
44-
- absorption_coefficient):: Extinction coefficient in 1/m (scalar, list, or ndarray).
45-
46-
Returns:
47-
- Absorption length in meters.
43+
Parameters
44+
----------
45+
absorption_coefficient : AbsorptionCoefficientPerMeter
46+
Extinction coefficient in 1/m (scalar, list, or ndarray).
4847
48+
Returns
49+
-------
50+
float or numpy.ndarray
51+
Absorption length in meters.
4952
"""
5053
absorption_coefficient = normalize_absorption_coefficient(absorption_coefficient) if isinstance(absorption_coefficient, str) else absorption_coefficient
5154
return np.reciprocal(absorption_coefficient)
@@ -54,31 +57,40 @@ def absorption_length_from_absorption_coefficient(absorption_coefficient: Absorp
5457
def extinction_coefficient_from_absorption_length(absorption_length: LengthMeter):
5558
"""
5659
Compute the extinction coefficient (in 1/m) from the absorption length (in meters).
57-
Formula: extinction_coefficient = 1 / absorption_length
60+
Formula: extinction_coefficient = 1 / absorption_length.
5861
59-
Parameters:
60-
- absorption_length: Absorption length in meters (scalar, list, or ndarray).
62+
Parameters
63+
----------
64+
absorption_length : LengthMeter
65+
Absorption length in meters (scalar, list, or ndarray).
6166
62-
Returns:
63-
- Extinction coefficient in 1/m.
67+
Returns
68+
-------
69+
float or numpy.ndarray
70+
Extinction coefficient in 1/m.
6471
"""
6572
absorption_length = normalize_length(absorption_length) if isinstance(absorption_length, str) else absorption_length
6673
return np.reciprocal(absorption_length)
6774

6875
@returns_unit("")
6976
def remaining_light_fraction(length: LengthMeter, absorption_coefficient: AbsorptionCoefficientPerMeter):
7077
"""
71-
Compute the remaining fraction of light after passing through a medium of given length (in meters).
78+
Compute the remaining fraction of light after passing through a medium of given length (in meters)
7279
with a given extinction coefficient (in 1/m).
7380
74-
Formula: fraction = exp(-absorption_coefficient * length)
81+
Formula: fraction = exp(-absorption_coefficient * length).
7582
76-
Parameters:
77-
- length: Length of the medium (scalar, list, or ndarray, any unit parsable by normalize_length)
78-
- absorption_coefficient: Extinction coefficient in 1/m (scalar, list, or ndarray)
83+
Parameters
84+
----------
85+
length : LengthMeter
86+
Length of the medium (scalar, list, or ndarray, any unit parsable by normalize_length).
87+
absorption_coefficient : AbsorptionCoefficientPerMeter
88+
Extinction coefficient in 1/m (scalar, list, or ndarray).
7989
80-
Returns:
81-
- Remaining fraction of light (unitless)
90+
Returns
91+
-------
92+
float or numpy.ndarray
93+
Remaining fraction of light (unitless).
8294
"""
8395
length = normalize_length(length) if isinstance(length, str) else length
8496
absorption_coefficient = normalize_absorption_coefficient(absorption_coefficient) if isinstance(absorption_coefficient, str) else absorption_coefficient
@@ -90,14 +102,19 @@ def length_from_remaining_fraction(remaining_fraction, absorption_coefficient: A
90102
Compute the length of the medium (in meters) given the remaining fraction of light
91103
and the extinction coefficient (in 1/m).
92104
93-
Formula: length = -ln(remaining_fraction) / absorption_coefficient
105+
Formula: length = -ln(remaining_fraction) / absorption_coefficient.
94106
95-
Parameters:
96-
- remaining_fraction: Remaining fraction of light (scalar, list, or ndarray, unitless)
97-
- absorption_coefficient: Extinction coefficient in 1/m (scalar, list, or ndarray)
107+
Parameters
108+
----------
109+
remaining_fraction : float or numpy.ndarray
110+
Remaining fraction of light (scalar, list, or ndarray, unitless).
111+
absorption_coefficient : AbsorptionCoefficientPerMeter
112+
Extinction coefficient in 1/m (scalar, list, or ndarray).
98113
99-
Returns:
100-
- Length in meters.
114+
Returns
115+
-------
116+
float or numpy.ndarray
117+
Length in meters.
101118
"""
102119
absorption_coefficient = normalize_absorption_coefficient(absorption_coefficient) if isinstance(absorption_coefficient, str) else absorption_coefficient
103120
return -np.log(remaining_fraction) / absorption_coefficient
@@ -108,11 +125,15 @@ def half_length(absorption_coefficient: AbsorptionCoefficientPerMeter):
108125
Compute the half-length, i.e., the length of medium where the remaining fraction of light is 0.5,
109126
for a given extinction coefficient (in 1/m).
110127
111-
Parameters:
112-
- absorption_coefficient: Extinction coefficient in 1/m (scalar, list, or ndarray)
128+
Parameters
129+
----------
130+
absorption_coefficient : AbsorptionCoefficientPerMeter
131+
Extinction coefficient in 1/m (scalar, list, or ndarray).
113132
114-
Returns:
115-
- Half-length in meters.
133+
Returns
134+
-------
135+
float or numpy.ndarray
136+
Half-length in meters.
116137
"""
117138
return length_from_remaining_fraction(0.5, absorption_coefficient)
118139

@@ -124,18 +145,23 @@ def absorption_coefficient_from_extinction_coefficient(extinction_coefficient, w
124145
125146
Uses the formula:
126147
alpha = (2 * omega * kappa) / c
127-
where omega = 2 * pi * c / wavelength
148+
where omega = 2 * pi * c / wavelength.
128149
129150
Source:
130151
SOLID STATE PHYSICS, Part II, M. S. Dresselhaus, Formula 5.2
131152
https://web.mit.edu/course/6/6.732/www/6.732-pt2.pdf
132153
133-
Parameters:
134-
- extinction_coefficient: Extinction coefficient kappa (unitless)
135-
- wavelength: Wavelength (meters or any unit parsable by normalize_length)
136-
137-
Returns:
138-
- Absorption coefficient alpha in 1/m
154+
Parameters
155+
----------
156+
extinction_coefficient : float or numpy.ndarray
157+
Extinction coefficient kappa (unitless).
158+
wavelength : LengthMeter
159+
Wavelength (meters or any unit parsable by normalize_length).
160+
161+
Returns
162+
-------
163+
float or numpy.ndarray
164+
Absorption coefficient alpha in 1/m.
139165
"""
140166
wavelength = normalize_length(wavelength) if isinstance(wavelength, str) else wavelength
141167
omega = 2 * np.pi * speed_of_light / wavelength

UliEngineering/Chemistry/DNARNA.py

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,21 @@ def dnarna_molecular_weight(length_nucleotides, fractions: NucleotideFractions =
107107
Compute the molecular weight of a single-stranded DNA molecule (e.g., oligonucleotide).
108108
109109
Formula (for single-stranded DNA):
110-
M.W. = (An x 313.2) + (Tn x 304.2) + (Cn x 289.2) + (Gn x 329.2) + 79.0
111-
112-
Parameters:
113-
- length_nucleotides: Length of the DNA in nucleotides (not base pairs!).
114-
- fractions: NucleotideFractions dataclass instance (A, T, G, C, U fractions, should sum to 1.0, U ignored).
115-
- nucleotide_weights: DNANucleotideWeights dataclass instance (optional, default standard values)
116-
117-
Returns:
118-
- Molecular weight in g/mol.
110+
M.W. = (An x 313.2) + (Tn x 304.2) + (Cn x 289.2) + (Gn x 329.2) + 79.0.
111+
112+
Parameters
113+
----------
114+
length_nucleotides : float or numpy.ndarray
115+
Length of the DNA in nucleotides (not base pairs!).
116+
fractions : NucleotideFractions
117+
NucleotideFractions dataclass instance (A, T, G, C, U fractions, should sum to 1.0, U ignored).
118+
nucleotide_weights : DNANucleotideWeights, optional
119+
DNANucleotideWeights dataclass instance (optional, default standard values).
120+
121+
Returns
122+
-------
123+
float or numpy.ndarray
124+
Molecular weight in g/mol.
119125
"""
120126
length_nucleotides = normalize_numeric(length_nucleotides) if isinstance(length_nucleotides, str) else length_nucleotides
121127
n_A = length_nucleotides * fractions.A
@@ -137,15 +143,21 @@ def rna_molecular_weight(length_nucleotides, fractions: NucleotideFractions = DN
137143
Compute the molecular weight of a single-stranded RNA molecule (e.g., oligonucleotide).
138144
139145
Formula (for single-stranded RNA):
140-
M.W. = (An x 329.2) + (Un x 306.2) + (Cn x 305.2) + (Gn x 345.2) + 159
141-
142-
Parameters:
143-
- length_nucleotides: Length of the RNA in nucleotides (not base pairs!).
144-
- fractions: NucleotideFractions dataclass instance (A, U, G, C, T fractions, should sum to 1.0, T ignored).
145-
- nucleotide_weights: RNANucleotideWeights dataclass instance (optional, default standard values)
146-
147-
Returns:
148-
- Molecular weight in g/mol.
146+
M.W. = (An x 329.2) + (Un x 306.2) + (Cn x 305.2) + (Gn x 345.2) + 159.
147+
148+
Parameters
149+
----------
150+
length_nucleotides : float or numpy.ndarray
151+
Length of the RNA in nucleotides (not base pairs!).
152+
fractions : NucleotideFractions
153+
NucleotideFractions dataclass instance (A, U, G, C, T fractions, should sum to 1.0, T ignored).
154+
nucleotide_weights : RNANucleotideWeights, optional
155+
RNANucleotideWeights dataclass instance (optional, default standard values).
156+
157+
Returns
158+
-------
159+
float or numpy.ndarray
160+
Molecular weight in g/mol.
149161
"""
150162
length_nucleotides = normalize_numeric(length_nucleotides) if isinstance(length_nucleotides, str) else length_nucleotides
151163
n_A = length_nucleotides * fractions.A

0 commit comments

Comments
 (0)