mirror of
https://gitlab.rlp.net/mobitar/julia_course.git
synced 2024-11-16 13:28:10 +00:00
Small fixes
This commit is contained in:
parent
0a85005cce
commit
5334e3f8f5
1 changed files with 6 additions and 4 deletions
|
@ -127,7 +127,7 @@ df2[0.15 .< df2.B .< 0.2, :]
|
|||
df2[(0.15 .< df2.B .< 0.2) .|| (df2.B .> 0.97), :]
|
||||
|
||||
# ╔═╡ 403e40d1-87ba-4847-951f-be7bca058573
|
||||
# Replace all table enteries having the value 100 with 42
|
||||
# Replace all table entries having the value 100 with 42
|
||||
replace!(df2.A, 100 => 42)
|
||||
|
||||
# ╔═╡ 44dd5cb6-0ad9-443a-ba48-fa551d8971b4
|
||||
|
@ -135,7 +135,7 @@ replace!(df2.A, 100 => 42)
|
|||
last(df2, 3)
|
||||
|
||||
# ╔═╡ 53c09851-b6a8-4e1e-abfb-9b1b7bc991e1
|
||||
# More flexiblity using `replace!`
|
||||
# More flexibility using `replace!`
|
||||
replace!(df2.A) do x
|
||||
# Anonymous function
|
||||
if isodd(x)
|
||||
|
@ -330,7 +330,8 @@ end
|
|||
|
||||
# Usually, you should not copy code! 😯
|
||||
# There is a better way of handling this redefinition without much copying.
|
||||
# But this code improvement was not done to avoid complication at this point.
|
||||
# The most elegant way would be to define a macro that rewrites your function and adds the two exclamation marks.
|
||||
# But this code improvement was not done to avoid unneeded complexity at this point.
|
||||
|
||||
# ╔═╡ 5280cdc2-bfcf-4c38-85f2-6134aa95d679
|
||||
# How to use the custom scattering function
|
||||
|
@ -454,7 +455,7 @@ Again, you can automate this process!
|
|||
"""
|
||||
|
||||
# ╔═╡ ef6274cf-f1fb-4f86-becf-eeb181ed92fc
|
||||
function automated_fit(model, df, x_column_name, y_column_name, p0=[1.0, 1.0])
|
||||
function automated_fit(model, df, x_column_name, y_column_name, p0)
|
||||
fit = curve_fit(
|
||||
model,
|
||||
ustrip.(Measurements.value.(df[!, x_column_name])),
|
||||
|
@ -475,6 +476,7 @@ param2, sigma2 = automated_fit(
|
|||
df_I_B_with_err,
|
||||
"I",
|
||||
"B",
|
||||
p0
|
||||
)
|
||||
|
||||
# ╔═╡ 00000000-0000-0000-0000-000000000001
|
||||
|
|
Loading…
Reference in a new issue