Skip to content

Commit 78f20f2

Browse files
committed
add other public attributes to gather class
1 parent d8ff247 commit 78f20f2

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

src/core/bindings.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ PYBIND11_MODULE(_num, m) {
3939
PYBIND11_MODULE(_gather, m) {
4040
py::class_<Gather>(m, "Gather")
4141
.def(py::init<>())
42-
.def_readwrite("id", &Gather::id);
42+
.def_readwrite("id", &Gather::id)
43+
.def_readwrite("dt", &Gather::dt)
44+
.def_readwrite("nt", &Gather::nt)
45+
.def_readwrite("nx", &Gather::nx);
4346
}

src/core/gather/gather.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
class Gather {
99
public:
1010
int id;
11+
int nt;
12+
int nx;
13+
double dt;
1114
};
1215

1316
#endif // GATHER_H

tests/libseis/test_add.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import pytest
2-
3-
from libseis import Gather, add, add_one
1+
from libseis import add, add_one
42

53

64
class TestLibseis:
@@ -17,22 +15,3 @@ def test_add(self):
1715
def test_add_one(self):
1816
expected = 4
1917
assert add_one(3) == expected
20-
21-
22-
class TestSeismicGather:
23-
"""Test the Gather class from."""
24-
25-
@pytest.fixture
26-
def gather(self):
27-
"""Fixture to create a Gather instance."""
28-
return Gather()
29-
30-
def test_gather_init(self, gather):
31-
"""Test the Gather class base constructor."""
32-
assert isinstance(gather, Gather)
33-
34-
def test_gather_id_is_publicly_accessible(self, gather):
35-
"""Test that the id attribute is publicly accessible."""
36-
my_id = 42
37-
gather.id = my_id
38-
assert gather.id == my_id

tests/libseis/test_gather.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pytest
2+
3+
from libseis import Gather
4+
5+
6+
class TestSeismicGather:
7+
"""Test the Gather class from."""
8+
9+
@pytest.fixture
10+
def gather(self):
11+
"""Fixture to create a Gather instance."""
12+
return Gather()
13+
14+
def test_gather_init(self, gather):
15+
"""Test the Gather class base constructor."""
16+
assert isinstance(gather, Gather)
17+
18+
@pytest.mark.parametrize("attr", ["id", "dt", "nx", "nt"])
19+
def test_public_int_attributes(self, gather, attr):
20+
"""Test that the id attribute is publicly accessible."""
21+
val = 42
22+
setattr(gather, attr, val)
23+
assert getattr(gather, attr) == val

0 commit comments

Comments
 (0)