├── .gitattributes ├── .github └── workflows │ └── maven-publish.yml ├── .gitignore ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── encodings.xml ├── inspectionProfiles │ └── Project_Default.xml ├── jarRepositories.xml ├── javacpp-embedded-python.iml ├── misc.xml ├── sbt.xml └── vcs.xml ├── LICENSE ├── README.md ├── docs └── apidocs │ ├── allclasses-index.html │ ├── allclasses.html │ ├── allpackages-index.html │ ├── constant-values.html │ ├── deprecated-list.html │ ├── element-list │ ├── help-doc.html │ ├── index-all.html │ ├── index.html │ ├── jquery │ ├── external │ │ └── jquery │ │ │ └── jquery.js │ ├── images │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ ├── ui-bg_glass_65_dadada_1x400.png │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ ├── ui-icons_222222_256x240.png │ │ ├── ui-icons_2e83ff_256x240.png │ │ ├── ui-icons_454545_256x240.png │ │ ├── ui-icons_888888_256x240.png │ │ └── ui-icons_cd0a0a_256x240.png │ ├── jquery-3.5.1.js │ ├── jquery-ui.css │ ├── jquery-ui.js │ ├── jquery-ui.min.css │ ├── jquery-ui.min.js │ ├── jquery-ui.structure.css │ ├── jquery-ui.structure.min.css │ ├── jszip-utils │ │ └── dist │ │ │ ├── jszip-utils-ie.js │ │ │ ├── jszip-utils-ie.min.js │ │ │ ├── jszip-utils.js │ │ │ └── jszip-utils.min.js │ └── jszip │ │ └── dist │ │ ├── jszip.js │ │ └── jszip.min.js │ ├── member-search-index.js │ ├── org │ └── bytedeco │ │ └── embeddedpython │ │ ├── NpNdarray.html │ │ ├── NpNdarrayBoolean.html │ │ ├── NpNdarrayByte.html │ │ ├── NpNdarrayChar.html │ │ ├── NpNdarrayDouble.html │ │ ├── NpNdarrayFloat.html │ │ ├── NpNdarrayInstant.html │ │ ├── NpNdarrayInt.html │ │ ├── NpNdarrayLong.html │ │ ├── NpNdarrayShort.html │ │ ├── Pip.html │ │ ├── Python.html │ │ ├── PythonException.html │ │ ├── class-use │ │ ├── NpNdarray.html │ │ ├── NpNdarrayBoolean.html │ │ ├── NpNdarrayByte.html │ │ ├── NpNdarrayChar.html │ │ ├── NpNdarrayDouble.html │ │ ├── NpNdarrayFloat.html │ │ ├── NpNdarrayInstant.html │ │ ├── NpNdarrayInt.html │ │ ├── NpNdarrayLong.html │ │ ├── NpNdarrayShort.html │ │ ├── Pip.html │ │ ├── Python.html │ │ └── PythonException.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ ├── overview-tree.html │ ├── package-search-index.js │ ├── resources │ ├── glass.png │ └── x.png │ ├── script.js │ ├── search.js │ ├── serialized-form.html │ ├── stylesheet.css │ └── type-search-index.js ├── pom.xml └── src ├── main └── java │ └── org │ └── bytedeco │ └── embeddedpython │ ├── NpNdarray.java │ ├── NpNdarrayBoolean.java │ ├── NpNdarrayByte.java │ ├── NpNdarrayChar.java │ ├── NpNdarrayDouble.java │ ├── NpNdarrayFloat.java │ ├── NpNdarrayInstant.java │ ├── NpNdarrayInt.java │ ├── NpNdarrayLong.java │ ├── NpNdarrayShort.java │ ├── Pip.java │ ├── PyTypes.java │ ├── Python.java │ ├── PythonException.java │ └── TypeTreeBuilder.java └── test └── java └── org └── bytedeco └── embeddedpython ├── PipTest.java └── PythonTest.java /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.github/workflows/maven-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created 2 | # For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path 3 | 4 | name: Maven Package 5 | 6 | on: 7 | push: 8 | branches: [main] 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-20.04 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Set up JDK 1.8 18 | uses: actions/setup-java@v1 19 | with: 20 | java-version: 1.8 21 | server-id: github # Value of the distributionManagement/repository/id field of the pom.xml 22 | settings-path: ${{ github.workspace }} # location for the settings.xml file 23 | 24 | - name: Build with Maven 25 | run: mvn -B package --file pom.xml 26 | 27 | - name: Publish to GitHub Packages Apache Maven 28 | run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml 29 | env: 30 | GITHUB_TOKEN: ${{ github.token }} 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #################################################################################################### 2 | # https://github.com/github/gitignore/blob/master/Java.gitignore 3 | #################################################################################################### 4 | 5 | # Compiled class file 6 | *.class 7 | 8 | # Log file 9 | *.log 10 | 11 | # BlueJ files 12 | *.ctxt 13 | 14 | # Mobile Tools for Java (J2ME) 15 | .mtj.tmp/ 16 | 17 | # Package Files # 18 | *.jar 19 | *.war 20 | *.nar 21 | *.ear 22 | *.zip 23 | *.tar.gz 24 | *.rar 25 | 26 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 27 | hs_err_pid* 28 | 29 | #################################################################################################### 30 | # https://github.com/github/gitignore/blob/master/Maven.gitignore 31 | #################################################################################################### 32 | 33 | target/ 34 | pom.xml.tag 35 | pom.xml.releaseBackup 36 | pom.xml.versionsBackup 37 | pom.xml.next 38 | release.properties 39 | dependency-reduced-pom.xml 40 | buildNumber.properties 41 | .mvn/timing.properties 42 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar 43 | .mvn/wrapper/maven-wrapper.jar 44 | 45 | #################################################################################################### 46 | # https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore 47 | #################################################################################################### 48 | 49 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 50 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 51 | 52 | # User-specific stuff 53 | .idea/**/workspace.xml 54 | .idea/**/tasks.xml 55 | .idea/**/usage.statistics.xml 56 | .idea/**/dictionaries 57 | .idea/**/shelf 58 | 59 | # Generated files 60 | .idea/**/contentModel.xml 61 | 62 | # Sensitive or high-churn files 63 | .idea/**/dataSources/ 64 | .idea/**/dataSources.ids 65 | .idea/**/dataSources.local.xml 66 | .idea/**/sqlDataSources.xml 67 | .idea/**/dynamic.xml 68 | .idea/**/uiDesigner.xml 69 | .idea/**/dbnavigator.xml 70 | 71 | # Gradle 72 | .idea/**/gradle.xml 73 | .idea/**/libraries 74 | 75 | # Gradle and Maven with auto-import 76 | # When using Gradle or Maven with auto-import, you should exclude module files, 77 | # since they will be recreated, and may cause churn. Uncomment if using 78 | # auto-import. 79 | # .idea/artifacts 80 | # .idea/compiler.xml 81 | # .idea/jarRepositories.xml 82 | # .idea/modules.xml 83 | # .idea/*.iml 84 | # .idea/modules 85 | # *.iml 86 | # *.ipr 87 | 88 | # CMake 89 | cmake-build-*/ 90 | 91 | # Mongo Explorer plugin 92 | .idea/**/mongoSettings.xml 93 | 94 | # File-based project format 95 | *.iws 96 | 97 | # IntelliJ 98 | out/ 99 | 100 | # mpeltonen/sbt-idea plugin 101 | .idea_modules/ 102 | 103 | # JIRA plugin 104 | atlassian-ide-plugin.xml 105 | 106 | # Cursive Clojure plugin 107 | .idea/replstate.xml 108 | 109 | # Crashlytics plugin (for Android Studio and IntelliJ) 110 | com_crashlytics_export_strings.xml 111 | crashlytics.properties 112 | crashlytics-build.properties 113 | fabric.properties 114 | 115 | # Editor-based Rest Client 116 | .idea/httpRequests 117 | 118 | # Android studio 3.1+ serialized cache file 119 | .idea/caches/build_file_checksums.ser 120 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/javacpp-embedded-python.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/sbt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JavaCPP Embedded Python 2 | 3 | With this library, you can embed Python to your Java or Scala project. 4 | This library is a wrapper of javacpp-presets/cpython. 5 | The main purpose of this library is to use Python libraries from Java or Scala. 6 | 7 | ## Apache Maven and sbt 8 | 9 | I have not uploaded this library to the Apache Maven Central Repository yet. 10 | You have to do ```mvn install```. 11 | 12 | Apache Maven 13 | 14 | ```xml 15 | 16 | org.bytedeco 17 | javacpp-embedded-python 18 | 1.0.0-SNAPSHOT 19 | 20 | 21 | org.bytedeco 22 | numpy-platform 23 | 1.20.1-1.5.5 24 | 25 | ``` 26 | 27 | sbt 28 | 29 | ```scala 30 | libraryDependencies += "org.bytedeco" % "javacpp-embedded-python" % "1.0.0-SNAPSHOT" 31 | libraryDependencies += "org.bytedeco" % "numpy-platform" % "1.20.1-1.5.5" 32 | ``` 33 | 34 | JavaCPP 1.5.3 or later is supported. 35 | If you want to use Python 3.7, replace numpy-platform version to ```1.19.1-1.5.4```. 36 | 37 | ## Javadoc 38 | 39 | http://bytedeco.org/javacpp-embedded-python/apidocs/ 40 | 41 | ## Usage 42 | 43 | You can put the global variable ```a```. 44 | 45 | ```Java 46 | Python.put("a", 1); 47 | ``` 48 | 49 | Execute the Python code. 50 | 51 | ```Java 52 | Python.exec("b = a + 2"); 53 | ``` 54 | 55 | Get the global variable ```b```. 56 | 57 | ```Java 58 | long b = Python.get("b"); 59 | ``` 60 | 61 | You can add a built-in global function to Python. 62 | The ```scala.Function2``` interface comes from scala-java8-compat library. 63 | If you don't need the return value, please return ```null```. 64 | This will return ```None``` in Python. 65 | 66 | ```Java 67 | import scala.Function2; 68 | 69 | Python.put("f", (Function2) (a, b) -> a + b); 70 | long v = Python.eval("f(1, 2)"); 71 | ``` 72 | 73 | You can also use a Numpy np.ndarray and convert it to a Java array. 74 | 75 | ```Java 76 | NpNdarrayFloat ndary = Python.eval("np.arange(6, dtype=np.float32).reshape([2, 3])"); 77 | float[][] ary = ndary.toArray2d(); 78 | ``` 79 | 80 | If you need a Python library, please use the Pip class. 81 | 82 | ```Java 83 | Pip.install("pandas"); 84 | ``` 85 | 86 | If you want to use the local Python files, use ```sys.path.append("your_src_dir")``` in Python. 87 | 88 | ## Type mappings 89 | 90 | ### Python to Java 91 | 92 | | Python | Java | 93 | |--------|------| 94 | | None | null | 95 | | bool
scalar np.bool8 | boolean | 96 | | scalar np.int8 | byte | 97 | | scalar np.int16 | short | 98 | | scalar np.uint16 | char | 99 | | scalar np.int32 | int | 100 | | int
scalar np.int64 | long | 101 | | scalar np.float32 | float | 102 | | float
scalar np.float64 | double | 103 | | scalar np.datetime64[W, D, h, m, s, ms, us, or ns] | Instant | 104 | | str | String | 105 | | bytes
bytearray | byte[] | 106 | | dict | LinkedHashMap | 107 | | ndarray np.int8 | NpNdarrayByte | 108 | | ndarray np.bool8 | NpNdarrayBoolean | 109 | | ndarray np.int16 | NpNdarrayShort | 110 | | ndarray np.uint16 | NpNdarrayChar | 111 | | ndarray np.int32 | NpNdarrayInt | 112 | | ndarray np.int64 | NpNdarrayLong | 113 | | ndarray np.float32 | NpNdarrayFloat | 114 | | ndarray np.float64 | NpNdarrayDouble | 115 | | ndarray np.datetime64[W, D, h, m, s, ms, us, or ns] | NpNdarrayInstant | 116 | | iterable | ArrayList | 117 | 118 | If you want to use Pandas DataFrames, please use ```DataFrame.reset_index().to_dict('list')```. 119 | If you are using datetimes in DataFrame, use ```DatetimeIndex.to_numpy()```. 120 | 121 | ### Java to Python 122 | 123 | | Java | Python | 124 | |--------|------| 125 | | null | None | 126 | | boolean | bool | 127 | | byte
short
char
int
long | int | 128 | | float
double | float | 129 | | Instant | np.datetime64[ns] | 130 | | String | str | 131 | | byte[] | bytes | 132 | | boolean[]
NpNdarrayBoolean | np.ndarray, dtype=np.bool8 | 133 | | NpNdarrayByte | np.ndarray, dtype=np.int8 | 134 | | short[]
NpNdarrayShort | np.ndarray, dtype=np.int16 | 135 | | char[]
NpNdarrayChar | np.ndarray, dtype=np.uint16 | 136 | | int[]
NpNdarrayInt | np.ndarray, dtype=np.int32 | 137 | | long[]
NpNdarrayLong | np.ndarray, dtype=np.int64 | 138 | | float[]
NpNdarrayFloat | np.ndarray, dtype=np.float32 | 139 | | double[]
NpNdarrayDouble | np.ndarray, dtype=np.float64 | 140 | | Instant[]
NpNdarrayInstant | np.ndarray, dtype=np.datetime64[ns] | 141 | | java.util.Map
scala.collection.Map | dict | 142 | | Object[]
Iterable | list | 143 | | scala.Function0 - Function22 | built-in global Python function | 144 | 145 | ### Value type tree 146 | 147 | If the value type conversion fails, its value type tree is included in the Exception message. 148 | 149 | For example, for this Java code, 150 | 151 | ```Java 152 | HashMap map = new HashMap<>(); 153 | map.put("a", Arrays.asList(1, 2)); 154 | map.put("b", UUID.randomUUID()); 155 | Python.put("v", map); 156 | ``` 157 | 158 | you get this message. Because UUID is unsupported, you have to convert it to a String. 159 | 160 | ``` 161 | org.bytedeco.embeddedpython.PythonException: Cannot convert the Java object to a Python object. 162 | 163 | Value type tree 164 | Map 165 | Map.Entry 166 | String 167 | Iterable(java.util.Arrays$ArrayList) 168 | Integer 169 | Integer 170 | Map.Entry 171 | String 172 | java.util.UUID <- Unsupported 173 | ``` 174 | 175 | ### Tips 176 | 177 | Because Python is a duck typing language, the Python value type is unclear statically. 178 | For example, people don't care about the difference between ```int``` and ```np.int64``` scalar. 179 | Therefore, I recommend converting the Python value type 180 | before passing it to the Java side and making it clear statically. 181 | For example, use such as ```int()```, ```np.array()```, or ```bytes()```. 182 | 183 | ## Exceptions 184 | 185 | ### Python to Java 186 | When Python code throws exceptions in ```Python.eval()``` or ```Python.exec()```, 187 | tracebacks are printed to stderr, 188 | and ```PythonException``` is thrown in Java. 189 | 190 | ### Java to Python 191 | When Java code throws exceptions in the Java lambda, 192 | ```Throwable.printStackTrace()``` is called, 193 | and ```RuntimeError``` is thrown in Python. 194 | 195 | ## Intel Math Kernel Library 196 | 197 | If you are using Intel CPU, add this dependency. 198 | 199 | ```xml 200 | 201 | org.bytedeco 202 | mkl-platform-redist 203 | 2021.1-1.5.5 204 | 205 | ``` 206 | 207 | ## Version matrix 208 | 209 | | javacpp-embedded-python | [numpy-platform](https://mvnrepository.com/artifact/org.bytedeco/numpy-platform) | [mkl-platform-redist](https://mvnrepository.com/artifact/org.bytedeco/mkl-platform-redist) | [CPython](https://mvnrepository.com/artifact/org.bytedeco/cpython-platform) | 210 | |-----|-----|-----|-----| 211 | |1.x.x|1.18.2-1.5.3|2020.1-1.5.3|3.7.7| 212 | |1.x.x|1.19.1-1.5.4|2020.3-1.5.4|3.7.9| 213 | |1.x.x|1.20.1-1.5.5|2021.1-1.5.5|3.9.2| 214 | 215 | ## Linux problem 216 | 217 | Because javacpp-presets/cpython has not been built correctly on Linux, you have to rebuild it. 218 | You can do it by this if you are using Ubuntu 20.04. 219 | See also https://devguide.python.org/setup/#linux for other Linux distributions. 220 | Change ```1.5.5``` to your JavaCPP version. 221 | javacpp-presets/cpython forgets to do ```apt-get build-dep python3.8```. 222 | 223 | ```bash 224 | echo 'deb-src http://archive.ubuntu.com/ubuntu/ focal main' | sudo tee -a /etc/apt/sources.list 225 | sudo apt update 226 | sudo apt-get build-dep python3.8 227 | sudo apt install maven openjdk-11-jdk 228 | 229 | git clone https://github.com/bytedeco/javacpp-presets.git 230 | cd javacpp-presets 231 | git checkout -b 1.5.5 refs/tags/1.5.5 232 | cd cpython 233 | mvn install 234 | ``` 235 | -------------------------------------------------------------------------------- /docs/apidocs/allclasses-index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | All Classes (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 38 | 41 |
42 | 98 |
99 |
100 |
101 |

All Classes

102 |
103 |
104 | 173 |
174 |
175 |
176 | 219 |

Copyright © 2021. All rights reserved.

220 |
221 | 222 | 223 | -------------------------------------------------------------------------------- /docs/apidocs/allclasses.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | All Classes (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 |

All Classes

21 |
22 | 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/apidocs/allpackages-index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | All Packages (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

All Packages

96 |
97 |
98 |
    99 |
  • 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 |
    Package Summary 
    PackageDescription
    org.bytedeco.embeddedpython 
    113 |
  • 114 |
115 |
116 |
117 |
118 | 161 |

Copyright © 2021. All rights reserved.

162 |
163 | 164 | 165 | -------------------------------------------------------------------------------- /docs/apidocs/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Constant Field Values (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Constant Field Values

96 |
97 |

Contents

98 |
99 |
100 |
101 |
102 | 145 |

Copyright © 2021. All rights reserved.

146 |
147 | 148 | 149 | -------------------------------------------------------------------------------- /docs/apidocs/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Deprecated List (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Deprecated API

96 |

Contents

97 |
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/element-list: -------------------------------------------------------------------------------- 1 | org.bytedeco.embeddedpython 2 | -------------------------------------------------------------------------------- /docs/apidocs/help-doc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | API Help (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

How This API Document Is Organized

96 |
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
97 |
98 |
99 |
    100 |
  • 101 |
    102 |

    Package

    103 |

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. These pages may contain six categories:

    104 |
      105 |
    • Interfaces
    • 106 |
    • Classes
    • 107 |
    • Enums
    • 108 |
    • Exceptions
    • 109 |
    • Errors
    • 110 |
    • Annotation Types
    • 111 |
    112 |
    113 |
  • 114 |
  • 115 |
    116 |

    Class or Interface

    117 |

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    118 |
      119 |
    • Class Inheritance Diagram
    • 120 |
    • Direct Subclasses
    • 121 |
    • All Known Subinterfaces
    • 122 |
    • All Known Implementing Classes
    • 123 |
    • Class or Interface Declaration
    • 124 |
    • Class or Interface Description
    • 125 |
    126 |
    127 |
      128 |
    • Nested Class Summary
    • 129 |
    • Field Summary
    • 130 |
    • Property Summary
    • 131 |
    • Constructor Summary
    • 132 |
    • Method Summary
    • 133 |
    134 |
    135 |
      136 |
    • Field Detail
    • 137 |
    • Property Detail
    • 138 |
    • Constructor Detail
    • 139 |
    • Method Detail
    • 140 |
    141 |

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    142 |
    143 |
  • 144 |
  • 145 |
    146 |

    Annotation Type

    147 |

    Each annotation type has its own separate page with the following sections:

    148 |
      149 |
    • Annotation Type Declaration
    • 150 |
    • Annotation Type Description
    • 151 |
    • Required Element Summary
    • 152 |
    • Optional Element Summary
    • 153 |
    • Element Detail
    • 154 |
    155 |
    156 |
  • 157 |
  • 158 |
    159 |

    Enum

    160 |

    Each enum has its own separate page with the following sections:

    161 |
      162 |
    • Enum Declaration
    • 163 |
    • Enum Description
    • 164 |
    • Enum Constant Summary
    • 165 |
    • Enum Constant Detail
    • 166 |
    167 |
    168 |
  • 169 |
  • 170 |
    171 |

    Use

    172 |

    Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its "Use" page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

    173 |
    174 |
  • 175 |
  • 176 |
    177 |

    Tree (Class Hierarchy)

    178 |

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. Classes are organized by inheritance structure starting with java.lang.Object. Interfaces do not inherit from java.lang.Object.

    179 |
      180 |
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • 181 |
    • When viewing a particular package, class or interface page, clicking on "Tree" displays the hierarchy for only that package.
    • 182 |
    183 |
    184 |
  • 185 |
  • 186 |
    187 |

    Deprecated API

    188 |

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    189 |
    190 |
  • 191 |
  • 192 |
    193 |

    Index

    194 |

    The Index contains an alphabetic index of all classes, interfaces, constructors, methods, and fields, as well as lists of all packages and all classes.

    195 |
    196 |
  • 197 |
  • 198 |
    199 |

    All Classes

    200 |

    The All Classes link shows all classes and interfaces except non-static nested types.

    201 |
    202 |
  • 203 |
  • 204 |
    205 |

    Serialized Form

    206 |

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    207 |
    208 |
  • 209 |
  • 210 |
    211 |

    Constant Field Values

    212 |

    The Constant Field Values page lists the static final fields and their values.

    213 |
    214 |
  • 215 |
  • 216 |
    217 |

    Search

    218 |

    You can search for definitions of modules, packages, types, fields, methods and other terms defined in the API, using some or all of the name. "Camel-case" abbreviations are supported: for example, "InpStr" will find "InputStream" and "InputStreamReader".

    219 |
    220 |
  • 221 |
222 |
223 | This help file applies to API documentation generated by the standard doclet.
224 |
225 |
226 | 269 |

Copyright © 2021. All rights reserved.

270 |
271 | 272 | 273 | -------------------------------------------------------------------------------- /docs/apidocs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | javacpp-embedded-python 1.0.0-SNAPSHOT API 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 |
17 | 20 |

org/bytedeco/embeddedpython/package-summary.html

21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-bg_glass_65_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-bg_glass_65_dadada_1x400.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/jquery/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /docs/apidocs/jquery/jquery-ui.structure.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI CSS Framework 1.12.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://api.jqueryui.com/category/theming/ 10 | */ 11 | /* Layout helpers 12 | ----------------------------------*/ 13 | .ui-helper-hidden { 14 | display: none; 15 | } 16 | .ui-helper-hidden-accessible { 17 | border: 0; 18 | clip: rect(0 0 0 0); 19 | height: 1px; 20 | margin: -1px; 21 | overflow: hidden; 22 | padding: 0; 23 | position: absolute; 24 | width: 1px; 25 | } 26 | .ui-helper-reset { 27 | margin: 0; 28 | padding: 0; 29 | border: 0; 30 | outline: 0; 31 | line-height: 1.3; 32 | text-decoration: none; 33 | font-size: 100%; 34 | list-style: none; 35 | } 36 | .ui-helper-clearfix:before, 37 | .ui-helper-clearfix:after { 38 | content: ""; 39 | display: table; 40 | border-collapse: collapse; 41 | } 42 | .ui-helper-clearfix:after { 43 | clear: both; 44 | } 45 | .ui-helper-zfix { 46 | width: 100%; 47 | height: 100%; 48 | top: 0; 49 | left: 0; 50 | position: absolute; 51 | opacity: 0; 52 | filter:Alpha(Opacity=0); /* support: IE8 */ 53 | } 54 | 55 | .ui-front { 56 | z-index: 100; 57 | } 58 | 59 | 60 | /* Interaction Cues 61 | ----------------------------------*/ 62 | .ui-state-disabled { 63 | cursor: default !important; 64 | pointer-events: none; 65 | } 66 | 67 | 68 | /* Icons 69 | ----------------------------------*/ 70 | .ui-icon { 71 | display: inline-block; 72 | vertical-align: middle; 73 | margin-top: -.25em; 74 | position: relative; 75 | text-indent: -99999px; 76 | overflow: hidden; 77 | background-repeat: no-repeat; 78 | } 79 | 80 | .ui-widget-icon-block { 81 | left: 50%; 82 | margin-left: -8px; 83 | display: block; 84 | } 85 | 86 | /* Misc visuals 87 | ----------------------------------*/ 88 | 89 | /* Overlays */ 90 | .ui-widget-overlay { 91 | position: fixed; 92 | top: 0; 93 | left: 0; 94 | width: 100%; 95 | height: 100%; 96 | } 97 | .ui-autocomplete { 98 | position: absolute; 99 | top: 0; 100 | left: 0; 101 | cursor: default; 102 | } 103 | .ui-menu { 104 | list-style: none; 105 | padding: 0; 106 | margin: 0; 107 | display: block; 108 | outline: 0; 109 | } 110 | .ui-menu .ui-menu { 111 | position: absolute; 112 | } 113 | .ui-menu .ui-menu-item { 114 | margin: 0; 115 | cursor: pointer; 116 | /* support: IE10, see #8844 */ 117 | list-style-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"); 118 | } 119 | .ui-menu .ui-menu-item-wrapper { 120 | position: relative; 121 | padding: 3px 1em 3px .4em; 122 | } 123 | .ui-menu .ui-menu-divider { 124 | margin: 5px 0; 125 | height: 0; 126 | font-size: 0; 127 | line-height: 0; 128 | border-width: 1px 0 0 0; 129 | } 130 | .ui-menu .ui-state-focus, 131 | .ui-menu .ui-state-active { 132 | margin: -1px; 133 | } 134 | 135 | /* icon support */ 136 | .ui-menu-icons { 137 | position: relative; 138 | } 139 | .ui-menu-icons .ui-menu-item-wrapper { 140 | padding-left: 2em; 141 | } 142 | 143 | /* left-aligned */ 144 | .ui-menu .ui-icon { 145 | position: absolute; 146 | top: 0; 147 | bottom: 0; 148 | left: .2em; 149 | margin: auto 0; 150 | } 151 | 152 | /* right-aligned */ 153 | .ui-menu .ui-menu-icon { 154 | left: auto; 155 | right: 0; 156 | } 157 | -------------------------------------------------------------------------------- /docs/apidocs/jquery/jquery-ui.structure.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.12.1 - 2018-12-06 2 | * http://jqueryui.com 3 | * Copyright jQuery Foundation and other contributors; Licensed MIT */ 4 | 5 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0} -------------------------------------------------------------------------------- /docs/apidocs/jquery/jszip-utils/dist/jszip-utils-ie.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip. 4 | 5 | 6 | (c) 2014 Stuart Knightley, David Duponchel 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 8 | 9 | */ 10 | ;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o\r\n"+ 18 | "\r\n"; 32 | 33 | // inject VBScript 34 | document.write(IEBinaryToArray_ByteStr_Script); 35 | 36 | global.JSZipUtils._getBinaryFromXHR = function (xhr) { 37 | var binary = xhr.responseBody; 38 | var byteMapping = {}; 39 | for ( var i = 0; i < 256; i++ ) { 40 | for ( var j = 0; j < 256; j++ ) { 41 | byteMapping[ String.fromCharCode( i + (j << 8) ) ] = 42 | String.fromCharCode(i) + String.fromCharCode(j); 43 | } 44 | } 45 | var rawBytes = IEBinaryToArray_ByteStr(binary); 46 | var lastChr = IEBinaryToArray_ByteStr_Last(binary); 47 | return rawBytes.replace(/[\s\S]/g, function( match ) { 48 | return byteMapping[match]; 49 | }) + lastChr; 50 | }; 51 | 52 | // enforcing Stuk's coding style 53 | // vim: set shiftwidth=4 softtabstop=4: 54 | 55 | },{}]},{},[1]) 56 | ; 57 | -------------------------------------------------------------------------------- /docs/apidocs/jquery/jszip-utils/dist/jszip-utils-ie.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip. 4 | 5 | 6 | (c) 2014 Stuart Knightley, David Duponchel 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 8 | 9 | */ 10 | !function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g\r\n";document.write(b),a.JSZipUtils._getBinaryFromXHR=function(a){for(var b=a.responseBody,c={},d=0;256>d;d++)for(var e=0;256>e;e++)c[String.fromCharCode(d+(e<<8))]=String.fromCharCode(d)+String.fromCharCode(e);var f=IEBinaryToArray_ByteStr(b),g=IEBinaryToArray_ByteStr_Last(b);return f.replace(/[\s\S]/g,function(a){return c[a]})+g}},{}]},{},[1]); 11 | -------------------------------------------------------------------------------- /docs/apidocs/jquery/jszip-utils/dist/jszip-utils.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip. 4 | 5 | 6 | (c) 2014 Stuart Knightley, David Duponchel 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 8 | 9 | */ 10 | !function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.JSZipUtils=e():"undefined"!=typeof global?global.JSZipUtils=e():"undefined"!=typeof self&&(self.JSZipUtils=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 5 | 6 | (c) 2014 Stuart Knightley, David Duponchel 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 8 | 9 | */ 10 | !function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.JSZipUtils=a():"undefined"!=typeof global?global.JSZipUtils=a():"undefined"!=typeof self&&(self.JSZipUtils=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.NpNdarray (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.NpNdarray

96 |
97 |
98 | 166 |
167 |
168 |
169 | 212 |

Copyright © 2021. All rights reserved.

213 |
214 | 215 | 216 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/NpNdarrayBoolean.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.NpNdarrayBoolean (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.NpNdarrayBoolean

96 |
97 |
No usage of org.bytedeco.embeddedpython.NpNdarrayBoolean
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/NpNdarrayByte.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.NpNdarrayByte (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.NpNdarrayByte

96 |
97 |
No usage of org.bytedeco.embeddedpython.NpNdarrayByte
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/NpNdarrayChar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.NpNdarrayChar (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.NpNdarrayChar

96 |
97 |
No usage of org.bytedeco.embeddedpython.NpNdarrayChar
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/NpNdarrayDouble.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.NpNdarrayDouble (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.NpNdarrayDouble

96 |
97 |
No usage of org.bytedeco.embeddedpython.NpNdarrayDouble
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/NpNdarrayFloat.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.NpNdarrayFloat (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.NpNdarrayFloat

96 |
97 |
No usage of org.bytedeco.embeddedpython.NpNdarrayFloat
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/NpNdarrayInstant.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.NpNdarrayInstant (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.NpNdarrayInstant

96 |
97 |
No usage of org.bytedeco.embeddedpython.NpNdarrayInstant
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/NpNdarrayInt.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.NpNdarrayInt (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.NpNdarrayInt

96 |
97 |
No usage of org.bytedeco.embeddedpython.NpNdarrayInt
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/NpNdarrayLong.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.NpNdarrayLong (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.NpNdarrayLong

96 |
97 |
No usage of org.bytedeco.embeddedpython.NpNdarrayLong
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/NpNdarrayShort.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.NpNdarrayShort (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.NpNdarrayShort

96 |
97 |
No usage of org.bytedeco.embeddedpython.NpNdarrayShort
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/Pip.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.Pip (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.Pip

96 |
97 |
No usage of org.bytedeco.embeddedpython.Pip
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/Python.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.Python (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.Python

96 |
97 |
No usage of org.bytedeco.embeddedpython.Python
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/class-use/PythonException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.bytedeco.embeddedpython.PythonException (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Class
org.bytedeco.embeddedpython.PythonException

96 |
97 |
No usage of org.bytedeco.embeddedpython.PythonException
98 |
99 |
100 | 143 |

Copyright © 2021. All rights reserved.

144 |
145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | org.bytedeco.embeddedpython (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Package org.bytedeco.embeddedpython

96 |
97 |
98 | 180 |
181 |
182 |
183 | 226 |

Copyright © 2021. All rights reserved.

227 |
228 | 229 | 230 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | org.bytedeco.embeddedpython Class Hierarchy (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Hierarchy For Package org.bytedeco.embeddedpython

96 |
97 |
98 |
99 |

Class Hierarchy

100 | 134 |
135 |
136 |
137 |
138 | 181 |

Copyright © 2021. All rights reserved.

182 |
183 | 184 | 185 | -------------------------------------------------------------------------------- /docs/apidocs/org/bytedeco/embeddedpython/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Package org.bytedeco.embeddedpython (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Uses of Package
org.bytedeco.embeddedpython

96 |
97 |
98 | 119 |
120 |
121 |
122 | 165 |

Copyright © 2021. All rights reserved.

166 |
167 | 168 | 169 | -------------------------------------------------------------------------------- /docs/apidocs/overview-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Class Hierarchy (javacpp-embedded-python 1.0.0-SNAPSHOT API) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 32 | 35 |
36 | 92 |
93 |
94 |
95 |

Hierarchy For All Packages

96 | Package Hierarchies: 97 | 100 |
101 |
102 |
103 |

Class Hierarchy

104 | 138 |
139 |
140 |
141 |
142 | 185 |

Copyright © 2021. All rights reserved.

186 |
187 | 188 | 189 | -------------------------------------------------------------------------------- /docs/apidocs/package-search-index.js: -------------------------------------------------------------------------------- 1 | packageSearchIndex = [{"l":"All Packages","url":"allpackages-index.html"},{"l":"org.bytedeco.embeddedpython"}] -------------------------------------------------------------------------------- /docs/apidocs/resources/glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/resources/glass.png -------------------------------------------------------------------------------- /docs/apidocs/resources/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytedeco/javacpp-embedded-python/5f1188117cb8329d2d0c5bfaefd3e44b0f5ae559/docs/apidocs/resources/x.png -------------------------------------------------------------------------------- /docs/apidocs/script.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | var moduleSearchIndex; 27 | var packageSearchIndex; 28 | var typeSearchIndex; 29 | var memberSearchIndex; 30 | var tagSearchIndex; 31 | function loadScripts(doc, tag) { 32 | createElem(doc, tag, 'jquery/jszip/dist/jszip.js'); 33 | createElem(doc, tag, 'jquery/jszip-utils/dist/jszip-utils.js'); 34 | if (window.navigator.userAgent.indexOf('MSIE ') > 0 || window.navigator.userAgent.indexOf('Trident/') > 0 || 35 | window.navigator.userAgent.indexOf('Edge/') > 0) { 36 | createElem(doc, tag, 'jquery/jszip-utils/dist/jszip-utils-ie.js'); 37 | } 38 | createElem(doc, tag, 'search.js'); 39 | 40 | $.get(pathtoroot + "module-search-index.zip") 41 | .done(function() { 42 | JSZipUtils.getBinaryContent(pathtoroot + "module-search-index.zip", function(e, data) { 43 | JSZip.loadAsync(data).then(function(zip){ 44 | zip.file("module-search-index.json").async("text").then(function(content){ 45 | moduleSearchIndex = JSON.parse(content); 46 | }); 47 | }); 48 | }); 49 | }); 50 | $.get(pathtoroot + "package-search-index.zip") 51 | .done(function() { 52 | JSZipUtils.getBinaryContent(pathtoroot + "package-search-index.zip", function(e, data) { 53 | JSZip.loadAsync(data).then(function(zip){ 54 | zip.file("package-search-index.json").async("text").then(function(content){ 55 | packageSearchIndex = JSON.parse(content); 56 | }); 57 | }); 58 | }); 59 | }); 60 | $.get(pathtoroot + "type-search-index.zip") 61 | .done(function() { 62 | JSZipUtils.getBinaryContent(pathtoroot + "type-search-index.zip", function(e, data) { 63 | JSZip.loadAsync(data).then(function(zip){ 64 | zip.file("type-search-index.json").async("text").then(function(content){ 65 | typeSearchIndex = JSON.parse(content); 66 | }); 67 | }); 68 | }); 69 | }); 70 | $.get(pathtoroot + "member-search-index.zip") 71 | .done(function() { 72 | JSZipUtils.getBinaryContent(pathtoroot + "member-search-index.zip", function(e, data) { 73 | JSZip.loadAsync(data).then(function(zip){ 74 | zip.file("member-search-index.json").async("text").then(function(content){ 75 | memberSearchIndex = JSON.parse(content); 76 | }); 77 | }); 78 | }); 79 | }); 80 | $.get(pathtoroot + "tag-search-index.zip") 81 | .done(function() { 82 | JSZipUtils.getBinaryContent(pathtoroot + "tag-search-index.zip", function(e, data) { 83 | JSZip.loadAsync(data).then(function(zip){ 84 | zip.file("tag-search-index.json").async("text").then(function(content){ 85 | tagSearchIndex = JSON.parse(content); 86 | }); 87 | }); 88 | }); 89 | }); 90 | if (!moduleSearchIndex) { 91 | createElem(doc, tag, 'module-search-index.js'); 92 | } 93 | if (!packageSearchIndex) { 94 | createElem(doc, tag, 'package-search-index.js'); 95 | } 96 | if (!typeSearchIndex) { 97 | createElem(doc, tag, 'type-search-index.js'); 98 | } 99 | if (!memberSearchIndex) { 100 | createElem(doc, tag, 'member-search-index.js'); 101 | } 102 | if (!tagSearchIndex) { 103 | createElem(doc, tag, 'tag-search-index.js'); 104 | } 105 | $(window).resize(function() { 106 | $('.navPadding').css('padding-top', $('.fixedNav').css("height")); 107 | }); 108 | } 109 | 110 | function createElem(doc, tag, path) { 111 | var script = doc.createElement(tag); 112 | var scriptElement = doc.getElementsByTagName(tag)[0]; 113 | script.src = pathtoroot + path; 114 | scriptElement.parentNode.insertBefore(script, scriptElement); 115 | } 116 | 117 | function show(type) { 118 | count = 0; 119 | for (var key in data) { 120 | var row = document.getElementById(key); 121 | if ((data[key] & type) !== 0) { 122 | row.style.display = ''; 123 | row.className = (count++ % 2) ? rowColor : altColor; 124 | } 125 | else 126 | row.style.display = 'none'; 127 | } 128 | updateTabs(type); 129 | } 130 | 131 | function updateTabs(type) { 132 | for (var value in tabs) { 133 | var sNode = document.getElementById(tabs[value][0]); 134 | var spanNode = sNode.firstChild; 135 | if (value == type) { 136 | sNode.className = activeTableTab; 137 | spanNode.innerHTML = tabs[value][1]; 138 | } 139 | else { 140 | sNode.className = tableTab; 141 | spanNode.innerHTML = "" + tabs[value][1] + ""; 142 | } 143 | } 144 | } 145 | 146 | function updateModuleFrame(pFrame, cFrame) { 147 | top.packageFrame.location = pFrame; 148 | top.classFrame.location = cFrame; 149 | } 150 | -------------------------------------------------------------------------------- /docs/apidocs/type-search-index.js: -------------------------------------------------------------------------------- 1 | typeSearchIndex = [{"l":"All Classes","url":"allclasses-index.html"},{"p":"org.bytedeco.embeddedpython","l":"NpNdarray"},{"p":"org.bytedeco.embeddedpython","l":"NpNdarrayBoolean"},{"p":"org.bytedeco.embeddedpython","l":"NpNdarrayByte"},{"p":"org.bytedeco.embeddedpython","l":"NpNdarrayChar"},{"p":"org.bytedeco.embeddedpython","l":"NpNdarrayDouble"},{"p":"org.bytedeco.embeddedpython","l":"NpNdarrayFloat"},{"p":"org.bytedeco.embeddedpython","l":"NpNdarrayInstant"},{"p":"org.bytedeco.embeddedpython","l":"NpNdarrayInt"},{"p":"org.bytedeco.embeddedpython","l":"NpNdarrayLong"},{"p":"org.bytedeco.embeddedpython","l":"NpNdarrayShort"},{"p":"org.bytedeco.embeddedpython","l":"Pip"},{"p":"org.bytedeco.embeddedpython","l":"Python"},{"p":"org.bytedeco.embeddedpython","l":"PythonException"}] -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.bytedeco 8 | javacpp-embedded-python 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | 13 | org.bytedeco 14 | numpy 15 | 1.26.3-1.5.10 16 | 17 | 18 | 19 | org.bytedeco 20 | numpy-platform 21 | 1.26.3-1.5.10 22 | test 23 | 24 | 25 | 26 | org.scala-lang.modules 27 | scala-java8-compat_2.13 28 | 1.0.2 29 | 30 | 31 | 32 | org.junit.jupiter 33 | junit-jupiter-api 34 | 5.11.0 35 | test 36 | 37 | 38 | 39 | 40 | 8 41 | 8 42 | UTF-8 43 | UTF-8 44 | 45 | 46 | 47 | ${project.artifactId} 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-compiler-plugin 52 | 3.8.1 53 | 54 | true 55 | 8 56 | 8 57 | 58 | -Xlint:unchecked 59 | 60 | true 61 | true 62 | 63 | 64 | 65 | org.apache.maven.plugins 66 | maven-jar-plugin 67 | 3.2.0 68 | 69 | 70 | org.apache.maven.plugins 71 | maven-install-plugin 72 | 3.0.0-M1 73 | 74 | 75 | org.apache.maven.plugins 76 | maven-source-plugin 77 | 3.2.1 78 | 79 | 80 | attach-source 81 | 82 | jar-no-fork 83 | 84 | 85 | 86 | 87 | 88 | org.apache.maven.plugins 89 | maven-javadoc-plugin 90 | 3.2.0 91 | 92 | -J-Duser.language=en_US 93 | 94 | -notimestamp 95 | 96 | en_US 97 | protected 98 | 8 99 | 100 | 101 | 102 | attach-javadocs 103 | 104 | jar 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | javacpp-embedded-python 113 | 114 | 115 | 116 | Apache License, Version 2.0 117 | http://www.apache.org/licenses/LICENSE-2.0 118 | repo 119 | 120 | 121 | 122 | 123 | 124 | Yu Kobayashi 125 | yukoba@gmail.com 126 | 127 | 128 | 129 | 130 | https://github.com/bytedeco/javacpp-embedded-python 131 | scm:git:git://github.com/bytedeco/javacpp-embedded-python.git 132 | scm:git:ssh://git@github.com/bytedeco/javacpp-embedded-python.git 133 | 134 | 135 | 136 | 137 | github 138 | GitHub Packages 139 | https://maven.pkg.github.com/bytedeco/javacpp-embedded-python 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /src/main/java/org/bytedeco/embeddedpython/NpNdarray.java: -------------------------------------------------------------------------------- 1 | package org.bytedeco.embeddedpython; 2 | 3 | import java.io.Serializable; 4 | import java.util.Arrays; 5 | 6 | /** 7 | * Numpy np.ndarray. 8 | */ 9 | public abstract class NpNdarray implements Serializable { 10 | private static final long serialVersionUID = 1L; 11 | 12 | /** 13 | * ndarray.shape 14 | */ 15 | public final int[] shape; 16 | /** 17 | * The unit of Numpy ndarray.strides is bytes, but the unit of this field is element. 18 | */ 19 | public final int[] strides; 20 | 21 | public NpNdarray(int[] shape, int[] strides) { 22 | if (shape.length != strides.length) 23 | throw new IllegalArgumentException( 24 | "shape.length = " + shape.length + ", strides.length = " + strides.length); 25 | 26 | this.shape = shape; 27 | this.strides = strides; 28 | } 29 | 30 | NpNdarray(int[] shape) { 31 | this.shape = shape; 32 | this.strides = toContiguousStrides(shape); 33 | } 34 | 35 | private static int[] toContiguousStrides(int[] shape) { 36 | int[] strides = new int[shape.length]; 37 | int s = 1; 38 | for (int i = shape.length - 1; i >= 0; i--) { 39 | strides[i] = s; 40 | s *= shape[i]; 41 | } 42 | return strides; 43 | } 44 | 45 | static int intAryProduct(int[] ary) { 46 | int s = 1; 47 | for (int j : ary) { 48 | s *= j; 49 | } 50 | return s; 51 | } 52 | 53 | /** 54 | * ndarray.ndim 55 | * 56 | * @return The length of shape. 57 | */ 58 | public int ndim() { 59 | return shape.length; 60 | } 61 | 62 | /** 63 | * ndarray.itemsize 64 | * 65 | * @return The bytes of element. 66 | */ 67 | public abstract int itemsize(); 68 | 69 | long[] stridesInBytes() { 70 | return Arrays.stream(strides).mapToLong(s -> ((long) s) * ((long) itemsize())).toArray(); 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return getClass().getSimpleName() + "{" + 76 | "shape=" + Arrays.toString(shape) + 77 | ", strides=" + Arrays.toString(strides) + 78 | '}'; 79 | } 80 | 81 | @Override 82 | public boolean equals(Object o) { 83 | if (this == o) return true; 84 | if (!(o instanceof NpNdarray)) return false; 85 | 86 | NpNdarray npNdarray = (NpNdarray) o; 87 | 88 | if (!Arrays.equals(shape, npNdarray.shape)) return false; 89 | return Arrays.equals(strides, npNdarray.strides); 90 | } 91 | 92 | @Override 93 | public int hashCode() { 94 | int result = Arrays.hashCode(shape); 95 | result = 31 * result + Arrays.hashCode(strides); 96 | return result; 97 | } 98 | } 99 | 100 | -------------------------------------------------------------------------------- /src/main/java/org/bytedeco/embeddedpython/Pip.java: -------------------------------------------------------------------------------- 1 | package org.bytedeco.embeddedpython; 2 | 3 | import org.bytedeco.javacpp.Loader; 4 | 5 | import java.io.IOException; 6 | import java.util.Arrays; 7 | import java.util.stream.Stream; 8 | 9 | /** 10 | * Pip. 11 | *

12 | * JavaCPP presets Python is installed to ~/.javacpp/cache folder. 13 | * This Pip class will install Python libraries to this folder. 14 | */ 15 | public class Pip { 16 | private static final String python = Loader.load(org.bytedeco.cpython.python.class); 17 | 18 | private Pip() { 19 | } 20 | 21 | /** 22 | * Install pip packages. 23 | * 24 | * @param packages The package names to install. 25 | * @return 0 on success. 26 | * @throws IOException If an I/O error occurs. 27 | * @throws InterruptedException If the current thread is interrupted by another thread. 28 | */ 29 | public static synchronized int install(String... packages) throws IOException, InterruptedException { 30 | return exec(concat(new String[]{python, "-m", "pip", "install"}, packages)); 31 | } 32 | 33 | /** 34 | * Upgrade pip packages. 35 | * 36 | * @param packages The package names to upgrade. 37 | * @return 0 on success. 38 | * @throws IOException If an I/O error occurs. 39 | * @throws InterruptedException If the current thread is interrupted by another thread. 40 | */ 41 | public static synchronized int upgrade(String... packages) throws IOException, InterruptedException { 42 | return exec(concat(new String[]{python, "-m", "pip", "install", "--upgrade"}, packages)); 43 | } 44 | 45 | /** 46 | * Uninstall pip packages. 47 | * 48 | * @param packages The package names to uninstall. 49 | * @return 0 on success. 50 | * @throws IOException If an I/O error occurs. 51 | * @throws InterruptedException If the current thread is interrupted by another thread. 52 | */ 53 | public static synchronized int uninstall(String... packages) throws IOException, InterruptedException { 54 | return exec(concat(new String[]{python, "-m", "pip", "uninstall", "-y"}, packages)); 55 | } 56 | 57 | private static int exec(String[] commands) throws IOException, InterruptedException { 58 | return new ProcessBuilder(commands).inheritIO().start().waitFor(); 59 | } 60 | 61 | private static String[] concat(String[] a, String[] b) { 62 | return Stream.concat(Arrays.stream(a), Arrays.stream(b)).toArray(String[]::new); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/bytedeco/embeddedpython/PyTypes.java: -------------------------------------------------------------------------------- 1 | package org.bytedeco.embeddedpython; 2 | 3 | import org.bytedeco.cpython.PyObject; 4 | import org.bytedeco.cpython.PyTypeObject; 5 | import org.bytedeco.cpython.global.python; 6 | 7 | import static org.bytedeco.cpython.global.python.*; 8 | import static org.bytedeco.numpy.global.numpy.*; 9 | 10 | class PyTypes { 11 | static final PyTypeObject noneType = _PyNone_Type(); 12 | static final PyTypeObject boolType = PyBool_Type(); 13 | static final PyTypeObject longType = PyLong_Type(); 14 | static final PyTypeObject floatType = PyFloat_Type(); 15 | static final PyTypeObject unicodeType = PyUnicode_Type(); 16 | static final PyTypeObject bytesType = PyBytes_Type(); 17 | static final PyTypeObject byteArrayType = PyByteArray_Type(); 18 | static final PyTypeObject dictType = PyDict_Type(); 19 | static final PyTypeObject boolArrType = PyBoolArrType_Type(); 20 | static final PyTypeObject byteArrType = PyByteArrType_Type(); 21 | static final PyTypeObject ushortArrType = PyUShortArrType_Type(); 22 | static final PyTypeObject shortArrType = PyShortArrType_Type(); 23 | static final PyTypeObject intArrType = PyIntArrType_Type(); 24 | static final PyTypeObject longArrType = PyLongArrType_Type(); 25 | static final PyTypeObject floatArrType = PyFloatArrType_Type(); 26 | static final PyTypeObject doubleArrType = PyDoubleArrType_Type(); 27 | static final PyTypeObject datetimeArrType = PyDatetimeArrType_Type(); 28 | static final PyTypeObject arrayType = PyArray_Type(); 29 | 30 | private PyTypes() { 31 | } 32 | 33 | static PyTypeObject Py_TYPE(PyObject ob) { 34 | return python.Py_TYPE(ob); 35 | } 36 | 37 | static boolean Py_IS_TYPE(PyObject ob, PyTypeObject type) { 38 | return Py_TYPE(ob).equals(type); 39 | } 40 | 41 | static boolean PyType_HasFeature(PyTypeObject type, long feature) { 42 | return ((type.tp_flags() & feature) != 0); 43 | } 44 | 45 | static boolean PyType_FastSubclass(PyTypeObject type, long flag) { 46 | return PyType_HasFeature(type, flag); 47 | } 48 | 49 | static boolean PyObject_TypeCheck(PyObject ob, PyTypeObject type) { 50 | return Py_IS_TYPE(ob, type) || (PyType_IsSubtype(Py_TYPE(ob), type) != 0); 51 | } 52 | 53 | static boolean PyNone_Check(PyObject x) { 54 | return Py_IS_TYPE(x, noneType); 55 | } 56 | 57 | static boolean PyBool_Check(PyObject x) { 58 | return Py_IS_TYPE(x, boolType); 59 | } 60 | 61 | static boolean PyLong_Check(PyObject op) { 62 | return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS); 63 | } 64 | 65 | static boolean PyFloat_Check(PyObject op) { 66 | return PyObject_TypeCheck(op, floatType); 67 | } 68 | 69 | static boolean PyUnicode_Check(PyObject op) { 70 | return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS); 71 | } 72 | 73 | static boolean PyBytes_Check(PyObject op) { 74 | return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS); 75 | } 76 | 77 | static boolean PyByteArray_Check(PyObject op) { 78 | return PyObject_TypeCheck(op, byteArrayType); 79 | } 80 | 81 | static boolean PyDict_Check(PyObject op) { 82 | return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/org/bytedeco/embeddedpython/PythonException.java: -------------------------------------------------------------------------------- 1 | package org.bytedeco.embeddedpython; 2 | 3 | public class PythonException extends RuntimeException { 4 | public PythonException(String message) { 5 | super(message); 6 | } 7 | 8 | public PythonException(String message, Throwable cause) { 9 | super(message, cause); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/bytedeco/embeddedpython/TypeTreeBuilder.java: -------------------------------------------------------------------------------- 1 | package org.bytedeco.embeddedpython; 2 | 3 | import java.util.Collections; 4 | 5 | class TypeTreeBuilder { 6 | private final StringBuilder stringBuilder = new StringBuilder(); 7 | int tab; 8 | 9 | public TypeTreeBuilder(int tab) { 10 | this.tab = tab; 11 | } 12 | 13 | void addType(String t) { 14 | stringBuilder.append(String.join("", Collections.nCopies(tab, " "))).append(t).append("\n"); 15 | } 16 | 17 | public String toString() { 18 | return stringBuilder.toString(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/org/bytedeco/embeddedpython/PipTest.java: -------------------------------------------------------------------------------- 1 | package org.bytedeco.embeddedpython; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import java.io.IOException; 6 | 7 | public class PipTest { 8 | @Test 9 | public void testInstall() throws IOException, InterruptedException { 10 | Pip.uninstall("pandas"); 11 | Pip.install("pandas"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/org/bytedeco/embeddedpython/PythonTest.java: -------------------------------------------------------------------------------- 1 | package org.bytedeco.embeddedpython; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import scala.Function0; 5 | import scala.Function1; 6 | import scala.Function2; 7 | 8 | import java.time.Instant; 9 | import java.util.*; 10 | 11 | import static org.junit.jupiter.api.Assertions.*; 12 | 13 | public class PythonTest { 14 | @Test 15 | public void testBasic() { 16 | double a = 355; 17 | double b = 113; 18 | Python.put("a", a); 19 | Python.put("b", b); 20 | Python.exec("v = a / b"); 21 | assertEquals(a / b, Python.get("v"), 1e-10); 22 | } 23 | 24 | @Test 25 | public void testLambda() { 26 | //noinspection Convert2MethodRef 27 | Python.put("f", (Function2) (a, b) -> a + b); 28 | long v = Python.eval("f(1, 2)"); 29 | assertEquals(3L, v); 30 | 31 | assertEquals("", Python.eval("str(f)")); 32 | } 33 | 34 | @Test 35 | public void testStringArray() { 36 | Python.put("v", new String[]{"foo", "bar"}); 37 | ArrayList v = Python.get("v"); 38 | assertEquals("foo", v.get(0)); 39 | assertEquals("bar", v.get(1)); 40 | } 41 | 42 | @Test 43 | public void testIterable() { 44 | Python.put("v", Arrays.asList("foo", 123)); 45 | ArrayList v = Python.get("v"); 46 | assertEquals("foo", v.get(0)); 47 | assertEquals(123L, v.get(1)); 48 | } 49 | 50 | @Test 51 | public void testMap() { 52 | LinkedHashMap> map1 = new LinkedHashMap<>(); 53 | map1.put("a", Arrays.asList(1, 2)); 54 | map1.put("b", Arrays.asList(3, 4)); 55 | Python.put("v", map1); 56 | 57 | LinkedHashMap> map2 = Python.get("v"); 58 | assertEquals(map1.keySet(), map2.keySet()); 59 | assertEquals(Arrays.asList(1L, 2L), map2.get("a")); 60 | assertEquals(Arrays.asList(3L, 4L), map2.get("b")); 61 | } 62 | 63 | @Test 64 | public void testBytes() { 65 | byte[] ary1 = new byte[]{1, 2, 3}; 66 | Python.put("v", ary1); 67 | byte[] ary2 = Python.get("v"); 68 | assertArrayEquals(ary1, ary2); 69 | } 70 | 71 | @Test 72 | public void testByteArray() { 73 | byte[] ary1 = new byte[]{1, 2, 3}; 74 | Python.put("v", ary1); 75 | byte[] ary2 = Python.eval("bytearray(v)"); 76 | assertArrayEquals(ary1, ary2); 77 | } 78 | 79 | @Test 80 | public void testLongArray() { 81 | Python.exec("import numpy as np"); 82 | 83 | long[] ary1 = new long[]{Long.MAX_VALUE - 1, Long.MAX_VALUE - 2}; 84 | Python.put("v", ary1); 85 | NpNdarrayLong ndary2 = Python.get("v"); 86 | NpNdarrayLong ndary3 = Python.eval("np.array(" + Arrays.toString(ary1) + ", dtype=np.int64)"); 87 | assertArrayEquals(ary1, ndary2.toArray()); 88 | assertArrayEquals(ary1, ndary3.toArray()); 89 | } 90 | 91 | @Test 92 | public void testFloatArray2d() { 93 | Python.exec("import numpy as np"); 94 | 95 | double v = Python.eval("10.0"); 96 | assertEquals(10d, v, 1e-10d); 97 | 98 | float ndary0 = Python.eval("np.float32(10)"); 99 | assertEquals(10f, ndary0, 1e-10f); 100 | 101 | NpNdarrayFloat ndary1 = Python.eval("np.arange(3, dtype=np.float32)"); 102 | float[] ary1 = ndary1.toArray(); 103 | assertEquals(3, ary1.length); 104 | assertEquals(2f, ary1[2], 1e-10f); 105 | assertEquals(ndary1, new NpNdarrayFloat(ary1)); 106 | 107 | NpNdarrayFloat ndary2 = Python.eval("np.arange(6, dtype=np.float32).reshape([2, 3])"); 108 | float[][] ary2 = ndary2.toArray2d(); 109 | assertEquals(2, ary2.length); 110 | assertEquals(3, ary2[0].length); 111 | assertEquals(3f, ary2[1][0], 1e-10f); 112 | assertEquals(ndary2, new NpNdarrayFloat(ary2)); 113 | 114 | NpNdarrayChar ndary3 = Python.eval("np.arange(24, dtype=np.uint16).reshape([2, 3, 4])"); 115 | char[][][] ary3 = ndary3.toArray3d(); 116 | assertEquals(2, ary3.length); 117 | assertEquals(3, ary3[0].length); 118 | assertEquals(4, ary3[0][0].length); 119 | assertEquals(17, ary3[1][1][1]); 120 | assertEquals(ndary3, new NpNdarrayChar(ary3)); 121 | } 122 | 123 | @Test 124 | public void testBooleanNdarray() { 125 | Python.exec("import numpy as np"); 126 | NpNdarrayBoolean npary = Python.eval("np.array([True, False])"); 127 | assertArrayEquals(new boolean[]{true, false}, npary.toArray()); 128 | } 129 | 130 | @Test 131 | public void testException() { 132 | assertThrows(PythonException.class, () -> Python.eval("aaaa + 1")); 133 | } 134 | 135 | @Test 136 | public void testSyntaxErrorEval() { 137 | assertThrows(PythonException.class, () -> Python.eval("print(Hello')")); 138 | } 139 | 140 | @Test 141 | public void testSyntaxErrorExec() { 142 | assertThrows(PythonException.class, () -> Python.exec("print(Hello')")); 143 | } 144 | 145 | @Test 146 | public void testLambdaException() { 147 | Python.put("f", (Function2) (a, b) -> { 148 | throw new RuntimeException("From lambda"); 149 | }); 150 | Python.exec("try:\n" + 151 | " f(1, 2)\n" + 152 | " v = Flase\n" + 153 | "except RuntimeError as e:\n" + 154 | " print(e)\n" + 155 | " v = True\n"); 156 | boolean v = Python.get("v"); 157 | assertTrue(v); 158 | } 159 | 160 | @Test 161 | public void testDatetime() { 162 | Python.exec("import numpy as np"); 163 | 164 | NpNdarrayInstant ndary1 = Python.eval("np.array(['2021-03-01T10:02:03'], dtype='datetime64[s]')"); 165 | assertEquals("2021-03-01T10:02:03Z", ndary1.toArray()[0].toString()); 166 | NpNdarrayInstant ndary2 = Python.eval("np.array(['2021-03-01T10:02:03'], dtype='datetime64[ms]')"); 167 | assertEquals("2021-03-01T10:02:03Z", ndary2.toArray()[0].toString()); 168 | NpNdarrayInstant ndary3 = Python.eval("np.array(['2021-03-01T10:02:03'], dtype='datetime64[us]')"); 169 | assertEquals("2021-03-01T10:02:03Z", ndary3.toArray()[0].toString()); 170 | NpNdarrayInstant ndary4 = Python.eval("np.array(['2021-03-01T10:02:03'], dtype='datetime64[ns]')"); 171 | assertEquals("2021-03-01T10:02:03Z", ndary4.toArray()[0].toString()); 172 | 173 | NpNdarrayInstant ndary5 = Python.eval("np.array(['2021-03-01T10:02:03'], dtype='datetime64[m]')"); 174 | assertEquals("2021-03-01T10:02:00Z", ndary5.toArray()[0].toString()); 175 | NpNdarrayInstant ndary6 = Python.eval("np.array(['2021-03-01T10:02:03'], dtype='datetime64[h]')"); 176 | assertEquals("2021-03-01T10:00:00Z", ndary6.toArray()[0].toString()); 177 | NpNdarrayInstant ndary7 = Python.eval("np.array(['2021-03-01T10:02:03'], dtype='datetime64[D]')"); 178 | assertEquals("2021-03-01T00:00:00Z", ndary7.toArray()[0].toString()); 179 | NpNdarrayInstant ndary8 = Python.eval("np.array(['2021-03-01T10:02:03'], dtype='datetime64[W]')"); 180 | assertEquals("2021-02-25T00:00:00Z", ndary8.toArray()[0].toString()); 181 | 182 | Python.put("v", ndary4); 183 | Python.exec("print(v)"); 184 | NpNdarrayInstant ndary9 = Python.get("v"); 185 | assertEquals(ndary4, ndary9); 186 | 187 | Python.put("v", ndary4.data); 188 | Python.exec("print(v)"); 189 | NpNdarrayInstant ndary10 = Python.get("v"); 190 | assertEquals(ndary4, ndary10); 191 | 192 | Python.put("v", ndary4.data[0]); 193 | Python.exec("print(v)"); 194 | Instant instant11 = Python.get("v"); 195 | assertEquals(ndary4.data[0], instant11); 196 | } 197 | 198 | @Test 199 | public void testStdoutBuffering() { 200 | System.out.println("1"); 201 | Python.exec("print(2)"); 202 | System.out.println("3"); 203 | } 204 | 205 | @Test 206 | public void testUnsupportedJavaType1() { 207 | assertThrows(PythonException.class, () -> { 208 | try { 209 | Python.put("v", UUID.randomUUID()); 210 | } catch (PythonException e) { 211 | e.printStackTrace(); 212 | throw e; 213 | } 214 | }); 215 | } 216 | 217 | @Test 218 | public void testUnsupportedJavaType2() { 219 | assertThrows(PythonException.class, () -> { 220 | try { 221 | HashMap map = new HashMap<>(); 222 | map.put("a", Arrays.asList(1, 2)); 223 | map.put("b", UUID.randomUUID()); 224 | Python.put("v", map); 225 | } catch (PythonException e) { 226 | e.printStackTrace(); 227 | throw e; 228 | } 229 | }); 230 | } 231 | 232 | @Test 233 | public void testUnsupportedJavaType3() { 234 | assertThrows(PythonException.class, () -> { 235 | try { 236 | Python.put("f", (Function0) UUID::randomUUID); 237 | Python.exec("f()"); 238 | } catch (PythonException e) { 239 | e.printStackTrace(); 240 | throw e; 241 | } 242 | }); 243 | } 244 | 245 | @Test 246 | public void testUnsupportedPythonType1() { 247 | assertThrows(PythonException.class, () -> { 248 | try { 249 | Python.exec("import uuid\nv = uuid.uuid4()\n"); 250 | Python.get("v"); 251 | } catch (PythonException e) { 252 | e.printStackTrace(); 253 | assertEquals(3L, (long) Python.eval("1 + 2")); 254 | throw e; 255 | } 256 | }); 257 | } 258 | 259 | @Test 260 | public void testUnsupportedPythonType2() { 261 | assertThrows(PythonException.class, () -> { 262 | try { 263 | Python.exec("import uuid\nv = dict(a=[1, 2], b=uuid.uuid4())\n"); 264 | Python.get("v"); 265 | } catch (PythonException e) { 266 | e.printStackTrace(); 267 | assertEquals(3L, (long) Python.eval("1 + 2")); 268 | throw e; 269 | } 270 | }); 271 | } 272 | 273 | @Test 274 | public void testUnsupportedPythonType3() { 275 | assertThrows(PythonException.class, () -> { 276 | try { 277 | Python.put("f", (Function1) (uuid) -> null); 278 | Python.exec("import uuid\nf(uuid.uuid4())"); 279 | } catch (PythonException e) { 280 | e.printStackTrace(); 281 | throw e; 282 | } 283 | }); 284 | } 285 | 286 | @Test 287 | public void testArgv() { 288 | Python.exec("import sys"); 289 | ArrayList argv = Python.eval("sys.argv"); 290 | assertEquals(1, argv.size()); 291 | assertEquals("", argv.get(0)); 292 | } 293 | 294 | @Test 295 | public void testSysExecutable() { 296 | Python.exec("import sys"); 297 | String sysExecutable = Python.eval("sys.executable"); 298 | System.out.println(sysExecutable); 299 | } 300 | 301 | @Test 302 | public void testOrderedDict() { 303 | LinkedHashMap map1 = new LinkedHashMap<>(); 304 | map1.put("a", 1L); 305 | map1.put("b", 2L); 306 | 307 | Python.exec("from collections import OrderedDict"); 308 | LinkedHashMap map2 = Python.eval("OrderedDict(a=1, b=2)"); 309 | assertEquals(map1, map2); 310 | } 311 | } 312 | --------------------------------------------------------------------------------