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 |
|---|---|---|---|---|---|---|
##
#
# File: ChemCompImageWorkflowTests.py
# Author: jdw
# Date: 10-Mar-2020
# Version: 0.001
#
# Updates:
##
"""
A collection of tests chemical component image generation workflows
"""
__docformat__ = "google en"
__author__ = "John Westbrook"
__email__ = "jwest@rcsb.rutgers.edu"
__license__ = "Creative Commons... | rcsb/py-rcsb_workflow | rcsb/workflow/tests/testChemCompImageWorkflow.py | .py | fc146fd649d63ce1 | 7.8 | 3 |
##
#
# File: testChemCompSearchIndexWorkflow.py
# Author: jdw
# Date: 10-Mar-2020
# Version: 0.001
#
# Updates:
##
"""
A collection of tests chemical component index generation workflows
"""
import logging
import os
import platform
import resource
import time
import unittest
from importlib.metadata import vers... | rcsb/py-rcsb_workflow | rcsb/workflow/tests/testChemCompSearchIndexWorkflow.py | .py | 33041469f9b99a0c | 7.8 | 3 |
##
# File: ExDbWorkflowTests.py
# Author: J. Westbrook
# Date: 17-Dec-2019
# Version: 0.001
#
# Updates:
# 31-Jan-2025 mjt Moved this script from rcsb.exdb (to remove circluar dependencies)
#
##
"""
Tests for simple workflows to excute ExDB loading operations.
"""
__docformat__ = "google en"
__author__ = "John... | rcsb/py-rcsb_workflow | rcsb/workflow/tests/testExDbWorkflow.py | .py | cd6343ab9ddd7d44 | 7.8 | 3 |
##
# File: testLigandQualityReferenceGenerator.py
# Date: 2025-12-25 Chenghua Shao
#
# Update:
##
"""
Unit tests for LigandQualityReferenceGenerator.py
"""
import json
import logging
import os
import platform
import resource
import time
import unittest
from rcsb.workflow.refstats.LigandQualityRef... | rcsb/py-rcsb_workflow | rcsb/workflow/tests/testLigandQualityReferenceGenerator.py | .py | 5a25ae3e1452a492 | 7.8 | 3 |
##
# File: testResidueRsccReferenceGenerator.py
# Date: 2025-12-25 Chenghua Shao
#
# Update:
##
"""
Unit tests for ResidueRsccReferenceGenerator.py
"""
import json
import logging
import os
import platform
import resource
import time
import unittest
from rcsb.utils.config.ConfigUtil import ConfigU... | rcsb/py-rcsb_workflow | rcsb/workflow/tests/testResidueRsccReferenceGenerator.py | .py | 03a64d2d0a47814a | 7.8 | 3 |
##
# File: BcifWorkflow.py
# Author: James Smith
# Date: 21-Feb-2025
##
"""
Run workflow for pdb entries specified in input list.
"""
__docformat__ = "google en"
__author__ = "James Smith"
__email__ = "james.smith@rcsb.org"
__license__ = "Apache 2.0"
import os
import logging
from rcsb.workflow.bcif.task_funct... | rcsb/py-rcsb_workflow | rcsb/workflow/wuw/BcifWorkflow.py | .py | 786317d96491c289 | 7.3 | 3 |
"""Images workflow functions that actually do the work."""
##
# File: PdbCsmImageWorkflow.py
# Date: 11-Dec-2024 mjt
#
# Pdb and Csm image generation - for workflow pipeline
#
# Updates:
# 12-Dec-2024 mjt Created class object
#
##
__docformat__ = "google en"
__author__ = "Michael Trumbull"
__email__ = "michael.tru... | rcsb/py-rcsb_workflow | rcsb/workflow/wuw/PdbCsmImageWorkflow.py | .py | bc6d6779f0b5f548 | 7.3 | 3 |
"""Extension of scikit-learn TfidfVectorizer and CountVectorizer that allows for online learning
Original module: https://github.com/idoshlomo/online_vectorizers
Re-imported here to avoid using submodules
"""
import logging
from collections import defaultdict
from itertools import chain
import numpy as np
import sci... | nicoloverardo/matrix_regression | matrixreg/online_vectorizers.py | .py | f411d18d0550b046 | 7 | 0 |
##
# File: BatchChemSearchWrapperTests.py
# Author: jdw
# Date: 1-Mar-2021
# Version: 0.001
#
# Updates:
#
##
"""
Wrapper for batch chemical search operations.
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "john.westbrook@rcsb.org"
__license__ = "Apache 2.0"
import logging... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/BatchChemSearch.py | .py | 7211a1cf517fabeb | 7.15 | 1 |
##
# File: CactvsMoleculeFactory.py
# Author: jdw
# Date: 25-Jan-2020
# Version: 0.001
#
# Updates:
# 16-Feb-2026 dwp Replace deprecated pkg_resources with importlib
#
##
"""
Classes to build CACTVS molecule objects data from chemical componenet data.
"""
__docformat__ = "restructuredtext en"
__author__ = "Jo... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/CactvsMoleculeFactory.py | .py | 2b9f125c534e2243 | 7.15 | 1 |
##
# File: ChemCompDepictWrapper.py
# Author: jdw
# Date: 9-Mar-2020
# Version: 0.001
#
# Updates:
# 24-Jun-2020 jdw make api follow the style of ChemCompSearchWrapper()
##
"""
Wrapper for chemical component depiction operations.
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/ChemCompDepictWrapper.py | .py | 2a5777c03c685821 | 7.15 | 1 |
##
# File: ChemCompIndexProvider.py
# Author: J. Westbrook
# Date: 16-Feb-2020
#
# Updates:
# 6-Feb-2024 dwp Suppress errors logged for UNL (UNknown Ligand) chemical component.
##
"""
Utilities to read and process an index of PDB chemical component definitions.
"""
__docformat__ = "restructuredtext en"
__autho... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/ChemCompIndexProvider.py | .py | 5935fe9f15766f8f | 7.15 | 1 |
##
# File: ChemCompMoleculeProvider.py
# Author: J. Westbrook
# Date: 16-Feb-2020
#
# Updates:
# 26-Aug-2021 jdw add file for obsolete component definitions
##
"""
Utilities to read and serialize the dictionary of PDBx/mmCIF chemical component definitions.
"""
__docformat__ = "restructuredtext en"
__author__ = ... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/ChemCompMoleculeProvider.py | .py | bbdcb9d8aa05ba2e | 7.15 | 1 |
##
# File: ChemCompSearchIndexProvider.py
# Author: J. Westbrook
# Date: 3-Mar-2020
#
# Updates:
# 13-Mar-2020 jdw Add formula index search method.
# 6-Feb-2024 dwp Suppress errors logged for UNL (UNknown Ligand) chemical component.
##
"""
Utilities to read and process a search index of PDB chemical component... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/ChemCompSearchIndexProvider.py | .py | 78031cd1c42b9e1c | 7.15 | 1 |
##
# File: IoUtils.py
# Author: jdw
# Date: 31-Dec-2019
# Version: 0.001
#
# Updates:
#
##
"""
Utilities to manage general component IO and format conversion operations.
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "john.westbrook@rcsb.org"
__license__ = "Apache 2.0"
impo... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/IoUtils.py | .py | c300f906dfa85a72 | 7.15 | 1 |
##
# File: MolecularFormula.py
# Date: 14-Mar-2020
#
# Adapted from recipe a recipe posted by at:
# https://github.com/Zapaan/python-chemical-formula-parser
##
import logging
import re
from collections import Counter
logger = logging.getLogger(__name__)
class MolecularFormula(object):
def __init__(self):
... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/MolecularFormula.py | .py | 55072767e6ef3202 | 7.15 | 1 |
##
# File: MoleculeAnnotationsCompare.py
# Author: jdw
# Date: 31-Dec-2019
# Version: 0.001
#
# Updates:
#
##
"""
Utilities to compare molecular feature annotations.
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "john.westbrook@rcsb.org"
__license__ = "Apache 2.0"
import l... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/MoleculeAnnotationsCompare.py | .py | 13a125863d0ea7ee | 7.15 | 1 |
##
# File: ObMoleculeFactory.py
# Author: jdw
# Date: 11-Jan-2020
# Version: 0.001
#
# Updates:
#
##
# flake8: noqa
# pylint: skip-file
"""
Classes to build OpenBabel molecule objects from chemical component definition data.
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "jo... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/ObMoleculeFactory.py | .py | d1cdd4af234a58cd | 7.15 | 1 |
##
# File: OeChemCompUtils.py
# Author: jdw
# Date: 17-Jan-2021
# Version: 0.001
#
# Updates:
#
#
##
"""
Utilities to build chemical component definitions from OE molecule objects.
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "jwest@rcsb.rutgers.edu"
__license__ = "Creativ... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/OeChemCompUtils.py | .py | 3e2aac9cb41215bf | 7.15 | 1 |
##
# File: OeCommonUtils.py
# Date: 22-Oct-2020
#
# Updates:
#
# 1-Mar-2021 jdw Move aromaticity constrain to relaxed criteria and add additional
# contraints to strict criteria (degree and ring membership) and
# add an exact criteria which further adds the hcount constraint to
# ... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/OeCommonUtils.py | .py | 802ff15ac270e451 | 7.15 | 1 |
##
# File: OeDepict.py
# Date: 25-Oct-2019 J. Westbrook adapted from earlier code module.
#
# Updates:
# 2-April-2020 jdw enlarge the base image size to avoid dropping labels.
# Tweak stereo style to include W/H but avoid undefined stereo marking
#
##
"""
Utilities to depict individual OE molecul... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/OeDepict.py | .py | 0d369a480a12ecb4 | 7.15 | 1 |
##
# File: OeMoleculeProvider.py
# Author: J. Westbrook
# Date: 24-Oct-2019
#
# Updates:
# 28-Oct-2019 jdw incorporate all of the public Bird cc definitions
##
"""
Utilities deliver OE molecule data for PDB chemical component definitions
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/OeMoleculeProvider.py | .py | 94995ba0fc0efef7 | 7.15 | 1 |
##
# File: OeSearchMoleculeProvider.py
# Author: J. Westbrook
# Date: 4-Mar-2020
#
# Updates:
#
##
"""
Utilities deliver OE molecule data for searchable chemical component data.
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "john.westbrook@rcsb.org"
__license__ = "Apache 2.0... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/OeSearchMoleculeProvider.py | .py | 008b17118363c1a8 | 7.15 | 1 |
##
# File: OeSearchUtils.py
# Author: jdw
# Date: 22-Oct-2019
# Version: 0.001
#
# Updates:
#
##
"""
Utilities to manage OE specific similarity search (match) operations.
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "john.westbrook@rcsb.org"
__license__ = "Apache 2.0"
im... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/OeSearchUtils.py | .py | ff4465b6acd66cd5 | 7.15 | 1 |
##
# File: OeSubStructSearchUtils.py
# Author: jdw
# Date: 2-Oct-2020
# Version: 0.001
#
# Updates:
#
##
"""
Utilities to manage OE specific substructure search operations (w/ formula/feature prefiltering)
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "john.westbrook@rcsb.o... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/OeSubStructSearchUtils.py | .py | b33a815b7abb67fe | 7.15 | 1 |
##
# File: RdMoleculeFactory.py
# Author: jdw
# Date: 1-Jan-2020
# Version: 0.001
#
# Updates:
#
##
# flake8: noqa
# pylint: skip-file
"""
Classes to build RdKit molecule objects from chemical component definition data.
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "john.we... | rcsb/py-rcsb_utils_chem | rcsb/utils/chem/RdMoleculeFactory.py | .py | 59477a013d3417d5 | 7.15 | 1 |
##
# File: BatchChemSearchTests.py
# Author: J. Westbrook
# Date: 3-Mar-2021
# Version: 0.001
#
# Update:
#
#
##
"""
Tests for batch search mode.
"""
import logging
import os
import platform
import resource
import time
import unittest
from importlib.metadata import version as get_package_version
from rcsb.util... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testBatchChemSearch.py | .py | 3c15b50edabd4d73 | 7.65 | 1 |
##
# File: CactvsMolecularFactoryTests.py
# Author: jdw
# Date: 25-Jan-2020
# Version: 0.001
#
# Updates:
#
##
"""
A collection of tests of CactvsMolecularFactory to compare assigned and computed features.
"""
import logging
import os
import unittest
from rcsb.utils.chem.IoUtils import IoUtils
from rcsb.utils.... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testCactvsMoleculeFactory.py | .py | 3e5e3cdba8f4b256 | 7.65 | 1 |
##
# File: ChemAxonDescriptorProviderTests.py
# Author: J. Westbrook
# Date: 17-Aug-2021
# Version: 0.001
#
# Update:
#
#
##
"""
Utilities to deliver ChemAxon rendered chemical descriptors for chemical component definitions.
"""
import logging
import os
import platform
import resource
import time
import unittest... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testChemAxonDescriptorProvider.py | .py | b0cdec997ec902be | 7.65 | 1 |
##
# File: ChemCompIndexProviderTests.py
# Author: J. Westbrook
# Date: 17-Feb-2020
# Version: 0.001
#
# Update:
#
#
##
"""
Tests for utilities to read and process an index of PDB chemical component definitions.
"""
import logging
import os
import platform
import resource
import time
import unittest
from impor... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testChemCompIndexProvider.py | .py | 10bdfe80208975c5 | 7.65 | 1 |
##
# File: ChemCompMoleculeProviderTests.py
# Author: J. Westbrook
# Date: 1-Oct-2019
# Version: 0.001
#
# Update:
# 5-Mar-2020 jdw all cases including filtered subsets working with naming prefixes.
#
##
"""
Tests for utilities to read and process the dictionary of PDB chemical component definitions.
"""
impor... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testChemCompMoleculeProvider.py | .py | 57291f7fa64a94c7 | 7.65 | 1 |
##
# File: ChemCompSearchIndexProviderTests.py
# Author: J. Westbrook
# Date: 3-Mar-2020
# Version: 0.001
#
# Update:
#
#
##
"""
Tests for utilities to generate a search index for reasonable tautomer and protomer
configurations for core PDB chemical component definitions.
"""
import logging
import os
import pla... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testChemCompSearchIndexProvider.py | .py | 2846414efbd9ab30 | 7.65 | 1 |
##
# File: IoUtilsTests.py
# Author: J. Westbrook
# Date: 1-Oct-2019
# Version: 0.001
#
# Update:
#
#
##
"""
Tests for utilities to read and write chemical component definitions.
"""
import logging
import os
import time
import unittest
from importlib.metadata import version as get_package_version
from rcsb.uti... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testIoUtils.py | .py | 8b96ebae8fa6a70d | 7.65 | 1 |
##
# File: ObMolecularFactoryTests.py
# Author: jdw
# Date: 11-Jan-2020
# Version: 0.001
#
# Updates:
#
##
"""
A collection of tests of ObMolecularFactory to compare assigned and computed features.
"""
import logging
import os
import unittest
from rcsb.utils.chem.IoUtils import IoUtils
try:
from rcsb.util... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testObMoleculeFactory.py | .py | a10479157e0f5fb8 | 7.65 | 1 |
##
# File: OeChemCompTests.py
# Author: jdw
# Date: 28-Oct-2019
# Version: 0.001
#
# Updates:
#
##
"""
A collection of tests of OeChemCompUtils.
"""
import logging
import os
import unittest
from rcsb.utils.chem.ChemCompMoleculeProvider import ChemCompMoleculeProvider
from rcsb.utils.chem.OeChemCompUtils import... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testOeChemCompUtils.py | .py | 347dfe8876ca615d | 7.65 | 1 |
##
#
# File: OeDepictTests.py
# Author: jdw
# Date: 5-May-2013
# Version: 0.001
#
# Updates:
# 4-May-2014 jdw add example for depiction from SMILES input
# 6-Jun-2016 jdw general cleanup
##
"""
A collection of tests for the OEDepict and related classes.
"""
__docformat__ = "restructuredtext en"
__author__ = "... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testOeDepict.py | .py | abbd7ec4e82f5898 | 7.65 | 1 |
##
#
# File: OeDepictAllTests.py
# Author: jdw
# Date: 5-May-2013
# Version: 0.001
#
# Updates:
# 4-May-2014 jdw add example for depiction from SMILES input
# 6-Jun-2016 jdw general cleanup
##
"""
A collection of tests for the OEDepict and related classes.
"""
__docformat__ = "restructuredtext en"
__author__ ... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testOeDepictAll.py | .py | a896c3a78f4eed70 | 7.65 | 1 |
##
# File: OeDepictCompareTests.py
# Author: jdw
# Date: 28-Oct-2019
# Version: 0.001
#
# Updates:
#
##
"""
A collection of tests to compare assigned and computed features.
"""
import logging
import os
import time
import unittest
from collections import defaultdict
from openeye import oechem
from rcsb.utils.ch... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testOeDepictCompare.py | .py | 4312cee714212d05 | 7.65 | 1 |
##
#
# File: OeDepictFromChemTests.py
# Author: jdw
# Date: 5-Mar-2020
# Version: 0.001
#
# Updates:
##
"""
A collection of tests for the OEDepict and related classes working directly from
chemical component definitions
"""
__docformat__ = "restructuredtext en"
__author__ = "John Westbrook"
__email__ = "john.we... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testOeDepictFromChemComp.py | .py | 369da75067ea97fb | 7.65 | 1 |
##
# File: OeOeIoUtilsTests.py
# Author: jdw
# Date: 28-Oct-2019
# Version: 0.001
#
# Updates:
#
##
"""
A collection of tests for OeIoUtils() operations.
"""
import logging
import os
import unittest
from rcsb.utils.chem.ChemCompMoleculeProvider import ChemCompMoleculeProvider
from rcsb.utils.chem.OeIoUtils imp... | rcsb/py-rcsb_utils_chem | rcsb/utils/tests-chem/testOeIoUtils.py | .py | 15a05ea78b5b52cf | 7.65 | 1 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
About
=====
Provides (or will provide) a number of options for smmoothing and noise reduction
of the images before processing.
This applies filters to the whole image
For example:
data_prepare = {"smooth": {"Gaussian": 2},
"cosmics": {},
... | ExperimentalMineralPhysics/Continuous-Peak-Fit | src/cpf/data_preprocess.py | .py | 06d9fd5cf99fb865 | 7.39 | 5 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__all__ = ["histogram1d"]
import matplotlib.pyplot as plt
import numpy as np
import numpy.ma as ma
import pyFAI.engines.histogram_engine as he
from cpf.util.logging import get_logger
logger = get_logger("cpf.histograms")
def calculate_n_bins(data, num_azi_bins=1, ... | ExperimentalMineralPhysics/Continuous-Peak-Fit | src/cpf/histograms.py | .py | 98771fc05478bf1a | 7.39 | 5 |
__all__ = ["Requirements", "WriteOutput"]
import glob
import os
# from cpf.Cascade import read_saved_chunks
import pandas as pd
from cpf.settings import get_settings
from cpf.util.io import make_outfile_name, peak_string
from cpf.util.logging import get_logger
logger = get_logger("cpf.output_types.WriteChunksTable"... | ExperimentalMineralPhysics/Continuous-Peak-Fit | src/cpf/output_formatters/WriteChunksTable.py | .py | 3d08455d756f63a5 | 7.39 | 5 |
__all__ = ["Requirements", "WriteOutput"]
import json
import os
import re
from itertools import product
import numpy as np
import pandas as pd
import cpf.peak_functions as pf
from cpf.output_formatters.fits_io import ReadFits_to_dataframe
from cpf.output_formatters.output_csv import make_header, write_csv
from cpf.... | ExperimentalMineralPhysics/Continuous-Peak-Fit | src/cpf/output_formatters/WriteCoefficientTable.py | .py | e5d824fb6b8b2725 | 7.39 | 5 |
__all__ = ["Requirements", "WriteOutput"]
import os
from copy import deepcopy
from textwrap import wrap
import matplotlib.pyplot as plt
import numpy as np
import proglog
# from typing import Literal, Optional
# from moviepy import concatenate
from moviepy import ImageClip, VideoFileClip, concatenate_videoclips
from... | ExperimentalMineralPhysics/Continuous-Peak-Fit | src/cpf/output_formatters/WriteCollectionMovie.py | .py | fe268ee5a390e6b5 | 7.39 | 5 |
__all__ = ["Requirements", "WriteOutput"]
import json
import os
import re
from itertools import product
import numpy as np
import pandas as pd
import cpf.peak_functions as pf
from cpf.output_formatters.fits_io import ReadFits_to_dataframe
from cpf.output_formatters.output_csv import make_header, write_csv
from cpf.... | ExperimentalMineralPhysics/Continuous-Peak-Fit | src/cpf/output_formatters/WriteDifferentialStrain.py | .py | a1833e0968b9c74c | 7.39 | 5 |
__all__ = ["Requirements", "WriteOutput"]
import json
import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from moviepy.video.VideoClip import VideoClip
from cpf.BrightSpots import SpotProcess
from cpf.data_preprocess import remove_cosmics as cosmicsimage_preprocess
from cpf.output_forma... | ExperimentalMineralPhysics/Continuous-Peak-Fit | src/cpf/output_formatters/WriteFitMovie.py | .py | a335b351343cc887 | 7.39 | 5 |
#!/usr/bin/env python3
"""
Secure video audio removal tool
Fixes: Command injection, path traversal, error handling
"""
import subprocess
import os
import sys
from pathlib import Path
POSSIBLE_EXTENSIONS = ["avi", "mp4", "mov"]
def validate_directory(directory_path):
"""Validate and sanitize directory path"""
... | hongyime/removeaudio | noaudio_secure.py | .py | 99114e75e13ef5d7 | 7.15 | 1 |
class WebInterface: #allows these attributes to be used with the object in main.py after creating an instance of it (aka the UI)
def __init__(self):
self.inputlabel = None
self.btnlabel = None
self.errmsg = None
self.board = None
self.winner = None
self.direct = None
... | hongyime/rainbowchess | chess.py | .py | ec9470db96133fea | 7 | 0 |
from flask import Flask
from flask import render_template, redirect
from chess import WebInterface, Board
from flask import request
from MoveHistory import MoveHistory
from copy import copy
from flask import Flask, render_template
app = Flask(__name__)
ui = WebInterface() #create instance of webinterface
game = Board... | hongyime/rainbowchess | main.py | .py | 2fefcb8afad476c6 | 7 | 0 |
import base64
import io
import os
from flask import Flask, render_template, request
import barcode
from barcode.writer import ImageWriter
from utils import is_nric_valid
app = Flask(__name__, template_folder='templates')
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
@app.after_request
def add_header(respon... | hongyime/sgNRICgenerator65 | app.py | .py | 1c0e5f4454f545c7 | 7 | 0 |
#!/usr/bin/env python3
"""
Unified Download Path Manager
==============================
Handles download path configuration across all toolkits.
Key Features:
- Always prompts for download path (no defaults, no env vars)
- Session-based caching with automatic cleanup
- Batch mode support via --out flag
- Path validati... | hongyime/sgNRICgenerator65 | path_manager.py | .py | d928fc239c69b7fd | 7 | 0 |
"""Car pooling service — REST API entry point.
Run with: python manage.py (or: uvicorn manage:app --port 9091)
Optional fairness policies (disabled by default to preserve the challenge
contract), set via environment variables:
QUEUE_TTL_SECONDS waiting groups give up after this many seconds
PRIORITY_... | aifriend/car_sharing_pooling_service | service/manage.py | .py | 1559bd55da11a5d1 | 7.24 | 2 |
"""Property-based tests: random operation sequences must preserve invariants."""
from hypothesis import HealthCheck, given, settings, strategies as st
from car_pooling.pool import MAX_SEATS, CarPool, CarPoolError
car_lists = st.lists(
st.tuples(st.integers(1, 100), st.integers(1, MAX_SEATS)),
min_size=1, max_... | aifriend/car_sharing_pooling_service | service/test/test_property.py | .py | 29d781e4c6ed4968 | 7.74 | 2 |
"""
A class to compute sunset and sunrise time at a specific location.
origin: https://github.com/SatAgro/suntime/blob/master/suntime/suntime.py
"""
from math import degrees, radians, atan, tan, asin, sin, acos, cos, floor
from datetime import date, datetime, time, timedelta, timezone
class Sun:
def ... | sourceperl/sandbox | astro/sunrise.py | .py | 2eea16462397b575 | 7 | 0 |
#!/usr/bin/env python3
""" Collect bluetooth low energy raw data. """
import logging
import os
import time
import sys
from bluepy.btle import Scanner, DefaultDelegate, ScanEntry
class ScanDelegate(DefaultDelegate):
def __init__(self):
DefaultDelegate.__init__(self)
def handleDiscovery(self, dev: Sc... | sourceperl/sandbox | bluetooth/ble_lib_bluepy/ble-raw-collect.py | .py | 250d7d3e15bd36ed | 7 | 0 |
#!/usr/bin/env python3
""" Collect ThermoPro TP357 bluetooth data (https://buythermopro.com/product/tp357/). """
import logging
import os
import time
from struct import unpack
import sys
from bluepy.btle import Scanner, DefaultDelegate, ScanEntry
class ScanDelegate(DefaultDelegate):
def __init__(self):
... | sourceperl/sandbox | bluetooth/ble_lib_bluepy/ble-tp357-collect.py | .py | 0a657c5111639251 | 7 | 0 |
#!/usr/bin/env python
"""
Pressure regulation simulator with a PID controller
"""
from collections import deque
from random import random
from os import chdir
from os.path import abspath, dirname
import numpy as np
import tkinter as tk
from tkinter import ttk
from matplotlib.figure import Figure
from matplotlib.backe... | sourceperl/sandbox | control/pid_sim/app.py | .py | 4812a03132f71d37 | 7 | 0 |
"""
Misc gas functions
"""
import math
def water_volume_m3(dn_mm: int, lenght_m: int) -> float:
"""Compute water volume for a specific pipe DN and length."""
dn_m = dn_mm/1000
return dn_m**2 * math.pi * lenght_m
def celsius_to_kelvin(deg_c: float) -> float:
"""Conversion from degree C... | sourceperl/sandbox | control/pid_sim/lib/misc.py | .py | a33705839abb7281 | 7 | 0 |
"""
PID class
origin PID class come from:
https://github.com/m-lundberg/simple-pid
"""
import time
# some class
class PID:
"""A simple PID controller."""
def __init__(
self,
kp=1.0,
ki=0.0,
kd=0.0,
setpoint=0,
sample_time=0.01,
ou... | sourceperl/sandbox | control/pid_sim/lib/pid.py | .py | e86617827fa55211 | 7 | 0 |
#!/usr/bin/env python3
""" Send email with SMTP protocol. """
from dataclasses import dataclass
import logging
import re
import smtplib
from typing import Sequence, Union
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders... | sourceperl/sandbox | email/smtp_ssl/sendmail.py | .py | 5c853270ebedf2ab | 7 | 0 |
"""
Show schedule of an amortizable loan.
"""
from dataclasses import dataclass
from typing import List
# some class
@dataclass
class MonthlyPay:
month_id: int
interest_pay: float
capital_pay: float
remaining_capital: float
monthly_pay: float
# some functions
def build_amor... | sourceperl/sandbox | finance/amort_loan_schedule.py | .py | 3225e710af552749 | 7 | 0 |
"""
Export data from flyspray to xlsx dashboards using SQLAlchemy ORM.
"""
import logging
from dataclasses import dataclass, field
from datetime import datetime, timezone
from os.path import join
from pathlib import Path
from typing import List, Optional
from zoneinfo import ZoneInfo
from app.config import DATABASES,... | sourceperl/sandbox | flyspray/fly_xlsx_archives_app/app/__init__.py | .py | 5ad05475cdf4a00b | 7 | 0 |
"""Initialise.py module contains all functionality to initialise the parameters and constants used in the
AGA8 DETAIL method."""
def initialise_an(n):
"""Initialise an(n+1, 1) array with known initial values."""
an = [0] * (n + 1)
# add initial values
an[1] = 0.1538326
an[2] = 1.341953
an[3] ... | sourceperl/sandbox | gas/aga8/AGA8/initialise.py | .py | 0c8ef54ea8a0780d | 7 | 0 |
import math
def get_vol_humidity(dew_point_c: float, p_bara: float) -> float:
"""
Compute the volumetric humidity in mg/nm3.
Args:
dew_point_c (float): dew point in degrees Celsius
p_bara (float): pressure in absolute bar
"""
a = 4.8309e3 * math.exp(7.5515e-2 * dew_point_c - 4.06... | sourceperl/sandbox | gas/gerg_water/GERG_WATER/__init__.py | .py | 612912cc8e170dd7 | 7 | 0 |
import tkinter as tk
from tkinter import ttk
from .conf import AppConf
# some functions
def hs_to_mj(hs_kwh: float) -> float:
"""Convert Hs from kwh/nm3 to MJ/nm3."""
return hs_kwh * 3.6
def hs_to_t25(hs_t0: float) -> float:
"""Convert Hs from t_comb = 0°C to 25 °C."""
return hs_t0 * 0.997_4
def ... | sourceperl/sandbox | gas/gui-app/app/misc.py | .py | 1ffd6d2aa81b91ea | 7 | 0 |
""" Compute compression factor Z and molar density rho_m with SGERG method. """
from SGERG_88 import SGERG
# some functions
def hs_to_mj(hs_kwh: float) -> float:
"""Convert Hs from kwh/nm3 to MJ/nm3."""
return hs_kwh * 3.6
def hs_to_t25(hs_t0: float) -> float:
"""Convert Hs from t_comb = 0°C to 25 °C."... | sourceperl/sandbox | gas/sgerg/main.py | .py | bf71096f1ce2e71e | 7 | 0 |
#!/usr/bin/env python
# amnonscript
# count k-mer header freq in a directory of fasta files
import argparse
import sys
import os
from collections import defaultdict
__version__ = "0.1"
def iterfastaseqs(filename):
"""
iterate a fasta file and return header,sequence
input:
filename - the fasta file name
outpu... | amnona/GetData | GetData/count_kmer.py | .py | 681fd429061d917b | 7.35 | 4 |
#!/usr/bin/env python
"""
amnonscript
Trim primer region from sequences
original script by Jenya
modified by Amnon for command line interface and trimming the primer sequences
"""
__version__ = "1.6"
import argparse
# from cogent.parse.fasta import MinimalFastaParser
# import skbio
import sys
import re
import os
... | amnona/GetData | GetData/get_region.py | .py | 320834a0194d056a | 7.35 | 4 |
# Copyright 2026 Stanford University
# Copyright 2016, Yahoo Inc.
# Licensed under the terms of the Apache License, Version 2.0. See the LICENSE file associated with the project for terms.
class Operation(object):
"""
This is an abstract class representing a data transformation. To use this,
please inheri... | slac-lcls/networkfox | networkfox/base.py | .py | f64ab2dc42542bde | 7.24 | 2 |
# Copyright 2026 Stanford University
# Copyright 2016, Yahoo Inc.
# Licensed under the terms of the Apache License, Version 2.0. See the LICENSE file associated with the project for terms.
from itertools import chain
from .base import Operation, NetworkOperation, Var, Control
from .network import Network
from .modifi... | slac-lcls/networkfox | networkfox/functional.py | .py | feccecbee15f551f | 7.24 | 2 |
# Copyright 2026 Stanford University
# Copyright 2016, Yahoo Inc.
# Licensed under the terms of the Apache License, Version 2.0. See the LICENSE file associated with the project for terms.
"""
This sub-module contains input/output modifiers that can be applied to
arguments to ``needs`` and ``provides`` to let NetworkF... | slac-lcls/networkfox | networkfox/modifiers.py | .py | 19c00761d8ec768f | 7.24 | 2 |
"""
Server that keeps track of which tests to run next.
"""
from unittest import TestCase
from fastapi.testclient import TestClient
from . import testing_server
client = TestClient(testing_server.app)
class UnitTests(TestCase):
"Initial unit tests"
def test_base_server(self):
"See if server works ... | rularner/py-test-distributor | server/test_server.py | .py | 2df2c6a12ed33797 | 7.5 | 0 |
'''
End-to-end tests that run the real client against a real, live server.
No mocks: these exist specifically to catch client/server contract
mismatches (wrong URLs, wrong payload encoding, wrong response shapes)
that per-component unit tests with mocked HTTP can miss.
'''
from client import testing_client
from server... | rularner/py-test-distributor | tests/test_integration.py | .py | 44aa53f556f8cdf9 | 7.5 | 0 |
import os
import logging
from ghapi.all import GhApi
GITHUB_TOKEN = os.environ.get("GITHUB_PERSONAL_ACCESS_TOKEN")
REPO_OWNER = "openshift-eng"
REPO_NAME = "ocp-build-data"
api = GhApi(owner=REPO_OWNER, repo=REPO_NAME, token=GITHUB_TOKEN)
# Set up logging
logger = logging.getLogger(__name__)
def get_directory_co... | openshift-eng/art-dashboard-server | api/fetchers/rpms_images_fetcher.py | .py | dc0a41720898c90e | 7.35 | 4 |
import asyncio
from typing import Union, Tuple, List
import cachetools
import datetime
import re
import requests
from fcntl import fcntl, F_GETFL, F_SETFL
import koji
import logging
import os
import shlex
import subprocess
from threading import RLock
import time
from api.kerberos import do_kinit
import functools
impor... | openshift-eng/art-dashboard-server | api/util.py | .py | d48790de3c5e8066 | 7.35 | 4 |
from django.db import models, connection
from datetime import datetime
from time import strftime
from .managers import BuildManager, DailyBuildReportManager
# Create your models here.
class UnixTimestampField(models.DateTimeField):
"""UnixTimestampField: creates a DateTimeField that is represented on the
da... | openshift-eng/art-dashboard-server | build/models.py | .py | 46a266850382531f | 7.35 | 4 |
class MultipleProxyMiddleware:
"""From Django docs. The get_host() method fails when the
host is behind multiple proxies. One solution is to use
middleware to rewrite the proxy headers"""
FORWARDED_FOR_FIELDS = [
"HTTP_X_FORWARDED_FOR",
"HTTP_X_FORWARDED_HOST",
"HTTP_X_FORWARDED... | AdamCottrill/fsdviz | config/middleware/mutiple_proxy_middleware.py | .py | ad6d493e094052a4 | 7 | 0 |
"""Django-filter classes that will be used to filter common objects.
The will be used in both views and api serializers.
"""
import django_filters
from django.contrib.gis.geos import GEOSGeometry
from .utils import NumberInFilter, ValueInFilter, NumberInOrNullFilter
from .models import (
ManagementUnit,
Juri... | AdamCottrill/fsdviz | fsdviz/common/filters.py | .py | 581ce812bfcc64a2 | 7 | 0 |
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "titlecase >= 2.0",
# ]
# ///
"""
Prints markdown for the Publications.md from .bib files.
Usage: Call `main` with the path to the bibfile and a list of citekeys.
If no citekeys are given, all entries in the .bib are printed.
The boolean `add_year` can ... | pylhc/pylhc.github.io | scripts/bib2md.py | .py | f70baf332cd27ac6 | 7.15 | 1 |
from __future__ import annotations
from collections.abc import Sequence
from pathlib import Path
import pandas as pd
def parse_file(file_path: Path) -> pd.DataFrame:
"""Parses a markdown file, containing a shift-table, into a pandas dataframe.
Args:
file_path (Path): Path to the markdown file.
... | pylhc/pylhc.github.io | scripts/parse_md_table.py | .py | 57e963aa5fc74b57 | 7.15 | 1 |
"""Command base for astctl."""
from abc import abstractmethod
from json import JSONDecodeError, loads
from re import Match
from typing import TypeVar
from uuid import uuid4
from pydantic import TypeAdapter
from astoria.common.components import StateConsumer
from astoria.common.ipc import ManagerMessage
T = TypeVar("... | srobo/astoria | astoria/astctl/command.py | .py | 13a6a5c720a27465 | 7.3 | 3 |
"""Command to list information about mounted disks."""
import click
from astoria.common.ipc import DiskManagerMessage
from .command import SingleManagerMessageCommand
@click.command("list-disks")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", "--config-file", type=click.Path(exists=True))
def l... | srobo/astoria | astoria/astctl/list_disks.py | .py | c02b4f2454c11ca5 | 7.3 | 3 |
"""Command to set a metadata attribute."""
import click
from astoria.astctl.command import Command
from astoria.common.ipc import MetadataSetManagerRequest
@click.command("set")
@click.argument("attribute")
@click.argument("value")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", "--config-file", ... | srobo/astoria | astoria/astctl/metadata/set.py | .py | 46281d0c39733533 | 7.3 | 3 |
"""Command to show metadata."""
import click
from astoria.astctl.command import SingleManagerMessageCommand
from astoria.common.ipc import MetadataManagerMessage
@click.command("show")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", "--config-file", type=click.Path(exists=True))
def show(*, verbo... | srobo/astoria | astoria/astctl/metadata/show.py | .py | fa4fa12a9cae5833 | 7.3 | 3 |
"""Command to add a filesystem path as a static disk."""
from pathlib import Path
import click
from astoria.astctl.command import Command
from astoria.common.ipc import AddStaticDiskRequest
@click.command("add")
@click.argument("path")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", "--config-fi... | srobo/astoria | astoria/astctl/static_disks/add.py | .py | d11bbff873cb3330 | 7.3 | 3 |
"""Command to add a filesystem path as a static disk."""
from pathlib import Path
import click
from astoria.astctl.command import Command
from astoria.common.ipc import RemoveStaticDiskRequest
@click.command("remove")
@click.argument("path")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", "--con... | srobo/astoria | astoria/astctl/static_disks/remove.py | .py | d743d0bf238dfd80 | 7.3 | 3 |
"""Command to add a filesystem path as a static disk."""
import click
from astoria.astctl.command import Command
from astoria.common.ipc import RemoveAllStaticDisksRequest
@click.command("remove-all")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", "--config-file", type=click.Path(exists=True))
d... | srobo/astoria | astoria/astctl/static_disks/remove_all.py | .py | 5cede11e817f9519 | 7.3 | 3 |
"""Command to restart running usercode."""
import click
from astoria.astctl.command import Command
from astoria.common.ipc import ManagerRequest
@click.command("kill")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", "--config-file", type=click.Path(exists=True))
def kill(*, verbose: bool, config_... | srobo/astoria | astoria/astctl/usercode/kill.py | .py | 5501b15e288defe0 | 7.3 | 3 |
"""Command to view usercode logs in real-time."""
import asyncio
import click
from astoria.astctl.command import Command
from astoria.common.ipc import UsercodeLogBroadcastEvent
from astoria.common.mqtt import BroadcastHelper
@click.command("log")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", ... | srobo/astoria | astoria/astctl/usercode/log.py | .py | 8a77a817cd6a655b | 7.3 | 3 |
"""Command to restart running usercode."""
import click
from astoria.astctl.command import Command
from astoria.common.ipc import ManagerRequest
@click.command("restart")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", "--config-file", type=click.Path(exists=True))
def restart(*, verbose: bool, c... | srobo/astoria | astoria/astctl/usercode/restart.py | .py | 9ebc1cb485373613 | 7.3 | 3 |
"""Command to show usercode info."""
import click
from astoria.astctl.command import SingleManagerMessageCommand
from astoria.common.ipc import ProcessManagerMessage
@click.command("show")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", "--config-file", type=click.Path(exists=True))
def show(*, v... | srobo/astoria | astoria/astctl/usercode/show.py | .py | b84217b45f147024 | 7.3 | 3 |
"""Command to virtually press start button."""
import click
from astoria.astctl.command import Command
from astoria.common.ipc import StartButtonBroadcastEvent
from astoria.common.mqtt import BroadcastHelper
@click.command("trigger")
@click.option("-v", "--verbose", is_flag=True)
@click.option("-c", "--config-file"... | srobo/astoria | astoria/astctl/usercode/trigger.py | .py | 798aa5699d54d470 | 7.3 | 3 |
"""StateManager to manage disks."""
import asyncio
import logging
from pathlib import Path
from astoria.common.components import StateManager
from astoria.common.ipc import DiskManagerMessage
from .disk_provider import DiskProvider
from .static import StaticDiskProvider
from .udisks import UdisksConnection
LOGGER =... | srobo/astoria | astoria/astdiskd/disk_manager.py | .py | 66aaffc20d774d6b | 7.3 | 3 |
"""A provider of disk information."""
from collections.abc import Callable, Coroutine
from pathlib import Path
from typing import TYPE_CHECKING
from astoria.common.disks import DiskUUID
if TYPE_CHECKING:
from .disk_manager import DiskManager
class DiskProvider:
"""
A provider of disk information.
... | srobo/astoria | astoria/astdiskd/disk_provider.py | .py | 697704c75b87d86b | 7.3 | 3 |
"""Allows disks to be added manually through local filesystem paths."""
import logging
from collections.abc import Callable, Coroutine
from pathlib import Path
from typing import TYPE_CHECKING
from astoria.common.disks import DiskUUID
from astoria.common.ipc import (
AddStaticDiskRequest,
RemoveAllStaticDisks... | srobo/astoria | astoria/astdiskd/static.py | .py | b854ca99b206ba03 | 7.3 | 3 |
"""Cache metadata attributes on disk."""
import logging
from json import JSONDecodeError, dumps, loads
from pathlib import Path
LOGGER = logging.getLogger(__name__)
class MetadataCache:
"""Manages loading and updating data from the metadata cache."""
def __init__(
self,
cached_keys: set[str... | srobo/astoria | astoria/astmetad/metadata_cache.py | .py | 8c3c477397519aaa | 7.3 | 3 |
"""Lifecycle classes to load metadata from disks."""
import logging
from abc import ABCMeta, abstractmethod
from json import JSONDecodeError, loads
from pathlib import Path
import tomli_w
from astoria.common.config import (
SSID_PREFIX,
AstoriaConfig,
NoRobotSettingsException,
NoValidRobotSettingsExc... | srobo/astoria | astoria/astmetad/metadata_disk_lifecycle.py | .py | cf3c37f147b098ff | 7.3 | 3 |
"""Metadata State Manager."""
import asyncio
import logging
from pydantic import ValidationError
from astoria.common.components import StateManager
from astoria.common.disks import DiskInfo, DiskType, DiskUUID
from astoria.common.ipc import (
MetadataManagerMessage,
MetadataSetManagerRequest,
RequestResp... | srobo/astoria | astoria/astmetad/metadata_manager.py | .py | c478212f57630c06 | 7.3 | 3 |
"""Process Manager Application."""
import asyncio
import logging
from astoria.common.code_status import CodeStatus
from astoria.common.components import StateManager
from astoria.common.disks import DiskInfo, DiskType, DiskUUID
from astoria.common.ipc import (
ProcessManagerMessage,
RequestResponse,
Userc... | srobo/astoria | astoria/astprocd/process_manager.py | .py | f334ba30b788d0ad | 7.3 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.