From 52f02559b21eebba159fbf14b712a15e4aa00733 Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Tue, 11 Aug 2020 17:01:55 +0200 Subject: [PATCH 1/7] Create python-app.yml --- .github/workflows/python-app.yml | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..c7f5067 --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,36 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python application + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest From bab91bb083f24bc6671790ea4c3c99330319d441 Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Tue, 11 Aug 2020 17:03:53 +0200 Subject: [PATCH 2/7] added gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..77e4dbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build +dist +*.egg-info +*.pyc From ea697f64f35d6414a3ad5a328864ea7f3cef388a Mon Sep 17 00:00:00 2001 From: Volodymyr Savchenko Date: Tue, 11 Aug 2020 17:04:52 +0200 Subject: [PATCH 3/7] cleaned up a bit --- build/lib/numpyencoder/__init__.py | 1 - build/lib/numpyencoder/numpyencoder.py | 33 --------------------- dist/numpyencoder-0.2.0-py3-none-any.whl | Bin 2981 -> 0 bytes dist/numpyencoder-0.2.0.tar.gz | Bin 1656 -> 0 bytes numpyencoder.egg-info/PKG-INFO | 31 ------------------- numpyencoder.egg-info/SOURCES.txt | 9 ------ numpyencoder.egg-info/dependency_links.txt | 1 - numpyencoder.egg-info/requires.txt | 1 - numpyencoder.egg-info/top_level.txt | 1 - numpyencoder/__init__.pyc | Bin 176 -> 0 bytes numpyencoder/numpyencoder.pyc | Bin 1294 -> 0 bytes 11 files changed, 77 deletions(-) delete mode 100644 build/lib/numpyencoder/__init__.py delete mode 100644 build/lib/numpyencoder/numpyencoder.py delete mode 100644 dist/numpyencoder-0.2.0-py3-none-any.whl delete mode 100644 dist/numpyencoder-0.2.0.tar.gz delete mode 100644 numpyencoder.egg-info/PKG-INFO delete mode 100644 numpyencoder.egg-info/SOURCES.txt delete mode 100644 numpyencoder.egg-info/dependency_links.txt delete mode 100644 numpyencoder.egg-info/requires.txt delete mode 100644 numpyencoder.egg-info/top_level.txt delete mode 100644 numpyencoder/__init__.pyc delete mode 100644 numpyencoder/numpyencoder.pyc diff --git a/build/lib/numpyencoder/__init__.py b/build/lib/numpyencoder/__init__.py deleted file mode 100644 index 3e5c56b..0000000 --- a/build/lib/numpyencoder/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .numpyencoder import NumpyEncoder diff --git a/build/lib/numpyencoder/numpyencoder.py b/build/lib/numpyencoder/numpyencoder.py deleted file mode 100644 index b39f9c6..0000000 --- a/build/lib/numpyencoder/numpyencoder.py +++ /dev/null @@ -1,33 +0,0 @@ -import json -import numpy as np - - -class NumpyEncoder(json.JSONEncoder): - """ Custom encoder for numpy data types """ - def default(self, obj): - if isinstance(obj, (np.int_, np.intc, np.intp, np.int8, - np.int16, np.int32, np.int64, np.uint8, - np.uint16, np.uint32, np.uint64)): - - return int(obj) - - elif isinstance(obj, (np.float_, np.float16, np.float32, np.float64)): - return float(obj) - - elif isinstance(obj, (np.complex_, np.complex64, np.complex128)): - return {'real': obj.real, 'imag': obj.imag} - - elif isinstance(obj, (np.ndarray,)): - return obj.tolist() - - elif isinstance(obj, (np.bool_)): - return bool(obj) - - elif isinstance(obj, (np.void)): - return None - - return json.JSONEncoder.default(self, obj) - - -if __name__ == '__main__': - numpy_encoder = NumpyEncoder() diff --git a/dist/numpyencoder-0.2.0-py3-none-any.whl b/dist/numpyencoder-0.2.0-py3-none-any.whl deleted file mode 100644 index 873dad2d9d8f16e8a5a2df8c57eb5f4295fc09c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2981 zcmai$c{r4N8^_1kMG=iHHL^C08Hy-NCgU(;9R`uCV~equJxhob*(xPEudJgY`>t$b z3}YK_r0hDjL1oF(na+97o1^o-Jbpy6^Az_ccN@GVuWb05*W2^nD}m zdeOlX^pzC71n7nL_wWkD;T=33aXv5`8&|xmpN);2S0GxZvjdSrCBp)M5D z(FN^*L5!CfAU{?@-toG6hBS)@I|r<6gG`=J0K;7)Z_)- zDLQ4#h&Y1mm3QYnidfS1E0wC@XkGj`PZE`y^I%X1-C|zIEJvap1X(Wm2*JZB23q)oO!a@|+#GeKiSik8~l8{{%&c${wvk5kdjm*y?Rg?Mwv zl#!0NR~N<26GFt_*AZ7Q>B=by*6un53phV5VA;R5out zW(2Or>yhYbgTW=Aqw^EO-@8GfcO#)z$#w*t#sp5cZE29l9u*@8CX_L7N!Yizeg76T$#Ecxt}1%q-{mIR)W9lffe z+Jc9MSvIqM7ekaBT!6ocEZVB7-gwtk*dS(>cuU7QBjOED{yH_Xh^zh~qh4Dqv7&`1 zLS)2lspGX(@C)Z)bMQv;yHnzsYLehAo=4WsiJuhF1X73qfhP7r*7*2LIMT2ccbjK= zV@h(_NkBls;#0ljj#p(@(&q!v({IhE3VaqvH{Xj>UrwstmUac{&3fT(O~CqD3Mm`C zTv4@{GV1Njr&_z`9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oK#J^m7KXSi us{79KVf_j3ZyMas-7mYpxMd8)pK<>bp%I#y{zCu&EB%(EYuAqb+v<0uyv7^= diff --git a/dist/numpyencoder-0.2.0.tar.gz b/dist/numpyencoder-0.2.0.tar.gz deleted file mode 100644 index ca394aff3cec23da8d78587d154fe86df0801b01..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1656 zcmV-;28a0{iwFpqccNYb|72-%bT4joZE$&IZewp`WpXVrE;24KE_7jX0PR|BZ`(Ey z_GkSHqWvH{kY&Bta$!Kjf;3&THcrr_+lQi18Hu*lNTeoGNsM9teWYG&*^Xl;agDz4 zK>}0cktgzar{f)Q7AI4LeG;IwZRnP6bQ-&c!O`#a#IM=!8TH=^4bygdMz?P}Hm^5( zhSP0;USki)D1#{gjY)Qgs9e}sF6u_wt4h2zJ-$pSEqXEb}PU7Fk;!zByybpbZDQ9$ga;dyV)K9~N z<e-HSf%*#ZO*b8Z?adWASZn7LgIQ2w&sHJVcQGR=^-Fv1)ZB`}4Iq||MyoGJes z0JWv@wWe8$JV^a8bl<>;t{uXUs9Rr@R()0HlYNJ#wQ-ujFr9 zhSe}E)9Lr6{oe<2!>n(#%nga36PxtE{_s>Au<`tF^k(+ovK_AfmLt#q`$4Jf!dX(v zaxQY=OW{OO6knWD7K}mecIm=3tX!MI;d=4nMRjVfyNr0rQxtSLeSk*dA7&A2QWT9e zK(4;F=4Z`t1VS2OE+6cpCU4U~llz1rW}XI$f?pMqs_<&vF|j-!=R~Gck=s^Pa=Ljb z+iHw#K1ennCCi6t@hL3yPZ7&f%zaKKCefNVqG-(&M-hSLB=cg)DleD3@^ZoK9$tBC z!ENQVzm}^{g!6t^@GT$8RVklL>(v^D|Eej15qFOHXu2qJPdSX?xU3Py{~qxwILJMJ zZ4EauBqLEsS+khn<`J(5iM%z#iMDM;b3?*_4+HKSXGk!b4^dVwD~rCm<++w|Zk~r> zj64sxE>Jx$h9UMmwRqv;1XF31yQq#W<=feR9gWBB5Rb@n4g!z%|1Fb$0Hpu_9en@i z@_$BF;L-7ai+ce*`Tdvie;NOm@qZcr-*f!`e*1rM_VL5f@rBOr*skM0cHdsI|F+qa z_J1#!C3_Ug{ndmY@s)M)Kjopofby`{plsY!YbdJy?@v8$Zm;PBq$&C*3sdwE2_uOY zp&JxEWgGvB@t=nUv8(v6VJ_)^&$hc#|MvkI*_HagmHyYQ>#p-ZrnCJ0m+{|y%Ktal z)XlDLOJgAQf1Un6!*$xM|Gg#s?;583{_kD>QvId=bNw$4g8pc{D;}Hge>ltczeP$| z>i-__i5qxN82HZ$gJbV13!?zIAb$uTL%eJ#(lGpb`u~jkUXRp&)9%;qe>nO5U&oO5 zzxIMW&yY);5fafV%aGU9uiC1!K%t1yr)6$nQe*}qg1NPr$EUf`7)``AfS}n@iojyC z$YaA8xoUmSsYO`-rpPY2YQ6=_N|+~iTy-hwv(W10sUKHeN&S>mQ4wr+)zg#9vg&05 z{cAWz)E$L5@T#X~t7x9Jep-Cd&qZ^7B_N8t>O5SLRcEM*uC^Sm`uHqT_4-RI>n>N^ zPv-eWg1{4lx#~iKpd2|%`KoQ1ek;3NmnoEL%3>#oG>Z6LS|xv$+n{c9mV{Ba$fT(A zJde6vBBkDAa~`Fn=E82t&zgjUgoK2IgoK2IgoK2IgoK2IgoMP;ivIyH2_SC(PyhhJ C@KZAY diff --git a/numpyencoder.egg-info/PKG-INFO b/numpyencoder.egg-info/PKG-INFO deleted file mode 100644 index c70879a..0000000 --- a/numpyencoder.egg-info/PKG-INFO +++ /dev/null @@ -1,31 +0,0 @@ -Metadata-Version: 2.1 -Name: numpyencoder -Version: 0.2.0 -Summary: Python JSON encoder for handling Numpy data types. -Home-page: https://github.com/hmallen/numpyencoder -Author: Hunter M. Allen -Author-email: allenhm@gmail.com -License: MIT -Description: # numpyencoder - - Custom Python JSON encoder for handling Numpy data types. - - **Example Use:** - - ```python - from numpyencoder import NumpyEncoder - - numpy_data = np.array([0, 1, 2, 3]) - - with open(json_file, 'w') as file: - json.dump(numpy_data, file, indent=4, sort_keys=True, - separators=(', ', ': '), ensure_ascii=False, - cls=NumpyEncoder) - ``` - -Keywords: numpy,json,encoder -Platform: UNKNOWN -Classifier: Programming Language :: Python :: 3 -Classifier: License :: OSI Approved :: MIT License -Classifier: Operating System :: OS Independent -Description-Content-Type: text/markdown diff --git a/numpyencoder.egg-info/SOURCES.txt b/numpyencoder.egg-info/SOURCES.txt deleted file mode 100644 index fe9bfc4..0000000 --- a/numpyencoder.egg-info/SOURCES.txt +++ /dev/null @@ -1,9 +0,0 @@ -README.md -setup.py -numpyencoder/__init__.py -numpyencoder/numpyencoder.py -numpyencoder.egg-info/PKG-INFO -numpyencoder.egg-info/SOURCES.txt -numpyencoder.egg-info/dependency_links.txt -numpyencoder.egg-info/requires.txt -numpyencoder.egg-info/top_level.txt \ No newline at end of file diff --git a/numpyencoder.egg-info/dependency_links.txt b/numpyencoder.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/numpyencoder.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/numpyencoder.egg-info/requires.txt b/numpyencoder.egg-info/requires.txt deleted file mode 100644 index 03de7e7..0000000 --- a/numpyencoder.egg-info/requires.txt +++ /dev/null @@ -1 +0,0 @@ -numpy>=1.14.3 diff --git a/numpyencoder.egg-info/top_level.txt b/numpyencoder.egg-info/top_level.txt deleted file mode 100644 index 5f1168c..0000000 --- a/numpyencoder.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -numpyencoder diff --git a/numpyencoder/__init__.pyc b/numpyencoder/__init__.pyc deleted file mode 100644 index 1d92c7c7e9398edeb2f28fb1c0e4a0f9df954faf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 176 zcmZSn%*)kOv?wl_0ScIav;zt5rH{bzaX5yrkdVwhW`SZ@qH$S`ff3LTGPQHIgp#J&ze2&Y$K}hj0pad8$ zxPYMtsRs(6@F5eB`tTLt9N^us0cr`-27K~h{0dZqc85*StTG6fP%;05zrJfD?N6%F z^rcQrs>X}-0u3*4*=+>OF~kIjm{L%hp%2j@^vK~JLU1y%&QyV#sRWrB2byGqG| zrXyv8gxqPZ<2u1*A7B;-a3;VBC_F}=vB9{+*koL0Twz>gY%#7ewjo=Cb8PoLxOEad z7cjVxzQ#`18E-J&gbc@m0pGxFTn)HI6D9KxvK6;!f|v9*S!0WF8#13=e?jiCcZY`5 zrMMkBq3)%?JM0OZJ=a7@V(2)h=sBn8 zO7)?gx3bd2n06Vrm}1a^W7LAz8Q6z+bsCSy@svfJDRb-G3W_AA8kOpcbgLIH7)xE( zrlaFtM3*+A*17CcW6D|Q#JKa%CQq64jaEzwYqVR#kk^B^{rV%|LQ<8*lhW}WXHToj zjC(YvMTh~wVE2&mRj=>-z0D&jS qtwiJ*1q8Stx{H9{SlzX(+y37|IPKF}U(e{=> Date: Tue, 11 Aug 2020 17:12:54 +0200 Subject: [PATCH 4/7] added test --- tests/test_example.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/test_example.py diff --git a/tests/test_example.py b/tests/test_example.py new file mode 100644 index 0000000..37ba263 --- /dev/null +++ b/tests/test_example.py @@ -0,0 +1,13 @@ +def test_array_of_int(): + import json + import numpy as np + from numpyencoder import NumpyEncoder + + numpy_data = np.array([np.int64(0), np.int32(1), 2, 3]) + baseline_data = [0, 1, 2, 3] + + j_np = json.dumps(numpy_data, sort_keys=True, + separators=(', ', ': '), ensure_ascii=False, + cls=NumpyEncoder) + + assert json.dumps(baseline_data, sort_keys=True) == j_np From 8c93d47c91537c59d9e13bb8bd12e498454be4dc Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Tue, 11 Aug 2020 17:15:16 +0200 Subject: [PATCH 5/7] Create requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..03de7e7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +numpy>=1.14.3 From 67d35983388db9233164215740e116750ed2971a Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Tue, 11 Aug 2020 17:36:44 +0200 Subject: [PATCH 6/7] Update python-app.yml --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index c7f5067..226f8ea 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -24,7 +24,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install . - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From dd0968563197590eed93851f5a02770d1d4de928 Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Tue, 11 Aug 2020 17:36:59 +0200 Subject: [PATCH 7/7] Delete requirements.txt --- requirements.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 03de7e7..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -numpy>=1.14.3