Skip to main content

No project description provided

Project description

nokogiri

This Python library is a sharp "nokogiri" that cuts through the problems that arise in the process of trial and error, such as machine learning.

pip install nokogiri

spylus

  • Now you can draw image with stylus pen or drawing tablet such as iPad, Surface and Wacom in JupyterLab/Notebook.
  • Of course it senses pressure so you can control the thickness of the line.
  • Clipboard image copy/paste feature supported! this is super effective for AI painting with clip studio/photoshop.
  • VSCode greatly limits functionality due to policies that prohibit the execution of javascript in notebooks. Please use JupyterLab/Notebook.

screenshot

demo.gif

Try it

Binder Hit this button and launch demo via binder.

from nokogiri.spylus import spylus

anyparse

Drop-in replacement library for (config)argparse that works anywhere (Jupyter Notebook, JupyterLab, VSCode Python Interactive). Have you ever met an annying error message like this?

usage: ipykernel_launcher.py [-h]
ipykernel_launcher.py: error: unrecognized arguments: -f 
…
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2

As shown in the following example. You can drop-in replace argparse with anyparse. You can also specify commands to be parsed only on jupyter.

from nokogiri import anyparse as argparse # Drop-in replacement
parser = argparse.ArgumentParser()
parser.add_argument('--readlink', type=str, default="")
parser.add_argument('--metrics', type=bool, default=False)
parser.jupyter_argument("--metrics True") # This command is parsed only on jupyter.
args = parser.parse_args()

If configargparse is already installed, all features are available!

working_dir

Enables import of any module not in the project tree from anywhere at any time

from nokogiri.working_dir import working_dir
with working_dir("/path/to/isolated_module"):
    import isolated_module
    with open("isolated_data") as f:
        isolated_data = f.read()

tqdm_load

Display a progress bar while reading a pickle file

from nokogiri.tqdm_load import tqdm_load
data = tqdm_load("/path/to/data.pkl")

defaultdotdict

defaultdict but also dotdict

from nokogiri.defaultdotdict import defaultdotdict
sounds = defaultdotdict(lambda: "meow")
print(sounds.dog) # "meow"
sounds["dog"] = "bow" # you can also access with []
print(sounds.dog) # "bow"

curry

currying function. add some syntax sugar for a lot of function arguments.

from nokogiri.curry import curry
# "pipe" iterable objects
@curry
def f(x):
    return x+1
@curry
def g(x):
    return 2*x
range(5)|f|g # [2,4,6,8,10]

# example of common use case
@curry
def f(a="a", b="b", c="c", d="d"):
    return f"/{a}/{b}/{c}/{d}"
f.hoge.fuga.piyo("root") # "/root/hoge/fuga/piyo"

# syntax
f.hoge.fuga.piyo == lambda x: f(x, 'hoge', 'fuga', 'piyo')
f[1][None][True] == lambda x: f(x, 1, None, True)
f._(key="value") == lambda x: f(x, key="value")

which_env

Detect notebook environment is Jupyter or Terminal or …

from nokogiri.which_env import which_env
if which_env() == which_env.JUPYTER:
    from tqdm.notebook import tqdm
else:
    from tqdm import tqdm

shared_map

share large size map/dict between notebok kernels

python -m nokogiri.shared_map /path/to/*.pkl
from nokogiri.shared_map import shared_map
sm = shared_map("/path/to")
for x in tqdm(range(100)):
    y = sm.hoge(x) # read from /path/to/hoge.pkl

cell

Bring Jupyter cell behavior to VSCode Python Interactive

from nokogiri.cell import cell
A = 1
B = 2
@cell()
def func(A, B):
    C = A+B
    D = A*B
    return C, D
print(C, D) # 3, 2

code embeding test (recently I noticed that Readme.md is code-embeddable like this.)

https://github.com/nat-chan/nokogiri/blob/e0d438d20d28a36467337bed540a1d2770c65caa/nokogiri/tqdm_load.py#L9-L17

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nokogiri-0.2.2-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file nokogiri-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: nokogiri-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.7.4

File hashes

Hashes for nokogiri-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 09dadd9221f6b4f18c96d8c53e18f917a0872fcaba8dc888ef359ab2054959a9
MD5 d83a9dec34eca031cc51cf9042d37a03
BLAKE2b-256 d5a47567756134420851c963a00da39791ea36d59eeadf8e8952ddbc11ebbaa3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page