@@ -36,19 +36,19 @@ Python installation instructions [here](https://docs.python-guide.org/starting/i
3636
3737
3838### Initialize python
39-
4039``` clojure
41- user>
40+ user> (require '[libpython-clj2.python
41+ :refer [as-python as-jvm
42+ ->python ->jvm
43+ get-attr call-attr call-attr-kw
44+ get-item initialize!
45+ run-simple-string
46+ add-module module-dict
47+ import-module
48+ python-type
49+ dir]
50+ :as py])
4251
43- user> (require [libpython-clj2.python
44- :refer [as-python as-jvm
45- ->python ->jvm
46- get-attr call-attr call-attr-kw
47- get-item initialize!
48- run-simple-string
49- add-module module-dict
50- import-module
51- python-type]])
5252nil
5353
5454; Mac and Linux
@@ -158,70 +158,27 @@ user> (get-attr ones-ary "shape")
158158user> (vec (get-attr ones-ary " shape" ))
159159[2 3 ]
160160
161- user> (att-type-map ones-ary)
162- {" T" :ndarray ,
163- " __abs__" :method-wrapper ,
164- " __add__" :method-wrapper ,
165- " __and__" :method-wrapper ,
166- " __array__" :builtin-function-or-method ,
167- " __array_finalize__" :none-type ,
168- " __array_function__" :builtin-function-or-method ,
169- " __array_interface__" :dict ,
170- " __array_prepare__" :builtin-function-or-method ,
171- " __array_priority__" :float ,
172- " __array_struct__" :py-capsule ,
173- " __array_ufunc__" :builtin-function-or-method ,
174- " __array_wrap__" :builtin-function-or-method ,
175- " __bool__" :method-wrapper ,
176- " __class__" :type ,
177- " __complex__" :builtin-function-or-method ,
178- " __contains__" :method-wrapper ,
179- ...
180- " std" :builtin-function-or-method ,
181- " strides" :tuple ,
182- " sum" :builtin-function-or-method ,
183- " swapaxes" :builtin-function-or-method ,
184- " take" :builtin-function-or-method ,
185- " tobytes" :builtin-function-or-method ,
186- " tofile" :builtin-function-or-method ,
187- " tolist" :builtin-function-or-method ,
188- " tostring" :builtin-function-or-method ,
189- " trace" :builtin-function-or-method ,
190- " transpose" :builtin-function-or-method ,
191- " var" :builtin-function-or-method ,
192- " view" :builtin-function-or-method }
193- ```
194-
195-
196- ### att-type-map
197-
198- It can be extremely helpful to print out the attribute name->attribute type map:
199-
200- ``` clojure
201- user> (att-type-map ones-ary)
202- {" T" :ndarray ,
203- " __abs__" :method-wrapper ,
204- " __add__" :method-wrapper ,
205- " __and__" :method-wrapper ,
206- " __array__" :builtin-function-or-method ,
207- " __array_finalize__" :none-type ,
208- " __array_function__" :builtin-function-or-method ,
209- " __array_interface__" :dict ,
161+ user> (dir ones-ary)
162+ [" T"
163+ " __abs__"
164+ " __add__"
165+ " __and__"
166+ " __array__"
167+ " __array_finalize__"
210168 ...
211- " real" :ndarray ,
212- " repeat" :builtin-function-or-method ,
213- " reshape" :builtin-function-or-method ,
214- " resize" :builtin-function-or-method ,
215- " round" :builtin-function-or-method ,
216- " searchsorted" :builtin-function-or-method ,
217- " setfield" :builtin-function-or-method ,
218- " setflags" :builtin-function-or-method ,
219- " shape" :tuple ,
220- " size" :int ,
221- " sort" :builtin-function-or-method ,
222169 ...
223- }
224- ```
170+ " strides"
171+ " sum"
172+ " swapaxes"
173+ " take"
174+ " tobytes"
175+ " tofile"
176+ " tolist"
177+ " tostring"
178+ " trace"
179+ " transpose"
180+ " var"
181+ " view" ]
225182
226183### DataFrame access full example
227184
@@ -240,6 +197,7 @@ table.loc[row_date]
240197
241198``` clojure
242199; Clojure
200+ (require '[libpython-clj2.require :refer [require-python]])
243201(require-python '[numpy :as np])
244202(require-python '[pandas :as pan])
245203
@@ -306,7 +264,7 @@ user> (py/$.. numpy random shuffle)
306264<built-in method shuffle of numpy.random.mtrand.RandomState object at 0x7fa66410cca8 >
307265```
308266
309- ##### New sugar ( fixme )
267+ ##### Extra sugar
310268
311269`libpython-clj` offers syntactic forms similar to those offered by
312270Clojure for interacting with Python classes and objects.
@@ -338,9 +296,9 @@ To achieve a chain of method/attribute access, use the `py..` for.
338296**Examples**
339297
340298```clojure
341- user=> (require '[libpython-clj .python :as py :refer [py. py.. py.-]])
299+ user=> (require '[libpython-clj2 .python :as py :refer [py. py.. py.-]])
342300nil
343- user=> (require '[libpython-clj .require :refer [require-python]])
301+ user=> (require '[libpython-clj2 .require :refer [require-python]])
344302
345303... debug info ...
346304
@@ -382,6 +340,7 @@ user=> (py.. requests (get "http://www.google.com") -content (decode "latin-1"))
382340Speaking of numpy, you can move data between numpy and java easily.
383341
384342```clojure
343+ (require '[tech.v3.tensor :refer [as-tensor]])
385344user> (def tens-data (as-tensor ones-ary))
386345#'user/tens-data
387346user> (println tens-data)
@@ -391,7 +350,7 @@ user> (println tens-data)
391350nil
392351
393352
394- user> (require '[tech.v2 .datatype :as dtype])
353+ user> (require '[tech.v3 .datatype :as dtype])
395354nil
396355user> (def ignored (dtype/copy! (repeat 6 5 ) tens-data))
397356#'user/ignored
0 commit comments