Skip to content

Commit e27c0ab

Browse files
committed
Add more docstrings
1 parent 4de4bbf commit e27c0ab

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

src/scyjava/__init__.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,71 @@
1+
"""
2+
Supercharged Java access from Python, built on JPype and jgo.
3+
4+
Use Java classes from Python:
5+
6+
>>> from scyjava import jimport
7+
>>> System = jimport('java.lang.System')
8+
>>> System.getProperty('java.version')
9+
'1.8.0_252'
10+
11+
Use Maven artifacts from remote repositories:
12+
13+
>>> from scyjava import config, jimport
14+
>>> config.add_option('-Djava.awt.headless=true')
15+
>>> config.add_repositories({
16+
... 'scijava.public': 'https://maven.scijava.org/content/groups/public',
17+
... })
18+
>>> config.endpoints.append('net.imagej:imagej:2.1.0')
19+
>>> ImageJ = jimport('net.imagej.ImageJ')
20+
>>> ij = ImageJ()
21+
>>> formula = "10 * (Math.cos(0.3*p[0]) + Math.sin(0.3*p[1]))"
22+
>>> ArrayImgs = jimport('net.imglib2.img.array.ArrayImgs')
23+
>>> blank = ArrayImgs.floats(64, 16)
24+
>>> sinusoid = ij.op().image().equation(blank, formula)
25+
>>> print(ij.op().image().ascii(sinusoid))
26+
,,,--+oo******oo+--,,,,,--+oo******o++--,,,,,--+oo******o++--,,,
27+
...,--+ooo**oo++--,....,,--+ooo**oo++-,,....,,--+ooo**oo++-,,...
28+
...,--++oooo++--,... ...,--++oooo++--,... ...,--++oooo++-,,...
29+
..,--++++++--,.. ..,--++o+++--,.. .,,--++o+++--,..
30+
..,,-++++++-,,. ..,,-++++++-,,. ..,--++++++-,,.
31+
.,,--++++--,,. .,,--++++--,,. .,,--++++--,..
32+
.,,--++++--,,. .,,-+++++--,,. .,,-+++++--,,.
33+
..,--++++++--,.. ..,--++++++--,.. ..,--++++++-,,..
34+
..,,-++oooo++-,,.. ..,,-++oooo++-,,.. ..,,-++ooo+++-,,..
35+
...,,-++oooooo++-,,.....,,-++oooooo++-,,.....,,-++oooooo+--,,...
36+
.,,,-++oo****oo++-,,,.,,,-++oo****oo+--,,,.,,,-++oo****oo+--,,,.
37+
,,--++o***OO**oo++-,,,,--++o***OO**oo+--,,,,--++o***OO**oo+--,,,
38+
---++o**OOOOOO**o++-----++o**OOOOOO*oo++-----++o**OOOOOO*oo++---
39+
--++oo*OO####OO*oo++---++oo*OO####OO*oo++---++o**OO####OO*oo++--
40+
+++oo*OO######O**oo+++++oo*OO######O**oo+++++oo*OO######O**oo+++
41+
+++oo*OO######OO*oo+++++oo*OO######OO*oo+++++oo*OO######OO*oo+++
42+
43+
Convert Java collections to Python:
44+
45+
>>> from scyjava import jimport
46+
>>> HashSet = jimport('java.util.HashSet')
47+
>>> moves = set(('jump', 'duck', 'dodge'))
48+
>>> fish = set(('walleye', 'pike', 'trout'))
49+
>>> jbirds = HashSet()
50+
>>> for bird in ('duck', 'goose', 'swan'): jbirds.add(bird)
51+
>>> from scyjava import to_python as j2p
52+
>>> j2p(jbirds).isdisjoint(moves)
53+
False
54+
>>> j2p(jbirds).isdisjoint(fish)
55+
True
56+
57+
Convert Python collections to Java:
58+
59+
>>> from scyjava import jimport
60+
>>> HashSet = jimport('java.util.HashSet')
61+
>>> jset = HashSet()
62+
>>> pset = set((1, 2, 3))
63+
>>> from scyjava import to_java as p2j
64+
>>> jset.addAll(p2j(pset))
65+
True
66+
>>> jset.toString()
67+
'[1, 2, 3]'
68+
"""
169
import logging
270
from functools import lru_cache
371
from typing import Any, Callable, Dict

src/scyjava/_arrays.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Utility functions for working with and reasoning about arrays.
3+
"""
4+
5+
16
def is_arraylike(arr):
27
"""
38
Return True iff the object is arraylike: possessing

src/scyjava/_java.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Utility functions for working with the Java and JVM.
33
"""
4+
45
import atexit
56
import logging
67
import os

src/scyjava/_versions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
Utility functions for working with and reasoning about software component versions.
3+
"""
4+
15
import logging
26
from importlib.util import find_spec
37

0 commit comments

Comments
 (0)