Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.jetbrains-research:npy:0.3.3'
}
dependencies {
implementation("com.github.jetbrains-research:npy:0.3.3")
}
<dependency>
<groupId>com.github.jetbrains-research</groupId>
<artifactId>npy</artifactId>
<version>0.3.3</version>
</dependency>
libraryDependencies += "com.github.jetbrains-research" % "npy" % "0.3.3"
:dependencies [[com.github.jetbrains-research/npy "0.3.3"]]
npy
allows to read and write files in NPY npy and [NPZ] npy formats
on the JVM.
The latest version of npy
is available on [Maven Central] maven-central. If you're using
Gradle just add the following to your build.gradle
:
repositories {
mavenCentral()
}
dependencies {
compile 'org.jetbrains.bio:npy:0.3.5'
}
With Maven, specify the following in your pom.xml
:
<dependency>
<groupId>org.jetbrains.bio</groupId>
<artifactId>npy</artifactId>
<version>0.3.5</version>
</dependency>
The previous versions were published on Bintray. They can be downloaded from GitHub Releases.
val values = intArrayOf(1, 2, 3, 4, 5, 6)
val path = Paths.get("sample.npy")
NpyFile.write(path, values, shape = intArrayOf(2, 3))
println(NpyFile.read(path))
// => NpyArray{data=[1, 2, 3, 4, 5, 6], shape=[2, 3]}
val values1 = intArrayOf(1, 2, 3, 4, 5, 6)
val values2 = booleanArrayOf(true, false)
val path = Paths.get("sample.npz")
NpzFile.write(path).use {
it.write("xs", values1, shape = intArrayOf(2, 3))
it.write("mask", values2)
}
NpzFile.read(path).use {
println(it.introspect())
// => [NpzEntry{name=xs, type=int, shape=[2, 3]},
// NpzEntry{name=mask, type=boolean, shape=[2]}]
println("xs = ${it["xs"]}")
println("mask = ${it["mask"]}")
// => xs = NpyArray{data=[1, 2, 3, 4, 5, 6], shape=[2, 3]}
// mask = NpyArray{data=[true, false], shape=[2]}
}
The implementation is rather minimal at the moment. Specifically it does not support the following types:
The build process is as simple as
$ ./gradlew jar
Note: don't use ./gradlew assemble
, since it includes the signing of the artifacts
and will fail if the correct credentials are not provided.
No extra configuration is required for running the tests from Gradle
$ ./gradlew test
However, some tests require Python and NumPy to run and will be skipped unless you have these.