Skip to content

Commit d53810f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 236393c commit d53810f

File tree

2 files changed

+47
-47
lines changed

2 files changed

+47
-47
lines changed

machine_learning/multilayer_perceptron_classifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ def wrapper(y):
2626
if __name__ == "__main__":
2727
import doctest
2828

29-
doctest.testmod()
29+
doctest.testmod()

physics/maxwells_equations.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@ def gauss_law_electric(
3131
) -> bool:
3232
"""
3333
Gauss's law for electricity: ∇·E = ρ/ε₀
34-
34+
3535
In integral form: ∮E·dA = Q_enclosed/ε₀
36-
37-
This law states that the electric flux through any closed surface is
36+
37+
This law states that the electric flux through any closed surface is
3838
proportional to the total electric charge enclosed within that surface.
39-
39+
4040
Args:
4141
electric_field_magnitude: Magnitude of electric field (V/m or N/C)
4242
surface_area: Area of the closed surface (m²)
4343
enclosed_charge: Total charge enclosed by the surface (C - coulombs)
4444
permittivity: Permittivity of the medium (F/m), defaults to vacuum
45-
45+
4646
Returns:
4747
bool: True if Gauss's law is satisfied within numerical tolerance
48-
48+
4949
Raises:
5050
ValueError: If surface_area is negative or permittivity is non-positive
51-
51+
5252
Example:
5353
>>> gauss_law_electric(1000, 1.0, 8.854e-9)
5454
True
@@ -79,24 +79,24 @@ def gauss_law_magnetic(
7979
) -> bool:
8080
"""
8181
Gauss's law for magnetism: ∇·B = 0
82-
82+
8383
In integral form: ∮B·dA = 0
84-
84+
8585
This law states that there are no magnetic monopoles - the magnetic flux
8686
through any closed surface is always zero. Magnetic field lines always
8787
form closed loops or extend to infinity.
88-
88+
8989
Args:
9090
magnetic_field_magnitude: Magnitude of magnetic field (T - tesla)
9191
surface_area: Area of the closed surface (m²)
92-
92+
9393
Returns:
9494
bool: Always True for physically realistic magnetic fields,
9595
False if net flux is non-zero (indicating monopoles)
96-
96+
9797
Raises:
9898
ValueError: If surface_area is negative
99-
99+
100100
Example:
101101
>>> gauss_law_magnetic(0.5, 2.0)
102102
True
@@ -124,19 +124,19 @@ def faraday_law(
124124
) -> bool:
125125
"""
126126
Faraday's law of electromagnetic induction: ∇×E = -∂B/∂t
127-
127+
128128
In integral form: ∮E·dl = -dΦ_B/dt
129-
129+
130130
This law describes how a changing magnetic field induces an electric field.
131131
The induced electric field opposes the change in magnetic flux (Lenz's law).
132-
132+
133133
Args:
134134
electric_field_circulation: Line integral of E around closed loop (V)
135135
magnetic_flux_change_rate: Rate of change of magnetic flux (Wb/s or V)
136-
136+
137137
Returns:
138138
bool: True if Faraday's law is satisfied within numerical tolerance
139-
139+
140140
Example:
141141
>>> faraday_law(10.0, -10.0)
142142
True
@@ -164,26 +164,26 @@ def ampere_maxwell_law(
164164
) -> bool:
165165
"""
166166
Ampère-Maxwell law: ∇×B = μ₀(J + ε₀∂E/∂t)
167-
167+
168168
In integral form: ∮B·dl = μ₀(I_enclosed + ε₀dΦ_E/dt)
169-
169+
170170
This law relates magnetic fields to electric currents and changing electric fields.
171171
Maxwell's addition of the displacement current term (ε₀∂E/∂t) was crucial for
172172
predicting electromagnetic waves.
173-
173+
174174
Args:
175175
magnetic_field_circulation: Line integral of B around closed loop (T·m)
176176
enclosed_current: Current passing through surface bounded by loop (A)
177177
electric_flux_change_rate: Rate of change of electric flux (V·m/s)
178178
permeability: Permeability of the medium (H/m), defaults to vacuum
179179
permittivity: Permittivity of the medium (F/m), defaults to vacuum
180-
180+
181181
Returns:
182182
bool: True if Ampère-Maxwell law is satisfied within numerical tolerance
183-
183+
184184
Raises:
185185
ValueError: If permeability or permittivity is non-positive
186-
186+
187187
Example:
188188
>>> ampere_maxwell_law(1.256e-6, 1.0, 0.0)
189189
True
@@ -217,20 +217,20 @@ def electromagnetic_wave_speed(
217217
) -> float:
218218
"""
219219
Calculate the speed of electromagnetic waves in a medium.
220-
220+
221221
From Maxwell's equations: c = 1/√(μ₀ε₀) in vacuum
222222
In a medium: v = 1/√(μεr)
223-
223+
224224
Args:
225225
permeability: Permeability of the medium (H/m)
226226
permittivity: Permittivity of the medium (F/m)
227-
227+
228228
Returns:
229229
float: Speed of electromagnetic waves in the medium (m/s)
230-
230+
231231
Raises:
232232
ValueError: If permeability or permittivity is non-positive
233-
233+
234234
Example:
235235
>>> abs(electromagnetic_wave_speed() - 2.998e8) < 1e6
236236
True
@@ -252,20 +252,20 @@ def electromagnetic_wave_impedance(
252252
) -> float:
253253
"""
254254
Calculate the impedance of electromagnetic waves in a medium.
255-
255+
256256
The impedance Z₀ = √(μ/ε) determines the ratio of electric to magnetic
257257
field strength in an electromagnetic wave.
258-
258+
259259
Args:
260260
permeability: Permeability of the medium (H/m)
261261
permittivity: Permittivity of the medium (F/m)
262-
262+
263263
Returns:
264264
float: Wave impedance of the medium (Ω - ohms)
265-
265+
266266
Raises:
267267
ValueError: If permeability or permittivity is non-positive
268-
268+
269269
Example:
270270
>>> abs(electromagnetic_wave_impedance() - 376.73) < 0.01
271271
True
@@ -288,21 +288,21 @@ def poynting_vector_magnitude(
288288
) -> float:
289289
"""
290290
Calculate the magnitude of the Poynting vector (electromagnetic power flow).
291-
291+
292292
The Poynting vector S = (1/μ₀) * E × B represents the directional energy
293293
flux density of an electromagnetic field (power per unit area).
294-
294+
295295
Args:
296296
electric_field: Magnitude of electric field (V/m)
297297
magnetic_field: Magnitude of magnetic field (T)
298298
permeability: Permeability of the medium (H/m)
299-
299+
300300
Returns:
301301
float: Magnitude of Poynting vector (W/m²)
302-
302+
303303
Raises:
304304
ValueError: If permeability is non-positive
305-
305+
306306
Example:
307307
>>> abs(poynting_vector_magnitude(1000, 1e-6) - 795.8) < 1.0
308308
True
@@ -326,22 +326,22 @@ def energy_density_electromagnetic(
326326
) -> float:
327327
"""
328328
Calculate the energy density of an electromagnetic field.
329-
329+
330330
The energy density u = ½(ε₀E² + B²/μ₀) represents the electromagnetic
331331
energy stored per unit volume.
332-
332+
333333
Args:
334334
electric_field: Magnitude of electric field (V/m)
335335
magnetic_field: Magnitude of magnetic field (T)
336336
permittivity: Permittivity of the medium (F/m)
337337
permeability: Permeability of the medium (H/m)
338-
338+
339339
Returns:
340340
float: Energy density (J/m³)
341-
341+
342342
Raises:
343343
ValueError: If permittivity or permeability is non-positive
344-
344+
345345
Example:
346346
>>> abs(energy_density_electromagnetic(1000, 1e-3) - 0.398) < 0.001
347347
True
@@ -371,9 +371,9 @@ def energy_density_electromagnetic(
371371
doctest.testmod(verbose=True)
372372

373373
# Additional demonstration
374-
print("\n" + "="*50)
374+
print("\n" + "=" * 50)
375375
print("Maxwell's Equations Demonstration")
376-
print("="*50)
376+
print("=" * 50)
377377

378378
# Demonstrate speed of light calculation
379379
c = electromagnetic_wave_speed()

0 commit comments

Comments
 (0)