Skip to content

Commit cbd16df

Browse files
committed
type check fix
1 parent 4a648bd commit cbd16df

3 files changed

Lines changed: 28 additions & 25 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ jobs:
3030
steps:
3131
- uses: actions/checkout@v4
3232
- uses: astral-sh/setup-uv@v4
33+
with:
34+
python-version: "3.12"
35+
- name: Install dependencies
36+
run: uv sync --dev
37+
working-directory: python
3338
- name: Type check
34-
run: uvx ty check src
39+
run: uv run ty check src
3540
working-directory: python
3641

3742
test:

python/examples/piezoelectric_cantilever.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import matplotlib.pyplot as plt
1818
import numpy as np
1919

20+
plt.style.use("piezod")
21+
2022
from piezod import CantileverPiezoelectric, FluidType, PiezoMaterial
2123

2224
# =============================================================================
@@ -144,52 +146,48 @@
144146
v_sens_aln = c_aln.v_f_sensitivity(freq)
145147
c_pzt.fluid = FluidType.AIR
146148
v_sens_pzt = c_pzt.v_f_sensitivity(freq)
147-
ax1.loglog(freq, v_sens_aln, "b-", linewidth=2, label="AlN")
148-
ax1.loglog(freq, v_sens_pzt, "r-", linewidth=2, label="PZT")
149+
ax1.loglog(freq, v_sens_aln, "b-", label="AlN")
150+
ax1.loglog(freq, v_sens_pzt, "r-", label="PZT")
149151
ax1.set_xlabel("Frequency (Hz)")
150152
ax1.set_ylabel("Voltage Sensitivity (V/N)")
151153
ax1.set_title("Voltage Mode Force Sensitivity")
152154
ax1.legend()
153-
ax1.grid(True, alpha=0.3)
154155

155156
# Plot 2: Voltage noise comparison
156157
ax2 = axes[0, 1]
157158
Vn_aln = c_aln.Vn(freq)
158159
Vn_pzt = c_pzt.Vn(freq)
159-
ax2.loglog(freq, Vn_aln * 1e9, "b-", linewidth=2, label="AlN")
160-
ax2.loglog(freq, Vn_pzt * 1e9, "r-", linewidth=2, label="PZT")
160+
ax2.loglog(freq, Vn_aln * 1e9, "b-", label="AlN")
161+
ax2.loglog(freq, Vn_pzt * 1e9, "r-", label="PZT")
161162
ax2.set_xlabel("Frequency (Hz)")
162163
ax2.set_ylabel("Voltage Noise (nV/sqrt(Hz))")
163164
ax2.set_title("Voltage Mode Noise")
164165
ax2.legend()
165-
ax2.grid(True, alpha=0.3)
166166

167167
# Plot 3: Force noise density (voltage mode)
168168
ax3 = axes[1, 0]
169169
Sfminv_aln = c_aln.Sfminv(freq)
170170
Sfminv_pzt = c_pzt.Sfminv(freq)
171-
ax3.loglog(freq, Sfminv_aln * 1e12, "b-", linewidth=2, label="AlN")
172-
ax3.loglog(freq, Sfminv_pzt * 1e12, "r-", linewidth=2, label="PZT")
171+
ax3.loglog(freq, Sfminv_aln * 1e12, "b-", label="AlN")
172+
ax3.loglog(freq, Sfminv_pzt * 1e12, "r-", label="PZT")
173173
ax3.set_xlabel("Frequency (Hz)")
174174
ax3.set_ylabel("Force Noise (pN/sqrt(Hz))")
175175
ax3.set_title("Force Noise Density (Voltage Mode)")
176176
ax3.legend()
177-
ax3.grid(True, alpha=0.3)
178177

179178
# Plot 4: Force noise density (charge mode)
180179
ax4 = axes[1, 1]
181180
Sfminq_aln = c_aln.Sfminq(freq)
182181
Sfminq_pzt = c_pzt.Sfminq(freq)
183-
ax4.loglog(freq, Sfminq_aln * 1e12, "b-", linewidth=2, label="AlN")
184-
ax4.loglog(freq, Sfminq_pzt * 1e12, "r-", linewidth=2, label="PZT")
182+
ax4.loglog(freq, Sfminq_aln * 1e12, "b-", label="AlN")
183+
ax4.loglog(freq, Sfminq_pzt * 1e12, "r-", label="PZT")
185184
ax4.set_xlabel("Frequency (Hz)")
186185
ax4.set_ylabel("Force Noise (pN/sqrt(Hz))")
187186
ax4.set_title("Force Noise Density (Charge Mode)")
188187
ax4.legend()
189-
ax4.grid(True, alpha=0.3)
190188

191189
plt.tight_layout()
192-
plt.savefig("piezoelectric_cantilever_comparison.png", dpi=150)
190+
plt.savefig("piezoelectric_cantilever_comparison.png")
193191
print("Saved comparison plot to: piezoelectric_cantilever_comparison.png")
194192

195193
# =============================================================================

python/examples/poly_cantilever.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import matplotlib.pyplot as plt
1414
import numpy as np
1515

16+
plt.style.use("piezod")
17+
1618
from piezod import CantileverPoly, Material
1719

1820
# =============================================================================
@@ -161,27 +163,25 @@
161163
amp_psd = c_poly.amplifier_PSD(freq)
162164
total_psd = johnson_psd + hooge_psd + thermo_psd + amp_psd
163165

164-
ax.loglog(freq, np.sqrt(johnson_psd) * 1e9, "b-", linewidth=2, label="Johnson")
165-
ax.loglog(freq, np.sqrt(hooge_psd) * 1e9, "r-", linewidth=2, label="1/f (Hooge)")
166-
ax.loglog(freq, np.sqrt(thermo_psd) * 1e9, "g-", linewidth=2, label="Thermomechanical")
167-
ax.loglog(freq, np.sqrt(amp_psd) * 1e9, "m-", linewidth=2, label="Amplifier")
168-
ax.loglog(freq, np.sqrt(total_psd) * 1e9, "k--", linewidth=2, label="Total")
166+
ax.loglog(freq, np.sqrt(johnson_psd) * 1e9, "b-", label="Johnson")
167+
ax.loglog(freq, np.sqrt(hooge_psd) * 1e9, "r-", label="1/f (Hooge)")
168+
ax.loglog(freq, np.sqrt(thermo_psd) * 1e9, "g-", label="Thermomechanical")
169+
ax.loglog(freq, np.sqrt(amp_psd) * 1e9, "m-", label="Amplifier")
170+
ax.loglog(freq, np.sqrt(total_psd) * 1e9, "k--", label="Total")
169171

170172
ax.axvline(x=c_poly.knee_frequency(), color="gray", linestyle=":", alpha=0.7)
171173
ax.text(
172174
c_poly.knee_frequency() * 1.1,
173175
np.sqrt(johnson_psd[0]) * 1e9 * 0.5,
174176
f"Knee: {c_poly.knee_frequency():.0f} Hz",
175-
fontsize=10,
176177
)
177178

178-
ax.set_xlabel("Frequency (Hz)", fontsize=12)
179-
ax.set_ylabel("Voltage Noise (nV/sqrt(Hz))", fontsize=12)
180-
ax.set_title("Poly-Si Cantilever Noise Spectrum", fontsize=14)
179+
ax.set_xlabel("Frequency (Hz)")
180+
ax.set_ylabel("Voltage Noise (nV/sqrt(Hz))")
181+
ax.set_title("Poly-Si Cantilever Noise Spectrum")
181182
ax.legend(loc="upper right")
182-
ax.grid(True, alpha=0.3)
183183
ax.set_xlim([1, 1000])
184184

185185
plt.tight_layout()
186-
plt.savefig("poly_cantilever_noise.png", dpi=150)
186+
plt.savefig("poly_cantilever_noise.png")
187187
print("Saved noise spectrum to: poly_cantilever_noise.png")

0 commit comments

Comments
 (0)