repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/imagedreamfusion.py
threestudio/systems/imagedreamfusion.py
import os import random import shutil from dataclasses import dataclass, field import torch import torch.nn.functional as F from torchmetrics import PearsonCorrCoef import threestudio from threestudio.systems.base import BaseLift3DSystem from threestudio.utils.ops import binary_cross_entropy, dot from threestudio.uti...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/prolificdreamer.py
threestudio/systems/prolificdreamer.py
import os from dataclasses import dataclass, field import torch import threestudio from threestudio.systems.base import BaseLift3DSystem from threestudio.utils.misc import cleanup, get_device from threestudio.utils.ops import binary_cross_entropy, dot from threestudio.utils.typing import * @threestudio.register("pr...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/optimizers.py
threestudio/systems/optimizers.py
# Copyright 2022 Garena Online Private Limited # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agre...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/control4d_multiview.py
threestudio/systems/control4d_multiview.py
import os from dataclasses import dataclass, field import torch import torch.nn.functional as F import threestudio from threestudio.systems.base import BaseLift3DSystem from threestudio.systems.utils import parse_optimizer from threestudio.utils.GAN.loss import discriminator_loss, generator_loss from threestudio.util...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/instructnerf2nerf.py
threestudio/systems/instructnerf2nerf.py
import os from dataclasses import dataclass, field import torch import threestudio from threestudio.systems.base import BaseLift3DSystem from threestudio.utils.misc import cleanup, get_device from threestudio.utils.ops import binary_cross_entropy, dot from threestudio.utils.perceptual import PerceptualLoss from three...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/zero123.py
threestudio/systems/zero123.py
import os import random import shutil from dataclasses import dataclass, field import torch import torch.nn.functional as F from PIL import Image, ImageDraw from torchmetrics import PearsonCorrCoef import threestudio from threestudio.systems.base import BaseLift3DSystem from threestudio.utils.ops import binary_cross_...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/utils.py
threestudio/systems/utils.py
import sys import warnings from bisect import bisect_right import torch import torch.nn as nn from torch.optim import lr_scheduler import threestudio def get_scheduler(name): if hasattr(lr_scheduler, name): return getattr(lr_scheduler, name) else: raise NotImplementedError def getattr_recu...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/dreamfusion.py
threestudio/systems/dreamfusion.py
from dataclasses import dataclass, field import torch import threestudio from threestudio.systems.base import BaseLift3DSystem from threestudio.utils.ops import binary_cross_entropy, dot from threestudio.utils.typing import * @threestudio.register("dreamfusion-system") class DreamFusion(BaseLift3DSystem): @data...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/__init__.py
threestudio/systems/__init__.py
from . import ( control4d_multiview, dreamfusion, fantasia3d, imagedreamfusion, instructnerf2nerf, latentnerf, magic3d, magic123, mvdream, prolificdreamer, sjc, textmesh, zero123, zero123_simple, )
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/fantasia3d.py
threestudio/systems/fantasia3d.py
from dataclasses import dataclass, field import torch import torch.nn.functional as F import threestudio from threestudio.systems.base import BaseLift3DSystem from threestudio.utils.ops import binary_cross_entropy, dot from threestudio.utils.typing import * @threestudio.register("fantasia3d-system") class Fantasia3...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/base.py
threestudio/systems/base.py
import os from dataclasses import dataclass, field import pytorch_lightning as pl import torch.nn.functional as F import threestudio from threestudio.models.exporters.base import Exporter, ExporterOutput from threestudio.systems.utils import parse_optimizer, parse_scheduler from threestudio.utils.base import ( Up...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/magic123.py
threestudio/systems/magic123.py
from dataclasses import dataclass, field import torch import torch.nn.functional as F import threestudio from threestudio.systems.base import BaseLift3DSystem from threestudio.utils.ops import binary_cross_entropy, dot from threestudio.utils.typing import * @threestudio.register("magic123-system") class Magic123(Ba...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/magic3d.py
threestudio/systems/magic3d.py
import os from dataclasses import dataclass, field import torch import threestudio from threestudio.systems.base import BaseLift3DSystem from threestudio.utils.misc import cleanup, get_device from threestudio.utils.ops import binary_cross_entropy, dot from threestudio.utils.typing import * @threestudio.register("ma...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/systems/sjc.py
threestudio/systems/sjc.py
from dataclasses import dataclass, field import numpy as np import torch import threestudio from threestudio.systems.base import BaseLift3DSystem from threestudio.utils.typing import * @threestudio.register("sjc-system") class ScoreJacobianChaining(BaseLift3DSystem): @dataclass class Config(BaseLift3DSystem...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/data/image.py
threestudio/data/image.py
import bisect import math import os from dataclasses import dataclass, field import cv2 import numpy as np import pytorch_lightning as pl import torch import torch.nn.functional as F from torch.utils.data import DataLoader, Dataset, IterableDataset import threestudio from threestudio import register from threestudio....
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/data/uncond.py
threestudio/data/uncond.py
import bisect import math import random from dataclasses import dataclass, field import pytorch_lightning as pl import torch import torch.nn.functional as F from torch.utils.data import DataLoader, Dataset, IterableDataset import threestudio from threestudio import register from threestudio.utils.base import Updateab...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/data/uncond_multiview.py
threestudio/data/uncond_multiview.py
import math import os import random from dataclasses import dataclass, field import cv2 import numpy as np import pytorch_lightning as pl import torch import torch.nn.functional as F from torch.utils.data import DataLoader, Dataset, IterableDataset from threestudio import register from threestudio.data.uncond import ...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/data/multiview.py
threestudio/data/multiview.py
import json import math import os import random from dataclasses import dataclass import cv2 import numpy as np import pytorch_lightning as pl import torch import torch.nn.functional as F from scipy.spatial.transform import Rotation as Rot from scipy.spatial.transform import Slerp from torch.utils.data import DataLoad...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/data/__init__.py
threestudio/data/__init__.py
from . import co3d, image, multiview, uncond, uncond_multiview
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/threestudio/data/co3d.py
threestudio/data/co3d.py
import gzip import json import os import warnings from dataclasses import dataclass, field from typing import List import cv2 import numpy as np import pytorch_lightning as pl import torch import torchvision.transforms.functional as TF from PIL import Image from torch.utils.data import DataLoader, Dataset, IterableDat...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/load/make_prompt_library.py
load/make_prompt_library.py
import json dreamfusion_gallery_video_names = [ "a_20-sided_die_made_out_of_glass.mp4", "a_bald_eagle_carved_out_of_wood.mp4", "a_banana_peeling_itself.mp4", "a_beagle_in_a_detective's_outfit.mp4", "a_beautiful_dress_made_out_of_fruit,_on_a_mannequin._Studio_lighting,_high_quality,_high_resolution....
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
liuff19/DreamReward
https://github.com/liuff19/DreamReward/blob/eeb5c648e6c2a25c8f6f8038edfe75d73c811614/load/tets/generate_tets.py
load/tets/generate_tets.py
# Copyright (c) 2020-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # NVIDIA CORPORATION, its affiliates and licensors retain all intellectual # property and proprietary rights in and to this material, related # documentation and any modifications thereto. Any use, reproduction, # disclosure or distributi...
python
MIT
eeb5c648e6c2a25c8f6f8038edfe75d73c811614
2026-01-05T07:14:33.752935Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/setup.py
setup.py
from setuptools import setup, find_packages if __name__ == "__main__": setup( name="cheap-proteins", version="1.0.0", author="Amy X. Lu", license="MIT", author_email="amyxlu@berkeley.edu", packages=find_packages(where="src"), package_dir={"": "src"}, )
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/run_benchmark.py
run_benchmark.py
import os import hydra import sys import math import pprint import shutil import logging import argparse import numpy as np import time import yaml import easydict from pathlib import Path import uuid import torch from torch import distributed as dist from omegaconf import OmegaConf, DictConfig import torchdrug from ...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/train_sequence_decoder.py
train_sequence_decoder.py
import typing as T from pathlib import Path import os import hydra import lightning as L from lightning.pytorch.loggers import WandbLogger from lightning.pytorch.utilities import rank_zero_only from omegaconf import DictConfig, OmegaConf import torch import time from plaid.utils import get_model_device from plaid.tr...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/benchmarking/ours.py
src/benchmarking/ours.py
import os from pathlib import Path from einops import reduce import torch from torch import nn from torchdrug import core, layers, utils, data from torchdrug.layers import functional from torchdrug.core import Registry as R import numpy as np import string # disassembled to maintain consistency with # https://gith...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/benchmarking/flip.py
src/benchmarking/flip.py
import os import csv import math from collections import defaultdict from tqdm import tqdm from torch.utils import data as torch_data from torchdrug import data, utils from torchdrug.core import Registry as R class FLIPDataset(data.ProteinDataset): def load_csv(self, csv_file, sequence_field="sequence", targe...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/proteins.py
src/cheap/proteins.py
import os import re import typing as T from pathlib import Path from tqdm import trange import numpy as np import torch import torch.nn.functional as F import pandas as pd import torch import typing as T import numpy as np import re from openfold.np import residue_constants from lightning.pytorch.utilities import ran...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/pretrained.py
src/cheap/pretrained.py
import os from pathlib import Path import torch from torch.hub import load_state_dict_from_url from .esmfold import esmfold_v1_embed_only from .model import HourglassProteinCompressionTransformer from .pipeline import Pipeline from .constants import CATH_COMPRESS_LEVEL_TO_ID, CHECKPOINT_DIR_PATH, HF_HUB_PREFIX from ...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/constants.py
src/cheap/constants.py
import os from pathlib import Path # defaults to ~/.cache/cheap, but can be overridden by setting the CHEAP_CACHE as an environment variable DEFAULT_CACHE = Path(os.environ.get("CHEAP_CACHE", Path.home() / ".cache/cheap")) if not DEFAULT_CACHE.exists(): DEFAULT_CACHE.mkdir(parents=True) HF_HUB_PREFIX = "https:...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/decoder.py
src/cheap/decoder.py
from pathlib import Path import torch.nn as nn import torch from torch.hub import load_state_dict_from_url from .esmfold import batch_encode_sequences from .constants import DECODER_CKPT_PATH, HF_HUB_PREFIX class FullyConnectedNetwork(nn.Module): def __init__( self, n_classes: int = 21, ...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/typed.py
src/cheap/typed.py
from typing import Union, List from pathlib import Path import torch import numpy as np ArrayLike = Union[np.ndarray, torch.Tensor, List] PathLike = Union[str, Path] DeviceLike = Union[str, torch.device]
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/pipeline.py
src/cheap/pipeline.py
""" CHEAP model pipeline wrapper around ESMFold embedding, normalization module, and hourglass compression. """ from typing import Optional, Union, List, Tuple import torch from .model import HourglassProteinCompressionTransformer from .esmfold import ESMFoldEmbed, esmfold_v1_embed_only from .utils import LatentSca...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/__init__.py
src/cheap/__init__.py
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/model/_hourglass.py
src/cheap/model/_hourglass.py
import typing as T import torch from torch import nn import numpy as np from . import HourglassDecoder, HourglassEncoder, VectorQuantizer, FiniteScalarQuantizer from ..utils import ( LatentScaler, trim_or_pad_batch_first, get_lr_scheduler, get_model_device, ) from ..esmfold._misc import batch_encode_s...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/model/__init__.py
src/cheap/model/__init__.py
from ._modules import ( HourglassDecoder, HourglassEncoder, VectorQuantizer, FiniteScalarQuantizer, ) from ._hourglass import HourglassProteinCompressionTransformer
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/model/_modules.py
src/cheap/model/_modules.py
import typing as T import math import torch from torch import nn, einsum import torch.nn.functional as F from einops import rearrange, reduce, repeat import einops import numpy as np from omegaconf import ListConfig # helpers def exists(val): return val is not None def default(val, d): return val if exis...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/_default_config.py
src/cheap/openfold_utils/_default_config.py
import re import copy import importlib import ml_collections as mlc def set_inf(c, inf): for k, v in c.items(): if isinstance(v, mlc.ConfigDict): set_inf(v, inf) elif k == "inf": c[k] = inf def enforce_config_constraints(config): def string_to_setting(s): path...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
true
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/_rigids.py
src/cheap/openfold_utils/_rigids.py
# Copyright 2021 AlQuraishi Laboratory # Copyright 2021 DeepMind Technologies Limited # # 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 # # U...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
true
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/_protein.py
src/cheap/openfold_utils/_protein.py
import dataclasses import numpy as np from typing import Optional, Sequence import io from Bio.PDB import PDBParser import warnings import string from transformers.models.esm.openfold_utils import residue_constants @dataclasses.dataclass(frozen=True) class Protein: """Protein structure representation.""" # ...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/_data_transforms.py
src/cheap/openfold_utils/_data_transforms.py
# Adapted from https://github.com/aqlaboratory/openfold/blob/main/openfold/data/data_transforms.py # to remove non-MSA and non-template dependencies. # To enable multimer mode, add necessary functions from # https://github.com/aqlaboratory/openfold/tree/main/openfold/utils/geometry # Copyright 2021 AlQuraishi Laborato...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/_losses.py
src/cheap/openfold_utils/_losses.py
# Copyright 2021 AlQuraishi Laboratory # Copyright 2021 DeepMind Technologies Limited # # 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 # # U...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
true
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/_feats.py
src/cheap/openfold_utils/_feats.py
# Copyright 2021 AlQuraishi Laboratory # Copyright 2021 DeepMind Technologies Limited # # 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 # # U...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/_tensor_utils.py
src/cheap/openfold_utils/_tensor_utils.py
import torch from typing import List from functools import partial def batched_gather(data, inds, dim=0, no_batch_dims=0): ranges = [] for i, s in enumerate(data.shape[:no_batch_dims]): r = torch.arange(s) r = r.view(*(*((1,) * i), -1, *((1,) * (len(inds.shape) - i - 1)))) ranges.appen...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/__init__.py
src/cheap/openfold_utils/__init__.py
from ._protein import Protein as OFProtein from ._protein import from_pdb_string as protein_from_pdb_string from ._protein import to_pdb as protein_to_pdb from ._rigids import Rigid, Rotation from ._tensor_utils import ( batched_gather, permute_final_dims, masked_mean, tree_map, tensor_tree_map, ) f...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/_data_pipeline.py
src/cheap/openfold_utils/_data_pipeline.py
from typing import Mapping import numpy as np from transformers.models.esm.openfold_utils import residue_constants from . import OFProtein FeatureDict = Mapping[str, np.ndarray] def _aatype_to_str_sequence(aatype): return "".join( [residue_constants.restypes_with_x[aatype[i]] for i in range(len(aatype))...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/_fape.py
src/cheap/openfold_utils/_fape.py
# Copyright 2021 AlQuraishi Laboratory # Copyright 2021 DeepMind Technologies Limited # # 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 # # U...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
true
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/openfold_utils/_residue_constants.py
src/cheap/openfold_utils/_residue_constants.py
# Copyright 2021 AlQuraishi Laboratory # Copyright 2021 DeepMind Technologies Limited # # 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 # # U...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
true
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/esmfold/_tri_self_attn_block.py
src/cheap/esmfold/_tri_self_attn_block.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from openfold.model.triangular_attention import ( TriangleAttentionEndingNode, TriangleAttentionStartingNode, ) from ope...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/esmfold/_trunk.py
src/cheap/esmfold/_trunk.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as T from contextlib import ExitStack from dataclasses import dataclass, field import torch import torch.nn as nn # from open...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/esmfold/_esmfold.py
src/cheap/esmfold/_esmfold.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as T from dataclasses import dataclass, field from functools import partial import pathlib as Path import time import torch im...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/esmfold/_pretrained.py
src/cheap/esmfold/_pretrained.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from pathlib import Path import torch from ._esmfold import ESMFold # https://github.com/facebookresearch/esm/blob/main/esm/esmfold/v1/pr...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/esmfold/_structure_module.py
src/cheap/esmfold/_structure_module.py
# Copyright 2021 AlQuraishi Laboratory # Copyright 2021 DeepMind Technologies Limited # # 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 # # U...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/esmfold/__init__.py
src/cheap/esmfold/__init__.py
ESMFOLD_S_DIM = 1024 # dimension of the s_s_0 tensor input to ESMFold folding trunk ESMFOLD_Z_DIM = 128 # dimension of the paired representation s_z_0 input from ._trunk import RelativePosition, FoldingTrunk, FoldingTrunkConfig from ._misc import batch_encode_sequences, output_to_pdb, make_s_z_0 from ._pretrained imp...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/esmfold/_misc.py
src/cheap/esmfold/_misc.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as T from pathlib import Path import numpy as np import torch import torch.nn.functional as F from einops import rearrange, re...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/esmfold/_categorical_mixture.py
src/cheap/esmfold/_categorical_mixture.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch class CategoricalMixture: def __init__(self, param, bins=50, start=0, end=1): # All tensors are of shape ..., bins...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/esmfold/_esmfold_embed_only.py
src/cheap/esmfold/_esmfold_embed_only.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as T import time from functools import partial import torch import torch.nn as nn from torch import nn from torch.nn import La...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/losses/__init__.py
src/cheap/losses/__init__.py
from ._functions import ( masked_huber_loss, masked_l1_loss, masked_mse_loss, masked_token_accuracy, masked_token_cross_entropy_loss, ) from ._modules import SequenceAuxiliaryLoss, BackboneAuxiliaryLoss
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/losses/_modules.py
src/cheap/losses/_modules.py
import typing as T from openfold.utils.loss import backbone_loss import pandas as pd import torch import wandb from . import masked_token_cross_entropy_loss, masked_token_accuracy from ..esmfold._misc import batch_encode_sequences from ..proteins import LatentToSequence, LatentToStructure from ..utils import outputs_...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/losses/_functions.py
src/cheap/losses/_functions.py
import typing as T import torch import torch.nn.functional as F import numpy as np import einops import torch def make_mask(broadcast_shape, mask): while len(mask.shape) < len(broadcast_shape): mask = mask[..., None] return mask.expand(broadcast_shape) def masked_mse_loss(pred: torch.Tensor, target:...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/datasets/__precomputed.py
src/cheap/datasets/__precomputed.py
from pathlib import Path import typing as T import torch from torch.utils.data import Dataset, DataLoader import numpy as np import h5py from ..utils import StructureFeaturizer from ..typed import PathLike ACCEPTED_LM_EMBEDDER_TYPES = [ "esmfold", # 1024 -- i.e. t36_3B with projection layers, used for final mo...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/datasets/_datamodules.py
src/cheap/datasets/_datamodules.py
import typing as T import torch from torch.utils.data import DataLoader from ..typed import PathLike from .__precomputed import H5Dataset, StructureH5Dataset from .__fasta import FastaDataset class H5DataModule: def __init__( self, shard_dir: PathLike, embedder: str = "esmfold", ...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/datasets/__fasta.py
src/cheap/datasets/__fasta.py
from typing import ( Any, TypeVar, Callable, Dict, Union, ) import threading from pathlib import Path from operator import methodcaller import subprocess import torch from torch.utils.data import DataLoader import numpy as np T = TypeVar("T") PathLike = Union[str, Path] """ Adapted from https:/...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/datasets/__init__.py
src/cheap/datasets/__init__.py
from ._datamodules import H5DataModule, StructureH5DataModule, FastaDataModule
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/utils/_latent_scaler.py
src/cheap/utils/_latent_scaler.py
from pathlib import Path import os import typing as T import numpy as np import torch from torch.hub import download_url_to_file from ._nn_utils import npy from ..constants import TENSOR_STATS_DIR, HF_HUB_PREFIX from ..typed import PathLike ArrayLike = T.Union[np.ndarray, T.List[float], torch.Tensor] GLOBAL_SEQEM...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/utils/_structure_featurizer.py
src/cheap/utils/_structure_featurizer.py
import typing as T from pathlib import Path import numpy as np import torch from ..openfold_utils import ( make_pdb_features, make_all_atom_aatype, make_seq_mask, make_atom14_masks, make_atom14_positions, atom37_to_frames, get_backbone_frames, OFProtein, protein_from_pdb_string, ) ...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/utils/_nn_utils.py
src/cheap/utils/_nn_utils.py
from typing import Union import torch import numpy as np ArrayLike = Union[np.ndarray, torch.Tensor] def npy(x: ArrayLike): if isinstance(x, torch.Tensor): return x.detach().cpu().numpy() else: return np.array(x) def to_tensor(x, device=None, dtype=None): if isinstance(x, torch.Tensor):...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/utils/__init__.py
src/cheap/utils/__init__.py
from ._latent_scaler import LatentScaler from ._scheduler import get_lr_scheduler from ._nn_utils import ( npy, to_tensor, count_parameters, get_model_device, outputs_to_avg_metric, ) from ._transforms import ( trim_or_pad_batch_first, trim_or_pad_length_first, get_random_sequence_crop, ...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/utils/_scheduler.py
src/cheap/utils/_scheduler.py
from transformers import ( get_scheduler, get_cosine_schedule_with_warmup, get_cosine_with_hard_restarts_schedule_with_warmup, Adafactor, ) import torch def get_lr_scheduler( optimizer: torch.optim.Optimizer, sched_type: str = "constant", num_warmup_steps: int = 0, num_training_steps: ...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/utils/_transforms.py
src/cheap/utils/_transforms.py
from typing import List, Tuple import torch import random import einops def mask_from_seq_lens(x: torch.Tensor, seqlen: torch.Tensor): mask = torch.arange(x.shape[1], device=x.device) mask = einops.repeat(mask[None, :], "1 L -> N L", N=x.shape[0]) < seqlen[:, None] return mask.long() def get_random_seq...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
amyxlu/cheap-proteins
https://github.com/amyxlu/cheap-proteins/blob/cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e/src/cheap/utils/_analysis.py
src/cheap/utils/_analysis.py
import typing as T import numpy as np from ._nn_utils import npy from ..typed import ArrayLike def calc_sequence_recovery( pred_seq: ArrayLike, orig_seq: ArrayLike, mask: T.Optional[ArrayLike] = None ): if isinstance(pred_seq[0], str): assert isinstance(orig_seq[0], str) pred_seq = np.array(...
python
MIT
cb8a4ac36e9a44c779d31aacfe5f80c5072d7e7e
2026-01-05T07:14:48.094150Z
false
taketwo/glasbey
https://github.com/taketwo/glasbey/blob/a0607959fe671f012599a7dd6031904340eaf99c/glasbey.py
glasbey.py
#!/usr/bin/env python # encoding: utf-8 import os import sys import ast import argparse import numpy as np from colorspacious import cspace_convert from view_palette import palette_to_image try: from progressbar import Bar, ETA, Percentage, ProgressBar except ImportError: class Bar: pass cla...
python
MIT
a0607959fe671f012599a7dd6031904340eaf99c
2026-01-05T07:14:48.850040Z
false
taketwo/glasbey
https://github.com/taketwo/glasbey/blob/a0607959fe671f012599a7dd6031904340eaf99c/view_palette.py
view_palette.py
#!/usr/bin/env python # encoding: utf-8 import argparse import numpy as np def palette_to_image(palette): from PIL import Image WIDTH = 180 HEIGHT_SEGMENT = 20 img = Image.new("RGB", (WIDTH, HEIGHT_SEGMENT * len(palette)), "black") pixels = img.load() for i, color in enumerate(palette): ...
python
MIT
a0607959fe671f012599a7dd6031904340eaf99c
2026-01-05T07:14:48.850040Z
false
taketwo/glasbey
https://github.com/taketwo/glasbey/blob/a0607959fe671f012599a7dd6031904340eaf99c/test/test_glasbey.py
test/test_glasbey.py
import os from shutil import copyfile, move from unittest import TestCase from glasbey import Glasbey import numpy class TestGlasbey(TestCase): def setUp(self) -> None: file_path = os.path.dirname(os.path.realpath(__file__)) self.test_palette = file_path + "/../palettes/set1.txt" self.test...
python
MIT
a0607959fe671f012599a7dd6031904340eaf99c
2026-01-05T07:14:48.850040Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/setup.py
setup.py
#!/usr/bin/env python # This is a shim to allow Github to detect the package, build is done with poetry import setuptools if __name__ == "__main__": setuptools.setup(name="nbtlib")
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/tests/test_tag.py
tests/test_tag.py
from io import BytesIO import pytest from nbtlib import ( End, Int, String, List, EndInstantiation, OutOfRange, IncompatibleItemType, CastError, ) from .inputs import ( bytes_for_valid_tags, out_of_range_numeric_tags, unsigned_values_for_integer_tags, ) @pytest.mark.param...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/tests/test_minecraft.py
tests/test_minecraft.py
import pytest from nbtlib.contrib.minecraft import StructureFile def test_structure_file(tmp_path): structure = StructureFile( { "DataVersion": 1139, "author": "dinnerbone", "size": [1, 2, 1], "palette": [ { "Name": "mine...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/tests/test_path.py
tests/test_path.py
import pytest from nbtlib import Path, load, parse_nbt path_strings_to_keys = [ ("", ()), ("hello", ("hello",)), ("hello.world", ("hello", "world")), ("with.trailing.dot.", ("with", "trailing", "dot")), ('using."quoted.keys"', ("using", "quoted.keys")), ('"escape \\"quotes\\""."in.quoted".key',...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/tests/inputs.py
tests/inputs.py
from nbtlib import ( Byte, ByteArray, Compound, Double, File, Float, Int, IntArray, List, Long, LongArray, Short, String, ) __all__ = [ "bytes_for_valid_tags", "out_of_range_numeric_tags", "literal_values_for_tags", "invalid_literals", "nbt_files"...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/tests/test_literal.py
tests/test_literal.py
import pytest from nbtlib import parse_nbt, InvalidLiteral from .inputs import literal_values_for_tags, invalid_literals, nbt_files @pytest.mark.parametrize("literal, expected_tag", literal_values_for_tags) def test_literal_parsing(literal, expected_tag): assert parse_nbt(literal) == expected_tag @pytest.mark...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/tests/test_nbt.py
tests/test_nbt.py
import pytest from nbtlib import nbt, Compound from .inputs import nbt_files def validate_types(tag, expected): return isinstance(tag, type(expected)) and ( not isinstance(tag, Compound) or all(validate_types(val, expected[key]) for key, val in tag.items()) ) @pytest.mark.parametrize("file...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/tests/__init__.py
tests/__init__.py
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/tests/test_schema.py
tests/test_schema.py
import pytest from nbtlib import schema, String, Int, List, CastError @pytest.fixture def LooseSchema(): return schema("Thing", {"foo": String, "bar": List[schema("Bar", {"value": Int})]}) @pytest.fixture def StrictSchema(): return schema( "Thing", {"foo": String, "bar": List[schema("Bar", ...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/tests/test_benchmark.py
tests/test_benchmark.py
from io import BytesIO import pytest from nbtlib import nbt def write_parse(nbt_tag): data = BytesIO() nbt_tag.write(data) data.seek(0) return nbt_tag.parse(data) @pytest.mark.parametrize( "filename", [ "byte.nbt", "short.nbt", "int.nbt", "long.nbt", ...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/path.py
nbtlib/path.py
"""This module defines utilities for accessing deeply nested properties. Exported items: Path -- Class representing an nbt path, inherits from `tuple` InvalidPath -- Exception raised when creating an invalid nbt path """ __all__ = ["Path", "InvalidPath", "NamedKey", "ListIndex", "CompoundMatch"] imp...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/cli.py
nbtlib/cli.py
from argparse import ArgumentParser, ArgumentTypeError from json import dumps as json_dumps from pprint import pprint from nbtlib import InvalidLiteral, Path, nbt, parse_nbt, serialize_tag from nbtlib.tag import Compound, find_tag # Validation helper def nbt_data(literal): try: nbt_data = parse_nbt(lite...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/schema.py
nbtlib/schema.py
"""This module defines tools for creating tag schemas. Exported items: schema -- Helper function to define compound schemas CompoundSchema -- `Compound` subclass that enforces a tag schema """ __all__ = ["schema", "CompoundSchema"] from itertools import chain from .tag import Compound, CastError ...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/tag.py
nbtlib/tag.py
r""" .. testsetup:: import io import struct from pprint import pprint from nbtlib import * All the tag classes have a :meth:`Base.parse` classmethod that reads nbt data from a file-like object and returns a tag instance. Tag instances can then write their binary representation back to file-like object...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
true
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/nbt.py
nbtlib/nbt.py
""" .. testsetup:: import io import nbtlib from nbtlib import * The library supports reading and writing nbt data in all its forms and treats everything as uncompressed big-endian nbt by default. You can load nbt files with the :func:`load` function. .. doctest:: >>> nbtlib.load("docs/hello_world.n...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/__main__.py
nbtlib/__main__.py
from .cli import main if __name__ == "__main__": main()
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/__init__.py
nbtlib/__init__.py
from .tag import * from .nbt import * from .path import * from .schema import * from .literal.parser import * from .literal.serializer import * __version__ = "2.0.4"
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/contrib/__init__.py
nbtlib/contrib/__init__.py
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/contrib/minecraft/structure.py
nbtlib/contrib/minecraft/structure.py
__all__ = ["StructureFile", "StructureFileData"] from nbtlib import File, CompoundSchema, tag class StructureFileData(CompoundSchema): """Schema that matches the Minecraft structure file format.""" class BlockState(CompoundSchema): schema = { "Name": tag.String, "Properties"...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/contrib/minecraft/__init__.py
nbtlib/contrib/minecraft/__init__.py
from .structure import *
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/literal/serializer.py
nbtlib/literal/serializer.py
"""This module exposes utilities for serializing nbt tags to snbt. Exported functions: serialize_tag -- Helper function that serializes nbt tags Exported classes: Serializer -- Class that can turn nbt tags into their literal representation Exported objects: STRING_QUOTES -- Maps the two types of quote...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/literal/parser.py
nbtlib/literal/parser.py
"""This module exposes utilities for parsing snbt. Exported functions: parse_nbt -- Helper function that parses nbt literals tokenize -- Generator that lazily yields tokens from a string Exported classes: Parser -- Class that can parse nbt tags from a literal token stream Exported exceptions: Invali...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/nbtlib/literal/__init__.py
nbtlib/literal/__init__.py
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/examples/level_dat_bedrock.py
examples/level_dat_bedrock.py
from io import BytesIO from nbtlib import CompoundSchema, File, schema from nbtlib.tag import ( INT, Byte, Float, Int, List, Long, String, read_numeric, write_numeric, ) # fmt: off BedrockLevelData = schema("BedrockLevelData", { "CenterMapsToOrigin": Byte, "Difficulty": Int...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/examples/uuid.py
examples/uuid.py
from uuid import UUID from nbtlib import Long def combine_uuid(uuid_most_tag, uuid_least_tag): uuid_most = uuid_most_tag.as_unsigned uuid_least = uuid_least_tag.as_unsigned return UUID(int=uuid_most << Long.bits | uuid_least) def split_uuid(uuid): uuid_most = uuid.int >> Long.bits & Long.mask u...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false
vberlier/nbtlib
https://github.com/vberlier/nbtlib/blob/a6c0cd949e10f189581ca11026a0c600ee298e11/examples/level_dat.py
examples/level_dat.py
from nbtlib import * # fmt: off LevelData = schema("LevelData", { "DataVersion": Int, "DimensionData": schema("DimensionData", { "1": schema("EndData", { "DragonFight": schema("DragonFight", { "ExitPortalLocation": schema("ExitPortalLocation", { "X": Byte...
python
MIT
a6c0cd949e10f189581ca11026a0c600ee298e11
2026-01-05T07:14:49.302206Z
false