Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

chrisbase

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrisbase - npm Package Compare versions

Comparing version
0.5.8
to
0.5.9
+4
-2
PKG-INFO

@@ -1,4 +0,4 @@

Metadata-Version: 2.2
Metadata-Version: 2.4
Name: chrisbase
Version: 0.5.8
Version: 0.5.9
Summary: Base library for python coding

@@ -15,2 +15,3 @@ Home-page: https://github.com/chrisjihee/chrisbase

Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Description-Content-Type: text/markdown

@@ -39,2 +40,3 @@ License-File: LICENSE

Requires-Dist: seqeval
Dynamic: license-file

@@ -41,0 +43,0 @@ # chrisbase

[metadata]
name = chrisbase
version = 0.5.8
version = 0.5.9
author = Jihee Ryu

@@ -18,2 +18,3 @@ author_email = chrisjihee@naver.com

Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12

@@ -20,0 +21,0 @@ [options]

@@ -1,4 +0,4 @@

Metadata-Version: 2.2
Metadata-Version: 2.4
Name: chrisbase
Version: 0.5.8
Version: 0.5.9
Summary: Base library for python coding

@@ -15,2 +15,3 @@ Home-page: https://github.com/chrisjihee/chrisbase

Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Description-Content-Type: text/markdown

@@ -39,2 +40,3 @@ License-File: LICENSE

Requires-Dist: seqeval
Dynamic: license-file

@@ -41,0 +43,0 @@ # chrisbase

@@ -32,2 +32,3 @@ import itertools

from chrisbase.util import tupled, SP, NO, to_dataframe
from transformers import set_seed

@@ -46,5 +47,6 @@ logger = logging.getLogger(__name__)

@staticmethod
def run(function: Callable[..., Any], **kwargs) -> None:
def run(*functions: Callable[..., Any], **kwargs) -> None:
app = AppTyper(**kwargs)
app.command()(function)
for function in functions:
app.command()(function)
app()

@@ -66,3 +68,3 @@

output_home: str | Path = Field(default="output")
output_name: str | Path = Field(default=None)
output_name: str | Path | None = Field(default=None)
run_version: str | int | Path | None = Field(default=None)

@@ -90,2 +92,5 @@ output_file: str | Path = Field(default=None)

self.setup_logger(self.logging_level)
if self.random_seed:
set_seed(self.random_seed)
logger.info(f"Set random seed to {self.random_seed}")
return self

@@ -373,3 +378,3 @@

self.fp.flush()
return file_lines(self.path)
return file_lines(self.path, encoding=self.opt.encoding)
else:

@@ -376,0 +381,0 @@ return -1

@@ -259,3 +259,3 @@ import bz2

def to_table_lines(*args, c="-", w=137, left='', tablefmt="plain", header_idx=0, bordered=False, **kwargs):
def to_table_lines(*args, left='', c="-", w=137, tablefmt="plain", header_idx=0, border_idx=-1, bordered=False, **kwargs):
table = str_table(*args, **kwargs, tablefmt=tablefmt)

@@ -268,2 +268,12 @@ lines = table.splitlines()

[border])
elif border_idx >= 0:
border = lines[border_idx]
lines = (
[] +
[border] +
lines[:header_idx + 1] +
lines[header_idx + 1:] +
[border] +
[]
)
for line in lines if not left else [left + line for line in lines]:

@@ -273,4 +283,4 @@ yield line

def log_table(my_logger, *args, c="-", w=137, level=logging.INFO, **kwargs):
for line in to_table_lines(*args, **kwargs, c=c, w=w):
def log_table(my_logger, *args, level=logging.INFO, **kwargs):
for line in to_table_lines(*args, **kwargs):
my_logger.log(level, line)

@@ -403,3 +413,3 @@

def file_lines(file):
def file_lines(file, encoding='utf-8'):
def blocks(f, size=65536):

@@ -412,7 +422,7 @@ while True:

with Path(file).open() as inp:
with Path(file).open(encoding=encoding) as inp:
return sum(b.count("\n") for b in blocks(inp))
def num_lines(path, mini=None):
def num_lines(path, encoding='utf-8', mini=None):
assert path, f"No path: {path}"

@@ -423,29 +433,29 @@ path = Path(path)

return mini
with path.open() as inp:
with path.open(encoding=encoding) as inp:
return sum(1 for _ in inp)
def all_lines(path, mini=None):
def all_lines(path, encoding='utf-8', mini=None):
assert path, f"No path: {path}"
path = Path(path)
full = not mini or mini <= 0
with path.open() as inp:
with path.open(encoding=encoding) as inp:
return map(lambda x: x.rstrip(), inp.readlines() if full else inp.readlines()[:mini])
def all_line_list(path, mini=None):
return list(all_lines(path, mini))
def all_line_list(path, encoding='utf-8', mini=None):
return list(all_lines(path, encoding=encoding, mini=mini))
def tsv_lines(*args, **kwargs):
return map(lambda x: x.split('\t'), all_lines(*args, **kwargs))
def tsv_lines(*args, encoding='utf-8', **kwargs):
return map(lambda x: x.split('\t'), all_lines(*args, encoding=encoding, **kwargs))
def key_lines(key, *args, **kwargs):
return [x for x in all_lines(*args, **kwargs) if key in x]
def key_lines(key, *args, encoding='utf-8', **kwargs):
return [x for x in all_lines(*args, encoding=encoding, **kwargs) if key in x]
def text_blocks(path) -> Iterable[List[str]]:
def text_blocks(path, encoding='utf-8') -> Iterable[List[str]]:
block = []
with open(path, mode="r", encoding="utf-8") as f:
with open(path, mode="r", encoding=encoding) as f:
for line in f:

@@ -452,0 +462,0 @@ line = line[:-1]