semvec/pypi-packages huggingface dataset:
sci-cache 0.1.4
A Python library for caching scientific data on disk, streamlining research workflows by storing intermediate results.
License: MIT
Requires Python: <4.0,>=3.10
Keywords: cache, scientific, data, performance, optimization

# sci-cache

A Python library for caching scientific data on disk, streamlining research workflows by storing intermediate results.

## Features

- **Method-Based Caching**: Automatically cache each method's result based on the method name to the specified directory.
- **Easy Integration**: Inherit from `MethodDiskCache` and use the `@sci_method_cache` decorator to enable caching.
- **Flexible Storage**: Store cached data in a designated folder, organized and managed automatically.
- **Supports Various Data Types**: Ideal for scientific data processing tasks, handling complex data types efficiently.

## Installation

```bash
pip install sci-cache
```

## Usage

```python
from pathlib import Path

from sci_cache import MethodDiskCache, sci_method_cache


# Define a caching class by inheriting from MethodDiskCache
class ScientificCache(MethodDiskCache):
    compute_square_count = 0  # Track compute_square calls
    compute_cube_count = 0  # Track compute_cube calls

    def get_cache_folder(self) -> Path:
        # Set the cache directory to 'cache' folder in the current script's directory
        return Path(__file__).parent / "cache"

    @sci_method_cache
    def compute_square(self) -> int:
        # Increment the count to track actual computation
        ScientificCache.compute_square_count += 1
        return 3 * 3  # Example computation

    @sci_method_cache
    def compute_cube(self) -> int:
        # Increment the count to track actual computation
        ScientificCache.compute_cube_count += 1
        return 2 * 2 * 2  # Example computation


# Instantiate the caching class and use the cached methods
cache1 = ScientificCache()

# First call: performs computation and caches the result
square1 = cache1.compute_square()
assert square1 == 9
assert ScientificCache.compute_square_count == 1

# Second call: retrieves the result from cache without recomputing
square2 = cache1.compute_square()
assert square2 == 9
assert ScientificCache.compute_square_count == 1

# First call: performs computation and caches the result
cube1 = cache1.compute_cube()
assert cube1 == 8
assert ScientificCache.compute_cube_count == 1

# Second call: retrieves the result from cache without recomputing
cube2 = cache1.compute_cube()
assert cube2 == 8
assert ScientificCache.compute_cube_count == 1

# Re-instantiate the caching class to simulate a new session
cache2 = ScientificCache()

# Call methods again to ensure cached results are used
square3 = cache2.compute_square()
assert square3 == 9
assert ScientificCache.compute_square_count == 1

cube3 = cache2.compute_cube()
assert cube3 == 8
assert ScientificCache.compute_cube_count == 1

print("All assertions passed.")
```

## License

MIT License. See [LICENSE](./LICENSE) for more information.
nonebot-plugin-alchelper 0.6.0
以nonebot-plugin-alconna为基础提供系列帮助功能的插件
License: MIT
Requires Python: >=3.9

# nonebot-plugin-alchelper
基于 [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna), 适用于 [Nonebot2](https://github.com/nonebot/nonebot2) 的命令帮助插件。

## 安装

- 使用 nb-cli

```shell
nb plugin install nonebot-plugin-alchelper
```

- 使用 pip

```shell
pip install nonebot-plugin-alchelper
```

## 注意事项

本插件使用了 `nonebot-plugin-orm`, 这需要你自行配置数据库相关配置

例如，在使用 `sqlite` 作为数据库驱动的情况下，你需要

1. 运行 `pip install nonebot-plugin-alchelper[aiosqlite]`
2. 在.env配置文件中设置 `SQLALCHEMY_DATABASE_URL=sqlite+aiosqlite:///path-to-your-database`
3. 通过 `nb-cli` 运行 `nb orm upgrade`，然后通过 `nb orm check` 检查是否存在问题

更多内容参阅 [`orm文档`](https://deploy-preview-2545--nonebot2.netlify.app/docs/next/best-practice/db/).

## 配置项

> 以下配置项可在 `.env.*` 文件中设置，具体参考 [NoneBot 配置方式](https://nonebot.dev/docs/appendices/config)

### `alchelper_command_start`
 - 类型：`Optional[Set[str]]`
 - 默认：`None`
 - 说明：插件使用的命令前缀，如果不填则使用全局命令前缀 (COMMAND_START)

### `alchelper_help`
 - 类型：`str`
 - 默认：`"help"`
 - 说明：插件使用的帮助命令名称

### `alchelper_help_index`
 - 类型：`bool`
 - 默认：`False`
 - 说明：插件使用的帮助命令是否显示索引

### `alchelper_help_max`
 - 类型：`int`
 - 默认：`-1`
 - 说明：插件使用的帮助命令最大显示数量，-1 为不限制

### `alchelper_statis`
 - 类型：`str`
 - 默认：`"statis"`
 - 说明：插件使用的统计命令名称

### `alchelper_statis_msgcount_default`
 - 类型：`int`
 - 默认：`10`
 - 说明：插件使用的统计命令默认显示消息数量

## 使用

> /help
> /statis [count = 10] 
> /第3页帮助
> /命令统计
> /用户统计 @xxx