Skip to content

Commit

Permalink
tests for separator # ---- after Result block
Browse files Browse the repository at this point in the history
  • Loading branch information
none committed Oct 5, 2024
1 parent 12811db commit 4ac9be3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion j2o/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def PRINT(*args):
# o = {"text": None, "data_file": None, "data_descr": None}
if o["text"] is not None:
if len(o["text"]) <= ORG_BABEL_MIN_LINES_FOR_BLOCK_OUTPUT:
PRINT("#+RESULTS:" + (f"{i}_{k}" if k > 0 else "")) # add index for several RESULT
PRINT("#+RESULTS:" + (f"{i}_{k}" if k > 0 else "")) # add index if there is several RESULT for one block
PRINT("".join([": " + t for t in o["text"]])) # .startswith()
PRINT()
else:
Expand Down
18 changes: 18 additions & 0 deletions tests/draw-samples.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import h5py
import matplotlib.pyplot as plt
import numpy as np
#+end_src
: #-------------------------

* Чтение файла
#+begin_src python :results output :exports both :session s1
with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset:
Expand All @@ -12,6 +14,8 @@ with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset:
: ['1609459200', '1609459800', '1609460400', '1609461000', '1609461600', '1609462200', '1609462800', '1609463400', '1609464000', '1609464600']


: #-------------------------

#+begin_src python :results output :exports both :session s1
with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset:
print(list(dataset['1609459200'].keys()))
Expand All @@ -20,6 +24,8 @@ with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset:
: ['events', 'intensity', 'radial_velocity', 'reflectivity']


: #-------------------------

#+begin_src python :results output :exports both :session s1
with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset:
print(f"events shape: {dataset['1609459200']['events'].shape}")
Expand All @@ -34,6 +40,8 @@ with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset:
: reflectivity shape: (10, 252, 252)


: #-------------------------

* Визуализация
#+begin_src python :results output :exports both :session s1
events = []
Expand Down Expand Up @@ -63,6 +71,8 @@ radial_velocity[radial_velocity == -1e6] = -1
reflectivity[reflectivity == -2e6] = -2
reflectivity[reflectivity == -1e6] = -1
#+end_src
: #-------------------------

** Погодные события
#+begin_src python :results file graphics :file /tmp/a-a-imgs/8_0.png :exports both :session s1
_, axs = plt.subplots(1, len(events), figsize=(20, 2))
Expand All @@ -73,6 +83,8 @@ for index in range(len(events)):
#+RESULTS:
[[file:/tmp/a-a-imgs/8_0.png]] <Figure size 1440x144 with 6 Axes>

: #-------------------------

** Интенсивность осадков
#+begin_src python :results file graphics :file /tmp/a-a-imgs/10_0.png :exports both :session s1
_, axs = plt.subplots(1, len(intensity), figsize=(20, 2))
Expand All @@ -83,6 +95,8 @@ for index in range(len(intensity)):
#+RESULTS:
[[file:/tmp/a-a-imgs/10_0.png]] <Figure size 1440x144 with 6 Axes>

: #-------------------------

** Радиальная скорость по высотам
#+begin_src python :results file graphics :file /tmp/a-a-imgs/12_0.png :exports both :session s1
_, axs = plt.subplots(10, len(radial_velocity), figsize=(20, 20))
Expand All @@ -96,6 +110,8 @@ for index in range(len(radial_velocity)):
#+RESULTS:
[[file:/tmp/a-a-imgs/12_0.png]] <Figure size 1440x1440 with 60 Axes>

: #-------------------------

** Отражаемость по высотам
#+begin_src python :results file graphics :file /tmp/a-a-imgs/14_0.png :exports both :session s1
_, axs = plt.subplots(10, len(reflectivity), figsize=(20, 20))
Expand All @@ -109,3 +125,5 @@ for index in range(len(reflectivity)):
#+RESULTS:
[[file:/tmp/a-a-imgs/14_0.png]] <Figure size 1440x1440 with 60 Axes>

: #-------------------------

5 changes: 5 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# steps to fix errors:
# $ python3 -m pytest
# diff /tmp/a.org tests/draw-samples.org
# mv /tmp/a.org tests/draw-samples.org

from filecmp import cmp
import os

Expand Down

0 comments on commit 4ac9be3

Please sign in to comment.