Skip to content

Commit 57e8a0b

Browse files
Alison WuAlison Wu
authored andcommitted
Revert "edited tests based on fixed file and function names"
This reverts commit 9c4e33c.
1 parent 09938ac commit 57e8a0b

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

tests/test_diffraction_objects.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
from freezegun import freeze_time
66

7-
from diffpy.utils.scattering_objects.diffraction_objects import DiffractionObject
7+
from diffpy.utils.scattering_objects.diffraction_objects import Diffraction_object
88

99
params = [
1010
( # Default
@@ -222,8 +222,8 @@
222222

223223
@pytest.mark.parametrize("inputs1, inputs2, expected", params)
224224
def test_diffraction_objects_equality(inputs1, inputs2, expected):
225-
diffraction_object1 = DiffractionObject()
226-
diffraction_object2 = DiffractionObject()
225+
diffraction_object1 = Diffraction_object()
226+
diffraction_object2 = Diffraction_object()
227227
diffraction_object1_attributes = [key for key in diffraction_object1.__dict__ if not key.startswith("_")]
228228
for i, attribute in enumerate(diffraction_object1_attributes):
229229
setattr(diffraction_object1, attribute, inputs1[i])
@@ -235,7 +235,7 @@ def test_dump(tmp_path, mocker):
235235
x, y = np.linspace(0, 5, 6), np.linspace(0, 5, 6)
236236
directory = Path(tmp_path)
237237
file = directory / "testfile"
238-
test = DiffractionObject()
238+
test = Diffraction_object()
239239
test.wavelength = 1.54
240240
test.name = "test"
241241
test.scat_quantity = "x-ray"
@@ -251,7 +251,7 @@ def test_dump(tmp_path, mocker):
251251
with open(file, "r") as f:
252252
actual = f.read()
253253
expected = (
254-
"[DiffractionObject]\nname = test\nwavelength = 1.54\nscat_quantity = x-ray\nthing1 = 1\n"
254+
"[Diffraction_object]\nname = test\nwavelength = 1.54\nscat_quantity = x-ray\nthing1 = 1\n"
255255
"thing2 = thing2\npackage_info = {'package2': '3.4.5', 'diffpy.utils': '3.3.0'}\n"
256256
"creation_time = 2012-01-14 00:00:00\n\n"
257257
"#### start data\n0.000000000000000000e+00 0.000000000000000000e+00\n"

tests/test_loaddata.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy
99
import pytest
1010

11-
from diffpy.utils.parsers.data_loader import load_data
11+
from diffpy.utils.parsers import loadData
1212

1313

1414
##############################################################################
@@ -18,41 +18,41 @@ def prepare_fixture(self, datafile):
1818
self.datafile = datafile
1919

2020
def test_loadData_default(self):
21-
"""check load_data() with default options"""
21+
"""check loadData() with default options"""
2222
loaddata01 = self.datafile("loaddata01.txt")
2323
d2c = numpy.array([[3, 31], [4, 32], [5, 33]])
24-
self.assertRaises(IOError, load_data, "doesnotexist")
24+
self.assertRaises(IOError, loadData, "doesnotexist")
2525
# the default minrows=10 makes it read from the third line
26-
d = load_data(loaddata01)
26+
d = loadData(loaddata01)
2727
self.assertTrue(numpy.array_equal(d2c, d))
2828
# the usecols=(0, 1) would make it read from the third line
29-
d = load_data(loaddata01, minrows=1, usecols=(0, 1))
29+
d = loadData(loaddata01, minrows=1, usecols=(0, 1))
3030
self.assertTrue(numpy.array_equal(d2c, d))
3131
# check the effect of usecols effect
32-
d = load_data(loaddata01, usecols=(0,))
32+
d = loadData(loaddata01, usecols=(0,))
3333
self.assertTrue(numpy.array_equal(d2c[:, 0], d))
34-
d = load_data(loaddata01, usecols=(1,))
34+
d = loadData(loaddata01, usecols=(1,))
3535
self.assertTrue(numpy.array_equal(d2c[:, 1], d))
3636
return
3737

3838
def test_loadData_1column(self):
3939
"""check loading of one-column data."""
4040
loaddata01 = self.datafile("loaddata01.txt")
4141
d1c = numpy.arange(1, 6)
42-
d = load_data(loaddata01, usecols=[0], minrows=1)
42+
d = loadData(loaddata01, usecols=[0], minrows=1)
4343
self.assertTrue(numpy.array_equal(d1c, d))
44-
d = load_data(loaddata01, usecols=[0], minrows=2)
44+
d = loadData(loaddata01, usecols=[0], minrows=2)
4545
self.assertTrue(numpy.array_equal(d1c, d))
46-
d = load_data(loaddata01, usecols=[0], minrows=3)
46+
d = loadData(loaddata01, usecols=[0], minrows=3)
4747
self.assertFalse(numpy.array_equal(d1c, d))
4848
return
4949

5050
def test_loadData_headers(self):
51-
"""check load_data() with headers options enabled"""
51+
"""check loadData() with headers options enabled"""
5252
loaddatawithheaders = self.datafile("loaddatawithheaders.txt")
5353
hignore = ["# ", "// ", "["] # ignore lines beginning with these strings
5454
delimiter = ": " # what our data should be separated by
55-
hdata = load_data(loaddatawithheaders, headers=True, hdel=delimiter, hignore=hignore)
55+
hdata = loadData(loaddatawithheaders, headers=True, hdel=delimiter, hignore=hignore)
5656
# only fourteen lines of data are formatted properly
5757
assert len(hdata) == 14
5858
# check the following are floats

tests/test_resample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pytest
33

4-
from diffpy.utils.resampler import wsinterp
4+
from diffpy.utils.parsers.resample import wsinterp
55

66

77
def test_wsinterp():

tests/test_serialization.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
import numpy
44
import pytest
55

6+
from diffpy.utils.parsers import deserialize_data, loadData, serialize_data
67
from diffpy.utils.parsers.custom_exceptions import ImproperSizeError, UnsupportedTypeError
7-
from diffpy.utils.parsers.data_loader import load_data
8-
from diffpy.utils.parsers.serializer import deserialize_data, serialize_data
98

109
tests_dir = os.path.dirname(os.path.abspath(locals().get("__file__", "file.py")))
1110

@@ -21,8 +20,8 @@ def test_load_multiple(tmp_path, datafile):
2120
for hfname in tlm_list:
2221
# gather data using loadData
2322
headerfile = os.path.normpath(os.path.join(tests_dir, "testdata", "dbload", hfname))
24-
hdata = load_data(headerfile, headers=True)
25-
data_table = load_data(headerfile)
23+
hdata = loadData(headerfile, headers=True)
24+
data_table = loadData(headerfile)
2625

2726
# check path extraction
2827
generated_data = serialize_data(headerfile, hdata, data_table, dt_colnames=["r", "gr"], show_path=True)
@@ -51,8 +50,8 @@ def test_exceptions(datafile):
5150
loadfile = datafile("loadfile.txt")
5251
warningfile = datafile("generatewarnings.txt")
5352
nodt = datafile("loaddatawithheaders.txt")
54-
hdata = load_data(loadfile, headers=True)
55-
data_table = load_data(loadfile)
53+
hdata = loadData(loadfile, headers=True)
54+
data_table = loadData(loadfile)
5655

5756
# improper file types
5857
with pytest.raises(UnsupportedTypeError):
@@ -88,15 +87,15 @@ def test_exceptions(datafile):
8887
assert numpy.allclose(r_extract[data_name]["r"], r_list)
8988
assert numpy.allclose(gr_extract[data_name]["gr"], gr_list)
9089
# no datatable
91-
nodt_hdata = load_data(nodt, headers=True)
92-
nodt_dt = load_data(nodt)
90+
nodt_hdata = loadData(nodt, headers=True)
91+
nodt_dt = loadData(nodt)
9392
no_dt = serialize_data(nodt, nodt_hdata, nodt_dt, show_path=False)
9493
nodt_data_name = list(no_dt.keys())[0]
9594
assert numpy.allclose(no_dt[nodt_data_name]["data table"], nodt_dt)
9695

9796
# ensure user is warned when columns are overwritten
98-
hdata = load_data(warningfile, headers=True)
99-
data_table = load_data(warningfile)
97+
hdata = loadData(warningfile, headers=True)
98+
data_table = loadData(warningfile)
10099
with pytest.warns(RuntimeWarning) as record:
101100
serialize_data(
102101
warningfile,

0 commit comments

Comments
 (0)