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
#!/usr/bin/env python # tools for generating MOM6 diagnostics import argparse import xarray as xr import numpy as np import matplotlib.pyplot as plt import warnings import os, yaml from mom6_tools import m6plot from mom6_tools.MOM6grid import MOM6grid from mom6_tools.m6toolbox import weighted_temporal_mean_vars, requ...
NCAR/mom6-tools
mom6_tools/latlon_analysis.py
.py
bc2b0cd4591e8c31
7.62
16
#!/usr/bin/env python # generates MOM6 diagnostics import argparse from netCDF4 import MFDataset, Dataset import numpy as np import matplotlib.pyplot as plt from mom6_tools.m6plot import xyplot from mom6_tools.MOM6grid import MOM6grid import warnings import os class MyError(Exception): """ Class for error handli...
NCAR/mom6-tools
mom6_tools/mom6_xyplot.py
.py
f46c8e4f25df8c0c
7.62
16
#!/usr/bin/env python import io, yaml, os import matplotlib.pyplot as plt import numpy as np import warnings, dask, netCDF4, intake from datetime import datetime, date import xarray as xr from ncar_jobqueue import NCARCluster from dask.distributed import Client from mom6_tools import m6plot from mom6_tools.DiagsCase i...
NCAR/mom6-tools
mom6_tools/poleward_heat_transport.py
.py
1bf26c9c8f474c83
7.62
16
import itertools import operator from functools import reduce import numpy as np import tqdm import xarray as xr def read_raw_files( paths, debug=False, parallel=False, use_cftime=True, engine="netcdf4", **kwargs ): """ Reads a list of paths as datasets. Returns a list of datasets. Parameters --...
NCAR/mom6-tools
mom6_tools/sections.py
.py
9b2777187ebb214a
7.62
16
import numpy as np from mom6_tools.stats import myStats_da import xarray as xr # starts with simple cases then build complexity. # Calculates min, max, mean, standard deviation and root-mean-square for DataArray ds # starts with simple cases then build complexity. # First, basins = None def test_case1(): # case 1,...
NCAR/mom6-tools
tests/test_mystats_da.py
.py
5f16f622d8478ca8
7.12
16
# Apache License Version 2.0 # # Copyright (c) 2021., Redis Labs Modules # All rights reserved. # import logging import requests from redisbench_admin.utils.remote import extract_git_vars PERF_CALLGRAPH_MODE_DEFAULT = "fp" PERF_DAEMON_LOGNAME = "/tmp/perf-daemon.log" class PerfDaemonRemoteCaller: def __init...
redis-performance/redisbench-admin
redisbench_admin/profilers/perf_daemon_caller.py
.py
9c3f7b717997dc9c
7.52
10
# Apache License Version 2.0 # # Copyright (c) 2021., Redis Labs Modules # All rights reserved. # import logging import os.path import subprocess import time class Vtune: def __init__(self): """ Profiling on top of intel's vtune """ self.vtune = os.getenv("VTUNE") if no...
redis-performance/redisbench-admin
redisbench_admin/profilers/vtune.py
.py
38cc79001af93ad5
7.52
10
#!/usr/bin/env python3 """ Prepare AEM payload for content fragment and page updates. This script replaces the Workato Python code that: 1. Validates tags match snowflake-site:taxonomy format 2. Builds URL-encoded form data for AEM Sling POST requests 3. Generates payloads for both content fragment and page updates ""...
Snowflake-Labs/sfquickstarts
scripts/aem-staging/prepare_aem_payload.py
.py
96a0353f3a867db5
7.62
16
#!/usr/bin/env python3 """Apply categories from CSV mapping and remove categories/tags lines from markdown files. Reads CSV at site/sfguides/src/_SCRIPTS/language_data.csv and for each row maps the id (col A) to the category values located in columns G, H, I, L, O, P, S, T, W, and X (Excel 1-based). Then walks site/sf...
Snowflake-Labs/sfquickstarts
scripts/categories/apply_categories_from_xlsx.py
.py
f1855c46af536e69
7.62
16
import os import re import json import subprocess from typing import Dict, List, Optional def find_repo_root() -> str: """ Find the repository root by searching for .git directory. Falls back to relative path from script location if not found. """ # Start from the script's directory current = ...
Snowflake-Labs/sfquickstarts
scripts/generate_manifest/manifest generator.py
.py
e21f0efa97255219
7.62
16
#!/usr/bin/env python3 """ move_archived_guides.py Move guide directories or markdown files whose mapping row has Status == 'Archived' into the folder site/sfguides/src/_archived. Safe by default: runs in dry-run mode unless --apply is passed. Usage: python3 move_archived_guides.py # dry-run, prints report ...
Snowflake-Labs/sfquickstarts
scripts/move_archived_guides.py
.py
381dd6ecbeb52ffd
7.62
16
''' Snowflake Inc. Code Disclaimer: The code provided by Snowflake is for demostration purposes only and is provided "as is," without any warranties. Use at your own risk. We do not provide technical support. You may modify the code but do not distribute it without proper attribution. Comply with all applicable laws. ...
Snowflake-Labs/sfquickstarts
site/sfguides/src/_archived/getting_started_with_amg_and_streamlit_on_real-time_dashboarding/assets/opensky.py
.py
7f68b45dc9ce0624
7.62
16
#!/usr/bin/env python3 """ MCP Client for A/B Testing Server Provides agent spawning, A/B test execution, and multi-judge evaluation. """ import requests import subprocess import time import os from typing import Optional, List, Dict MCP_DEFAULT_PORT = 8517 MCP_DEFAULT_URL = f"http://localhost:{MCP_DEFAULT_PORT}" cl...
Snowflake-Labs/sfquickstarts
site/sfguides/src/agent-verbosity-cortex-evaluation/ab_mcp_client.py
.py
790086a3a5618169
7.62
16
""" Cross-Model Verbosity Comparison Runner Compares Claude Opus 4 vs Mistral Large 2 across all 8 verbosity levels. """ import snowflake.connector import pandas as pd from datetime import datetime from typing import Dict, List, Any import json # Configuration DATABASE = "FANCYWORKS_DEMO_DB" SCHEMA = "PUBLIC" MODEL...
Snowflake-Labs/sfquickstarts
site/sfguides/src/agent-verbosity-cortex-evaluation/compare_models.py
.py
ba9c1f99675bf7e3
7.62
16
""" Cross-Model Verbosity Comparison - Using CORTEX.COMPLETE Works without CREATE CORTEX AGENT syntax. """ import snowflake.connector import json from datetime import datetime from typing import Dict, List # Configuration DATABASE = "FANCYWORKS_DEMO_DB" SCHEMA = "PUBLIC" WAREHOUSE = "SNOW_INTELLIGENCE_DEMO_WH" MODEL...
Snowflake-Labs/sfquickstarts
site/sfguides/src/agent-verbosity-cortex-evaluation/compare_models_complete.py
.py
d864acac48e44df1
7.62
16
#!/usr/bin/env python3 """ MCP Client for Wiki Q&A Server Provides health check and API consumption utilities. """ import requests import subprocess import time import os from typing import Optional, List, Dict MCP_DEFAULT_PORT = 8503 MCP_DEFAULT_URL = f"http://localhost:{MCP_DEFAULT_PORT}" class WikiMCPClient: "...
Snowflake-Labs/sfquickstarts
site/sfguides/src/agent-verbosity-cortex-evaluation/mcp_client.py
.py
73e8ce5bee1ecfc4
7.62
16
""" Persona-based Q&A Generator using Vine Copula Generates questions across domains with persona-specific response evaluation """ import numpy as np from scipy import stats from typing import List, Dict, Optional import re import requests from dataclasses import dataclass import textstat # For Flesch reading ease @d...
Snowflake-Labs/sfquickstarts
site/sfguides/src/agent-verbosity-cortex-evaluation/persona_qa_generator.py
.py
ed14f44713945bbc
7.62
16
#!/usr/bin/env python3 """ Run All Comparisons - Automated runner for Model Comparison Dashboard Executes all tabs with default settings and saves results. """ import argparse import json import os import subprocess import sys import time from datetime import datetime from pathlib import Path import snowflake.connecto...
Snowflake-Labs/sfquickstarts
site/sfguides/src/agent-verbosity-cortex-evaluation/run_all_comparisons.py
.py
b0f27879fc6bcd91
7.62
16
""" Test all 8 verbosity agents with the query: "What is needle in the haystack benchmark?" """ import snowflake.connector import requests import json import os # Configuration DATABASE = "FANCYWORKS_DEMO_DB" SCHEMA = "PUBLIC" QUERY = "What is needle in the haystack benchmark?" AGENTS = [ ("MINIMAL_AGENT", "--min...
Snowflake-Labs/sfquickstarts
site/sfguides/src/agent-verbosity-cortex-evaluation/test_agents.py
.py
3a5984e122b5fbaa
8.12
16
""" Wikipedia Q&A Generator using Vine Copula Generates synthetic questions from Wikipedia articles with dependency modeling """ import numpy as np from scipy import stats from typing import List, Dict, Tuple, Optional import re import requests from dataclasses import dataclass @dataclass class QAPair: article: st...
Snowflake-Labs/sfquickstarts
site/sfguides/src/agent-verbosity-cortex-evaluation/wiki_qa_generator.py
.py
ad8a801121db2881
7.62
16
import contextlib import io import os import warnings import zlib from typing import cast class IteratorMixin: """ Produce a series of lines, from a readable that only exposes a `read` method """ __block_size = 65536 __line_iterator = None def __iter__(self): # We use a BytesIO as ou...
NHSDigital/mesh-client
mesh_client/io_helpers.py
.py
8512c013938f7e09
7.63
17
import contextlib import json import os from collections.abc import Mapping from werkzeug import Response from mesh_client import Endpoint _PACKAGE_DIR = os.path.dirname(__file__) MOCK_CA_CERT = os.path.join(_PACKAGE_DIR, "ca.cert.pem") MOCK_CERT = os.path.join(_PACKAGE_DIR, "client.cert.pem") MOCK_KEY = os.path.joi...
NHSDigital/mesh-client
tests/helpers.py
.py
16ed700a5374bbcb
8.13
17
#!/usr/bin/env python """ Performance test for pixel classification on real edep-sim file. Mimics test_voxelization_performance.py but applies pixel classification per event/TPC. """ import os import sys import time from math import ceil import argparse import numpy as np import h5py import cupy as cp from larndsim i...
DUNE/larnd-sim
examples/far_field/test_pixel_classification_performance.py
.py
74811b926d229d0d
8.04
11
#!/usr/bin/env python """ Performance test for voxelization on real edep-sim file. Mimics simulate_pixels.py structure but focuses on voxelization only. """ import os import sys import time from math import ceil import argparse import numpy as np import h5py import cupy as cp from larndsim import consts, quenching, d...
DUNE/larnd-sim
examples/far_field/test_voxelization_performance.py
.py
144a29bdcb10e870
8.04
11
R""" Classifies pixels into physics categories (CHARGE_COLLECTION, CHARGE_NEIGHBOR, INDUCTION_ONLY, INACTIVE) based on: - Perpendicular distance from segment line to pixel surface (point-to-box distance) - Expected diffusion spread (:math:`\sigma_T = \sqrt{2 * D_T * t_\mathrm{drift}}`) - Far-field induction signal str...
DUNE/larnd-sim
larndsim/far_field/pixel_classifier.py
.py
4d61512863fc9157
7.54
11
""" Signal calculation module for far field """ from functools import lru_cache import math from typing import Any, Optional import numpy as np import cupy as cp import cupy.typing as cpt import numba as nb from numba import cuda from larndsim.consts import detector, ff_induction, sim @cuda.jit def calculate_ff_vo...
DUNE/larnd-sim
larndsim/far_field/signal_calculation.py
.py
d934b5660be2dff3
7.54
11
""" Module that simulates the scattering of photons throughout the detector from the location of the edep to the location of each photodetector """ import numba as nb from numba import cuda #from .consts import light #from .consts.light import OP_CHANNEL_EFFICIENCY, OP_CHANNEL_TO_TPC #from .consts.detector import TP...
DUNE/larnd-sim
larndsim/lightLUT.py
.py
10c2e70538ac7534
7.54
11
import cupy as cp import numpy as np from math import ceil from ..active_volume import select_active_volume class TrackSegmentBatcher(object): """ Base class for LArND-sim simulation batching, implements an iterator that creates masks into an array of track segments """ def __init__(self, all_track_seg, ...
DUNE/larnd-sim
larndsim/util/batching.py
.py
0cbaca7d733dd16d
7.54
11
#!/usr/bin/env python import random import numpy as np import pytest from larndsim import detsim class TestTrackCharge: """ Track charge calculation testing """ charge = random.randint(100,1000) start = np.array([random.uniform(-5, 5), random.uniform(-5, 5), random.uniform(-5, 5)]) end = np....
DUNE/larnd-sim
tests/testTrackCharge.py
.py
a7a85d481e1e6ae6
8.04
11
#! /bin/python3 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BASE_URI = '/api/v1...
opalstack/installers
core/django/install.py
.py
ff5078aaade0d423
7.54
11
#! /usr/bin/python3.6 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse import secrets API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') AP...
opalstack/installers
core/etherpad/install.py
.py
168754af8bf26d4c
7.54
11
#! /usr/bin/python3.6 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BASE_URI = '/...
opalstack/installers
core/fastapi/install.py
.py
91d9a060eaafd6ff
7.54
11
#!/usr/local/bin/python3.11 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BASE_UR...
opalstack/installers
core/ghost/install.py
.py
78b79566631d5d72
7.54
11
#! /usr/bin/python3 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BASE_URI = '/ap...
opalstack/installers
core/gitea/install.py
.py
4088f40e9dd969bc
7.54
11
#! /usr/bin/python3.6 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse import re API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BAS...
opalstack/installers
core/laravel/install.py
.py
5ede0690dbb01fc8
7.54
11
#! /usr/bin/python3.6 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BASE_URI = '/...
opalstack/installers
core/nextjs/install.py
.py
30b5b3c32672a465
7.54
11
#! /usr/bin/python3.6 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BASE_URI = '/...
opalstack/installers
core/node/install.py
.py
10300acc48409695
7.54
11
#!/usr/bin/env python3 """ Opalstack Installer for MCP VibeSHEL This installer sets up the MCP VibeSHEL PHP server, which enables AI assistants to securely interact with files on your Opalstack account via the Model Context Protocol (MCP). Requirements: - Opalstack account with an Nginx/PHP-FPM (NPF) application - PH...
opalstack/installers
core/php_mcp/install.py
.py
5fff28a398271e85
7.54
11
#! /bin/python3 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BASE_URI = '/api/v1...
opalstack/installers
el9/django/install.py
.py
91ef990f0956d386
7.54
11
#! /usr/bin/python3 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BASE_URI = '/ap...
opalstack/installers
el9/forgejo/install.py
.py
22e7f3cacaffaec4
7.54
11
#!/usr/local/bin/python3.13 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random import time from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://')...
opalstack/installers
el9/ghost/install.py
.py
5be464e43fc87123
7.54
11
#! /usr/bin/python3 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BASE_URI = '/ap...
opalstack/installers
el9/gitea/install.py
.py
db90221764858bc8
7.54
11
#! /bin/python3 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse import re API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') API_BASE_URI ...
opalstack/installers
el9/laravel/install.py
.py
0fada05350fe38ab
7.54
11
#!/usr/local/bin/python3.13 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random import time import re from urllib.parse import urlparse API_HOST = os.environ.get("API_URL", "").strip().strip("https:...
opalstack/installers
el9/matrix/install.py
.py
a4c7f698929886e9
7.54
11
#!/usr/local/bin/python3.13 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random import time from urllib.parse import urlparse API_HOST = os.environ.get("API_URL").strip("https://").strip("http://") ...
opalstack/installers
el9/n8n/install.py
.py
7cc7db02fb4df950
7.54
11
#! /bin/python3 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse import time CMD_ENV = {} def install_package( import_name, package_name=None, max_...
opalstack/installers
el9/nextjs/install.py
.py
d013f58b41e1d922
7.54
11
#!/bin/python3 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random from urllib.parse import urlparse import time CMD_ENV = None def install_package( import_name, package_name=None, max...
opalstack/installers
el9/node22/install.py
.py
8ecf7ceeefb771d8
7.54
11
#!/usr/local/bin/python3.13 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random import time from urllib.parse import urlparse DEFAULT_API_HOST = "api.opalstack.com" API_URL_ENV = os.environ.get("API...
opalstack/installers
el9/openclaw/install.py
.py
0cf40d4d860936dd
7.54
11
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Discourse installer for the Opalstack platform (no Docker). - Mirrors the style/flow of the Mastodon installer. - Creates DB via Opalstack API, fetches tagged Discourse, installs deps, writes configs and helper scripts, notifies API. Notes: - Modern Discourse uses ...
opalstack/installers
el9/podman/discourse.py
.py
d191bda76939a8f5
7.54
11
#!/usr/local/bin/python3.13 import argparse import sys import logging import os import http.client import json import textwrap import secrets import string import subprocess import shlex import random import time from urllib.parse import urlparse API_HOST = os.environ.get('API_URL').strip('https://').strip('http://') ...
opalstack/installers
el9/podman/minio.py
.py
548c31a5e3b67279
7.54
11
#! /bin/python3 import argparse import sys import logging import os import http.client import json import secrets import string import subprocess import shlex import random import time import shutil API_HOST = os.environ.get("API_URL").strip("https://").strip("http://") API_BASE_URI = "/api/v1" CMD_ENV = { "PATH"...
opalstack/installers
el9/wagtail/install.py
.py
4d9dfb5db631c9c2
7.54
11
"""The publication claim boundary, enforced on generated text. **This module is the reason the agentic layer is safe to build.** Every agent here turns frozen evidence into prose, and prose is the easiest way in this entire programme to make a claim the evidence does not support. Appendix A of the Research Execution H...
DebalekhaChakraborty/CardioSentinel
src/cardiosentinel/agents/claims.py
.py
5ab35eced4f7f4d6
7.57
13
"""The Explanation Context Builder: what a language model is allowed to see. The evidence graph for one alert is 35 nodes and 39 edges. Handing all of it to a model is the RAG failure mode in miniature -- give it everything and it will narrate whatever correlation it notices. This module decides what the model sees, a...
DebalekhaChakraborty/CardioSentinel
src/cardiosentinel/agents/context.py
.py
6a3ac4f9988b7ebd
7.57
13
"""The four metrics of the evaluation protocol §3. Every one is computed from the explanation text and the `ExplanationContext` that produced it. Nothing here needs a model, a network, or a credential. """ from __future__ import annotations import re from dataclasses import asdict, dataclass from typing import Any ...
DebalekhaChakraborty/CardioSentinel
src/cardiosentinel/agents/evaluation/metrics.py
.py
e9e7eb7672e2a0f0
7.57
13
"""The Evidence Agent: why did CardioSentinel raise this alert? **No language model.** Every field is read from an `AlertEvent`, the `EdgeObservation`s it spans, and the frozen provenance the session carried. The agent assembles and renders; it does not infer, summarise or judge. That is deliberate: this is the layer ...
DebalekhaChakraborty/CardioSentinel
src/cardiosentinel/agents/evidence.py
.py
375f8df2e4c7dabc
7.57
13
"""The Patient Explanation Agent: language over evidence, never instead of it. **The generator is a communication layer, not a source of truth.** The chain is sensor -> runtime -> evidence -> explanation, and only the last hop is generative. If the model is unavailable, unconfigured, slow, or produces something that b...
DebalekhaChakraborty/CardioSentinel
src/cardiosentinel/agents/explain.py
.py
05a96cf2c863545d
7.57
13
"""Generator adapters. Optional, replaceable, and never required. Each adapter is a thin translation from `ExplanationProvider` onto a vendor SDK. They are constructed lazily and import their SDK inside the constructor, so a machine without the package -- or without credentials -- degrades to the deterministic rendere...
DebalekhaChakraborty/CardioSentinel
src/cardiosentinel/agents/providers.py
.py
3eaa45b0aa6941e5
7.57
13
"""Pinned LTSTDB V1 source acquisition and checksum verification.""" from __future__ import annotations import re from datetime import datetime, timezone from pathlib import Path from typing import Any, Iterable from cardiosentinel.baseline.cache import ( read_json, require_nonversioned_path, write_json_...
DebalekhaChakraborty/CardioSentinel
src/cardiosentinel/baseline/source.py
.py
7ab6ec62062775a1
7.57
13
"""Dataset source identity, file hashing, and run provenance helpers.""" from __future__ import annotations import hashlib import subprocess import sys from pathlib import Path from typing import Iterable from cardiosentinel import __version__ def sha256_file(path: Path) -> str: """Return a SHA-256 digest with...
DebalekhaChakraborty/CardioSentinel
src/cardiosentinel/data/provenance.py
.py
8d59d20f0add93eb
7.57
13
"""Column budget adjustment quantities.""" from typing import cast import numpy as np import windspharm.xarray import xarray as xr from .names import LAT_STR, LON_STR, TIME_STR def uv_col_budg_adj( u_col_int: xr.DataArray, v_col_int: xr.DataArray, tendency: xr.DataArray, source: xr.DataArray, l...
spencerahill/puffins
puffins/budget_adj.py
.py
2bcfe002642170ac
7.42
6
"""Functionality relating to calendars, times, and dates.""" from typing import cast, overload import numpy as np import xarray as xr from .names import TIME_STR months = dict( jan=1, feb=2, mar=3, apr=4, may=5, jun=6, jul=7, aug=8, sep=9, oct=10, nov=11, dec=12, ) se...
spencerahill/puffins
puffins/dates.py
.py
9b99dbd667eb7c96
7.42
6
#! /usr/bin/env python """Functions for interpolation.""" from __future__ import annotations from collections.abc import Iterable from typing import TYPE_CHECKING, cast import numpy as np import xarray as xr if TYPE_CHECKING: from xarray.core.types import InterpOptions from .names import ( BK_STR, LAT_...
spencerahill/puffins
puffins/interp.py
.py
bc4f0e8d58e88850
7.42
6
"""Kuo-Eliassen equation solver and related functionality.""" import numpy as np import xarray as xr from .calculus import _check_uniform_spacing, lat_deriv from .constants import C_P, GRAV_EARTH, P0, R_D, RAD_EARTH, ROT_RATE_EARTH from .dynamics import coriolis_param from .names import LAT_STR, LEV_STR, SIGMA_STR fr...
spencerahill/puffins
puffins/kuo_el.py
.py
8f861c156a897542
7.42
6
#!/usr/bin/env python """Functionality relating to parsing and comparing longitudes.""" from __future__ import annotations from collections.abc import Callable from typing import Any import numpy as np import xarray as xr from ._typing import ArrayLike def lon_to_0360(lon: ArrayLike) -> ArrayLike: """Convert ...
spencerahill/puffins
puffins/longitude.py
.py
2086a2d11a371189
7.42
6
#! /usr/bin/env python """Utility functions useful for interactive work in Jupyter notebooks.""" import subprocess from glob import glob import numpy as np import xarray as xr from .constants import RAD_EARTH from .names import DAY_OF_YEAR_STR, LAT_STR, TIME_STR # Coordinate arrays. def coord_arr_1d( start=Non...
spencerahill/puffins
puffins/nb_utils.py
.py
b8677f9013e8c7a0
7.42
6
#! /usr/bin/env python """Numerical solvers.""" from collections.abc import Callable, Sequence from typing import Any, cast import numpy as np import scipy import xarray as xr from puffins._typing import SolverGuessRange, SolverParamRange def brentq_solver_sweep_param( func: Callable[..., float], param_ran...
spencerahill/puffins
puffins/num_solver.py
.py
7c90ef3560ba9180
7.42
6
#! /usr/bin/env python """Expressions from Plumb and Hou 1992.""" import numpy as np import xarray as xr from .constants import GRAV_EARTH, RAD_EARTH, ROT_RATE_EARTH, THETA_REF from .grad_bal import grad_wind_bouss from .nb_utils import cosdeg, sindeg def pot_temp_rce_ph92( lat, theta_max_factor, lat_max=25, no...
spencerahill/puffins
puffins/plumb_hou_1992.py
.py
88006f7f0dd424c8
7.42
6
"""Tests for the bootstrap module.""" import numpy as np import pytest import xarray as xr from puffins.bootstrap import ( boot_risk_ratio, bootstrap_samples, corr_bootstrap, corr_sig_nonzero_bootstrap, corr_sig_nonzero_from_full_and_boot, perm_risk_ratio, ) from puffins.stats import risk_rati...
spencerahill/puffins
puffins/tests/test_bootstrap.py
.py
82b4acde947d80fd
7.92
6
"""Tests for dates module.""" import numpy as np import pytest import xarray as xr from puffins.dates import ( ann_harm, ann_subset_ts, ann_subsets, ann_ts_djf, monthly_anom, subset_ann, time_to_year_and_day, ) @pytest.fixture def monthly_ts() -> xr.DataArray: """3-year monthly time ...
spencerahill/puffins
puffins/tests/test_dates.py
.py
59257170e430a068
7.92
6
"""Tests for the eofs module.""" import numpy as np import xarray as xr from eofs.xarray import Eof from puffins.eofs import eof_solver_lat from puffins.names import LAT_STR, LON_STR, YEAR_STR def _lat_lon_coords(nlat: int = 13, nlon: int = 12) -> tuple[np.ndarray, np.ndarray]: """Latitudes bounded away from th...
spencerahill/puffins
puffins/tests/test_eofs.py
.py
d0cb8a941dc5f682
7.92
6
"""Tests for the held_hou_1980 module. Held & Hou (1980), "Nonlinear Axially Symmetric Circulations in a Nearly Inviscid Atmosphere", J. Atmos. Sci., 37, 515-533. Each function with a closed-form expression carries at least one known-value test that reconstructs the expected output from raw numpy (not from the module...
spencerahill/puffins
puffins/tests/test_held_hou_1980.py
.py
04251cf112233e87
7.92
6
"""Tests for hides module.""" import numpy as np import xarray as xr from puffins.constants import RAD_EARTH, ROT_RATE_EARTH from puffins.hides import ( _flip_dim, _flip_lats, _maybe_flip_lats, hides_above_eq_mom, hides_negative, hides_vort_zero_cross, ) from puffins.names import LAT_STR def...
spencerahill/puffins
puffins/tests/test_hides.py
.py
4d11c0f25fe2b03d
7.92
6
"""Tests for kuo_el module.""" import numpy as np import pytest import xarray as xr from puffins.kuo_el import _check_uniform_spacing class TestCheckUniformSpacing: """Tests for _check_uniform_spacing.""" def test_uniform_spacing_passes(self) -> None: """Uniform spacing should not raise.""" ...
spencerahill/puffins
puffins/tests/test_kuo_el.py
.py
2f40983dad2e1c19
7.92
6
"""Tests for the plotting module.""" from collections.abc import Iterator import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt # noqa: E402 import numpy as np # noqa: E402 import pytest # noqa: E402 import xarray as xr # noqa: E402 from puffins.plotting import ( # noqa: E402 band_colors...
spencerahill/puffins
puffins/tests/test_plotting.py
.py
82c176be8e810364
7.92
6
from django.contrib.auth.models import AbstractUser, BaseUserManager from django.db import models from django.utils.translation import gettext_lazy as _ class UserManager(BaseUserManager): """Define a model manager for User model with no username field.""" use_in_migrations = True def _create_user(self,...
one-zero-eight/sport
adminpage/accounts/models.py
.py
2020b25f516f16ff
7.48
8
import json from datetime import datetime, timedelta from typing import List import requests import jwt from jwt.algorithms import RSAAlgorithm from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey from django.conf import settings from django.contrib.auth import get_user_model from rest_framework impo...
one-zero-eight/sport
adminpage/adminpage/authentication.py
.py
a185fa21142ab294
7.48
8
from typing import List, Dict from django.db import transaction, connection from api.crud import dictfetchall from sport.models import Student, Enroll, Group @transaction.atomic def enroll_student(group: Group, student: Student): """ Enrolls given student in a group """ Enroll.objects.create(studen...
one-zero-eight/sport
adminpage/api/crud/crud_enrolled.py
.py
e87ebcf5ae0146d4
7.48
8
from typing import Optional from django.conf import settings from django.db import connection from django.db.models import F from django.db.models import Q from django.db.models import Count, Sum, IntegerField import api.crud from api.crud.utils import dictfetchall, get_trainers_group from api.crud.crud_semester impo...
one-zero-eight/sport
adminpage/api/crud/crud_groups.py
.py
c844b1ad9e95402d
7.48
8
from typing import List from sport.models import Semester def get_ongoing_semester() -> Semester: """ Retrieves current ongoing semester @return ongoing semester """ return Semester.objects.raw('SELECT * FROM semester WHERE id = current_semester()')[0] def get_semester_crud(current: bool, with_f...
one-zero-eight/sport
adminpage/api/crud/crud_semester.py
.py
26ca2792e365c527
7.48
8
from django.db import connection from django.db.models import F from django.db.models import Q from django.db.models import Value from django.db.models.functions import Concat from api.crud.utils import dictfetchall from sport.models import Student, Group def get_email_name_like_students(pattern: str, limit: int = 5...
one-zero-eight/sport
adminpage/api/crud/crud_users.py
.py
8cbb09aac3cabffa
7.48
8
from django.db.models import F from django.db.models.expressions import Subquery from django.db.models.fields import IntegerField from sport.models import Training, Group class SumSubquery(Subquery): output_field = None def __init__(self, queryset, sum_by, output_field=IntegerField(), **extra): super...
one-zero-eight/sport
adminpage/api/crud/utils.py
.py
1d239e9978ae8625
7.48
8
"""Pipeline to run Lightning Pose on a single IBL video with trained networks.""" import logging import shutil import sys from pathlib import Path import cv2 import numpy as np import pandas as pd import torch from lightning_pose.utils.predictions import _create_labeled_video as create_labeled_video from moviepy impo...
int-brain-lab/iblvideo
iblvideo/pose_lp.py
.py
965756cf2dcecbb3
7.48
8
"""Helper functions to run Lightning Pose on a single IBL video with trained networks.""" import gc import os from pathlib import Path import lightning.pytorch as pl import numpy as np import nvidia.dali.fn as fn import nvidia.dali.types as types import pandas as pd import torch import yaml from eks.ibl_pupil_smoothe...
int-brain-lab/iblvideo
iblvideo/pose_lp_utils.py
.py
ffe88354d7d61864
7.48
8
"""Pipeline to run Lightning Action on a single IBL video with trained networks.""" import logging import shutil import sys from pathlib import Path import pandas as pd from iblvideo import download_la_models from iblvideo.params_lp import LEFT_VIDEO, RIGHT_VIDEO from iblvideo.segmentation_la_utils import analyze_vi...
int-brain-lab/iblvideo
iblvideo/segmentation_la.py
.py
7ff485083cbe1332
7.48
8
"""Helper functions for running Lightning Action on IBL pose and wheel data.""" import logging import sys from pathlib import Path import numpy as np import pandas as pd from lightning_action.api import Model from scipy.interpolate import interp1d from scipy.signal import butter, sosfiltfilt logging.basicConfig(stre...
int-brain-lab/iblvideo
iblvideo/segmentation_la_utils.py
.py
8c8cefe6daaeb8e2
7.48
8
import cv2 import numpy as np import subprocess import alf.io from one.api import ONE from pathlib import Path import os import time import logging _logger = logging.getLogger('ibllib') ''' For a session where there is DLC already computed, load DLC traces to cut video ROIs and then compute motion energy for these R...
int-brain-lab/iblvideo
prototyping/motion_energy_pipeline.py
.py
9e7027c97d493bb3
7.48
8
import numpy as np from one.api import ONE def get_dlc_XYs(eid, video_type, query_type='remote'): #video_type = 'left' Times = one.load_dataset(eid,f'alf/_ibl_{video_type}Camera.times.npy', query_type=query_type) cam = one.load_dataset(eid,f'alf/_ibl_{video_type}Camera.d...
int-brain-lab/iblvideo
prototyping/post_dlc/licking.py
.py
b0a0ed673cc436e1
7.48
8
import numpy as np from one.api import ONE from scipy.interpolate import interp1d def get_dlc_XYs(one, eid, view, likelihood_thresh=0.9): dataset_types = ['camera.dlc', 'camera.times'] try: times = one.load_dataset(eid, '_ibl_%sCamera.times.npy' % view) cam = one.load_dataset(eid, '_ibl_%sCame...
int-brain-lab/iblvideo
prototyping/post_dlc/pupil_diameter.py
.py
d9d2405dd810a2b4
7.48
8
""" Batch process multiple sessions by calling process_single_session.py for each EID. Sessions will run sequentially on the current node: python run_task.py --eid_file eids.txt --list 0,2,5,8 --run_lp --run_post_lp --cameras left right body python run_task.py --eid_file eids.txt --list 0-14 --run_la --run_pos...
int-brain-lab/iblvideo
scripts/lightning/run_task.py
.py
1e7edbb7a1b25fe9
7.48
8
"""Tests for the pose_lp module.""" import gc import multiprocessing import shutil import numpy as np import pandas as pd import torch from iblvideo.pose_lp import lightning_pose from iblvideo.weights import download_lp_models from tests.download_test_data import _download_lp_test_data def _run_test_in_process(cam...
int-brain-lab/iblvideo
tests/test_pose_lp.py
.py
c94fdfae02cd9c74
7.98
8
# -*- coding: utf-8 -*- import pytest # type: ignore from nisystemlink.clients import core from nisystemlink.clients.core._uplink._json_model import JsonModel from pydantic import Extra def pytest_addoption(parser): """Register command line flags that tell us how to connect to the web server. Note that com...
ni/nisystemlink-clients-python
conftest.py
.py
7382659cd82724ce
8.02
10
# -*- coding: utf-8 -*- """Sphinx extension to clean up autodoc output.""" import inspect import re import docutils.nodes as nodes def _skip_member(app, what, name, obj, skip, options): # When ":meta private:" or ":meta public:" is explicitly included in the docstr, # obey it, regardless of what autodoc ot...
ni/nisystemlink-clients-python
docs/cleanup.py
.py
b70d2eb0698f00b7
7.52
10
from nisystemlink.clients.core import HttpConfiguration from nisystemlink.clients.testmonitor import TestMonitorClient from nisystemlink.clients.testmonitor.models import ( CreateResultRequest, QueryResultsRequest, QueryResultValuesRequest, ResultField, Status, StatusType, UpdateResultReques...
ni/nisystemlink-clients-python
examples/testmonitor/results.py
.py
0ec46734af0ec467
7.02
10
from typing import cast from nisystemlink.clients.core import HttpConfiguration from nisystemlink.clients.testmonitor import TestMonitorClient from nisystemlink.clients.testmonitor.models import ( CreateResultRequest, CreateStepRequest, Measurement, NamedValue, QueryStepsRequest, QueryStepValue...
ni/nisystemlink-clients-python
examples/testmonitor/steps.py
.py
bc98dd792295d473
7.02
10
"""Collaborative filtering model implemented in PyTorch.""" from __future__ import annotations import argparse import logging import sys import tempfile from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING import polars as pl import torch # type: ignore[import-not-found] from ...
recommend-games/board-game-recommender
src/board_game_recommender/dnn.py
.py
5b87dd5623a5482a
7.6
15
"""Evaluate recommender models.""" from __future__ import annotations import logging from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING import numpy as np import polars as pl if TYPE_CHECKING: import os from collections.abc import Iterable from board_game_recomm...
recommend-games/board-game-recommender
src/board_game_recommender/evaluation.py
.py
482d8e9f05010ebb
7.6
15
"""Light recommender model, without the heavy Turi Create dependency.""" from __future__ import annotations import logging from collections import defaultdict from collections.abc import Iterable from dataclasses import asdict, dataclass from pathlib import Path from typing import TYPE_CHECKING import numpy as np f...
recommend-games/board-game-recommender
src/board_game_recommender/light.py
.py
24003e044ef0f5df
7.6
15
"""Tests for the package's public API.""" from __future__ import annotations import importlib import pkgutil import board_game_recommender def test_public_api_is_importable() -> None: """Every name in __all__ can actually be imported from the package.""" for name in board_game_recommender.__all__: ...
recommend-games/board-game-recommender
tests/test_api.py
.py
82731914305fca5f
8.1
15
"""Tests for the evaluation harness.""" from __future__ import annotations import json import math from typing import TYPE_CHECKING import numpy as np import polars as pl import pytest from board_game_recommender.evaluation import ( RecommenderTestData, calculate_metrics, effective_catalog_size, loa...
recommend-games/board-game-recommender
tests/test_evaluation.py
.py
2c1b331683efb219
8.1
15
"""Tests for the light recommender's similarity methods.""" from __future__ import annotations import math from typing import TYPE_CHECKING import numpy as np import pytest from board_game_recommender.light import ( CollaborativeFilteringData, LightGamesRecommender, cosine_similarity, ) if TYPE_CHECKIN...
recommend-games/board-game-recommender
tests/test_light.py
.py
724ac5d1c0c7c13a
8.1
15