Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Rename 'replace_object' with 'update_object' for clarity #32

Merged
merged 1 commit into from
Sep 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sdafile/sda_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ def replace(self, label, data):
self.remove(label)
self.insert(label, data, attrs['Description'], attrs['Deflate'])

def replace_object(self, label, data):
""" Replace an existing object record.
def update_object(self, label, data):
""" Update an existing object record.

Parameters
----------
Expand All @@ -409,9 +409,9 @@ def replace_object(self, label, data):

Notes
-----
This is more strict than **replace** in that the intention is to
replace an 'object' record while preserving the record type. The
simplest way to make use of this is to *extract* an object record,
This is more strict than **replace** in that the intention is to update
the contents of an 'object' record while preserving the record type.
The simplest way to make use of this is to *extract* an object record,
replace some data, and then call this to update the stored record.

"""
Expand Down
16 changes: 8 additions & 8 deletions sdafile/tests/test_sda_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ def test_probe(self):
assert_array_equal(state['Deflate'], [0, 1])


class TestSDAFileReplace(unittest.TestCase):
class TestSDAFileReplaceUpdate(unittest.TestCase):

def test_replace(self):

Expand Down Expand Up @@ -807,9 +807,9 @@ def test_replace_non_object(self):
label = 'example A'
data = sda_file.extract('example I')
with self.assertRaises(ValueError):
sda_file.replace_object(label, data)
sda_file.update_object(label, data)

def test_replace_object_with_equivalent_record(self):
def test_update_object_with_equivalent_record(self):

reference_path = data_path('SDAreference.sda')
with temporary_file() as file_path:
Expand All @@ -824,7 +824,7 @@ def test_replace_object_with_equivalent_record(self):
# Replace some stuff with the same type
data = sda_file.extract(label)
data['Parameter'] = np.arange(5)
sda_file.replace_object(label, data)
sda_file.update_object(label, data)

extracted = sda_file.extract(label)

Expand All @@ -840,7 +840,7 @@ def test_replace_object_with_equivalent_record(self):
self.assertEqual(len(extracted), 1)
assert_equal(extracted['Parameter'], data['Parameter'])

def test_replace_object_with_inequivalent_record(self):
def test_update_object_with_inequivalent_record(self):

reference_path = data_path('SDAreference.sda')
with temporary_file() as file_path:
Expand All @@ -853,9 +853,9 @@ def test_replace_object_with_inequivalent_record(self):
data = sda_file.extract(label)
data['Parameter'] = 'hello world'
with self.assertRaises(ValueError):
sda_file.replace_object(label, data)
sda_file.update_object(label, data)

def test_replace_object_with_non_record(self):
def test_update_object_with_non_record(self):

reference_path = data_path('SDAreference.sda')
with temporary_file() as file_path:
Expand All @@ -866,4 +866,4 @@ def test_replace_object_with_non_record(self):

# Replace some stuff with a non-dictionary
with self.assertRaises(ValueError):
sda_file.replace_object(label, 'hello')
sda_file.update_object(label, 'hello')