text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
"""new 2
Revision ID: c93f54e30e5c
Revises: 0c11825e2e0c
Create Date: 2024-04-24 15:23:57.850036
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "c93f54e30e5c"
down_revision: Union[str, None] = "0c11825e... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2024_04_24_1523-c93f54e30e5c_new_2.py | .py | 3bcc51e96171a9b5 | 7.3 | 3 |
"""add_account_locking_columns
Revision ID: 5c76e4868fe4
Revises: 8c263ccc446a
Create Date: 2025-04-25 01:44:00.165605
"""
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy import inspect
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "5c76e4868fe4"
down_r... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_25_0144-5c76e4868fe4_add_account_locking_columns.py | .py | e6dce2fc02696f1f | 7.3 | 3 |
"""add_needs_to_change_password
Revision ID: 2025_04_25_1200
Revises: 5c76e4868fe4
Create Date: 2025-04-25 12:00:00
"""
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy import inspect
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "2025_04_25_1200"
down_r... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_25_1200-add_needs_to_change_password.py | .py | 6bd09924fa56d19e | 7.3 | 3 |
"""rename_needs_to_change_password_column
Revision ID: 10fcb44b9e37
Revises: 2025_04_25_1200
Create Date: 2025-04-26 09:57:37.590460
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "10fcb44b9e37"
down_re... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_26_0957-10fcb44b9e37_rename_needs_to_change_password_column.py | .py | 433d7a7cf1dc4b0f | 7.3 | 3 |
"""merge heads
Revision ID: bd7fd9f11370
Revises: 10fcb44b9e37, 2025_04_26_1010
Create Date: 2025-04-26 10:04:37.382905
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "bd7fd9f11370"
down_revision: Union... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_26_1004-bd7fd9f11370_merge_heads.py | .py | 98f2601689682386 | 7.3 | 3 |
"""rename needsToChangePassword to needs_to_change_password
Revision ID: 2025_04_26_1010
Revises: 2025_04_25_1200
Create Date: 2025-04-26 10:10:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy.engine.reflection import Inspector
from alembic import op
# revision identifiers,... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_26_1010-rename_needs_to_change_password.py | .py | 840b0f5180dd8bb2 | 7.3 | 3 |
"""fix_rolegroupmap_case_conflict
Revision ID: 2271ef9d5855
Revises: bd7fd9f11370
Create Date: 2025-04-26 10:20:00.919243
"""
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy.engine import reflection
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "2271ef9... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_26_1020-2271ef9d5855_fix_rolegroupmap_case_conflict.py | .py | b9e948d94980598d | 7.3 | 3 |
"""add_role_group_id_field_to_roles
Revision ID: 24cc34ec6962
Revises: 2025_04_27_1530
Create Date: 2025-04-27 13:59:11.469264
"""
from typing import Sequence, Union
from uuid import UUID
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "24cc3... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_1359-24cc34ec6962_add_role_group_id_field_to_roles.py | .py | 95fa1a9c1db3ca15 | 7.3 | 3 |
"""add audit logs
Revision ID: 2025_04_27_1523
Revises: 2025_04_25_1200
Create Date: 2025-04-27 15:23:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "2025_04_27_1523"
down_revision: Union[str, None] = "2025_0... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_1523-add_audit_logs.py | .py | b26c83f070aee4bd | 7.3 | 3 |
"""merge heads
Revision ID: 2025_04_27_1524
Revises: 2271ef9d5855, 2025_04_27_1523
Create Date: 2025-04-27 15:24:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "2025_04_27_1524"
down_revision:... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_1524_merge_heads.py | .py | 07309a5b40565b89 | 7.3 | 3 |
"""add role group map
Revision ID: 2025_04_27_1525
Revises: 2025_04_27_1524
Create Date: 2025-04-27 15:25:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "2025_04_27_1525"
down_revision: Union[... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_1525_add_role_group_map.py | .py | b5c0a749492c2cb0 | 7.3 | 3 |
"""merge all heads
Revision ID: 2025_04_27_1526
Revises: 2025_04_27_1523, 2025_04_27_1525, 2271ef9d5855
Create Date: 2025-04-27 15:26:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "2025_04_27... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_1526_merge_all_heads.py | .py | 64d624797d0a58bf | 7.3 | 3 |
"""final merge
Revision ID: 2025_04_27_1527
Revises: 2025_04_27_1523, 2025_04_27_1525, 2025_04_27_1526, 2271ef9d5855
Create Date: 2025-04-27 15:27:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str ... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_1527_final_merge.py | .py | 05fd28532e67e267 | 7.3 | 3 |
"""merge all branches
Revision ID: 2025_04_27_1528
Revises: 2025_04_27_1523, 2025_04_27_1525, 2025_04_27_1526, 2025_04_27_1527, 2271ef9d5855
Create Date: 2025-04-27 15:28:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_1528_merge_all_branches.py | .py | 8905586739769ce8 | 7.3 | 3 |
"""remove duplicate table
Revision ID: 2025_04_27_1529
Revises: 2025_04_27_1528
Create Date: 2025-04-27 15:29:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "2025_04_27_1529"
down_revision: st... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_1529_remove_duplicate_table.py | .py | 52ec286e9985f437 | 7.3 | 3 |
"""standardize table names
Revision ID: 2025_04_27_1530
Revises: 2025_04_27_1529
Create Date: 2025-04-27 15:30:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from sqlalchemy import inspect
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "20... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_1530_standardize_table_names.py | .py | 20282a49c9d53411 | 7.3 | 3 |
"""merge_heads
Revision ID: bf342191792b
Revises: 24cc34ec6962, 2025_04_27_2030
Create Date: 2025-04-27 20:19:12.351888
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "bf342191792b"
down_revision: Union... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_2019-bf342191792b_merge_heads.py | .py | 8e20a8bc5beace40 | 7.3 | 3 |
"""add parent_id to role group
Revision ID: 2025_04_27_2030
Revises: 2025_04_27_1525
Create Date: 2025-04-27 20:30:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "20... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_04_27_2030_add_parent_id_to_role_group.py | .py | 8c31adbd38155cea | 7.3 | 3 |
"""add fields to userpasswordhistory manually
Revision ID: add_fields_to_userpasswordhistory_manual
Revises: 74a7cd91e8fa
Create Date: 2025-05-23 15:00:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import UUID as pg_UUID
from alembic import op
# revis... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_05_23_1645-17a6c5744ad5_add_new_fields_to_userpasswordhistory.py | .py | 175f06c1041e4aad | 7.3 | 3 |
"""fix_audit_log_table_schema
Revision ID: 5b37ec4d07bc
Revises: 8ba4877e61a2
Create Date: 2025-06-14 18:31:05.103889
"""
from typing import Sequence, Union
import sqlalchemy as sa
import sqlmodel
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "5b37ec4d07bc"
down_revision: Union[s... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_06_14_1831-5b37ec4d07bc_fix_audit_log_table_schema.py | .py | b58e6b20c7536e76 | 7.3 | 3 |
"""
Add unique constraint to RoleGroup.name
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "2025_06_15_0000"
down_revision: Union[str, None] = "5b37ec4d07bc"
branch_labels: Union[str, Sequence[str], None] = None
depends_... | mnaimfaizy/fastapi_rbac | backend/alembic/versions/2025_06_15_0000_add_unique_constraint_rolegroup_name.py | .py | a3934ef959c5e415 | 7.3 | 3 |
import logging
import os
import ssl
import sys
from pathlib import Path
from typing import Any
import tenacity
from redis.exceptions import AuthenticationError # Import AuthenticationError directly
from sqlalchemy import create_engine, text
# Add the 'backend' directory (parent of 'app') to sys.path
# Path(__file__)... | mnaimfaizy/fastapi_rbac | backend/app/backend_pre_start.py | .py | 1bc8a498e9ac72ef | 7.3 | 3 |
"""
Celery configuration module for the FastAPI RBAC project.
This module provides configuration settings for Celery tasks and workers.
"""
from functools import lru_cache
from typing import Any, Dict
from kombu import Queue
from app.core.config import ModeEnum, settings
def get_celery_config() -> Dict[str, Any]:
... | mnaimfaizy/fastapi_rbac | backend/app/core/celery_config.py | .py | b27b37bfd7235403 | 7.3 | 3 |
"""Shared slowapi HTTP rate limiter for the FastAPI app.
HTTP rate limits use this single Limiter instance (app.state + route decorators).
Abuse counters (hand-rolled Redis incr/expire in auth) are separate.
"""
from __future__ import annotations
import os
from slowapi import Limiter
from slowapi.util import get_re... | mnaimfaizy/fastapi_rbac | backend/app/core/rate_limit.py | .py | c5c53846ecf080ad | 7.3 | 3 |
import base64
import hashlib
import hmac
import logging
import os
from datetime import datetime, timedelta, timezone
from typing import Any, Literal, Union
import bcrypt
import jwt
from cryptography.fernet import Fernet
from fastapi import HTTPException, status
from jwt.exceptions import (
ExpiredSignatureError,
... | mnaimfaizy/fastapi_rbac | backend/app/core/security.py | .py | 77337b1aa7935dfe | 7.3 | 3 |
"""
Service configuration for environment-specific settings.
Manages Redis, Celery, and other service configurations.
"""
import os
from typing import Any, Dict
from app.core.config import ModeEnum, settings
class ServiceSettings:
"""
Environment-specific service settings for Celery,
Redis, and other ex... | mnaimfaizy/fastapi_rbac | backend/app/core/service_config.py | .py | 7087f3f59e025b1a | 7.3 | 3 |
import os
import sys
from datetime import datetime
import pandas as pd # type: ignore
import plotly # type: ignore
import plotly.graph_objects as go # type: ignore
import pytz # type: ignore
def load_and_prepare_data(file_path: str) -> pd.DataFrame:
""" CSVファイルを読み込み、必要なデータを抽出して変換する """
try:
df = ... | MareMare/SpeedTestAnalysis | analysis.py | .py | 2dd156d54be1f878 | 7.3 | 3 |
from pathlib import Path
from re import sub
from subprocess import PIPE, run # nosec
from scruft import exceptions
DIFF_SRC_PREFIX = "upstream-template-old"
DIFF_DST_PREFIX = "upstream-template-new"
def _git_diff(*args: str) -> list[str]:
# https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---binary ... | allenporter/scruft | scruft/_commands/utils/diff.py | .py | b09769dadc54438b | 7.24 | 2 |
import os
import json
import pandas as pd
from datetime import datetime
from tqdm import tqdm
from openai import OpenAI
class FineTunedModelProcessor:
def __init__(self, config_path: str, test_folder: str, system_file_path: str, output_folder: str):
"""
初始化微调模型处理器
:param config_path: 配置文件路... | lzhzzzzwill/MOFh6 | extrfinetune/cftm.py | .py | 288fcd3d5bab4daa | 7.15 | 1 |
import os
import json
import re
import time
from typing import List, Dict, Optional
from openai import OpenAI
from tqdm import tqdm
from extrfinetune.prompt.elsehl import prompt_template
class AcronymExtractor:
def __init__(self, config_path: str, input_folder: str, output_folder: str):
"""
初始化缩写提取... | lzhzzzzwill/MOFh6 | extrfinetune/chl.py | .py | da1c42b5e72052ab | 7.15 | 1 |
import os
import json
import re
import time
from typing import List, Dict
from openai import OpenAI
from tqdm import tqdm
from datetime import datetime
from extrfinetune.prompt.jtjprompt import prompt_template
class CrystalDataComparator:
"""晶体数据比对类"""
def __init__(self, config_path: str):
# 加载配置文件
... | lzhzzzzwill/MOFh6 | extrfinetune/cjtj.py | .py | 5573e66cf2716558 | 7.15 | 1 |
import os
import json
from openai import OpenAI
from extrfinetune.prompt.sstru1 import prompt_template
from tqdm import tqdm
class MOFDataProcessor:
def __init__(self, config_path: str):
"""
初始化处理器
:param config_path: 配置文件路径
"""
with open(config_path, 'r', encoding='utf-8') ... | lzhzzzzwill/MOFh6 | extrfinetune/cstrucout.py | .py | fb7ae97d06b67203 | 7.15 | 1 |
import os
import json
import re
import time
from typing import List, Dict, Optional
from openai import OpenAI
from tqdm import tqdm
from extrfinetune.prompt.elsedatatable import prompt_template
class ElsevierTableExtractor:
def __init__(self, config_path: str, input_folder: str, output_file: str):
"""
... | lzhzzzzwill/MOFh6 | extrfinetune/ctotable.py | .py | 2d7fc4cb76c9a8af | 7.15 | 1 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import os
import pandas as pd
import time
import traceback
import requests
import re
import io
from urllib.parse import urlparse
# PDF 处理相关
from PyPDF2 import PdfReader, PdfWriter
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import lett... | lzhzzzzwill/MOFh6 | refer/ACS_crawler.py | .py | 786d20a3bdc0bcc9 | 7.15 | 1 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import os
import pandas as pd
import time
import traceback
import requests
import re
import io
from urllib.parse import urlparse
# PDF相关
from PyPDF2 import PdfReader, PdfWriter
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
... | lzhzzzzwill/MOFh6 | refer/RSC_crawler.py | .py | 47316b4133f6eb0a | 7.15 | 1 |
from dataclasses import dataclass
from typing import Optional
import json
@dataclass
class Config:
api_key: str
# base_url: Optional[str]
xlsx_path: str
def load_config(config_path: str) -> Config:
"""Load configuration from JSON file with enhanced error handling"""
try:
with open(config_pa... | lzhzzzzwill/MOFh6 | request/config/config.py | .py | 0fda375b7903697c | 7.15 | 1 |
import pandas as pd
from typing import Dict, List
from utils.constants import NECESSARY_COLUMNS
class DataProcessor:
@staticmethod
def preprocess_dataframe(df: pd.DataFrame) -> pd.DataFrame:
"""Preprocess DataFrame with enhanced error handling and data validation"""
# Verify columns
exi... | lzhzzzzwill/MOFh6 | request/core/data_processor.py | .py | be5352df0765daf6 | 7.15 | 1 |
import os
import sys
import logging
import fitz # PyMuPDF
from pathlib import Path
from dataclasses import dataclass
from typing import Optional, Tuple
import re
# 设置日志
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s'
)
@dataclass
class PDFMetadata:
title: Optio... | lzhzzzzwill/MOFh6 | request/utils/pdf_processor.py | .py | 61946d4d22d02226 | 7.15 | 1 |
import pandas as pd
import subprocess
import os
import logging
from typing import Dict, Optional
class DOIRouter:
def __init__(self):
# Define DOI prefixes for different publishers
self.publisher_prefixes: Dict[str, str] = {
"10.1126": "AAAS",
"10.1021": "ACS",
"... | lzhzzzzwill/MOFh6 | request/utils/rdoi.py | .py | 5767bca7dc20a1d3 | 7.15 | 1 |
from pathlib import Path
import json
import re
from typing import Optional, Dict, Any, Union
from datetime import datetime
import pandas as pd
from ulanggraph.workflow_core import WorkflowBase
class FileProcessor(WorkflowBase):
"""文件处理类"""
def __init__(self, config_path: str, output_dir: str):
super().... | lzhzzzzwill/MOFh6 | ulanggraph/file_processor.py | .py | 056127140e0c6ceb | 7.15 | 1 |
from pathlib import Path
import json
from datetime import datetime
from typing import Dict
class WorkflowBase:
"""工作流基础类"""
def __init__(self, config_path: str, output_dir: str):
self.config_path = Path(config_path)
self.output_dir = Path(output_dir)
self.timestamp = datetime.now().strf... | lzhzzzzwill/MOFh6 | ulanggraph/workflow_core.py | .py | 753df709bb79b9e8 | 7.15 | 1 |
#!/usr/bin/env python3
"""
Color Palettes - Professional, harmonious color schemes for GIFs.
Using consistent, well-designed color palettes makes GIFs look professional
and polished instead of random and amateurish.
"""
from typing import Optional
import colorsys
# Professional color palettes - hand-picked for GIF ... | fastcmsdomain/scherzo | .claude/skills/slack-gif-creator/core/color_palettes.py | .py | bbffe4a7904b05b7 | 7 | 0 |
#!/usr/bin/env python3
"""
Easing Functions - Timing functions for smooth animations.
Provides various easing functions for natural motion and timing.
All functions take a value t (0.0 to 1.0) and return eased value (0.0 to 1.0).
"""
import math
def linear(t: float) -> float:
"""Linear interpolation (no easing)... | fastcmsdomain/scherzo | .claude/skills/slack-gif-creator/core/easing.py | .py | 1e7e2e2507db0a56 | 7 | 0 |
#!/usr/bin/env python3
"""
GIF Builder - Core module for assembling frames into GIFs optimized for Slack.
This module provides the main interface for creating GIFs from programmatically
generated frames, with automatic optimization for Slack's requirements.
"""
from pathlib import Path
from typing import Optional
imp... | fastcmsdomain/scherzo | .claude/skills/slack-gif-creator/core/gif_builder.py | .py | b5042a3c5f03d603 | 7 | 0 |
#!/usr/bin/env python3
"""
Validators - Check if GIFs meet Slack's requirements.
These validators help ensure your GIFs meet Slack's size and dimension constraints.
"""
from pathlib import Path
def check_slack_size(gif_path: str | Path, is_emoji: bool = True) -> tuple[bool, dict]:
"""
Check if GIF meets Sla... | fastcmsdomain/scherzo | .claude/skills/slack-gif-creator/core/validators.py | .py | 39e0756c3ff78eaf | 7 | 0 |
import asyncio
import copy
from collections import defaultdict
from logging import INFO
from typing import Any, Dict, Optional, Set, Tuple
import utils.constants as constants
from utils.channel import sort_channel_result, generate_channel_statistic, write_channel_to_file, retain_origin
from utils.config import config
... | Hi-360/TV | utils/aggregator.py | .py | 897bb8d82ad7d927 | 7 | 0 |
from typing import TypedDict, Literal, Union, NotRequired
OriginType = Literal["hls", "local", "whitelist", "subscribe"]
IPvType = Literal["ipv4", "ipv6", None]
class ChannelData(TypedDict):
"""
Channel data types, including url, date, resolution, origin and ipv_type
"""
id: int
url: str
host... | Hi-360/TV | utils/types.py | .py | 712b28862274fed4 | 7 | 0 |
import os
import re
from collections import defaultdict
from typing import List, Pattern
import utils.constants as constants
from utils.tools import get_real_path, resource_path
from utils.types import WhitelistMaps
def load_whitelist_maps(path: str = constants.whitelist_path) -> WhitelistMaps:
"""
Load whit... | Hi-360/TV | utils/whitelist.py | .py | 537aac3725dc2cc3 | 7 | 0 |
"""
# Definition for a Node.
class Node:
def __init__(self, val = 0, neighbors = None):
self.val = val
self.neighbors = neighbors if neighbors is not None else []
"""
from typing import Optional
class Solution:
def cloneGraph(self, node: Optional['Node']) -> Optional['Node']:
# start fr... | thedxrknight8/leetcode | 133-clone-graph/clone-graph.py | .py | 52662829031a1da6 | 7 | 0 |
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2024-2026 Jason Lynch <jason@aexoden.com>
# ruff:file-ignore[print] (print() used for output)
"""Utility for analyzing factorization statistics."""
from __future__ import annotations
import sys
from pathlib import Path
from loguru import logger
from tap impor... | aexoden/factortool | src/factortool/analyzer/main.py | .py | dbf35e3b7ed190bd | 7.35 | 4 |
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2024 Jason Lynch <jason@aexoden.com>
"""Adaptive batch size controller for factorization tasks."""
from __future__ import annotations
import math
import time
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pathlib import Path
from loguru import l... | aexoden/factortool | src/factortool/batch.py | .py | 71eedf05827d84e1 | 7.35 | 4 |
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2024 Jason Lynch <jason@aexoden.com>
"""Configuration for factorization tool."""
from __future__ import annotations
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Literal
from loguru import logger
from pydantic import... | aexoden/factortool | src/factortool/config.py | .py | 0b0a7a279d886d23 | 7.35 | 4 |
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2024 Jason Lynch <jason@aexoden.com>
"""Interface for interacting with FactorDB."""
from __future__ import annotations
import datetime
import queue
import re
import threading
import time
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.... | aexoden/factortool | src/factortool/factordb.py | .py | 0779753fafb01f88 | 7.35 | 4 |
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2024 Jason Lynch <jason@aexoden.com>
"""Utility functions for factortool."""
from __future__ import annotations
import math
import os
import sys
import tempfile
from functools import cache
from pathlib import Path
from typing import TYPE_CHECKING
if TYPE_CHEC... | aexoden/factortool | src/factortool/util.py | .py | ea9db70bb6da2462 | 7.35 | 4 |
"""
Diagnostic: Check pure bias law δ²(y₀; h_fit) ∝ h_fit^(2s)
This script tests the local fit bias directly without divergence computation,
following the user's diagnostic framework to identify remaining sources of
slope flattening.
"""
import numpy as np
import matplotlib.pyplot as plt
import argparse
from pathlib ... | pmahon3/Resolvent_Framework | archive/articles/combined/code/archive/old_workflow/diagnose_bias_law.py | .py | c524451486e009c9 | 7 | 0 |
"""
Final η estimation with tricube kernel - production version.
Implements:
1. Automatic bias-regime detection
2. Strict locality guards (0.3 ≤ r_eff/h ≤ 0.5)
3. Per-bin η estimates
4. Bootstrap CI
5. Kernel comparison table
"""
import numpy as np
import argparse
from pathlib import Path
from src.core import common... | pmahon3/Resolvent_Framework | archive/articles/combined/code/archive/old_workflow/final_eta_tricube.py | .py | 27e6ac127f9974ee | 7 | 0 |
"""
JSON serialization utilities for converting numpy types to Python natives.
Prevents "TypeError: Object of type X is not JSON serializable"
"""
import numpy as np
from typing import Any, Dict, List
def to_python_type(obj: Any) -> Any:
"""
Recursively convert numpy types to Python native types.
Parame... | pmahon3/Resolvent_Framework | archive/articles/combined/code/src/analysis/json_utils.py | .py | e18b047185c7753b | 7 | 0 |
"""
Robust slope estimation with quality guards for locality validation.
Implements:
- Theil-Sen robust slope estimation
- Second-derivative curvature guard
- Monotonicity check
- Per-bin fit window auto-selection
- Bootstrap confidence intervals
"""
import numpy as np
from typing import Tuple, Optional, Dict
from sci... | pmahon3/Resolvent_Framework | archive/articles/combined/code/src/analysis/robust_fitting.py | .py | 9167d05b817a901d | 7 | 0 |
"""
PRESSURE TEST: do separating sigma-additive states survive the finite->limit
passage on L2, and where do they put mass on the infinite witness p = \/_n b|C_n ?
L2 = constancy-sublogic of prod_{n} MO2 (singleton blocks C_n = {n}).
A STATE s: L2 -> [0,1], s(1)=1, additive on ORTHOGONAL pairs.
MO2 atoms: a, a', b, b... | pmahon3/Resolvent_Framework | notes/archive/oml_descent_inhabitation_dead/l2_states.py | .py | 02e87daa0e1a1bf8 | 7 | 0 |
#!/usr/bin/env python3
"""Bad-mask atomic batching prototype for adjacent full-cycle kernels.
This replaces construction of an 842-component physical core for each
symbolic kernel by exact conditional-trace masks. For retained event A put
Bad_A(D) = {s : trace_s(D) is not contained in trace_s(A)}.
For an admissib... | pmahon3/Resolvent_Framework | notes/open_questions/verification/adjacent_full_cycle_badmask_atomic_batch.py | .py | 39431e1766e62aa3 | 7 | 0 |
#!/usr/bin/env python3
"""Boolean-envelope and coarse mixed-shadow checkpoint for adjacent full cycles.
The shadow retained here is only the three-valued empty/partial/full
classification over each shared state. It forgets the section inside every
partial fibre and therefore cannot certify an actual local lower/upper... | pmahon3/Resolvent_Framework | notes/open_questions/verification/adjacent_full_cycle_boolean_envelope_shadow.py | .py | d08561de28f2f6f2 | 7 | 0 |
#!/usr/bin/env python3
"""Exact first-round old-cylinder lower-kernel scan for adjacent full cycles.
For z=A_L disjoint-union B_R, physical disjointness is E_A cap E_B=empty.
The greatest possible left-coordinate cylinder contained in z has section
A_s when B_s is not full, and X_s when B_s is full,
so its exact roo... | pmahon3/Resolvent_Framework | notes/open_questions/verification/adjacent_full_cycle_exact_lower_kernel_scan.py | .py | 2c1f3cad1d38d317 | 7 | 0 |
#!/usr/bin/env python3
"""Exact first-round old-cylinder shadow test for adjacent full cycles.
For every actual descriptor A in one completed copy and every distinct
existential/universal shadow class (E_B,U_B) occurring in the other copy for
which E_A cap E_B is empty, test the exact old-cylinder bounds of the mixed
... | pmahon3/Resolvent_Framework | notes/open_questions/verification/adjacent_full_cycle_exact_old_shadow.py | .py | 27686b33a514a32c | 7 | 0 |
import asyncio
import csv
import json
import os
from pathlib import Path
import shutil
from deepdiff import DeepDiff
from utils.get_academic_year import get_academic_year
from utils.struct import (
AcademicYearPathVersionManager,
RootPathVersionManager,
recursion_generate_paths_info_file,
)
from utils.uti... | NSYSU-OpenDev/NSYSUCourseAPI | scripts/API_generation.py | .py | 16681730737d95bb | 7.3 | 3 |
import io
import os
from typing import Literal, Union
import requests
from bs4 import Tag
from utils.utils import is_integer
ACADEMIC_YEAR_MAP = ["暑碩", "上", "下", "暑期"]
def parse_academic_year_code(academic_year: str) -> str:
"""
Parse an academic year code into a formatted string.
Args:
acade... | NSYSU-OpenDev/NSYSUCourseAPI | utils/parse_info.py | .py | 7c111c5799776fe2 | 7.3 | 3 |
import asyncio
import copy
from collections import defaultdict
from logging import INFO
from typing import Any, Dict, Optional, Set, Tuple
import utils.constants as constants
from utils.channel import sort_channel_result, generate_channel_statistic, write_channel_to_file, retain_origin
from utils.config import config
... | yuguod/TV | utils/aggregator.py | .py | f99b78c2ca6fcd65 | 7 | 0 |
import asyncio
import copy
from collections import defaultdict
from logging import INFO
import utils.constants as constants
from utils.channel import sort_channel_result, generate_channel_statistic
from utils.channel import write_channel_to_file
from utils.config import config
from utils.tools import get_logger
clas... | xtxujun/TV | utils/aggregator.py | .py | 801e5e7094c56168 | 7 | 0 |
"""Generate commits for shroud my GitHub profile in activity."""
import json
import os
import random
from typing import Sequence
PLAYS = [play for _, _, plays in os.walk("./fog_machine/shakespeare") for play in plays]
def main(dir_path: str = "./fog_machine/shakespeare/") -> None:
"""Generate Zalgo text messag... | walshification/fog-machine | fog_machine/make_fog.py | .py | 95a81525d1d84a1f | 7 | 0 |
import datetime
from typing import Any, Self
import typer
from githubkit import GitHub
from githubkit.webhooks import parse
from ._graphql import (
AddCommentMutation,
CommentsForPrQuery,
PrsForBranchQuery,
UpdateCommentMutation,
)
from ._utils import pr_id_from_number
class NotCommenting(Exception)... | mjpieters/pyright-analysis-action | src/pyright_analysis_action/comment.py | .py | 033b7d55a2e22aea | 7.24 | 2 |
import gzip
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
import numpy as np
import pandas as pd
from config import cell_types, mpra_path, mpra_raw_path, project_root
from utils import build_basic_masks
gosai_raw_dir = project_root / "data/Gosai_MPRA"
gosai_raw_dat... | maplecai/EpiCast | paper/analysis/01_prepare_gosai_data.py | .py | b57135accb4ad1de | 7.24 | 2 |
"""Zero-shot evaluation on the independent Castillo MPRA (fig5).
This is the only entry point that computes the fig5 numbers; the plotting lives in
plot/fig5, and the paths and the model registry come from config.
Analysis choices, all deliberate and different from the Gosai evaluation:
* All 8,152 genomic and synthe... | maplecai/EpiCast | paper/analysis/12_eval_castillo.py | .py | 5a6def7f054a6a7d | 7.24 | 2 |
"""Export one self-describing table per model: measured activity next to predictions.
The prediction npy files carry no keys and are matched to the MPRA tables by row
order, which is easy to get wrong downstream. These tables put both sides in one
file so a reader never has to re-derive the alignment, which is why eve... | maplecai/EpiCast | paper/analysis/14_export_prediction_tables.py | .py | 991570e57771dad8 | 7.24 | 2 |
"""Shared paths, cell types and model registry for the paper analysis bundle."""
import os
from pathlib import Path
from matplotlib.colors import LinearSegmentedColormap
bundle_root = Path(__file__).resolve().parent
project_root = bundle_root.parent
data_dir = project_root / "data/gosai_mpra"
saved_dir = project_roo... | maplecai/EpiCast | paper/config.py | .py | 67e40e2785be37b9 | 7.24 | 2 |
"""fig4A / fig4C: pairwise correlations among the four VEFs, absolute and residual.
One PDF per manuscript panel. Each holds two heatmaps side by side, titled with their VEF
source: Sei on the left and AlphaGenome on the right, the order every figure that shows
both sources uses.
The assay order is DNase, H3K4me3, H3... | maplecai/EpiCast | paper/plot/fig4ac_vef_correlation_heatmap.py | .py | 67b37b811466f32e | 7.24 | 2 |
"""fig4B / fig4D / fig4E: what each VEF still explains once the other three are held fixed.
fig4B and fig4D are one row of eight panels, four assays under Sei and four under
AlphaGenome, with a wide gap between the two sources; every panel has two x positions,
the marginal VEF-activity correlation and the partial one ... | maplecai/EpiCast | paper/plot/fig4bde_vef_partial_correlation.py | .py | 7f299c310e7ca583 | 7.24 | 2 |
"""fig5A-5E: zero-shot evaluation on the independent Castillo-Hair MPRA.
One PDF per manuscript panel, plus a shared cell-type legend. The panel headers, which also carry the n printed to stdout
by this script, are added by hand.
5A whole CRE set, activity 1 x 2, PCC and SCC
5B union CTS set, activ... | maplecai/EpiCast | paper/plot/fig5_castillo_metrics.py | .py | b4efff2a4c3c2e43 | 7.24 | 2 |
"""Why these four assays: availability and predictive performance on one pair of axes.
Every assay that can be scored at all is placed by how many biosamples AlphaGenome covers
it in (availability) against how well its VEF predicts measured activity (performance).
A VEF exists for a cell type only if the assay has a ... | maplecai/EpiCast | paper/plot/figs1_vef_assay_selection.py | .py | 2c18ed4f34b47692 | 7.24 | 2 |
import numpy as np
import torch
from torch.utils.data import IterableDataset, get_worker_info
from typing import List, Optional
import time
# from .enformer_web_dataset import EnformerWebDataset
class MixedLengthEnformerDataset(IterableDataset):
def __init__(
self,
base_dataset_args: di... | maplecai/EpiCast | src/epicast/datasets/mixed_length_dataset.py | .py | f34c4ee666ac2581 | 7.24 | 2 |
import torch
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import MSELoss, L1Loss, BCEWithLogitsLoss, BCELoss, CrossEntropyLoss, PoissonNLLLoss, HuberLoss
from torch.nn.functional import mse_loss, binary_cross_entropy_with_logits, cross_entropy, binary_cross_e... | maplecai/EpiCast | src/epicast/metrics/losses.py | .py | 4c6067c02bc4f950 | 7.24 | 2 |
import torch
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
# from scipy.stats import pearsonr, spearmanr
import sklearn.metrics
import scipy.stats
from ..utils import *
import numpy as np
from numpy.typing import ArrayLike
def metrics_each_channel(
x: ArrayLik... | maplecai/EpiCast | src/epicast/metrics/metrics.py | .py | 356741bcf4726354 | 7.24 | 2 |
#!/usr/bin/env python
"""
Test script to verify the RecordedBy and RecordedDate implementation.
This script creates a mock observation with observation field values and tests
that the new fields are properly extracted and processed.
"""
import datetime
import sys
import os
# Add the project root to the path
sys.path... | EcoNet-NZ/inaturalist-to-cams | test_recorded_by_implementation.py | .py | 4025a8ccbc25b9d4 | 7.8 | 3 |
# -*- coding: utf-8 -*-
"""
Copyright 2023-2026 Maen Artimy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agre... | martimy/Bat-Q | common/plotting.py | .py | 4a5b294d58b71ec0 | 7.39 | 5 |
# -*- coding: utf-8 -*-
"""
Copyright 2023-2026 Maen Artimy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agre... | martimy/Bat-Q | common/presenter.py | .py | 25f0faf57b4aeb93 | 7.39 | 5 |
# -*- coding: utf-8 -*-
"""
Copyright 2023-2026 Maen Artimy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agre... | martimy/Bat-Q | common/queries.py | .py | df560b8823f56484 | 7.39 | 5 |
# -*- coding: utf-8 -*-
import io
import re
import pandas as pd
from .presenter import json_to_dataframe, flatten_trace_data, select_questions, format_result, format_result_lite
INVALID_SHEET_CHARS = r'[]:*?/\\'
def _safe_sheet_name(name, used):
"""Excel sheet names: <=31 chars, no []:*?/\\, must be un... | martimy/Bat-Q | common/spreadsheet.py | .py | 892817b151fe6043 | 7.39 | 5 |
# -*- coding: utf-8 -*-
"""
Copyright 2023-2026 Maen Artimy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agre... | martimy/Bat-Q | common/utils.py | .py | 5606f0943278d5f8 | 7.39 | 5 |
# -*- coding: utf-8 -*-
"""
Copyright 2023-2026 Maen Artimy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agre... | martimy/Bat-Q | views/net_setup.py | .py | 250f5891c8515cf6 | 7.39 | 5 |
# -*- coding: utf-8 -*-
"""
Copyright 2023-2026 Maen Artimy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agre... | martimy/Bat-Q | views/questions.py | .py | 702085fb36913b80 | 7.39 | 5 |
"""Train Coconut from a YAML configuration."""
from __future__ import annotations
import argparse
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from coconut.config import TrainingConfig
from coconut.curriculum import CurriculumEncoder, add_coconut_tokens
from coconut.data import JsonReas... | lucasbiagettia/coconut-latent-reasoning | train.py | .py | a38a523dce60c896 | 7.15 | 1 |
"""CamillaDSP WebSocket client"""
import json
import math
import time
import websockets.exceptions
import websockets.sync.client
import audera
from audera.errors import ServiceError, Unreachable
_CMD_GET_CONFIG_JSON = 'GetConfigJson'
_CMD_SET_CONFIG_JSON = 'SetConfigJson'
_CMD_VALIDATE_CONFIG = 'ValidateConfig'
_CM... | Eleff-org/audera | audera/clients/camilladsp.py | .py | 510f6682d3be26d3 | 7.15 | 1 |
"""Plex-Amp local HTTP API client"""
import xml.etree.ElementTree
from typing import Optional
import httpx
import audera
from audera.models import stream
class PlexAmpClient:
"""A synchronous client for the Plex-Amp local HTTP API.
Parameters
----------
host: `str`
The hostname or IP addre... | Eleff-org/audera | audera/clients/plexamp.py | .py | db1c3095e36d117f | 7.15 | 1 |
"""Snapcast JSON-RPC WebSocket client"""
import ipaddress
import json
import time
import uuid
from typing import Any, List, Optional
import websockets.exceptions
import websockets.sync.client
import audera
from audera.errors import ServiceError, Unreachable
from audera.models import player
def _normalize_host_ip(r... | Eleff-org/audera | audera/clients/snapserver.py | .py | fbecc46dd850f1eb | 7.15 | 1 |
"""Preset DSP configuration-layer"""
import glob
import json
import os
from typing import Union
from audera import io
from audera.dal import path
from audera.models import dsp
PATH: Union[str, os.PathLike] = os.path.join(path.HOME, 'dsp', 'presets')
def get_all_presets() -> list[dsp.Preset]:
"""Returns every s... | Eleff-org/audera | audera/dal/presets.py | .py | d840764baa0fc7b4 | 7.15 | 1 |
"""Settings configuration-layer"""
import json
import logging
import os
from typing import Callable, Union
from audera import io
from audera.dal import path
from audera.errors import StorageError
from audera.models import settings
logger = logging.getLogger(__name__)
PATH: Union[str, os.PathLike] = path.HOME
FILE_N... | Eleff-org/audera | audera/dal/settings.py | .py | 1d9c4ddca440a8b5 | 7.15 | 1 |
"""Audio sources configuration-layer
`~/.audera/sources.json` holds `{'sources': {'enabled': [...], 'setup': {id: {...}}}}`.
`enabled` is which audio sources the operator wants running. Snapcast does not persist this. A
source absent from the list is disabled, so adding a catalog entry needs no migration.
`setup` is... | Eleff-org/audera | audera/dal/sources.py | .py | fc63a3360aef34ea | 7.15 | 1 |
"""Per-player volume cache
`~/.audera/volume/{player_id}.json` holds `{'volume': {'player_id': '<raw-id>', 'percent': <int>}}`.
The raw player id is stored inside the document because `path.to_filename()` is lossy (MAC-address
colons become dashes). `get_all()` reads `player_id` from each document so callers always s... | Eleff-org/audera | audera/dal/volume.py | .py | 1b0a7e71548e638f | 7.15 | 1 |
"""DSP compiler"""
import copy
from audera.models.dsp import PASS_TYPES, Band, DSPConfig
_MANAGED_PREFIX = 'audera_'
_PREAMP_KEY = 'audera_preamp'
_PEQ_PREFIX = 'audera_peq_'
def _band_to_biquad(band: Band) -> dict:
"""Returns a CamillaDSP Biquad filter `dict` for a single `Band`.
Shared by the compiler a... | Eleff-org/audera | audera/domains/dsp/compiler.py | .py | 8ed0e77ec3d96603 | 7.15 | 1 |
"""DSP headroom"""
from camilladsp_plot import eval_filter
from camilladsp_plot.eval_filterconfig import logspace
from audera.domains.dsp.compiler import _band_to_biquad
from audera.models.dsp import Band, DSPConfig
_SAMPLERATE = 48000
_CHART_NPOINTS = 400
_SAFETY_NPOINTS = 1000
# Ceilings within this of 0 dB are fl... | Eleff-org/audera | audera/domains/dsp/headroom.py | .py | 1102c4b966f8c7f2 | 7.15 | 1 |
"""System DSP presets"""
import uuid
from audera.models.dsp import Band
_LOUDNESS_LOW_BOOST = 10.0
_LOUDNESS_HIGH_BOOST = 6.0
def loudness_preset() -> list[Band]:
"""Returns two fresh, editable loudness shelf bands.
A `Lowshelf` at 90 Hz (+10 dB) and a `Highshelf` at 8000 Hz (+6 dB), each with
`q=0.7`... | Eleff-org/audera | audera/domains/dsp/presets.py | .py | 86dbea4732cd8ab5 | 7.15 | 1 |
"""Import/export parametric-EQ bands as CamillaDSP YAML
Compatible with REW (v5.20.14+).
"""
import uuid
from typing import Any, Optional, get_args
import yaml
from pydantic import BaseModel, Field
from audera.domains.dsp.compiler import _band_to_biquad
from audera.models.dsp import DEFAULT_Q, PASS_TYPES, Band
# C... | Eleff-org/audera | audera/domains/dsp/rew.py | .py | 4bff8295ec43f952 | 7.15 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.