repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
crowdresearch/daemo | https://github.com/crowdresearch/daemo/blob/36e3b70d4e2c06b4853e9209a4916f8301ed6464/csp/wsgi.py | csp/wsgi.py | """
WSGI config for csp project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
os.environ.... | python | MIT | 36e3b70d4e2c06b4853e9209a4916f8301ed6464 | 2026-01-05T07:09:36.946315Z | false |
crowdresearch/daemo | https://github.com/crowdresearch/daemo/blob/36e3b70d4e2c06b4853e9209a4916f8301ed6464/csp/urls.py | csp/urls.py | from django.conf.urls import include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import RedirectView
from rest_framework.routers import SimpleRouter
from crowdsourcing import views
from crowdsourcing.viewsets.fi... | python | MIT | 36e3b70d4e2c06b4853e9209a4916f8301ed6464 | 2026-01-05T07:09:36.946315Z | false |
EthanRosenthal/spacecutter | https://github.com/EthanRosenthal/spacecutter/blob/063fe875f5122063e6f616512cffd9ffa4df1974/setup.py | setup.py | import os
from setuptools import setup, find_packages
from spacecutter import __version__
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.md')) as f:
long_description = f.read()
with open(os.path.join(here, 'requirements.txt')) as f:
requirements = f.read().splitlines... | python | MIT | 063fe875f5122063e6f616512cffd9ffa4df1974 | 2026-01-05T07:09:46.516384Z | false |
EthanRosenthal/spacecutter | https://github.com/EthanRosenthal/spacecutter/blob/063fe875f5122063e6f616512cffd9ffa4df1974/tests/test_losses.py | tests/test_losses.py | import numpy as np
import pytest
import torch
from spacecutter import losses
class Test_reduction:
def test__reduction_mean(self):
loss = torch.FloatTensor([[6.0], [4.0]])
output = losses._reduction(loss, 'elementwise_mean')
assert output.item() == 5.0
def test__reduction_sum(self):... | python | MIT | 063fe875f5122063e6f616512cffd9ffa4df1974 | 2026-01-05T07:09:46.516384Z | false |
EthanRosenthal/spacecutter | https://github.com/EthanRosenthal/spacecutter/blob/063fe875f5122063e6f616512cffd9ffa4df1974/tests/test_models.py | tests/test_models.py | import numpy as np
from skorch import NeuralNet
import torch
from torch import nn
from spacecutter.callbacks import AscensionCallback
from spacecutter.losses import CumulativeLinkLoss
from spacecutter.models import OrdinalLogisticModel
SEED = 666
def test_loss_lowers_on_each_epoch():
torch.manual_seed(SEED)
... | python | MIT | 063fe875f5122063e6f616512cffd9ffa4df1974 | 2026-01-05T07:09:46.516384Z | false |
EthanRosenthal/spacecutter | https://github.com/EthanRosenthal/spacecutter/blob/063fe875f5122063e6f616512cffd9ffa4df1974/tests/test_callbacks.py | tests/test_callbacks.py | import torch
from torch import nn
from spacecutter import callbacks
from spacecutter.models import OrdinalLogisticModel
def test_clip_ensures_sorted_cutpoints():
predictor = nn.Linear(5, 1)
model = OrdinalLogisticModel(predictor, 4, init_cutpoints='ordered')
# model.link.cutpoints = [-1.5, -0.5, 0.5]
... | python | MIT | 063fe875f5122063e6f616512cffd9ffa4df1974 | 2026-01-05T07:09:46.516384Z | false |
EthanRosenthal/spacecutter | https://github.com/EthanRosenthal/spacecutter/blob/063fe875f5122063e6f616512cffd9ffa4df1974/tests/__init__.py | tests/__init__.py | python | MIT | 063fe875f5122063e6f616512cffd9ffa4df1974 | 2026-01-05T07:09:46.516384Z | false | |
EthanRosenthal/spacecutter | https://github.com/EthanRosenthal/spacecutter/blob/063fe875f5122063e6f616512cffd9ffa4df1974/spacecutter/callbacks.py | spacecutter/callbacks.py | from skorch.callbacks import Callback
from torch.nn import Module
from spacecutter.models import LogisticCumulativeLink
class AscensionCallback(Callback):
"""
Ensure that each cutpoint is ordered in ascending value.
e.g.
.. < cutpoint[i - 1] < cutpoint[i] < cutpoint[i + 1] < ...
This is done by... | python | MIT | 063fe875f5122063e6f616512cffd9ffa4df1974 | 2026-01-05T07:09:46.516384Z | false |
EthanRosenthal/spacecutter | https://github.com/EthanRosenthal/spacecutter/blob/063fe875f5122063e6f616512cffd9ffa4df1974/spacecutter/models.py | spacecutter/models.py | from copy import deepcopy
import torch
from torch import nn
class LogisticCumulativeLink(nn.Module):
"""
Converts a single number to the proportional odds of belonging to a class.
Parameters
----------
num_classes : int
Number of ordered classes to partition the odds into.
init_cutpo... | python | MIT | 063fe875f5122063e6f616512cffd9ffa4df1974 | 2026-01-05T07:09:46.516384Z | false |
EthanRosenthal/spacecutter | https://github.com/EthanRosenthal/spacecutter/blob/063fe875f5122063e6f616512cffd9ffa4df1974/spacecutter/losses.py | spacecutter/losses.py | import numpy as np
import torch
from torch import nn
from typing import Optional
def _reduction(loss: torch.Tensor, reduction: str) -> torch.Tensor:
"""
Reduce loss
Parameters
----------
loss : torch.Tensor, [batch_size, num_classes]
Batch losses.
reduction : str
Method for re... | python | MIT | 063fe875f5122063e6f616512cffd9ffa4df1974 | 2026-01-05T07:09:46.516384Z | false |
EthanRosenthal/spacecutter | https://github.com/EthanRosenthal/spacecutter/blob/063fe875f5122063e6f616512cffd9ffa4df1974/spacecutter/__init__.py | spacecutter/__init__.py | __version__ = "0.2.1"
| python | MIT | 063fe875f5122063e6f616512cffd9ffa4df1974 | 2026-01-05T07:09:46.516384Z | false |
miguelgrinberg/two-factor-auth-flask | https://github.com/miguelgrinberg/two-factor-auth-flask/blob/45cb4a1f6d8974c3da7a219952e784a96237b1ec/config.py | config.py | import os
SECRET_KEY = 'top-secret'
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', 'sqlite:///db.sqlite')
SQLALCHEMY_TRACK_MODIFICATIONS = False
| python | MIT | 45cb4a1f6d8974c3da7a219952e784a96237b1ec | 2026-01-05T07:09:46.904029Z | false |
miguelgrinberg/two-factor-auth-flask | https://github.com/miguelgrinberg/two-factor-auth-flask/blob/45cb4a1f6d8974c3da7a219952e784a96237b1ec/app.py | app.py | import os
import base64
from io import BytesIO
from flask import Flask, render_template, redirect, url_for, flash, session, \
abort
from werkzeug.security import generate_password_hash, check_password_hash
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager, UserMixin, login_user, logout_us... | python | MIT | 45cb4a1f6d8974c3da7a219952e784a96237b1ec | 2026-01-05T07:09:46.904029Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/setup.py | setup.py | #!/usr/bin/env python
import re
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
version = ''
with open('django_oss_storage/__init__.py', 'r') as fd:
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
fd.read(), re.MULTILINE).gro... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/tests/manage.py | tests/manage.py | #!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django-oss-storage-test.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. ... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/tests/django-oss-storage-test/settings.py | tests/django-oss-storage-test/settings.py | import os
import sys
import uuid
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(os.path.dirname(BASE_DIR))
SECRET_KEY = "test"
USE_TZ = True
TIME_ZONE = 'UTC'
# OSS settings
OSS_ACCESS_KEY_ID = os.environ.get("OSS_ACCESS_KEY_ID")
OSS_ACCESS_KEY_SECRET = os.environ.get("OSS_AC... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/tests/django-oss-storage-test/__init__.py | tests/django-oss-storage-test/__init__.py | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false | |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/tests/django-oss-storage-test/tests.py | tests/django-oss-storage-test/tests.py | # -*- coding: utf-8 -*-
import os
import logging
import requests
import oss2
from datetime import timedelta
from contextlib import contextmanager
from logging.handlers import RotatingFileHandler
from django.conf import settings
from django.test import SimpleTestCase
from django.core.exceptions import ImproperlyConfig... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/django_oss_storage/defaults.py | django_oss_storage/defaults.py | # -*- coding: utf-8 -*-
"""
Global defaults
"""
import logging
# Default logger
log = logging.getLogger()
def logger():
return log
| python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/django_oss_storage/backends.py | django_oss_storage/backends.py | # coding=utf-8
import os
import six
import shutil
try:
from urllib.parse import urljoin
except ImportError:
from urlparse import urljoin
from datetime import datetime
from django.core.files import File
from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation
from django.core.files.storage... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/django_oss_storage/__init__.py | django_oss_storage/__init__.py | __version__ = '1.1.1'
| python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/manage.py | demo_site/manage.py | #!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo_site.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that th... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/upload/views.py | demo_site/upload/views.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
# Create your views here.
| python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/upload/admin.py | demo_site/upload/admin.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
# Register your models here.
| python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/upload/models.py | demo_site/upload/models.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.contrib import admin
from django.db.models.signals import pre_delete
from django.dispatch.dispatcher import receiver
# Create your models here.
class Photo(models.Model):
image = models.ImageField(upload_to='p... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/upload/__init__.py | demo_site/upload/__init__.py | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false | |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/upload/tests.py | demo_site/upload/tests.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
# Create your tests here.
class SampleTest(TestCase):
def test_basic_operation(self):
"""
Test a simple math addition
"""
self.assertEqual(100 + 200, 300)
| python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/upload/apps.py | demo_site/upload/apps.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.apps import AppConfig
class UploadConfig(AppConfig):
name = 'upload'
| python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/upload/migrations/__init__.py | demo_site/upload/migrations/__init__.py | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false | |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/demo_site/views.py | demo_site/demo_site/views.py | # -*- coding: utf-8 -*-
from django.contrib import messages
from django.shortcuts import redirect
def home(request):
messages.add_message(request, messages.WARNING,
'Default user & password are both "admin".')
return redirect('admin:index')
| python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/demo_site/settings.py | demo_site/demo_site/settings.py | """
Django settings for demo_site project.
Generated by 'django-admin startproject' using Django 1.11.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import ... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/demo_site/__init__.py | demo_site/demo_site/__init__.py | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false | |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/demo_site/auth.py | demo_site/demo_site/auth.py | from django.conf import settings
from django.contrib.auth.models import User
class SettingsBackend(object):
"""
Authenticate against the settings ADMIN_LOGIN and ADMIN_PASSWORD.
"""
def authenticate(self, username=None, password=None):
"""
Username and password authentication
"... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/demo_site/wsgi.py | demo_site/demo_site/wsgi.py | """
WSGI config for demo_site project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SE... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
aliyun/django-oss-storage | https://github.com/aliyun/django-oss-storage/blob/e4b78fd9ef39f9b969b20a603a2d2f2389253da3/demo_site/demo_site/urls.py | demo_site/demo_site/urls.py | """demo_site URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-... | python | MIT | e4b78fd9ef39f9b969b20a603a2d2f2389253da3 | 2026-01-05T07:09:47.154021Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/setup.py | setup.py | from setuptools import setup, find_packages
test_packages = [
"pytest>=5.4.3",
"black>=19.10b0",
"flake8>=3.8.3",
"mktestdocs>=0.1.0",
"interrogate>=1.2.0",
]
yaml_packages = ["PyYAML>=5.3.1"]
util_packages = ["jupyterlab>=2.2.0", "pre-commit>=2.6.0"]
docs_packages = [
"mkdocs>=1.1",
"m... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/conftest.py | tests/conftest.py | from clumper import Clumper
import pytest
@pytest.fixture(scope="module")
def base_clumper():
"""A standard clumper object that tests can use"""
data = [
{"data": [i for _ in range(2)], "i": i, "c": c}
for i, c in enumerate("abcdefghijklmnopqrstuvwxyz")
]
return Clumper(data)
| python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_combined.py | tests/test_combined.py | import json
import pathlib
import pytest
from clumper import Clumper
@pytest.fixture()
def pokemon():
"""Pokemon data as a fixture"""
return json.loads(pathlib.Path("tests/data/pokemon.json").read_text())
def test_no_mutate_query(pokemon):
"""
This was an error that happened in the past.
"""
... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/__init__.py | tests/__init__.py | """
This is where we keep the unit tests.
"""
| python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_basics.py | tests/test_basics.py | from clumper import Clumper
def test_length_list():
"""
Basic tests to ensure that len() works as expected.
"""
assert len(Clumper([])) == 0
assert len(Clumper([{"a": 1}])) == 1
assert len(Clumper([{"a": 1} for i in range(100)])) == 100
def test_mutability_insurance():
"""
We don't w... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_summary_methods.py | tests/test_summary_methods.py | import pytest
from clumper import Clumper
def make_clumper(size, constant=False):
"""clumper generator function"""
return Clumper([{"i": 1 if constant else i} for i in range(size)])
@pytest.fixture(params=[1, 5, 10])
def n(request):
"""number as a fixture"""
return request.param
def test_n_unique... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/scripts/check_pip.py | tests/scripts/check_pip.py | import sys
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("verb", help="installed/missing")
parser.add_argument(
"packages", help="list of items to be there/not be there", nargs="+"
)
if __name__ == "__main__":
args = parser.parse_args()
installed = subprocess.che... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_read_write/test_read_json.py | tests/test_read_write/test_read_json.py | import pathlib
import pytest
from clumper import Clumper
@pytest.mark.parametrize("lines, expected", [(None, 800), (1, 1), (2, 2), (801, 800)])
def test_local_read_json_expected(lines, expected):
"""The number of lines read is not equal to expected number of lines"""
clump = Clumper.read_json(pathlib.Path("te... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_read_write/test_read_csv.py | tests/test_read_write/test_read_csv.py | import pathlib
import pytest
from itertools import product
from clumper import Clumper
from string import ascii_uppercase
paths = [
"tests/data/monopoly.csv",
"https://calmcode.io/datasets/monopoly.csv",
pathlib.Path("tests/data/monopoly.csv"),
]
nrows = [(None, 22), (10, 10), (15, 15), [80, 22]]
fields =... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_read_write/test_read_jsonl.py | tests/test_read_write/test_read_jsonl.py | import pathlib
import pytest
from clumper import Clumper
@pytest.mark.parametrize("lines, expected", [(None, 4), (1, 1), (2, 2), (5, 4)])
def test_local_read_jsonl_expected(lines, expected):
"""The number of lines read is not equal to expected number of lines"""
clump = Clumper.read_jsonl("tests/data/cards.js... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_read_write/test_write_jsonl.py | tests/test_read_write/test_write_jsonl.py | import pytest
import os
from clumper import Clumper
def test_local_write_exists(tmp_path):
"""Test that an error is raised if the written file JSONL doesn't exists."""
path = str(tmp_path / "cards_copy.jsonl")
clump = Clumper.read_jsonl("tests/data/cards.jsonl")
clump.write_jsonl(path)
assert os.p... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_read_write/test_read_yaml.py | tests/test_read_write/test_read_yaml.py | import pathlib
import pytest
from clumper import Clumper
@pytest.mark.parametrize(
"path,size",
[
("tests/data/demo-flat-1.yaml", 3),
("tests/data/demo-flat-2.yaml", 3),
("tests/data/demo-nested.yml", 1),
],
)
def test_can_read_yaml_yml(path, size):
"""Test we can read in the... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_read_write/test_write_csv.py | tests/test_read_write/test_write_csv.py | import pytest
from clumper import Clumper
def temp_file(tmp_path):
"""helper function to create temporary file."""
d = tmp_path / "sub"
d.mkdir()
path = d / "nulls.csv"
return path
def test_write_csv(tmp_path):
"""The file we write is the same as the one we read"""
path = temp_file(tmp_p... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_read_write/test_write_yaml.py | tests/test_read_write/test_write_yaml.py | from clumper import Clumper
def test_local_read_write_content_same(tmp_path):
"""Test that an error is raised if the written JSON file is not the same as what is read locally"""
path = str(tmp_path / "pokemon_copy.json")
writer = Clumper.read_yaml("tests/data/demo-nested.yml")
writer.write_yaml(path)
... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_read_write/test_write_json.py | tests/test_read_write/test_write_json.py | import pytest
import os
from clumper import Clumper
def test_local_write_exists(tmp_path):
"""Test that an error is raised if the written file JSON doesn't exists."""
path = str(tmp_path / "pokemon_copy.json")
clump = Clumper.read_json("tests/data/pokemon.json")
clump.write_json(path)
assert os.pa... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_decorator/test_multifile.py | tests/test_decorator/test_multifile.py | from clumper import Clumper
import pytest
from pathlib import Path
def test_non_existent_pattern(tmp_path):
"""When there's no paths that exist, throw an error"""
with pytest.raises(ValueError):
Clumper.read_json(str(tmp_path / "*.json"))
Clumper.read_json(list(Path(tmp_path).glob("*.json")))
... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_decorator/test_dict_only.py | tests/test_decorator/test_dict_only.py | import pytest
from clumper import Clumper
@pytest.fixture
def no_dict_clumper():
"""Returns clumper based on numbers, not a dict"""
return Clumper([1, 2, 3, 4])
@pytest.mark.parametrize(
"method",
[
"agg",
"transform",
"_subsets",
"select",
"drop",
"k... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_decorator/test_return_values.py | tests/test_decorator/test_return_values.py | from clumper import Clumper
def test_case_zero():
"""We need to raise sensible defaults on an empty clumper"""
empty_c = Clumper([])
assert empty_c.mean("i") is None
assert empty_c.max("i") is None
assert empty_c.min("i") is None
assert empty_c.sum("i") is None
assert empty_c.unique("i") =... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_documentation/test_docs.py | tests/test_documentation/test_docs.py | import pathlib
import pytest
from mktestdocs import check_md_file
paths = ["docs/index.md", "README.md"]
globbed = [str(_) for _ in pathlib.Path("docs/examples").glob("*.md")]
@pytest.mark.parametrize("fpath", paths + globbed, ids=str)
def test_files_good(fpath):
"""Confirm the python code in markdown files run... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_documentation/test_docstring.py | tests/test_documentation/test_docstring.py | import pytest
from mktestdocs import check_docstring, get_codeblock_members
from clumper import Clumper
from clumper.sequence import row_number, smoothing, expanding, rolling, impute
@pytest.mark.parametrize(
"func",
[row_number, smoothing, expanding, rolling, impute],
ids=lambda d: d.__name__,
)
def tes... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_mappers/test_impute.py | tests/test_mappers/test_impute.py | from clumper import Clumper
from clumper.sequence import impute
def test_correct_values_prev():
"""Check that we can impute by taking the previous value."""
list_dicts = [
{"a": 1, "b": 2},
{"a": 2, "b": 3},
{"a": 3},
{"a": 4, "b": 6},
{"a": 5},
]
res = Clumper... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_implode.py | tests/test_verbs/test_implode.py | from clumper import Clumper
def test_correct_keys():
"""
Ensure that the original key of the dictionary is replaced with the new one.
"""
data = [
{"a": 1, "b": 1, "item": 1},
{"a": 1, "b": 1, "item": 2},
{"a": 1, "b": 1, "item": 1},
{"a": 2, "b": 2, "c": 2, "item": 3},... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_join.py | tests/test_verbs/test_join.py | from clumper import Clumper
def test_left_join_base_example():
"""Base Example"""
d1 = [{"a": 1, "b": 1, "d": 1}, {"a": 1, "b": 2, "d": 1}, {"a": 1, "b": 5, "d": 1}]
d2 = [
{"b": 1, "c": 1, "d": 2},
{"b": 2, "c": 2, "d": 2},
{"b": 2, "c": 20, "d": 20},
]
joined = Clumper(d1... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_grouping_utils.py | tests/test_verbs/test_grouping_utils.py | import itertools as it
import pytest
from clumper import Clumper
from clumper.sequence import row_number
def test_group_combos_one_group():
"""Ensure that we get the right definition with a single group defined"""
prod = it.product([1, 2, 3, 4, 5], [-0.1, 0.0, 0.1], [True, False], ["a", "b"])
clump = Cl... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_mutate.py | tests/test_verbs/test_mutate.py | def test_can_overwrite(base_clumper):
"""
Make sure that we can overwrite values.
"""
new_clumper = base_clumper.mutate(i=lambda d: d["i"] * 2)
zipped = zip(base_clumper.collect(), new_clumper.collect())
assert all([c1["i"] * 2 == c2["i"] for c1, c2 in zipped])
def test_can_make_new(base_clump... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_explode.py | tests/test_verbs/test_explode.py | import itertools as it
import pytest
from clumper import Clumper
def test_explode_basic(base_clumper):
"""
Base clumper has a nested list of size two on each item.
When we explode that, our new clumper should be twice as big.
"""
assert len(base_clumper.explode(d="data")) == 2 * len(base_clumper... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_headtail.py | tests/test_verbs/test_headtail.py | import pytest
@pytest.mark.parametrize("n,expected", [(0, 0), (5, 5), (10, 10), (26, 26), (1000, 26)])
def test_headtail_size(base_clumper, n, expected):
"""
If we grab 1000 elements out of a set of 26, we should just grab 26. No errors.
"""
assert len(base_clumper.head(n)) == expected
assert len(... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_agg.py | tests/test_verbs/test_agg.py | import itertools as it
from clumper import Clumper
import pytest
def test_no_group_simple_agg(base_clumper):
"""
Ensure that we can count the number of items.
"""
c = base_clumper.agg(n=("i", "count")).collect()
assert c[0]["n"] == 26
def test_no_group_multi_agg(base_clumper):
"""
Ensu... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_flatten_keys.py | tests/test_verbs/test_flatten_keys.py | import pytest
from clumper import Clumper
@pytest.mark.parametrize("keyname", ["foo", "bar", "buz"])
def test_can_rename_key(keyname):
"""We should be able to change the keyname"""
data = {
"f1": {"p1": 1, "p2": 2},
"f2": {"p1": 3, "p2": 4},
"f3": {"p1": 5, "p2": 6},
}
expect... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_unpack.py | tests/test_verbs/test_unpack.py | from clumper import Clumper
d = [
{
"download_count": 661467185,
"project": "pyyaml",
"url": "https://libraries.io/pypi/pyyaml",
"data": [
{"sourcerank": 25},
{"dependents": 5280},
{"versions": 24},
{"stargazers": 1220},
{"... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_grouping.py | tests/test_verbs/test_grouping.py | def test_mutate_does_not_remove_groups(base_clumper):
"""Ensure we don't remove groups via mutate"""
grps = base_clumper.group_by("i").mutate(i2=lambda d: d["i"] * 2).groups
assert grps == ("i",)
def test_sort_does_not_remove_groups(base_clumper):
"""Ensure we don't remove groups via sort"""
grps ... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_keep.py | tests/test_verbs/test_keep.py | import pytest
from clumper import Clumper
def test_can_collect_all(base_clumper):
"""
Confirm extreme value cases.
"""
assert len(base_clumper.keep(lambda d: True)) == len(base_clumper)
assert len(base_clumper.keep(lambda d: False)) == 0
@pytest.mark.parametrize("elem", "qwertyuiopasdfghjklzxcvb... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/tests/test_verbs/test_sample.py | tests/test_verbs/test_sample.py | from clumper.clump import Clumper
import pytest
import itertools
def test_oversampling_no_replace(base_clumper):
"""
Make sure that over sampling is not allowed when sampling without replacement
"""
with pytest.raises(ValueError):
base_clumper.sample(n=len(base_clumper) + 1, replace=False)
d... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/clumper/sequence.py | clumper/sequence.py | """
A collection of functions to be used in `mutate`/`map`-verbs.
"""
from typing import Callable
class row_number:
"""
This stateful function can be used to calculate row numbers.

Usage:
```python
from clumper import Clumper
from clumper.sequence import row_... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/clumper/error.py | clumper/error.py | def raise_yaml_dep_error():
"""Raises an appropriate error when a dependency is missing."""
msg = """
If you want to read yaml files you need to install PyYaml.
To install, run:
> python -m pip install clumper[yaml]
"""
raise RuntimeError(msg)
| python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/clumper/decorators.py | clumper/decorators.py | from functools import wraps, reduce
from copy import deepcopy
import inspect
from glob import glob
from pathlib import Path
def return_value_if_empty(value=None):
"""
This decorator ensures that if an aggregation column does not
exist that we return the appropriate value.
"""
def decorator_return... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/clumper/this.py | clumper/this.py | poem = """
When you start a package,
you can wonder if you really should.
But it can be a great idea,
if code brings joy and the learning is good.
Understanding all the rules,
can quickly become a chore.
But if you understand them well,
you'll know which ones to ignore.
Not every dataset is huge,
premature optimisati... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/clumper/clump.py | clumper/clump.py | import csv
import itertools as it
import json
import pathlib
import random
import urllib.request
from copy import deepcopy
from functools import reduce
from random import choices
from statistics import mean, median, stdev, variance
from typing import Optional, Tuple, List
from clumper.decorators import (
dict_coll... | python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | true |
koaning/clumper | https://github.com/koaning/clumper/blob/075eead3f7fac994da1110a4f17b8745640ef6a9/clumper/__init__.py | clumper/__init__.py | from clumper.clump import Clumper
| python | MIT | 075eead3f7fac994da1110a4f17b8745640ef6a9 | 2026-01-05T07:09:47.557992Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/test_example.py | test_example.py | from example import main
def test_main():
main(inference=False)
assert True
| python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/example.py | example.py | import re
from pydantic import BaseModel
import validex
# Example usage
class Superhero(BaseModel):
name: str
age: int
power: str
enemies: list[str]
def fix(self):
# Logic to auto fix and normalize the generated data
if self.age < 0:
self.age = 0
def check_hallu... | python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/tests/test_flow.py | tests/test_flow.py | from unittest.mock import patch
import pytest
from pydantic import BaseModel
import validex.loaders as loaders
from validex.base import App, DataCleaner
# Example usage
class Superhero(BaseModel):
name: str
age: int
power: str
enemies: list[str]
class Superhero2(BaseModel):
name: str
age: ... | python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/tests/test_loaders.py | tests/test_loaders.py | from unittest.mock import mock_open, patch
import pytest
import responses
from validex.loaders import (
LocalTextLoader,
LocalTextPatternLoader,
PdfFileLoader,
RobotsTxtLoader,
RssLoader,
TextBlobLoader,
WebPageLoader,
)
@pytest.fixture
def sample_url():
return "https://example.com"
... | python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/tests/__init__.py | tests/__init__.py | python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false | |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/tests/test_lib.py | tests/test_lib.py | from validex.base import DataCleaner
class TestDataCleaner:
# clean text with multiple spaces to single space
def test_clean_text_with_multiple_spaces(self):
cleaner = DataCleaner()
input_text = "This is a test"
expected_output = "This is a test"
assert cleaner.clean(inpu... | python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/validex/training.py | validex/training.py | """Experimental training mixin for local model training."""
import json
from typing import Any
from validex.logger import log
class TrainingMixin:
def save(self, filename: str) -> None:
import torch
log.info(f"Saving model state to {filename}")
# Ensure the model exists
if not h... | python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/validex/logger.py | validex/logger.py | import logging
import time
from collections.abc import Callable
from datetime import datetime
from typing import Any
class ColorFormatter(logging.Formatter):
COLORS = {
"DEBUG": 95, # gray
"INFO": 92, # blue
"WARNING": 91, # yellow
"ERROR": 31, # red
"CRITICAL": 31, # ... | python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/validex/utils.py | validex/utils.py | import functools
import hashlib
import os
import pickle
import time
from collections.abc import Callable
def async_cache_to_disk(expiration_time: int = 182 * 24 * 60 * 60) -> Callable:
def decorator(func: Callable) -> Callable:
@functools.wraps(func)
async def wrapper(*args, **kwargs):
... | python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/validex/__init__.py | validex/__init__.py | from .base import App # noqa
| python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/validex/base.py | validex/base.py | import json
import re
from concurrent.futures import ThreadPoolExecutor, as_completed
from typing import TypeVar
import tqdm
from cache_to_disk import cache_to_disk
from magentic import prompt
from pydantic import BaseModel
from rich.box import ROUNDED
from rich.console import Console
from rich.table import Table
imp... | python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
msoedov/validex | https://github.com/msoedov/validex/blob/22a633920020c9a2c6ae0fdad7656bfa229e211e/validex/loaders.py | validex/loaders.py | import glob
import re
from abc import ABC, abstractmethod
from typing import Any
from urllib.parse import urljoin
from urllib.robotparser import RobotFileParser
import justext
import requests
import stamina
from cache_to_disk import cache_to_disk
from .logger import log
class BaseLoader(ABC):
@abstractmethod
... | python | MIT | 22a633920020c9a2c6ae0fdad7656bfa229e211e | 2026-01-05T07:09:49.767462Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/setup.py | setup.py | from setuptools import find_packages, setup
setup(
install_requires=[
'colorama',
'termcolor',
],
name='aptos',
version='1.0.2',
url='https://github.com/pennsignals/aptos',
author='Jason Walsh',
author_email='jason.walsh@uphs.upenn.edu',
maintainer='Jason Walsh',
pac... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/primitive.py | aptos/primitive.py | import re
from copy import deepcopy
class Component:
def accept(self, visitor, *args):
raise NotImplementedError()
class Creator:
@staticmethod
def create(identifier):
return {
str: lambda identifier: {
'boolean': Boolean,
'null': Null,
... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/parser.py | aptos/parser.py | from .primitive import Creator
from .visitor import ResolveVisitor
class Parser:
@staticmethod
def parse(schema):
raise NotImplementedError()
class SchemaParser(Parser):
@staticmethod
def parse(schema):
component = Creator.create(schema.get('type')).unmarshal(schema)
compon... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/__main__.py | aptos/__main__.py | import argparse
import json
import sys
import colorama
from termcolor import colored
from .parser import SchemaParser
from .primitive import Object
from .visitor import ValidationVisitor
from .schema.visitor import AvroSchemaVisitor
def validate(arguments):
with open(arguments.schema) as fp:
schema = jso... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/visitor.py | aptos/visitor.py | import re
from .primitive import Creator, Translator
class SchemaArrayValidationHandler:
def __init__(self, visitor):
self.visitor = visitor
def __call__(self, sequence, *args):
errors = []
for element in sequence:
try:
element.accept(self.visitor, *args)... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/__init__.py | aptos/__init__.py | __version__ = '1.0.2'
| python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/swagger/__init__.py | aptos/swagger/__init__.py | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false | |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/swagger/v3/parser.py | aptos/swagger/v3/parser.py | from .model import Swagger
from .visitor import OpenAPIResolveVisitor
from ...parser import Parser
class OpenAPIParser(Parser):
@staticmethod
def parse(schema):
component = Swagger.unmarshal(schema)
component.accept(OpenAPIResolveVisitor(schema))
return component
| python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/swagger/v3/model.py | aptos/swagger/v3/model.py | from copy import deepcopy
from ...primitive import Component, Creator, SchemaMap
class Swagger(Component):
"""This is the root document object of the
`OpenAPI document <https://swagger.io/specification/#oasDocument>`_.
"""
def __init__(self, openapi='3.0.0', info=None, servers=None, paths=None,
... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/swagger/v3/visitor.py | aptos/swagger/v3/visitor.py | from ...primitive import Creator
from ...visitor import ResolveVisitor
class OpenAPIResolveVisitor(ResolveVisitor):
def __init__(self, context):
self.context = context
def visit_reference(self, reference, *args):
if reference.resolved: # pragma: no cover
return reference
... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/swagger/v3/__init__.py | aptos/swagger/v3/__init__.py | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false | |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/schema/visitor.py | aptos/schema/visitor.py | from ..primitive import Array, Object, Reference, Enumeration
class AvroSchemaVisitor:
def visit_empty_schema(self, schema, *args): # pragma: no cover
return
def visit_enumeration(self, enumeration, *args):
return {
'type': 'enum', 'name': enumeration.title,
'symbols... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/aptos/schema/__init__.py | aptos/schema/__init__.py | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false | |
pennsignals/aptos | https://github.com/pennsignals/aptos/blob/2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498/tests/test_schema_conversion.py | tests/test_schema_conversion.py | import json
import os
import unittest
from aptos.parser import SchemaParser
from aptos.schema.visitor import AvroSchemaVisitor
BASE_DIR = os.path.dirname(__file__)
class AvroSchemaTestCase(unittest.TestCase):
def runTest(self):
with open(os.path.join(BASE_DIR, 'schema', 'product')) as fp:
s... | python | Apache-2.0 | 2ed4d15e8ddb9d3db7a8e58f74c0c72a6e206498 | 2026-01-05T07:09:54.214590Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.