Skip to content

Commit

Permalink
Changed write function in writers.py to writers
Browse files Browse the repository at this point in the history
  • Loading branch information
ifeoluwaale committed Dec 25, 2023
1 parent 86e467a commit 70b2e16
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions dplpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
from chron_stabilized import chron_stabilized
from xdate import xdate, xdate_plot
from series_corr import series_corr
from writers import write
from writers import writers

__all__ = [
readers,
Expand All @@ -77,5 +77,5 @@
xdate,
xdate_plot,
series_corr,
write
writers
]
2 changes: 1 addition & 1 deletion dplpy/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
It also allows you to append files that are missing metadata and write them back out
Accepted file types are CSV, RWL, CRN (in dev) and TXT (in dev)
"""
def write(data, label, format):
def writers(data, label, format):
if not isinstance(data, pd.DataFrame):
raise TypeError("Expected input data to be pandas dataframe, not " + str(type(data)))

Expand Down
10 changes: 5 additions & 5 deletions tests/integs/test_integ_readers_and_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_read_and_write_csv(tmp_path):

write_path = os.path.join(tmp_path,"test_write")

dpl.write(ca533, write_path, "csv")
dpl.writers(ca533, write_path, "csv")

ca533_alt = dpl.readers(write_path + ".csv")

Expand All @@ -20,7 +20,7 @@ def test_read_and_write_rwl_no_headers(tmp_path):

write_path = os.path.join(tmp_path, "test_write")

dpl.write(viet001, write_path, "rwl")
dpl.writers(viet001, write_path, "rwl")

viet001_alt = dpl.readers(write_path + ".rwl")

Expand All @@ -32,7 +32,7 @@ def test_read_and_write_rwl_with_headers(tmp_path):

write_path = os.path.join(tmp_path, "test_write")

dpl.write(th001, write_path, "rwl")
dpl.writers(th001, write_path, "rwl")

th001_alt = dpl.readers(write_path + ".rwl")

Expand All @@ -44,7 +44,7 @@ def test_read_and_write_long_rwl(tmp_path):

write_path = os.path.join(tmp_path, "test_write")

dpl.write(ca667, write_path, "rwl")
dpl.writers(ca667, write_path, "rwl")

ca667_alt = dpl.readers(write_path + ".rwl")

Expand All @@ -55,7 +55,7 @@ def test_read_and_write_weird_rwl(tmp_path):

write_path = os.path.join(tmp_path, "test_write")

dpl.write(wwr, write_path, "rwl")
dpl.writers(wwr, write_path, "rwl")

wwr_alt = dpl.readers(write_path + ".rwl")

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_write_invalid_type_data():
"Year": [1, 2, 3, 4]})

with pytest.raises(TypeError) as errorMsg:
dpl.write(input_df['SeriesA'], "label", "ext")
dpl.writers(input_df['SeriesA'], "label", "ext")
expected_msg = "Expected input data to be pandas dataframe, not <class 'pandas.core.series.Series'>"
assert expected_msg == str(errorMsg.value)

Expand All @@ -27,7 +27,7 @@ def test_write_invalid_type_label():
"Year": [1, 2, 3, 4]})

with pytest.raises(TypeError) as errorMsg:
dpl.write(input_df, 1, "ext")
dpl.writers(input_df, 1, "ext")
expected_msg = "Expected label to be of type str, not <class 'int'>"
assert expected_msg == str(errorMsg.value)

Expand All @@ -38,7 +38,7 @@ def test_write_invalid_type_format():
"Year": [1, 2, 3, 4]})

with pytest.raises(TypeError) as errorMsg:
dpl.write(input_df, "label", 1)
dpl.writers(input_df, "label", 1)
expected_msg = "Expected format to be of type str, not <class 'int'>"
assert expected_msg == str(errorMsg.value)

Expand All @@ -50,7 +50,7 @@ def test_write_csv(tmpdir):

file = tmpdir.join('output.csv')

dpl.write(input_df, file.strpath[:-4], "csv")
dpl.writers(input_df, file.strpath[:-4], "csv")

expected_csv_lines = ['"Year","SeriesA","SeriesB"\n',
'1,0.1,0.2\n',
Expand All @@ -69,7 +69,7 @@ def test_write_rwl(tmpdir):

file = tmpdir.join('output.rwl')

dpl.write(input_df, file.strpath[:-4], "rwl")
dpl.writers(input_df, file.strpath[:-4], "rwl")

expected_rwl_lines = ['SeriesA 1 0100 0300 0500 0700 -9999\n',
'SeriesB 1 0200 0400 0600 0800 -9999\n']
Expand Down

0 comments on commit 70b2e16

Please sign in to comment.