mxnet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [incubator-mxnet] branch master updated: Get bz2 data fix (#8020)
Date Wed, 11 Oct 2017 02:48:56 GMT
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new fa47c61  Get bz2 data fix (#8020)
fa47c61 is described below

commit fa47c6116e1cfadd6bdeff4a4bbec689a2892a1b
Author: Anirudh Subramanian <anirudh2290@gmail.com>
AuthorDate: Tue Oct 10 19:48:54 2017 -0700

    Get bz2 data fix (#8020)
    
    * Add documentation
    
    * Add kdda example
    
    * Changes to documentation
    
    * Additional changes to the documentation
    
    * Remove chdir calls
---
 python/mxnet/test_utils.py | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/python/mxnet/test_utils.py b/python/mxnet/test_utils.py
index bc92257..78e5bdd 100644
--- a/python/mxnet/test_utils.py
+++ b/python/mxnet/test_utils.py
@@ -1442,10 +1442,31 @@ def get_mnist():
             'test_data':test_img, 'test_label':test_lbl}
 
 def get_bz2_data(data_dir, data_name, url, data_origin_name):
-    """Download and extract bz2 data."""
-    download(url, dirname=data_dir, overwrite=False)
-    os.chdir(data_dir)
+    """Download and extract bz2 data.
+
+    Parameters
+    ----------
+
+    data_dir : str
+        Absolute or relative path of the directory name to store bz2 files
+    data_name : str
+        Name of the output file in which bz2 contents will be extracted
+    url : str
+        URL to download data from
+    data_origin_name : str
+        Name of the downloaded b2 file
+
+    Examples
+    --------
+    >>> get_bz2_data("data_dir", "kdda.t",
+                     "https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/kdda.t.bz2",
+                     "kdda.t.bz2")
+    """
+
+    data_name = os.path.join(data_dir, data_name)
+    data_origin_name = os.path.join(data_dir, data_origin_name)
     if not os.path.exists(data_name):
+        download(url, dirname=data_dir, overwrite=False)
         bz_file = bz2.BZ2File(data_origin_name, 'rb')
         with open(data_name, 'wb') as fout:
             try:
@@ -1454,7 +1475,6 @@ def get_bz2_data(data_dir, data_name, url, data_origin_name):
             finally:
                 bz_file.close()
         os.remove(data_origin_name)
-    os.chdir("..")
 
 def set_env_var(key, val, default_val=""):
     """Set environment variable

-- 
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <commits@mxnet.apache.org>'].

Mime
View raw message