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 |
|---|---|---|---|---|---|---|
from __future__ import annotations
import argparse
import copy
import logging
import uuid
from collections import Counter
from collections.abc import Collection
from dataclasses import dataclass
from typing import Any, cast
import annofabapi
from annofabapi.models import DefaultAnnotationType
from annofabapi.plugin i... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/add_label.py | .py | 940b0ac22d42991c | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import json
import logging
import uuid
from collections.abc import Sequence
from dataclasses import dataclass, replace
from pathlib import Path
from typing import Any, cast
import annofabapi
import pandas
from annofabapi.util.annotation_specs import get_l... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/add_labels.py | .py | f34a4336fc274a20 | 7.98 | 8 |
import logging
from collections.abc import Collection
from typing import Any
from annofabapi.util.annotation_specs import get_attribute_name_en, get_choice_name_en, get_label_name_en
from more_itertools import first_true
logger = logging.getLogger(__name__)
class AttributeRestrictionMessage:
"""
アノテーション仕様の属... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/attribute_restriction.py | .py | 3faeea0592676aae | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import logging
from collections.abc import Mapping
from dataclasses import dataclass
from typing import Any, cast
import annofabapi
from annofabapi.util.annotation_specs import AnnotationSpecsAccessor, get_attribute_name_en
import annofabcli.common.cli
f... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/change_attribute_type.py | .py | acb6ffb14f89c03c | 7.98 | 8 |
from __future__ import annotations
import re
from typing import TypedDict
class RgbColor(TypedDict):
"""
Annofab API で利用する RGB 色です。
"""
red: int
green: int
blue: int
def hex_to_rgb(color_code: str) -> RgbColor:
"""
16進数カラーコードを Annofab API 向けの RGB 辞書へ変換する。
Args:
color_c... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/color.py | .py | 1ef11787d30d5aab | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import json
import logging
import sys
from collections.abc import Collection
from dataclasses import dataclass
from typing import Any
import annofabapi
from annofabapi.util.annotation_specs import AnnotationSpecsAccessor
import annofabcli.common.cli
from... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/delete_attribute_restriction.py | .py | 7996453c45c7f243 | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import logging
from collections.abc import Collection, Mapping, Sequence
from dataclasses import dataclass
from typing import Any
import annofabapi
from annofabapi.util.annotation_specs import AnnotationSpecsAccessor, get_attribute_name_en, get_choice_nam... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/delete_choices.py | .py | c48b839f2e1895c5 | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import logging
from collections.abc import Collection, Mapping, Sequence
from dataclasses import dataclass
from typing import Any
import annofabapi
from annofabapi.util.annotation_specs import AnnotationSpecsAccessor, get_attribute_name_en, get_label_name... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/delete_labels.py | .py | 57492f3aac1b6153 | 7.98 | 8 |
from __future__ import annotations
import json
from collections import Counter
from collections.abc import Iterable, Sequence
from typing import Any, Literal
from annofabapi.util.annotation_specs import get_message_with_lang
from annofabcli.annotation_specs.diff_models import (
AnnotationSpecsDiff,
Attribute... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/diff_compare.py | .py | 2bd4ffadc1584c94 | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import functools
import json
import logging
from collections.abc import Callable
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any
import annofabapi
from annofabapi.util.annotation_specs import AnnotationSpecsAccesso... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/import_annotation_specs.py | .py | 672de42021afa72d | 7.98 | 8 |
# Natural Language Toolkit: Parser API
#
# Copyright (C) 2001-2019 NLTK Project
# Author: Steven Bird <stevenbird1@gmail.com>
# Edward Loper <edloper@gmail.com>
# URL: <http://nltk.org/>
# For license information, see LICENSE.TXT
#
import itertools
from nltk.internals import overridden
class ParserI(object)... | dengking/compiler-principle | docs/Guide/Parsing-algorithm/src/parse/api.py | .py | 9486de92f595d668 | 7.48 | 8 |
# Natural Language Toolkit: Interface to BLLIP Parser
#
# Author: David McClosky <dmcc@bigasterisk.com>
#
# Copyright (C) 2001-2019 NLTK Project
# URL: <http://nltk.org/>
# For license information, see LICENSE.TXT
from nltk.parse.api import ParserI
from nltk.tree import Tree
"""
Interface for parsing with BLLIP Parse... | dengking/compiler-principle | docs/Guide/Parsing-algorithm/src/parse/bllip.py | .py | b05fc0b08a92a1f5 | 7.48 | 8 |
# Natural Language Toolkit: evaluation of dependency parser
#
# Author: Long Duong <longdt219@gmail.com>
#
# Copyright (C) 2001-2019 NLTK Project
# URL: <http://nltk.org/>
# For license information, see LICENSE.TXT
import unicodedata
class DependencyEvaluator(object):
"""
Class for measuring labelled and unl... | dengking/compiler-principle | docs/Guide/Parsing-algorithm/src/parse/evaluate.py | .py | de6db1c1cb03c7a7 | 7.48 | 8 |
# -*- coding: utf-8 -*-
# Natural Language Toolkit: Generating from a CFG
#
# Copyright (C) 2001-2019 NLTK Project
# Author: Steven Bird <stevenbird1@gmail.com>
# Peter Ljunglöf <peter.ljunglof@heatherleaf.se>
# URL: <http://nltk.org/>
# For license information, see LICENSE.TXT
#
import itertools
import sys
fr... | dengking/compiler-principle | docs/Guide/Parsing-algorithm/src/parse/generate.py | .py | 90489640b794a640 | 7.48 | 8 |
# -*- coding: utf-8 -*-
# Natural Language Toolkit: Interface to the Stanford Parser
#
# Copyright (C) 2001-2019 NLTK Project
# Author: Steven Xu <xxu@student.unimelb.edu.au>
#
# URL: <http://nltk.org/>
# For license information, see LICENSE.TXT
import tempfile
import os
import warnings
from unittest import skip
from ... | dengking/compiler-principle | docs/Guide/Parsing-algorithm/src/parse/stanford.py | .py | 39edebcb647086d7 | 7.48 | 8 |
# Dear PyGuiのプログラム中でtkinterのファイルダイアログを使うサンプルプログラム
from dearpygui.core import *
from dearpygui.simple import *
import tkinter
import tkinter.filedialog as filedialog
def apply_selected_file(sender: str, data) -> None:
"""
Dear PyGuiのファイルダイアログの実行結果を取得するコールバック
ダイアログで [Cancel] を選択した場合には実行されません
:param sen... | morikatron/snippet | dear_pygui/file_dialog.py | .py | 4d6c0a11ec08ad2b | 7.54 | 11 |
"""
sample code for testing jax auto-grad system
"""
from jax import grad
def f(x1, x2):
# x1 derive -> 2x1 + x2
# x2 derive -> x1 + 2x2
return x1 ** 2 + x1 * x2 + x2 ** 2
def main():
x1 = 1.0
x2 = 2.0
x1_grad = grad(f, argnums=0)(x1, x2)
print(f"x1 grad: {x1_grad}") # -> 4.0
x2_gra... | morikatron/snippet | jax_sample/grad_sample.py | .py | 142d49814c364147 | 7.04 | 11 |
"""
simple test for jax-implemented multi-layered perceptron
"""
from timeit import timeit
import jax
import jax.numpy as jnp
from jax import grad, jit, vmap, random
@jit
def softmax(x):
x = x - jnp.max(x, axis=1) # for avoiding overflow
return jnp.exp(x) / jnp.sum(jnp.exp(x), axis=1, keepdims=True)
@jit
de... | morikatron/snippet | jax_sample/mlp_sample.py | .py | 2a989f44e218b28f | 7.54 | 11 |
"""
simple test for jax-implemented mnist deep-learning
"""
import time
import jax.numpy as jnp
from jax import grad, jit, vmap, random
from sklearn import datasets
from sklearn.preprocessing import OneHotEncoder
from sklearn.model_selection import train_test_split
from tqdm import tqdm
# ===== define mlp functions ... | morikatron/snippet | jax_sample/mnist_sample.py | .py | 02c05c4050eb3601 | 7.54 | 11 |
"""
same experiment with tensorflow (for comparision)
"""
import numpy as np
import random
import tensorflow as tf
from tensorflow.keras import Model, Input
from tensorflow.keras.layers import Dense
from tensorflow.keras.activations import relu, softmax
from tensorflow.keras.optimizers import SGD, RMSprop
from sklear... | morikatron/snippet | jax_sample/tf_sample.py | .py | 31c2ed85512adc28 | 7.54 | 11 |
"""
ジュリア集合の計算アルゴリズムは オライリー「ハイパフォーマンス Python」に記載されているものを使っています。
書籍: https://www.oreilly.co.jp/books/9784873117409/
Github: https://github.com/mynameisfiber/high_performance_python/blob/master/01_profiling/cpu_profiling/julia1_nopil.py
"""
import os
import datetime
from concurrent.futures import ProcessPoolExecutor, Thr... | morikatron/snippet | parallelization/sample1.py | .py | 9b31aca075cdda5f | 7.54 | 11 |
"""
ジュリア集合の計算アルゴリズムは オライリー「ハイパフォーマンス Python」に記載されているものを使っています。
書籍: https://www.oreilly.co.jp/books/9784873117409/
Github: https://github.com/mynameisfiber/high_performance_python/blob/master/01_profiling/cpu_profiling/julia1_nopil.py
"""
import os
import time
import datetime
from concurrent.futures import ProcessPoolE... | morikatron/snippet | parallelization/sample2.py | .py | dbaa9bd9b8f119f1 | 7.54 | 11 |
"""
sample4_play_all_tracks.py
© Morikatron Inc. 2020
written by matsubara@morikatron.co.jp
3つのトラックをミックスして再生するサンプルコード
"""
import numpy as np # install : conda install numpy
import pyaudio # install : conda install pyaudio
# サンプリングレートを定義
SAMPLE_RATE = 44100
# 指定ノート番号のサイン波を、指定秒数生成してnumpy配列で返す関数
def notenumber2... | morikatron/snippet | python_and_music/sample4_play_all_tracks.py | .py | 5252e6c11f8939e8 | 7.54 | 11 |
#!/usr/bin/env python3
"""
Reload the Chrome browser page for local development.
This script triggers a page reload after assets (CSS/JS) are updated.
"""
import json
import sys
import urllib.request
import urllib.error
def find_chrome_page():
"""Find the Chrome DevTools debugging port and page."""
try:
... | copdips/copdips.github.io | scripts/reload_page.py | .py | 22b1a724b273a2bd | 7.45 | 7 |
#!/usr/bin/env python3
import argparse
import re
import shutil
import sys
import unicodedata
from pathlib import Path
from tempfile import NamedTemporaryFile
# ----- Patterns & Tables -----
# Zero-width and bidi control junk to remove
ZERO_WIDTH_BIDI_RE = re.compile(
"[" # open char class
... | copdips/copdips.github.io | scripts/remove_gremlins.py | .py | a3e75e0852e1abe0 | 7.45 | 7 |
"""Generate Markdown isolated from our current document options."""
import markdown
import yaml
import re
from collections import OrderedDict
from csv2md.table import Table
def yaml_load(stream, loader=yaml.Loader):
"""
Custom YAML loader.
Load all strings as Unicode.
http://stackoverflow.com/a/29674... | copdips/copdips.github.io | tools/pymdownx_md_render.py | .py | 33b1e46998825d8a | 7.45 | 7 |
#!/usr/bin/env uv run python
"""
Congressional Job Classification Analyzer
This script analyzes the classified congressional job data and generates reports
showing distribution of job categories over time and by various dimensions.
"""
import os
import json
from pathlib import Path
from datetime import datetime
from ... | dwillis/house-jobs | analyze_classifications.py | .py | 3d2c0a99eb2e4c25 | 7.48 | 8 |
#!/usr/bin/env uv run python
"""
Congressional Job Classifier
This script classifies congressional job listings into four categories:
- administrative: Office management, HR, scheduling, administrative support
- legislative: Policy research, bill analysis, committee work, legal research
- communications: Press, media ... | dwillis/house-jobs | job_classifier.py | .py | 9902d3ca14aa2448 | 7.48 | 8 |
#!/usr/bin/env uv run python
"""
Test script for the congressional job classifier.
Tests the classification on a small sample before running on the full dataset.
"""
import json
import os
from job_classifier import classify_job
def test_sample_job():
"""Test classification on a sample job."""
sample_job = {
... | dwillis/house-jobs | test_classifier.py | .py | ba6f017691ad246c | 7.98 | 8 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# 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 ... | facebookresearch/svinfer | svinfer/linear_model/linear_regression.py | .py | bc363bf1bebe0fb4 | 7.6 | 15 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
from __future__ import annotations
# 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/lice... | facebookresearch/svinfer | svinfer/linear_model/logistic_regression.py | .py | f2a080dad1964bc4 | 7.6 | 15 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# 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 ... | facebookresearch/svinfer | svinfer/processor/commons.py | .py | 460197a2a21d3425 | 7.6 | 15 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# 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 ... | facebookresearch/svinfer | svinfer/summary_statistics/summary_statistics.py | .py | 915445052c906da2 | 7.6 | 15 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# 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 ... | facebookresearch/svinfer | svinfer/tests/test_linear_regression.py | .py | 322a54bd51e96dff | 7.1 | 15 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# 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 ... | facebookresearch/svinfer | svinfer/tests/test_logistic_regression.py | .py | 0bb1864d3b61142b | 8.1 | 15 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# 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 ... | facebookresearch/svinfer | svinfer/tests/test_summary_statistics.py | .py | 129007918a75a962 | 7.1 | 15 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# 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 ... | facebookresearch/svinfer | svinfer/tests/utilities.py | .py | a6ef500c0d6975a5 | 8.1 | 15 |
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
import json
import os
import shutil
import subprocess
import traceback
import pbs
def debug(msg):
pbs.logmsg(pbs.EVENT_DEBUG, "azpbs_autoscale - %s" % msg)
def error(msg):
pbs.logmsg(pbs.EVENT_ERROR, "azpbs_au... | Azure/cyclecloud-pbspro | pbspro/conf/autoscale_hook.py | .py | 2924eb50f529481d | 7.62 | 16 |
import io
import os
import typing
from typing import Any, Dict, List, Optional, Set
from hpc.autoscale import hpclogging as logging
from hpc.autoscale.node import constraints as conslib
from pbspro.util import filter_host_resources, filter_non_host_resources
if typing.TYPE_CHECKING:
from pbspro.pbsqueue import S... | Azure/cyclecloud-pbspro | pbspro/src/pbspro/parser.py | .py | fafc0a053eb33fa4 | 7.62 | 16 |
import pytest
from hpc.autoscale.job.schedulernode import SchedulerNode
from hpc.autoscale.node.constraints import SharedConsumableResource
from pbspro.parser import PBSProParser
from pbspro.pbsqueue import PBSProLimit, PBSProQueue
from pbspro.resource import LongType, PBSProResourceDefinition, ResourceState
def tes... | Azure/cyclecloud-pbspro | pbspro/test/pbspro_test/queue_test.py | .py | 454a3dd54f218c0c | 7.12 | 16 |
#!/usr/bin/env python
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
import getopt, sys, time
def calcPiNewton(digits):
# Newtons formula for PI is:
# PI / 2 = sum_n_from_0_to_inf(n! / (2 * n + 1)!!)
# This can be written as:
# PI / 2 = 1 + 1/3 * (1 + 2/... | Azure/cyclecloud-pbspro | specs/default/cluster-init/files/pi.py | .py | 641f82f3ea067afc | 7.12 | 16 |
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
import unittest
import subprocess
class TestExecute(unittest.TestCase):
def test_simple(self):
p = subprocess.Popen(['/opt/pbs/bin/qstat'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, s... | Azure/cyclecloud-pbspro | specs/execute/cluster-init/tests/test_execute.py | .py | 1e4e743a09766ac0 | 7.12 | 16 |
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
from jetpack import config
import subprocess
import os
import sys
import traceback
from io import StringIO
import logging
import platform
if platform.system() != 'Windows':
import pwd
logger = logging.getLogger(__name... | Azure/cyclecloud-pbspro | specs/server/cluster-init/tests/helper.py | .py | 0bc7b73b9b8b4c13 | 8.12 | 16 |
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Bryan W. Berry <bryan.berry@gmail.com>
# License: BSD New, see LICENSE for details.
import sys
import os
import time
from abc import ABCMeta, abstractmethod
from functools import wraps, total_ordering
# Is this Python 3?
PY3 = sys.version_info > (3, 0)
class Null(object... | Azure/cyclecloud-pbspro | specs/server/cluster-init/tests/tryme.py | .py | 3e649d4dad2c136b | 7.12 | 16 |
"""
Batch command module - test multiple student submissions.
Teachers can use this to grade homework assignments in batch.
"""
import argparse
import json
import csv
from pathlib import Path
from concurrent.futures import ProcessPoolExecutor
from typing import Tuple, List, Dict, Any
from datetime import datetime
fro... | djeada/Testio | src/apps/cli/commands/batch.py | .py | e523553f603ba49e | 7.42 | 6 |
"""
Export command module - export problem descriptions and results to various formats.
Teachers can use this to generate printable materials for students.
"""
import argparse
import json
from pathlib import Path
from typing import Dict, Any, Optional
from datetime import datetime
def add_parser(subparsers: argparse... | djeada/Testio | src/apps/cli/commands/export.py | .py | f252558f65ce2272 | 7.42 | 6 |
"""
Generate command module - interactively generate configuration files.
Teachers can use this to create test configurations easily.
"""
import argparse
import json
from pathlib import Path
from typing import Dict, Any, List, Optional
def add_parser(subparsers: argparse._SubParsersAction) -> None:
"""Add the ge... | djeada/Testio | src/apps/cli/commands/generate.py | .py | 2c03a38fbefc4d48 | 7.42 | 6 |
"""
Run command module - executes tests from a config file.
This is the original CLI functionality refactored as a command.
"""
import argparse
import uuid
from concurrent.futures import ProcessPoolExecutor
from pathlib import Path
from typing import Tuple, List
from src.apps.cli.result_renderer import (
ResultRe... | djeada/Testio | src/apps/cli/commands/run.py | .py | 698a86d92497a906 | 7.42 | 6 |
"""
Student command module - student-focused testing functionality.
Students can use this to test their submissions before submitting.
"""
import argparse
import json
import os
import sys
import tempfile
from pathlib import Path
from typing import Optional, Dict, Any
from src.core.config_parser.parsers import ConfigP... | djeada/Testio | src/apps/cli/commands/student.py | .py | c7d708bad604a670 | 7.42 | 6 |
"""
Validate command module - validates configuration files and test cases.
Teachers can use this to ensure their test configurations are correct.
"""
import argparse
import json
from pathlib import Path
from typing import List, Dict, Any
def add_parser(subparsers: argparse._SubParsersAction) -> None:
"""Add the... | djeada/Testio | src/apps/cli/commands/validate.py | .py | 0d140c5ce858b14f | 7.42 | 6 |
"""
Main module for the CLI application.
You can start the application by using the main function.
The CLI supports multiple commands for different use cases:
- run: Execute tests from a configuration file
- validate: Validate configuration files and test cases
- batch: Test multiple student submissions in batch
- exp... | djeada/Testio | src/apps/cli/main.py | .py | 8946dbb12f9bde7e | 7.42 | 6 |
"""
Constants for strings used in the program.
"""
from dataclasses import dataclass
@dataclass
class REPORT_MESSAGES:
"""
Constants for report messages strings.
"""
TEST_PASSED: str = "Test passed!"
TEST_FAILED: str = "Test failed :("
ALL_SUCCESSFUL: str = "All tests passed :)"
ERROR: s... | djeada/Testio | src/apps/cli/string_consts.py | .py | b2c2663168f2d5d9 | 7.42 | 6 |
"""iplib3's functionality specific to addresses."""
from __future__ import annotations
from enum import IntFlag, auto
from itertools import groupby
from typing import TYPE_CHECKING, Self
from iplib3.constants.address import (
IPV4_LOCALHOST,
IPV6_LOCALHOST,
)
from iplib3.constants.ipv4 import (
IPV4_MAX_... | Diapolo10/iplib3 | src/iplib3/address.py | .py | 289ae545cd51f4a4 | 7.56 | 12 |
"""Subnet constants."""
from __future__ import annotations
from enum import StrEnum
from iplib3.constants.ipv4 import IPV4_MAX_SEGMENT_COUNT, IPV4_SEGMENT_BIT_COUNT
from iplib3.constants.ipv6 import IPV6_MAX_SEGMENT_COUNT, IPV6_SEGMENT_BIT_COUNT
# Subnet mask constants
IPV4_VALID_SUBNET_SEGMENTS = (0, 128, 192, 224... | Diapolo10/iplib3 | src/iplib3/constants/subnet.py | .py | b6382afcbd750111 | 7.56 | 12 |
"""iplib3's functionality specific to subnetting."""
from __future__ import annotations
from typing import overload
from iplib3.constants.ipv4 import (
IPV4_MIN_SEGMENT_COUNT,
IPV4_SEGMENT_BIT_COUNT,
)
from iplib3.constants.subnet import (
IPV4_MAX_SUBNET_VALUE,
IPV4_MIN_SUBNET_VALUE,
IPV6_MAX_SU... | Diapolo10/iplib3 | src/iplib3/subnet.py | .py | 909dbf7e5de226b3 | 7.56 | 12 |
"""Unit tests for iplib3.address."""
import pytest
from iplib3 import IPAddress
from iplib3.address import AddressFormat, IPv4, IPv6, PureAddress
from iplib3.constants import IPV6_MAX_VALUE
from tests.test_cases_address import (
TEST_CASES_IPADDRESS,
TEST_CASES_IPADDRESS_AS_IPV4,
TEST_CASES_IPADDRESS_AS_I... | Diapolo10/iplib3 | tests/test_address.py | .py | 1fb89716c215819c | 7.06 | 12 |
"""Unit tests for iplib3.subnet."""
import pytest
from iplib3.constants.subnet import SubnetType
from iplib3.subnet import (
PureSubnetMask,
SubnetMask,
)
from tests.test_cases_subnet import (
TEST_CASES_PURE_SUBNET_MASK_EQUALITY,
TEST_CASES_PURE_SUBNET_MASK_INEQUALITY,
TEST_CASES_PURE_SUBNET_MASK... | Diapolo10/iplib3 | tests/test_subnet.py | .py | a5ed9b1efffeedc7 | 7.06 | 12 |
"""Unit tests for iplib3.validators."""
import pytest
from iplib3.constants.subnet import SubnetType
from iplib3.validators import (
ValidationMode,
_ipv4_subnet_validator,
_ipv6_subnet_validator,
_port_stripper,
ip_validator,
ipv4_validator,
ipv6_validator,
port_validator,
subnet_... | Diapolo10/iplib3 | tests/test_validators.py | .py | 8035fec85ac501a4 | 7.06 | 12 |
from __future__ import annotations
import argparse
import json
import logging
import os
from datetime import datetime
from datetime import timedelta
import git
import humanfriendly
from datalad.plugin import export_archive
from github import Github
from scripts.datalad_utils import get_dataset
from scripts.datalad_u... | CONP-PCNO/conp-dataset | scripts/auto_archive.py | .py | 651550e5d4856b8a | 7.64 | 18 |
import json
import logging
import os
from collections import Counter
from copy import deepcopy
import requests
logger = logging.getLogger(__name__)
CONP_DATASET_ROOT_DIR = os.path.abspath(os.path.join(__file__, "../../.."))
# conp-dataset/projects
PROJECTS_DIR = os.path.join(CONP_DATASET_ROOT_DIR, "projects")
CURR... | CONP-PCNO/conp-dataset | scripts/conp_to_nidm_terms/functions.py | .py | a82c65cfdbc5841a | 7.64 | 18 |
import getopt
import os
import sys
import lib.Utility as Utility
def main(argv):
# create the getopt table + read and validate the options given to the script
conp_dataset_dir = parse_input(argv)
# read the content of the DATS.json files present in the conp-dataset directory
dataset_descriptor_list... | CONP-PCNO/conp-dataset | scripts/data_aggregation_summary_scripts/create_dataset_statistcs_per_data_providers.py | .py | 81ff2d7b6db6c8cf | 7.64 | 18 |
"""Docstring."""
import getopt
import os
import sys
import lib.Utility as Utility
def main(argv):
"""Doctring."""
# create the getopt table + read and validate the options given to the script
tools_json_dir_path = parse_input(argv)
# read the content of the DATS.json files present in the boutiques's... | CONP-PCNO/conp-dataset | scripts/data_aggregation_summary_scripts/create_tools_statistics_per_domain.py | .py | a18aad378c2bc45b | 7.64 | 18 |
import csv
import datetime
import json
import os
def read_conp_dataset_dir(conp_dataset_dir_path):
"""
Reads the conp-dataset projects directory and return the contents
of every dataset DATS.json file in a list (one list item = one
dataset DATS.json content).
:param conp_dataset_dir_path: path to... | CONP-PCNO/conp-dataset | scripts/data_aggregation_summary_scripts/lib/Utility.py | .py | a9bcaf33f8870169 | 7.64 | 18 |
import argparse
import json
import logging
import pathlib as pal
import sys
import time
import jsonschema as jss
CONTEXT_DIR = (pal.Path(__file__).parent / "context" / "sdo").resolve()
SCHEMA_DIR = (pal.Path(__file__).parent / "schema").resolve()
logger = logging.getLogger("DATS annotator")
def find_schema(parent_... | CONP-PCNO/conp-dataset | scripts/dats_jsonld_annotator/annotator.py | .py | 47200494abf14d74 | 7.64 | 18 |
import getopt
import json
import logging
import os
from sys import argv
import jsonschema
import requests
logger = logging.getLogger(__name__)
# path to a top-level schema
SCHEMA_PATH = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"conp-dats",
"dataset_schema.json",
)
# set value to 0 if ... | CONP-PCNO/conp-dataset | scripts/dats_validator/validator.py | .py | 5134e68cea047a76 | 7.64 | 18 |
#!/usr/bin/env python
import json
import os
import re
import traceback
from datalad import api
from git import Repo
def project_name2env(project_name: str) -> str:
"""Convert the project name to a valid ENV var name.
The ENV name for the project must match the regex `[a-zA-Z_]+[a-zA-Z0-9_]*`.
Parameter... | CONP-PCNO/conp-dataset | scripts/unlock.py | .py | 6b87e323e443e2e1 | 7.64 | 18 |
import os
import re
import string
from typing import List
import requests
from git import Repo
def get_datasets():
datasets: List[str] = list(map(lambda x: x.path, Repo(".").submodules))
pull_number = os.getenv("CIRCLE_PR_NUMBER", False)
if pull_number:
response = requests.get(
f"htt... | CONP-PCNO/conp-dataset | tests/create_tests.py | .py | 42fc59dde7f9e649 | 8.14 | 18 |
import json
import os
import random
import re
import shutil
import signal
import subprocess
from contextlib import contextmanager
from functools import reduce
import datalad.api as api
import git
import humanize
import keyring
import pytest
from datalad.support.annexrepo import AnnexRepo
from git.exc import InvalidGit... | CONP-PCNO/conp-dataset | tests/functions.py | .py | 3a4ac65e3fa03577 | 8.14 | 18 |
"""Template to base the test of the datasets.
"""
import json
import os
import time
from threading import Lock
import git
import humanfriendly
import pytest
from datalad import api
from scripts.dats_validator.validator import validate_date_types
from scripts.dats_validator.validator import validate_is_about
from scri... | CONP-PCNO/conp-dataset | tests/template.py | .py | 5190afa9f492652b | 8.14 | 18 |
"""Test the minimalTest function in create_tests.py.
This function should return the minimal set of test to execute.
"""
import git
import pytest
from tests.create_tests import minimal_tests
@pytest.fixture(autouse=True)
def retrieve_submodule():
"""Fixture to get all the CONP datasets before a test."""
pyt... | CONP-PCNO/conp-dataset | tests/test_minimal_tests.py | .py | 8bad89e94eb363bb | 7.14 | 18 |
#!/usr/bin/env python
# coding: utf-8
# In[14]:
import numpy as np
import galsim
import ngmix
from shapepipe.modules.ngmix_package.ngmix import (
get_noise,
)
#print("Use shapepipe version of metacal")
#from shapepipe.modules.ngmix_package.ngmix import do_ngmix_metacal
print("Use this version of metacal")
f... | CosmoStat/shapepipe | scripts/jupyter/test_centroid_shift.py | .py | df2363f10a51ab75 | 8.14 | 18 |
#!/usr/bin/env python
"""Script canfar_avail_results.py
Check whether results files are available on vos.
:Author: Martin Kilbinger
:Date: 07/2020
"""
import re
import os
import sys
import glob
import copy
import io
from contextlib import redirect_stdout
from optparse import OptionParser
from cs_util.canfar impo... | CosmoStat/shapepipe | scripts/python/canfar_avail_results.py | .py | 514897a3ae82b6cc | 7.64 | 18 |
#!/usr/bin/env python3
"""
Clean up previous ngmix run directories for completed tiles.
Removes *_prev directories when the current run has finished.
"""
import argparse
import os
import re
import shutil
import glob
from pathlib import Path
from astropy.io import fits
def get_fits_info(fits_file):
"""Get number ... | CosmoStat/shapepipe | scripts/python/clear_ngmix_prev.py | .py | e1e08f51de7f4962 | 7.64 | 18 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Script create_star_cat.py
:Description: Create reference star catalogue for masking of
bright star halos and diffraction spikes
:Authors: Axel Guinot, Martin Kilbinger
"""
import os
import re
import sys
from cs_util import args as cs_args
from cs_util import logg... | CosmoStat/shapepipe | scripts/python/create_star_cat.py | .py | dc75684590d46bcc | 7.64 | 18 |
#!/usr/bin/env python
"""
distribute_tiles.py
Uses canfar.helpers.distributed.chunk to automatically distribute tiles
across replicas, then processes each tile assigned to this replica.
"""
import os
import sys
import subprocess
from multiprocessing import Pool
import fcntl
from canfar.helpers.distributed import chun... | CosmoStat/shapepipe | scripts/python/distribute_tiles.py | .py | 5ae0b62ede33905b | 7.64 | 18 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Script get_number_objects.py
Get number of objects in a (last-run SExtractor) catalogue.
:Author: Martin Kilbinger <martin.kilblinger@cea.fr>
"""
import sys
import copy
import glob
from optparse import OptionParser
from astropy.io import fits
from shapepipe.pipel... | CosmoStat/shapepipe | scripts/python/get_number_objects.py | .py | 82a68b118ca1b7d0 | 7.64 | 18 |
#!/usr/bin/env python3
"""
Initialise the directory structure for a v2.0 ShapePipe run.
Creates tile and exposure staging directories, config symlinks,
and a tile number list.
Config file is loaded first (if provided), then overridden by command-line arguments.
"""
import argparse
import sys
from pathlib import Path... | CosmoStat/shapepipe | scripts/python/init_run_v2.0.py | .py | 3ce318012c725b7b | 7.64 | 18 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Script link_to_exp_for_tile.py
:Description: Link to exposure and PSF catalogue
for a given tile.
:Author: Martin Kilbinger
"""
import os
import sys
import re
import copy
from optparse import OptionParser
class param:
"""General class to store (default) var... | CosmoStat/shapepipe | scripts/python/link_to_exp_for_tile.py | .py | b2512b5d26396383 | 7.64 | 18 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Script merge_final_cat.py
Merge all final catalogues, created by ShapePipe module
``make_catalogue_runner``, into a joined numpy binary file.
:Authors: Axel Guinot, Martin Kilbinger
"""
from astropy.io import fits
import numpy as np
import os
import sys
import re
i... | CosmoStat/shapepipe | scripts/python/merge_final_cat.py | .py | 200a8e6fbcec0deb | 7.64 | 18 |
# /// script
# requires-python = ">=3.10"
# dependencies = ["numpy", "matplotlib", "seaborn"]
# ///
"""Column figure for the resolution x noise breakdown grid (v2).
Reads the JSON emitted by ``run_breakdown_grid.py`` (v2 schema) and draws three
vertically stacked panels sharing the x-axis -- multiplicative bias ``m1``... | CosmoStat/shapepipe | scripts/python/plot_breakdown_grid.py | .py | 36d07cdab2676211 | 7.64 | 18 |
#!/usr/bin/env python
"""Small-multiple trends figure from the board ``history.json``.
The companion to ``build_history.py``: that script accumulates the status-board
metric set across commits; this one draws it as a grid of small multiples, one
panel per metric *family*, x = build (date + short commit), y = value wit... | CosmoStat/shapepipe | scripts/python/plot_trends.py | .py | 4216d2b218044fa2 | 7.64 | 18 |
# canfar_monitor.py
# Monitor job submitted with the canfar client
import os
import sys
from requests.exceptions import ReadTimeout
from httpx import HTTPStatusError
from pydantic import ValidationError
from canfar.sessions import Session
import pandas as pd
from cs_util import args as cs_args
from cs_util import ... | CosmoStat/shapepipe | src/shapepipe/canfar/canfar_monitor.py | .py | 0ed811132aa1e6a8 | 7.64 | 18 |
# canfar_submit_job.py
# Submit job with the canfar client
import os
import sys
import asyncio
import math
from canfar.sessions import Session
from canfar.sessions import AsyncSession
from datetime import datetime
from cs_util import args as cs_args
from cs_util import logging
class Job(object):
"""Class Job.... | CosmoStat/shapepipe | src/shapepipe/canfar/canfar_submit.py | .py | bcafad400fe43d99 | 7.64 | 18 |
"""FAKE PSF.
Create fake PSF postage-stamp dictionaries for image simulations.
:Author: Martin Kilbinger <martin.kilbinger@cea.fr>
"""
import pickle
import numpy as np
from astropy.io import fits
from sqlitedict import SqliteDict
class FakePsf:
"""Fake PSF.
Parameters
----------
sexcat_path : st... | CosmoStat/shapepipe | src/shapepipe/modules/fake_psf_package/fake_psf.py | .py | 2e029d3a2713433a | 7.64 | 18 |
"""FIND EXPOSURES SCRIPT.
This module contains a class to identify single exposures that were used
to create tiles.
:Author: Martin Kilbinger <martin.kilbinger@cea.fr>
"""
import re
import astropy.io.fits as fits
class FindExposures:
"""Find Exposures.
This class finds exposures that are used for a give... | CosmoStat/shapepipe | src/shapepipe/modules/find_exposures_package/find_exposures.py | .py | 5de82f5d1566e645 | 7.64 | 18 |
"""Pytest-only import shims for environments without docassemble.webapp.
The CI test environment installs ``docassemble.base`` but intentionally avoids
``docassemble.webapp`` because the upstream sdist is currently broken. A small
subset of tests imports modules that transitively load ``docassemble.base.util``
or ``do... | SuffolkLITLab/docassemble-ALDashboard | conftest.py | .py | 3ef642f1a1df8cb8 | 8.12 | 16 |
from docassemble.base.util import (
log,
space_to_underscore,
bold,
DAObject,
DAList,
DAFile,
DAFileList,
path_and_mimetype,
user_info,
)
from .docassemble_compat import SavedFile, directory_for
import datetime
import zipfile
import os
import re
from typing import Optional, Any, Dict... | SuffolkLITLab/docassemble-ALDashboard | docassemble/ALDashboard/create_package.py | .py | 9d695fc6e1f38fa9 | 7.62 | 16 |
"""Database-session compatibility for docassemble 1.9 and 1.10."""
from contextlib import contextmanager
from typing import Any, Iterator
try:
from docassemble.webapp.db import (
get_session as get_database_session,
session_scope as database_session_scope,
)
except ModuleNotFoundError as err:
... | SuffolkLITLab/docassemble-ALDashboard | docassemble/ALDashboard/database_compat.py | .py | a3c1f79d9dc40173 | 7.62 | 16 |
import re
from collections import Counter
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple
def _parse_bool(value: Any, *, default: bool = False) -> bool:
"""Coerce common serialized boolean values used by the PDF labeler UI.
Args:
value: The raw value to interpret.
defa... | SuffolkLITLab/docassemble-ALDashboard | docassemble/ALDashboard/pdf_export_utils.py | .py | 54df26b086dbd242 | 7.62 | 16 |
# do not pre-load
import subprocess
import sys
import unittest
class TestPDFFieldLabelerImport(unittest.TestCase):
def test_import_does_not_force_docassemble_config_load(self):
module_name = "docassemble.ALDashboard.pdf_field_labeler"
probe = """
import importlib
from unittest.mock import patch
im... | SuffolkLITLab/docassemble-ALDashboard | docassemble/ALDashboard/test/test_pdf_field_labeler_import.py | .py | 60f45386c0f10c65 | 7.12 | 16 |
from __future__ import annotations
import hashlib
import json
import logging
import os
import shutil
import tempfile
import time
import warnings
from pathlib import Path
from typing import Dict, Optional
import requests
from assemblyline.common.safe_archive import safe_extract_tar
from assemblyline.common import exce... | CybercentreCanada/assemblyline-v4-service | assemblyline_v4_service/common/base.py | .py | 91b296bc9b2d2761 | 7.62 | 16 |
"""
Pytest configuration file, setup global pytest fixtures and functions here.
"""
import os
import pytest
from assemblyline.common import forge
from assemblyline.datastore.helper import AssemblylineDatastore
from assemblyline.datastore.store import ESStore
original_skip = pytest.skip
# Check if we are in an unatte... | CybercentreCanada/assemblyline-v4-service | test/conftest.py | .py | 5b74a2790a59b19a | 8.12 | 16 |
import logging
from collections import OrderedDict
from multiprocessing import Process
import pytest
import requests_mock
from assemblyline.common.version import FRAMEWORK_VERSION, SYSTEM_VERSION
from assemblyline_v4_service.common import helper
from assemblyline_v4_service.common.api import *
from requests import Con... | CybercentreCanada/assemblyline-v4-service | test/test_common/test_api.py | .py | 8e4810c5567acef1 | 7.12 | 16 |
from test.test_common import setup_module, teardown_module
import pytest
from assemblyline_v4_service.common.helper import *
from assemblyline.common.classification import InvalidDefinition
from assemblyline.common.version import FRAMEWORK_VERSION, SYSTEM_VERSION
def test_get_classification():
with pytest.raise... | CybercentreCanada/assemblyline-v4-service | test/test_common/test_helper.py | .py | b0ee98022061293a | 7.12 | 16 |
import os
import pytest
from assemblyline_v4_service.common.ocr import (
detections,
ocr_detections,
update_ocr_config,
)
from test.test_common import TESSERACT_LIST
@pytest.mark.skipif(
len(TESSERACT_LIST) < 1, reason="Requires tesseract-ocr apt package"
)
def test_ocr_detections():
update_ocr_... | CybercentreCanada/assemblyline-v4-service | test/test_common/test_ocr.py | .py | 5ff63773fc9f4658 | 7.12 | 16 |
import json
import logging
import os
import tempfile
from test.test_common import setup_module
setup_module()
import pytest
from assemblyline_v4_service.common.ontology_helper import OntologyHelper, validate_tags, merge_tags
from assemblyline_v4_service.common.result import ResultSection
from assemblyline.odm.models... | CybercentreCanada/assemblyline-v4-service | test/test_common/test_ontology_helper.py | .py | 43df84a9ea3c221e | 7.12 | 16 |
"""Android specific functions."""
# pylint: disable=invalid-name,import-error,import-outside-toplevel
import uuid
from pathlib import Path
from android import activity as android_activity
from jnius import autoclass, cast
from kivy.logger import Logger
Context = autoclass("android.content.Context")
Icon = autoclass(... | b3b/pythonhere | pythonhere/android_here.py | .py | c0164d0e082589c8 | 7.45 | 7 |
"""App exceptions manager."""
import asyncio
import traceback
from pathlib import Path
from kivy.base import (
ExceptionHandler,
ExceptionManager,
)
from kivy.clock import Clock
from kivy.lang import Builder
from kivy.logger import Logger
from kivy.properties import StringProperty # pylint: disable=no-name-i... | b3b/pythonhere | pythonhere/exception_manager_here.py | .py | f9462a1916f3928c | 7.45 | 7 |
"""Utilities for launching scripts."""
import os
import runpy
import sys
from pathlib import Path
from kivy import platform
from kivy.logger import Logger
def run_script(script: str):
"""Execute given script."""
Logger.info("PythonHere: Run script %s", script)
try:
path = Path(script).resolve(st... | b3b/pythonhere | pythonhere/launcher_here.py | .py | 239cc1a4dd0fde19 | 7.45 | 7 |
"""PythonHere prompt sections for ``%%there ai``."""
from importlib.resources import files
from herethere.there.ai import register_ai_prompt, set_ai_prompts
PYTHONHERE_AI_ACTIVE_PROMPTS = (
"kivy-runtime",
"kivy-kv",
"android-runtime",
"jnius",
"android-permissions",
"android-packages",
"... | b3b/pythonhere | pythonhere/magic_here/prompts.py | .py | 922352b873c42202 | 7.45 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.