Repository: physiopy/phys2bids

Issue:
Rename utils.writejson() to utils.write_json()
<!--- Provide a general summary of the issue in the Title above -->
<!--- Please label the issue with one of the following: Documentation, Outreach or Question -->

## Summary
<!--- Describe the motivation behind the issue -->
Most of the functions in `phys2bids.utils` are in PEP8-compatible snake case, but [`phys2bids.utils.writejson()`](https://github.com/physiopy/phys2bids/blob/da3a5306a91a046f3956f1d033b6f86b5c14611b/phys2bids/utils.py#L238) is not. We can rename it to `write_json()` to match convention.

## Next Steps
<!--- Provide possible steps to take in order to address the issue -->

    * Rename the function
    * Update tests
    * Update all uses of the function throughout the package
    * Update the API page of the docs


Discussion:

Patch:
diff --git a/phys2bids/bids.py b/phys2bids/bids.py
index 18a101b..5a9afbf 100644
--- a/phys2bids/bids.py
+++ b/phys2bids/bids.py
@@ -269,7 +269,7 @@ def dataset_description_file(outdir):
     if not os.path.exists(file_path):
         LGR.warning('phys2bids could not find dataset_description.json,'
                     'generating it with provided info')
-        utils.writejson(file_path, data_dict)
+        utils.write_json(file_path, data_dict)
 
 
 def readme_file(outdir):
diff --git a/phys2bids/phys2bids.py b/phys2bids/phys2bids.py
index 8b5cbc8..30cc28c 100644
--- a/phys2bids/phys2bids.py
+++ b/phys2bids/phys2bids.py
@@ -112,7 +112,7 @@ def print_json(outfile, samp_freq, time_offset, ch_name):
     summary = dict(SamplingFrequency=samp_freq,
                    StartTime=round(start_time, 4),
                    Columns=ch_name)
-    utils.writejson(outfile, summary, indent=4, sort_keys=False)
+    utils.write_json(outfile, summary, indent=4, sort_keys=False)
 
 
 @due.dcite(
diff --git a/phys2bids/utils.py b/phys2bids/utils.py
index 34689b7..80962a7 100644
--- a/phys2bids/utils.py
+++ b/phys2bids/utils.py
@@ -206,7 +206,7 @@ def write_file(filename, ext, text):
         print(text, file=text_file)
 
 
-def writejson(filename, data, **kwargs):
+def write_json(filename, data, **kwargs):
     """
     Output a json file with the given data inside.
 


Test patch:
diff --git a/phys2bids/tests/test_utils.py b/phys2bids/tests/test_utils.py
index 90fc029..d4dc2ed 100644
--- a/phys2bids/tests/test_utils.py
+++ b/phys2bids/tests/test_utils.py
@@ -75,13 +75,13 @@ def test_write_file(tmpdir):
     utils.write_file(test_old_path, ext, test_text)
 
 
-# Tests writejson
-def test_writejson(tmpdir):
+# Tests write_json
+def test_write_json(tmpdir):
     test_json_filename = tmpdir.join('foo')
     test_json_data = dict(SamplingFrequency=42,
                           StartTime='00:00 ET',
                           Columns='Rick')
-    utils.writejson(str(test_json_filename), test_json_data, indent=4, sort_keys=False)
+    utils.write_json(str(test_json_filename), test_json_data, indent=4, sort_keys=False)
     test_json_filename += '.json'
     assert os.path.isfile(test_json_filename)
     with open(test_json_filename, 'r') as src: