Skip to content

Commit 261452c

Browse files
committed
improved tests
1 parent 5181855 commit 261452c

File tree

3 files changed

+32
-29
lines changed

3 files changed

+32
-29
lines changed

README.md

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pip install SimulatedLIBS
2424
## Import
2525

2626
```python
27-
from SimulatedLIBS import simulation
27+
from SimulatedLIBS import SimulatedLIBS
2828
```
2929
## Example
3030
Parameters:
@@ -40,15 +40,15 @@ Parameters:
4040

4141
### Static websraping
4242
```python
43-
libs = simulation.SimulatedLIBS(Te=1.0,
44-
Ne=10**17,
45-
elements=['W','Fe','Mo'],
46-
percentages=[50,25,25],
47-
resolution=1000,
48-
low_w=200,
49-
upper_w=1000,
50-
max_ion_charge=3,
51-
webscraping='static')
43+
libs = SimulatedLIBS(Te=1.0,
44+
Ne=10**17,
45+
elements=['W','Fe','Mo'],
46+
percentages=[50,25,25],
47+
resolution=1000,
48+
low_w=200,
49+
upper_w=1000,
50+
max_ion_charge=3,
51+
webscraping='static')
5252
```
5353

5454
### Plot
@@ -75,15 +75,15 @@ libs.get_raw_spectrum()
7575
```
7676
### Dynamic webscraping
7777
```python
78-
libs = simulation.SimulatedLIBS(Te=1.0,
79-
Ne=10**17,
80-
elements=['W','Fe','Mo'],
81-
percentages=[50,25,25],
82-
resolution=1000,
83-
low_w=200,
84-
upper_w=1000,
85-
max_ion_charge=3,
86-
webscraping='dynamic')
78+
libs = SimulatedLIBS(Te=1.0,
79+
Ne=10**17,
80+
elements=['W','Fe','Mo'],
81+
percentages=[50,25,25],
82+
resolution=1000,
83+
low_w=200,
84+
upper_w=1000,
85+
max_ion_charge=3,
86+
webscraping='dynamic')
8787
```
8888

8989
### Plot
@@ -102,7 +102,7 @@ libs.plot_ion_spectra()
102102
Based on .csv file with chemical composition of samples, one can generate dataset of simulated LIBS measurements
103103
with different Te and Ne values.
104104

105-
Example of input .csv file:
105+
Example of input_composition_df pd.DataFrame:
106106

107107
|W |H |He |name|
108108
|---|---|---|----|
@@ -111,13 +111,12 @@ Example of input .csv file:
111111
|40 |40 |20 |C |
112112

113113
```python
114-
simulation.SimulatedLIBS.create_dataset(input_csv_file="data.csv",
115-
output_csv_file='output.csv',
116-
size=100,
117-
Te_min=1.0,
118-
Te_max=2.0,
119-
Ne_min=10**17,
120-
Ne_max=10**18)
114+
SimulatedLIBS.create_dataset(input_composition_df,
115+
size=100,
116+
Te_min=1.0,
117+
Te_max=2.0,
118+
Ne_min=10**17,
119+
Ne_max=10**18)
121120
```
122121

123122
Example of output .csv file:

SimulatedLIBS/simulation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ def plot(
295295
plt.ylabel("Line Intensity [a.u.]")
296296

297297
def plot_ion_spectra(self):
298-
299298
self.ion_spectra.drop(["Sum(calc)"], axis=1).plot(
300299
x="Wavelength (nm)",
301300
xlabel=r"$\lambda$ [nm]",
@@ -413,7 +412,6 @@ def create_dataset(
413412

414413
for spectra in spectra_pool:
415414
intensity = spectra.result()["spectrum"]["intensity"].values.tolist()
416-
417415
percentages = spectra.result()["composition"]["percentages"].values.tolist()
418416
intensity.extend(percentages)
419417
intensity.append(spectra.result()["name"])

tests/test_SimulatedLIBS.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ def test_values():
3535
def test_dataset():
3636
input_df = pd.read_csv("data.csv")
3737
libs_df = SimulatedLIBS.create_dataset(input_df, size=1)
38+
assert (
39+
input_df[
40+
input_df["name"] == libs_df.iloc[:, -6:-2]["name"].iloc[0]
41+
].values.tolist()[0]
42+
== libs_df.iloc[:, -6:-2].iloc[0].values.tolist()
43+
)
3844
assert libs_df.iloc[:, :-6].max().max() > 0
3945
if os.path.exists("out_put.csv"):
4046
os.remove("out_put.csv")

0 commit comments

Comments
 (0)