index
int64
0
50.7k
project_path
stringclasses
279 values
completion_path
stringlengths
57
199
signature_postion
stringlengths
3
11
class_position
stringlengths
3
11
function_name
stringlengths
1
62
class_name
stringlengths
0
55
body_position
stringlengths
3
11
body_position_with_comments
stringlengths
3
11
masked_class
stringlengths
14
8.32k
masked_class_with_comment
stringlengths
14
8.32k
func_body
stringlengths
9
6.72k
func_body_with_comment
stringlengths
9
6.72k
len_func_body
int64
1
643
len_input
int64
10
2.02k
len_output
int64
4
1.9k
total
int64
20
2.05k
file_code
stringlengths
14
442k
file_code_with_comment
stringlengths
14
442k
0
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/cli.py
22,23
1,103
main
23,94
23,94
import argparse import os import torch from llava.conversation import conv_templates from llava.mm_utils import ( KeywordsStoppingCriteria, get_model_name_from_path, load_pretrained_model, process_images, tokenizer_image_token, ) from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IN...
import argparse import os import torch from llava.conversation import conv_templates from llava.mm_utils import ( KeywordsStoppingCriteria, get_model_name_from_path, load_pretrained_model, process_images, tokenizer_image_token, ) from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IN...
model_path = os.path.expanduser(args.model_path) key_info["model_path"] = model_path get_model_name_from_path(model_path) tokenizer, model, image_processor, _ = load_pretrained_model(model_path) conv = conv_templates["mm_default"].copy() roles = conv.roles image = load_image(args.image_fil...
model_path = os.path.expanduser(args.model_path) key_info["model_path"] = model_path get_model_name_from_path(model_path) tokenizer, model, image_processor, _ = load_pretrained_model(model_path) conv = conv_templates["mm_default"].copy() roles = conv.roles image = load_image(args.image_fil...
152
313
772
1,085
import argparse import os import torch from llava.conversation import conv_templates from llava.mm_utils import ( KeywordsStoppingCriteria, get_model_name_from_path, load_pretrained_model, process_images, tokenizer_image_token, ) from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IN...
import argparse import os import torch from llava.conversation import conv_templates from llava.mm_utils import ( KeywordsStoppingCriteria, get_model_name_from_path, load_pretrained_model, process_images, tokenizer_image_token, ) from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IN...
1
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/llava/conversation.py
27,28
12,184
get_prompt
Conversation
28,56
28,56
@dataclasses.dataclass class Conversation: """A class that keeps all conversation history.""" system: str roles: List[str] messages: List[List[str]] offset: int sep_style: SeparatorStyle = SeparatorStyle.SINGLE sep: str = "###" sep2: str = None version: str = "Unknown" skip_nex...
@dataclasses.dataclass class Conversation: """A class that keeps all conversation history.""" system: str roles: List[str] messages: List[List[str]] offset: int sep_style: SeparatorStyle = SeparatorStyle.SINGLE sep: str = "###" sep2: str = None version: str = "Unknown" skip_nex...
messages = self.messages if len(messages) > 0 and type(messages[0][1]) is tuple: messages = self.messages.copy() init_role, init_msg = messages[0].copy() init_msg = init_msg[0].replace("<image_placeholder>", "").strip() if "mmtag" in self.version: ...
messages = self.messages if len(messages) > 0 and type(messages[0][1]) is tuple: messages = self.messages.copy() init_role, init_msg = messages[0].copy() init_msg = init_msg[0].replace("<image_placeholder>", "").strip() if "mmtag" in self.version: ...
103
1,467
355
1,822
import dataclasses from enum import Enum, auto from typing import List class SeparatorStyle(Enum): """Different separator style.""" SINGLE = auto() @dataclasses.dataclass class Conversation: """A class that keeps all conversation history.""" system: str roles: List[str] messages: List[List...
import dataclasses from enum import Enum, auto from typing import List class SeparatorStyle(Enum): """Different separator style.""" SINGLE = auto() @dataclasses.dataclass class Conversation: """A class that keeps all conversation history.""" system: str roles: List[str] messages: List[List...
2
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/llava/model/llava_llama.py
137,145
39,164
prepare_inputs_for_generation
LlavaLlamaForCausalLM
145,164
145,164
class LlavaLlamaForCausalLM(LlamaForCausalLM, LlavaMetaForCausalLM): config_class = LlavaConfig def __init__(self, config): super(LlamaForCausalLM, self).__init__(config) self.model = LlavaLlamaModel(config) self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False) ...
class LlavaLlamaForCausalLM(LlamaForCausalLM, LlavaMetaForCausalLM): config_class = LlavaConfig def __init__(self, config): super(LlamaForCausalLM, self).__init__(config) self.model = LlavaLlamaModel(config) self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False) ...
if past_key_values: input_ids = input_ids[:, -1:] # if `inputs_embeds` are passed, we only want to use them in the 1st generation step if inputs_embeds is not None and past_key_values is None: model_inputs = {"inputs_embeds": inputs_embeds} else: mode...
if past_key_values: input_ids = input_ids[:, -1:] # if `inputs_embeds` are passed, we only want to use them in the 1st generation step if inputs_embeds is not None and past_key_values is None: model_inputs = {"inputs_embeds": inputs_embeds} else: mode...
58
1,128
224
1,352
# Copyright 2023 Haotian Liu # # 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...
# Copyright 2023 Haotian Liu # # 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...
3
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/llava/model/multimodal_projector/builder.py
32,33
1,65
build_vision_projector
33,65
33,65
import re import torch.nn as nn class IdentityMap(nn.Module): def __init__(self): super().__init__() def forward(self, x, *args, **kwargs): return x @property def config(self): return {"mm_projector_type": "identity"} class SimpleResBlock(nn.Module): def __init__(self,...
import re import torch.nn as nn class IdentityMap(nn.Module): def __init__(self): super().__init__() def forward(self, x, *args, **kwargs): return x @property def config(self): return {"mm_projector_type": "identity"} class SimpleResBlock(nn.Module): def __init__(self,...
projector_type = getattr(config, "mm_projector_type", "linear") if projector_type == "linear": return nn.Linear(config.mm_hidden_size, config.hidden_size) use_norm = False if "_Norm" in projector_type: use_norm = True projector_type = projector_type.replace("_Norm", "") mlp...
projector_type = getattr(config, "mm_projector_type", "linear") if projector_type == "linear": return nn.Linear(config.mm_hidden_size, config.hidden_size) use_norm = False if "_Norm" in projector_type: use_norm = True projector_type = projector_type.replace("_Norm", "") mlp...
76
245
432
677
import re import torch.nn as nn class IdentityMap(nn.Module): def __init__(self): super().__init__() def forward(self, x, *args, **kwargs): return x @property def config(self): return {"mm_projector_type": "identity"} class SimpleResBlock(nn.Module): def __init__(self,...
import re import torch.nn as nn class IdentityMap(nn.Module): def __init__(self): super().__init__() def forward(self, x, *args, **kwargs): return x @property def config(self): return {"mm_projector_type": "identity"} class SimpleResBlock(nn.Module): def __init__(self,...
4
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/llava/model/multimodal_projector/builder.py
10,11
6,18
forward
IdentityMap
11,13
11,13
class IdentityMap(nn.Module): def __init__(self): super().__init__() def forward(self, x, *args, **kwargs): FILL_FUNC_BODY @property def config(self): return {"mm_projector_type": "identity"}
class IdentityMap(nn.Module): def __init__(self): super().__init__() def forward(self, x, *args, **kwargs): FILL_FUNC_BODY @property def config(self): return {"mm_projector_type": "identity"}
return x
return x
2
79
7
86
import re import torch.nn as nn class IdentityMap(nn.Module): def __init__(self): super().__init__() def forward(self, x, *args, **kwargs): FILL_FUNC_BODY @property def config(self): return {"mm_projector_type": "identity"} class SimpleResBlock(nn.Module): def __init__(self, cha...
import re import torch.nn as nn class IdentityMap(nn.Module): def __init__(self): super().__init__() def forward(self, x, *args, **kwargs): FILL_FUNC_BODY @property def config(self): return {"mm_projector_type": "identity"} class SimpleResBlock(nn.Module): def __init__(self, cha...
5
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/llava/model/multimodal_projector/builder.py
27,28
18,32
forward
SimpleResBlock
28,32
28,32
class SimpleResBlock(nn.Module): def __init__(self, channels): super().__init__() self.pre_norm = nn.LayerNorm(channels) self.proj = nn.Sequential( nn.Linear(channels, channels), nn.GELU(), nn.Linear(channels, channels) ) def forward(self, x): FILL_FUNC_BODY
class SimpleResBlock(nn.Module): def __init__(self, channels): super().__init__() self.pre_norm = nn.LayerNorm(channels) self.proj = nn.Sequential( nn.Linear(channels, channels), nn.GELU(), nn.Linear(channels, channels) ) def forward(self, x): FILL_FUNC_BODY
x = self.pre_norm(x) return x + self.proj(x)
x = self.pre_norm(x) return x + self.proj(x)
7
111
29
140
import re import torch.nn as nn class IdentityMap(nn.Module): def __init__(self): super().__init__() def forward(self, x, *args, **kwargs): return x @property def config(self): return {"mm_projector_type": "identity"} class SimpleResBlock(nn.Module): def __init__(self,...
import re import torch.nn as nn class IdentityMap(nn.Module): def __init__(self): super().__init__() def forward(self, x, *args, **kwargs): return x @property def config(self): return {"mm_projector_type": "identity"} class SimpleResBlock(nn.Module): def __init__(self,...
6
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/VL/single_inference.py
27,28
1,111
single_infer
28,94
28,94
import argparse import os import torch from llava.conversation import conv_templates from llava.mm_utils import ( KeywordsStoppingCriteria, expand2square, get_model_name_from_path, load_pretrained_model, tokenizer_image_token, ) from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IND...
import argparse import os import torch from llava.conversation import conv_templates from llava.mm_utils import ( KeywordsStoppingCriteria, expand2square, get_model_name_from_path, load_pretrained_model, tokenizer_image_token, ) from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IND...
disable_torch_init() model_path = os.path.expanduser(args.model_path) key_info["model_path"] = model_path get_model_name_from_path(model_path) tokenizer, model, image_processor, context_len = load_pretrained_model(model_path) image_file = args.image_file qs = args.question qs = DEFAULT_...
disable_torch_init() model_path = os.path.expanduser(args.model_path) key_info["model_path"] = model_path get_model_name_from_path(model_path) tokenizer, model, image_processor, context_len = load_pretrained_model(model_path) image_file = args.image_file qs = args.question qs = DEFAULT_...
153
477
845
1,322
import argparse import os import torch from llava.conversation import conv_templates from llava.mm_utils import ( KeywordsStoppingCriteria, expand2square, get_model_name_from_path, load_pretrained_model, tokenizer_image_token, ) from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IND...
import argparse import os import torch from llava.conversation import conv_templates from llava.mm_utils import ( KeywordsStoppingCriteria, expand2square, get_model_name_from_path, load_pretrained_model, tokenizer_image_token, ) from llava.model.constants import DEFAULT_IMAGE_TOKEN, IMAGE_TOKEN_IND...
8
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/demo/text_generation.py
36,37
1,73
main
37,70
37,70
import argparse from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer def parse_inputs(): parser = argparse.ArgumentParser(description="Yi-6B text generation demo") parser.add_argument( "--model", type=str, default="01-ai/Yi-6B", help="pretrained model pat...
import argparse from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer def parse_inputs(): parser = argparse.ArgumentParser(description="Yi-6B text generation demo") parser.add_argument( "--model", type=str, default="01-ai/Yi-6B", help="pretrained model pat...
print(args) if args.cpu: device_map = "cpu" else: device_map = "auto" model = AutoModelForCausalLM.from_pretrained( args.model, device_map=device_map, torch_dtype="auto" ) tokenizer = AutoTokenizer.from_pretrained(args.model) inputs = tokenizer( args.prompt,...
print(args) if args.cpu: device_map = "cpu" else: device_map = "auto" model = AutoModelForCausalLM.from_pretrained( args.model, device_map=device_map, torch_dtype="auto" ) tokenizer = AutoTokenizer.from_pretrained(args.model) inputs = tokenizer( args.prompt,...
58
337
327
664
import argparse from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer def parse_inputs(): parser = argparse.ArgumentParser(description="Yi-6B text generation demo") parser.add_argument( "--model", type=str, default="01-ai/Yi-6B", help="pretrained model pat...
import argparse from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer def parse_inputs(): parser = argparse.ArgumentParser(description="Yi-6B text generation demo") parser.add_argument( "--model", type=str, default="01-ai/Yi-6B", help="pretrained model pat...
9
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/data/raw_datasets.py
77,78
41,81
get_prompt_and_rejected
DahoasRmstaticDataset
78,81
78,81
class DahoasRmstaticDataset(PromptRawDataset): def __init__(self, output_path, seed, local_rank, dataset_name): print("init DahoasRMStaicDataset") super().__init__(output_path, seed, local_rank, dataset_name) print("loading at dataset_name {}".format(dataset_name)) self.raw_datasets ...
class DahoasRmstaticDataset(PromptRawDataset): def __init__(self, output_path, seed, local_rank, dataset_name): print("init DahoasRMStaicDataset") super().__init__(output_path, seed, local_rank, dataset_name) print("loading at dataset_name {}".format(dataset_name)) self.raw_datasets ...
return sample["prompt"] + sample["rejected"]
return sample["prompt"] + sample["rejected"]
4
441
19
460
# Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py from datasets import load_dataset # The template prompt dataset class that all new dataset porting needs to # follow in order to have a unified API and unified ...
# Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py from datasets import load_dataset # The template prompt dataset class that all new dataset porting needs to # follow in order to have a unified API and unified ...
10
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/data/raw_datasets.py
105,106
81,134
get_prompt
LocalJsonFileDataset
106,111
106,111
class LocalJsonFileDataset(PromptRawDataset): def __init__(self, output_path, seed, local_rank, dataset_name, chat_path): super().__init__(output_path, seed, local_rank, dataset_name) self.dataset_name = "local/jsonfile" self.dataset_name_clean = "jsonfile" self.raw_datasets = load_d...
class LocalJsonFileDataset(PromptRawDataset): def __init__(self, output_path, seed, local_rank, dataset_name, chat_path): super().__init__(output_path, seed, local_rank, dataset_name) self.dataset_name = "local/jsonfile" self.dataset_name_clean = "jsonfile" self.raw_datasets = load_d...
if sample["prompt"] is not None: return " " + sample["prompt"] return None # The chosen response should be in the format of: " " + actual_response_sentence
if sample["prompt"] is not None: return " " + sample["prompt"] return None # The chosen response should be in the format of: " " + actual_response_sentence
26
539
55
594
# Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py from datasets import load_dataset # The template prompt dataset class that all new dataset porting needs to # follow in order to have a unified API and unified ...
# Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py from datasets import load_dataset # The template prompt dataset class that all new dataset porting needs to # follow in order to have a unified API and unified ...
11
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/data/raw_datasets.py
25,26
7,41
get_chosen
PromptRawDataset
26,30
26,30
class PromptRawDataset(object): def __init__(self, output_path, seed, local_rank, dataset_name): print("init PromptRawDataset with dataname {}".format(dataset_name)) self.output_path = output_path self.seed = seed self.local_rank = local_rank def get_train_data(self): re...
class PromptRawDataset(object): def __init__(self, output_path, seed, local_rank, dataset_name): print("init PromptRawDataset with dataname {}".format(dataset_name)) self.output_path = output_path self.seed = seed self.local_rank = local_rank def get_train_data(self): re...
return # The rejected response should be in the format of: " " + actual_response_sentence # If the dataset does not have rejected response, return None
return # The rejected response should be in the format of: " " + actual_response_sentence # If the dataset does not have rejected response, return None
26
265
44
309
# Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py from datasets import load_dataset # The template prompt dataset class that all new dataset porting needs to # follow in order to have a unified API and unified ...
# Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py from datasets import load_dataset # The template prompt dataset class that all new dataset porting needs to # follow in order to have a unified API and unified ...
12
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/data/raw_datasets.py
158,159
134,167
get_prompt
YiDataset
159,163
159,163
class YiDataset(PromptRawDataset): def __init__(self, output_path, seed, local_rank, dataset_name, chat_path): super().__init__(output_path, seed, local_rank, dataset_name) print("data path is {}".format(chat_path)) self.dataset_name = "yi" self.dataset_name_clean = "yi" self...
class YiDataset(PromptRawDataset): def __init__(self, output_path, seed, local_rank, dataset_name, chat_path): super().__init__(output_path, seed, local_rank, dataset_name) print("data path is {}".format(chat_path)) self.dataset_name = "yi" self.dataset_name_clean = "yi" self...
if sample["prompt"] is not None: return " " + sample["prompt"] return None
if sample["prompt"] is not None: return " " + sample["prompt"] return None
12
344
32
376
# Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py from datasets import load_dataset # The template prompt dataset class that all new dataset porting needs to # follow in order to have a unified API and unified ...
# Part of the code is adapted from https://github.com/microsoft/DeepSpeedExamples/blob/master/applications/DeepSpeed-Chat/training/utils/data/raw_datasets.py from datasets import load_dataset # The template prompt dataset class that all new dataset porting needs to # follow in order to have a unified API and unified ...
13
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/model/model_utils.py
7,16
1,60
create_hf_model
16,60
16,60
import math from transformers import AutoConfig from transformers.deepspeed import HfDeepSpeedConfig def create_hf_model( model_class, model_name_or_path, tokenizer, ds_config=None, rlhf_training=False, disable_dropout=False, eval_mode=False, ): FILL_FUNC_BODY
import math from transformers import AutoConfig from transformers.deepspeed import HfDeepSpeedConfig def create_hf_model( model_class, model_name_or_path, tokenizer, ds_config=None, rlhf_training=False, disable_dropout=False, eval_mode=False, ): FILL_FUNC_BODY
model_config = AutoConfig.from_pretrained( model_name_or_path, trust_remote_code=True ) # print(model_config) if disable_dropout: model_config.dropout = 0.0 # Note: dschf is defined in function scope to avoid global effects # https://huggingface.co/docs/transformers/main_classes/...
model_config = AutoConfig.from_pretrained( model_name_or_path, trust_remote_code=True ) # print(model_config) if disable_dropout: model_config.dropout = 0.0 # Note: dschf is defined in function scope to avoid global effects # https://huggingface.co/docs/transformers/main_classes/...
103
108
536
644
import math from transformers import AutoConfig from transformers.deepspeed import HfDeepSpeedConfig def create_hf_model( model_class, model_name_or_path, tokenizer, ds_config=None, rlhf_training=False, disable_dropout=False, eval_mode=False, ): FILL_FUNC_BODY
import math from transformers import AutoConfig from transformers.deepspeed import HfDeepSpeedConfig def create_hf_model( model_class, model_name_or_path, tokenizer, ds_config=None, rlhf_training=False, disable_dropout=False, eval_mode=False, ): FILL_FUNC_BODY
14
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/finetune/utils/perf.py
5,6
1,74
print_throughput
6,45
6,45
import torch # This function can be used to print throughput for Step 1 and 2 only def print_throughput(hf_model, args, e2e_time, rank=0): FILL_FUNC_BODYdef calculate_flops(checkpoint_activations_factor, batch_size, seq_length, hf_config): num_layers, hidden_size, vocab_size = get_hf_configs(hf_config) # TODO...
import torch # This function can be used to print throughput for Step 1 and 2 only def print_throughput(hf_model, args, e2e_time, rank=0): FILL_FUNC_BODYdef calculate_flops(checkpoint_activations_factor, batch_size, seq_length, hf_config): num_layers, hidden_size, vocab_size = get_hf_configs(hf_config) # TODO...
if rank <= 0: hf_config = hf_model.config num_layers, hidden_size, vocab_size = get_hf_configs(hf_config) gpus_per_model = torch.distributed.get_world_size() seq_length = args.max_seq_len batch_size = args.per_device_train_batch_size samples_per_second = batch_size /...
if rank <= 0: hf_config = hf_model.config num_layers, hidden_size, vocab_size = get_hf_configs(hf_config) gpus_per_model = torch.distributed.get_world_size() seq_length = args.max_seq_len batch_size = args.per_device_train_batch_size samples_per_second = batch_size /...
139
422
583
1,005
import torch # This function can be used to print throughput for Step 1 and 2 only def print_throughput(hf_model, args, e2e_time, rank=0): FILL_FUNC_BODYdef calculate_flops(checkpoint_activations_factor, batch_size, seq_length, hf_config): num_layers, hidden_size, vocab_size = get_hf_configs(hf_config) # TODO...
import torch # This function can be used to print throughput for Step 1 and 2 only def print_throughput(hf_model, args, e2e_time, rank=0): FILL_FUNC_BODYdef calculate_flops(checkpoint_activations_factor, batch_size, seq_length, hf_config): num_layers, hidden_size, vocab_size = get_hf_configs(hf_config) # TODO...
15
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/quantization/gptq/eval_quantized_model.py
4,5
1,46
run_quantization
5,35
5,35
from transformers import AutoModelForCausalLM, AutoTokenizer def run_quantization(args): FILL_FUNC_BODYif __name__ == "__main__": import argparse parser = argparse.ArgumentParser(description="Run GPTQ quantized model") parser.add_argument("--model", type=str, help="The quantized name") parser.add_arg...
from transformers import AutoModelForCausalLM, AutoTokenizer def run_quantization(args): FILL_FUNC_BODYif __name__ == "__main__": import argparse parser = argparse.ArgumentParser(description="Run GPTQ quantized model") parser.add_argument("--model", type=str, help="The quantized name") parser.add_arg...
# Load model tokenizer = AutoTokenizer.from_pretrained( args.model, trust_remote_code=args.trust_remote_code, local_files_only=True, legacy=True, use_fast=False, ) model = AutoModelForCausalLM.from_pretrained( args.model, device_map="cuda:0", ...
# Load model tokenizer = AutoTokenizer.from_pretrained( args.model, trust_remote_code=args.trust_remote_code, local_files_only=True, legacy=True, use_fast=False, ) model = AutoModelForCausalLM.from_pretrained( args.model, device_map="cuda:0", ...
52
154
311
465
from transformers import AutoModelForCausalLM, AutoTokenizer def run_quantization(args): FILL_FUNC_BODYif __name__ == "__main__": import argparse parser = argparse.ArgumentParser(description="Run GPTQ quantized model") parser.add_argument("--model", type=str, help="The quantized name") parser.add_arg...
from transformers import AutoModelForCausalLM, AutoTokenizer def run_quantization(args): FILL_FUNC_BODYif __name__ == "__main__": import argparse parser = argparse.ArgumentParser(description="Run GPTQ quantized model") parser.add_argument("--model", type=str, help="The quantized name") parser.add_arg...
16
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi
/home/hieuvd/dung_repo/raw/stars_01/01-ai_Yi/Yi/quantization/gptq/quant_autogptq.py
7,8
1,69
run_quantization
8,43
8,43
import argparse import logging from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GPTQConfig def run_quantization(args): FILL_FUNC_BODYif __name__ == "__main__": logger = logging.getLogger() logging.basicConfig( format="%(asctime)s %(levelname)s [%(name)s] %(message)s", ...
import argparse import logging from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GPTQConfig def run_quantization(args): FILL_FUNC_BODYif __name__ == "__main__": logger = logging.getLogger() logging.basicConfig( format="%(asctime)s %(levelname)s [%(name)s] %(message)s", ...
# Load model tokenizer = AutoTokenizer.from_pretrained( args.model, trust_remote_code=args.trust_remote_code, local_files_only=True, legacy=True, use_fast=False, ) model_config = AutoConfig.from_pretrained( args.model, trust_remote_code=args.trust...
# Load model tokenizer = AutoTokenizer.from_pretrained( args.model, trust_remote_code=args.trust_remote_code, local_files_only=True, legacy=True, use_fast=False, ) model_config = AutoConfig.from_pretrained( args.model, trust_remote_code=args.trust...
52
372
354
726
import argparse import logging from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GPTQConfig def run_quantization(args): FILL_FUNC_BODYif __name__ == "__main__": logger = logging.getLogger() logging.basicConfig( format="%(asctime)s %(levelname)s [%(name)s] %(message)s", ...
import argparse import logging from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GPTQConfig def run_quantization(args): FILL_FUNC_BODYif __name__ == "__main__": logger = logging.getLogger() logging.basicConfig( format="%(asctime)s %(levelname)s [%(name)s] %(message)s", ...
20
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/docs/example.py
4,5
3,21
construct
SquareToCircle
5,21
5,21
class SquareToCircle(Scene): def construct(self): FILL_FUNC_BODY
class SquareToCircle(Scene): def construct(self): FILL_FUNC_BODY
circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) square = Square() self.play(ShowCreation(square)) self.wait() self.play(ReplacementTransform(square, circle)) self.wait() # Try typing the following lines ...
circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) square = Square() self.play(ShowCreation(square)) self.wait() self.play(ReplacementTransform(square, circle)) self.wait() # Try typing the following lines ...
40
27
222
249
from manimlib import * class SquareToCircle(Scene): def construct(self): FILL_FUNC_BODYclass SquareToCircleEmbed(Scene): def construct(self): circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) self.add(circle) self.wait() sel...
from manimlib import * class SquareToCircle(Scene): def construct(self): FILL_FUNC_BODYclass SquareToCircleEmbed(Scene): def construct(self): circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) self.add(circle) self.wait() sel...
21
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/docs/example.py
22,23
21,38
construct
SquareToCircleEmbed
23,38
23,38
class SquareToCircleEmbed(Scene): def construct(self): FILL_FUNC_BODY
class SquareToCircleEmbed(Scene): def construct(self): FILL_FUNC_BODY
circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) self.add(circle) self.wait() self.play(circle.animate.stretch(4, dim=0)) self.wait(1.5) self.play(Rotate(circle, TAU / 4)) self.wait(1.5) self.play(cir...
circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) self.add(circle) self.wait() self.play(circle.animate.stretch(4, dim=0)) self.wait(1.5) self.play(Rotate(circle, TAU / 4)) self.wait(1.5) self.play(cir...
27
30
215
245
from manimlib import * class SquareToCircle(Scene): def construct(self): circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) square = Square() self.play(ShowCreation(square)) self.wait() self.play(ReplacementTransform(squa...
from manimlib import * class SquareToCircle(Scene): def construct(self): circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) square = Square() self.play(ShowCreation(square)) self.wait() self.play(ReplacementTransform(squa...
22
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
72,73
71,115
construct
AnimatingMethods
73,115
73,115
class AnimatingMethods(Scene): def construct(self): FILL_FUNC_BODY
class AnimatingMethods(Scene): def construct(self): FILL_FUNC_BODY
grid = Tex(R"\pi").get_grid(10, 10, height=4) self.add(grid) # You can animate the application of mobject methods with the # ".animate" syntax: self.play(grid.animate.shift(LEFT)) # Both of those will interpolate between the mobject's initial # state and whateve...
grid = Tex(R"\pi").get_grid(10, 10, height=4) self.add(grid) # You can animate the application of mobject methods with the # ".animate" syntax: self.play(grid.animate.shift(LEFT)) # Both of those will interpolate between the mobject's initial # state and whateve...
151
27
506
533
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
23
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
712,713
695,736
text_updater
ControlsExample
713,726
713,726
class ControlsExample(Scene): drag_to_pan = False def setup(self): self.textbox = Textbox() self.checkbox = Checkbox() self.color_picker = ColorSliders() self.panel = ControlPanel( Text("Text", font_size=24), self.textbox, Line(), Text("Show/Hide Text", f...
class ControlsExample(Scene): drag_to_pan = False def setup(self): self.textbox = Textbox() self.checkbox = Checkbox() self.color_picker = ColorSliders() self.panel = ControlPanel( Text("Text", font_size=24), self.textbox, Line(), Text("Show/Hide Text", f...
assert(isinstance(old_text, Text)) new_text = Text(self.textbox.get_value(), font_size=old_text.font_size) # new_text.align_data_and_family(old_text) new_text.move_to(old_text) if self.checkbox.get_value(): new_text.set_fill( ...
assert(isinstance(old_text, Text)) new_text = Text(self.textbox.get_value(), font_size=old_text.font_size) # new_text.align_data_and_family(old_text) new_text.move_to(old_text) if self.checkbox.get_value(): new_text.set_fill( ...
18
274
178
452
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
24
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
342,343
341,420
construct
CoordinateSystemExample
343,420
343,420
class CoordinateSystemExample(Scene): def construct(self): FILL_FUNC_BODY
class CoordinateSystemExample(Scene): def construct(self): FILL_FUNC_BODY
axes = Axes( # x-axis ranges from -1 to 10, with a default step size of 1 x_range=(-1, 10), # y-axis ranges from -2 to 2 with a step size of 0.5 y_range=(-2, 2, 0.5), # The axes will be stretched so as to match the specified # height and wi...
axes = Axes( # x-axis ranges from -1 to 10, with a default step size of 1 x_range=(-1, 10), # y-axis ranges from -2 to 2 with a step size of 0.5 y_range=(-2, 2, 0.5), # The axes will be stretched so as to match the specified # height and wi...
285
27
998
1,025
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
25
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
421,422
420,501
construct
GraphExample
422,501
422,501
class GraphExample(Scene): def construct(self): FILL_FUNC_BODY
class GraphExample(Scene): def construct(self): FILL_FUNC_BODY
axes = Axes((-3, 10), (-1, 8), height=6) axes.add_coordinate_labels() self.play(Write(axes, lag_ratio=0.01, run_time=1)) # Axes.get_graph will return the graph of a function sin_graph = axes.get_graph( lambda x: 2 * math.sin(x), color=BLUE, ) ...
axes = Axes((-3, 10), (-1, 8), height=6) axes.add_coordinate_labels() self.play(Write(axes, lag_ratio=0.01, run_time=1)) # Axes.get_graph will return the graph of a function sin_graph = axes.get_graph( lambda x: 2 * math.sin(x), color=BLUE, ) ...
269
25
996
1,021
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
26
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
650,651
649,695
construct
InteractiveDevelopment
651,695
651,695
class InteractiveDevelopment(Scene): def construct(self): FILL_FUNC_BODY
class InteractiveDevelopment(Scene): def construct(self): FILL_FUNC_BODY
circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) square = Square() self.play(ShowCreation(square)) self.wait() # This opens an iPython terminal where you can keep writing # lines as if they were part of this constru...
circle = Circle() circle.set_fill(BLUE, opacity=0.5) circle.set_stroke(BLUE_E, width=4) square = Square() self.play(ShowCreation(square)) self.wait() # This opens an iPython terminal where you can keep writing # lines as if they were part of this constru...
210
27
511
538
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
27
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
13,14
12,71
construct
OpeningManimExample
14,71
14,71
class OpeningManimExample(Scene): def construct(self): FILL_FUNC_BODY
class OpeningManimExample(Scene): def construct(self): FILL_FUNC_BODY
intro_words = Text(""" The original motivation for manim was to better illustrate mathematical functions as transformations. """) intro_words.to_edge(UP) self.play(Write(intro_words)) self.wait(2) # Linear transform grid = Num...
intro_words = Text(""" The original motivation for manim was to better illustrate mathematical functions as transformations. """) intro_words.to_edge(UP) self.play(Write(intro_words)) self.wait(2) # Linear transform grid = Num...
108
28
613
641
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
28
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
570,571
569,649
construct
SurfaceExample
571,649
571,649
class SurfaceExample(ThreeDScene): def construct(self): FILL_FUNC_BODY
class SurfaceExample(ThreeDScene): def construct(self): FILL_FUNC_BODY
surface_text = Text("For 3d scenes, try using surfaces") surface_text.fix_in_frame() surface_text.to_edge(UP) self.add(surface_text) self.wait(0.1) torus1 = Torus(r1=1, r2=1) torus2 = Torus(r1=3, r2=1) sphere = Sphere(radius=3, resolution=torus1.resolutio...
surface_text = Text("For 3d scenes, try using surfaces") surface_text.fix_in_frame() surface_text.to_edge(UP) self.add(surface_text) self.wait(0.1) torus1 = Torus(r1=1, r2=1) torus2 = Torus(r1=3, r2=1) sphere = Sphere(radius=3, resolution=torus1.resolutio...
225
28
1,021
1,049
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
29
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
502,503
501,569
construct
TexAndNumbersExample
503,569
503,569
class TexAndNumbersExample(Scene): def construct(self): FILL_FUNC_BODY
class TexAndNumbersExample(Scene): def construct(self): FILL_FUNC_BODY
axes = Axes((-3, 3), (-3, 3), unit_size=1) axes.to_edge(DOWN) axes.add_coordinate_labels(font_size=16) circle = Circle(radius=2) circle.set_stroke(YELLOW, 3) circle.move_to(axes.get_origin()) self.add(axes, circle) # When numbers show up in tex, they can ...
axes = Axes((-3, 3), (-3, 3), unit_size=1) axes.to_edge(DOWN) axes.add_coordinate_labels(font_size=16) circle = Circle(radius=2) circle.set_stroke(YELLOW, 3) circle.move_to(axes.get_origin()) self.add(axes, circle) # When numbers show up in tex, they can ...
203
29
822
851
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
30
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
229,230
228,281
construct
TexIndexing
230,281
230,281
class TexIndexing(Scene): def construct(self): FILL_FUNC_BODY
class TexIndexing(Scene): def construct(self): FILL_FUNC_BODY
# You can index into Tex mobject (or other StringMobjects) by substrings equation = Tex(R"e^{\pi i} = -1", font_size=144) self.add(equation) self.play(FlashAround(equation["e"])) self.wait() self.play(Indicate(equation[R"\pi"])) self.wait() self.play(Tran...
# You can index into Tex mobject (or other StringMobjects) by substrings equation = Tex(R"e^{\pi i} = -1", font_size=144) self.add(equation) self.play(FlashAround(equation["e"])) self.wait() self.play(Indicate(equation[R"\pi"])) self.wait() self.play(Tran...
192
27
691
718
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
31
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
157,158
156,228
construct
TexTransformExample
158,228
158,228
class TexTransformExample(Scene): def construct(self): FILL_FUNC_BODY
class TexTransformExample(Scene): def construct(self): FILL_FUNC_BODY
# Tex to color map t2c = { "A": BLUE, "B": TEAL, "C": GREEN, } # Configuration to pass along to each Tex mobject kw = dict(font_size=72, t2c=t2c) lines = VGroup( Tex("A^2 + B^2 = C^2", **kw), Tex("A^2 = C^2 - B^2...
# Tex to color map t2c = { "A": BLUE, "B": TEAL, "C": GREEN, } # Configuration to pass along to each Tex mobject kw = dict(font_size=72, t2c=t2c) lines = VGroup( Tex("A^2 + B^2 = C^2", **kw), Tex("A^2 = C^2 - B^2...
266
27
839
866
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
32
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
116,117
115,156
construct
TextExample
117,156
117,156
class TextExample(Scene): def construct(self): FILL_FUNC_BODY
class TextExample(Scene): def construct(self): FILL_FUNC_BODY
# To run this scene properly, you should have "Consolas" font in your computer # for full usage, you can see https://github.com/3b1b/manim/pull/680 text = Text("Here is a text", font="Consolas", font_size=90) difference = Text( """ The most important difference be...
# To run this scene properly, you should have "Consolas" font in your computer # for full usage, you can see https://github.com/3b1b/manim/pull/680 text = Text("Here is a text", font="Consolas", font_size=90) difference = Text( """ The most important difference be...
144
25
517
542
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
33
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/example_scenes.py
282,283
281,341
construct
UpdatersExample
283,341
283,341
class UpdatersExample(Scene): def construct(self): FILL_FUNC_BODY
class UpdatersExample(Scene): def construct(self): FILL_FUNC_BODY
square = Square() square.set_fill(BLUE_E, 1) # On all frames, the constructor Brace(square, UP) will # be called, and the mobject brace will set its data to match # that of the newly constructed object brace = always_redraw(Brace, square, UP) label = TexText("Wi...
square = Square() square.set_fill(BLUE_E, 1) # On all frames, the constructor Brace(square, UP) will # be called, and the mobject brace will set its data to match # that of the newly constructed object brace = always_redraw(Brace, square, UP) label = TexText("Wi...
232
27
674
701
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
from manimlib import * import numpy as np # To watch one of these scenes, run the following: # manimgl example_scenes.py OpeningManimExample # Use -s to skip to the end and just save the final frame # Use -w to write the animation to a file # Use -o to write it to a file and open it once done # Use -n <number> to skip...
34
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/__main__.py
9,10
1,30
main
10,28
10,28
#!/usr/bin/env python from manimlib import __version__ import manimlib.config import manimlib.extract_scene import manimlib.logger import manimlib.utils.init_config def main(): FILL_FUNC_BODYif __name__ == "__main__": main()
#!/usr/bin/env python from manimlib import __version__ import manimlib.config import manimlib.extract_scene import manimlib.logger import manimlib.utils.init_config def main(): FILL_FUNC_BODYif __name__ == "__main__": main()
print(f"ManimGL \033[32mv{__version__}\033[0m") args = manimlib.config.parse_cli() if args.version and args.file is None: return if args.log_level: manimlib.logger.log.setLevel(args.log_level) if args.config: manimlib.utils.init_config.init_customization() else: ...
print(f"ManimGL \033[32mv{__version__}\033[0m") args = manimlib.config.parse_cli() if args.version and args.file is None: return if args.log_level: manimlib.logger.log.setLevel(args.log_level) if args.config: manimlib.utils.init_config.init_customization() else: ...
30
84
185
269
#!/usr/bin/env python from manimlib import __version__ import manimlib.config import manimlib.extract_scene import manimlib.logger import manimlib.utils.init_config def main(): FILL_FUNC_BODYif __name__ == "__main__": main()
#!/usr/bin/env python from manimlib import __version__ import manimlib.config import manimlib.extract_scene import manimlib.logger import manimlib.utils.init_config def main(): FILL_FUNC_BODYif __name__ == "__main__": main()
36
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/animation.py
167,173
23,208
get_sub_alpha
Animation
173,184
173,184
class Animation(object): def __init__( self, mobject: Mobject, run_time: float = DEFAULT_ANIMATION_RUN_TIME, # Tuple of times, between which the animation will run time_span: tuple[float, float] | None = None, # If 0, the animation is applied to all submobjects at the...
class Animation(object): def __init__( self, mobject: Mobject, run_time: float = DEFAULT_ANIMATION_RUN_TIME, # Tuple of times, between which the animation will run time_span: tuple[float, float] | None = None, # If 0, the animation is applied to all submobjects at the...
# TODO, make this more understanable, and/or combine # its functionality with AnimationGroup's method # build_animations_with_timings lag_ratio = self.lag_ratio full_length = (num_submobjects - 1) * lag_ratio + 1 value = alpha * full_length lower = index * lag_rat...
# TODO, make this more understanable, and/or combine # its functionality with AnimationGroup's method # build_animations_with_timings lag_ratio = self.lag_ratio full_length = (num_submobjects - 1) * lag_ratio + 1 value = alpha * full_length lower = index * lag_rat...
51
1,863
146
2,009
from __future__ import annotations from copy import deepcopy from manimlib.mobject.mobject import _AnimationBuilder from manimlib.mobject.mobject import Mobject from manimlib.utils.rate_functions import smooth from manimlib.utils.rate_functions import squish_rate_func from manimlib.utils.simple_functions import clip ...
from __future__ import annotations from copy import deepcopy from manimlib.mobject.mobject import _AnimationBuilder from manimlib.mobject.mobject import Mobject from manimlib.utils.rate_functions import smooth from manimlib.utils.rate_functions import squish_rate_func from manimlib.utils.simple_functions import clip ...
37
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/composition.py
84,85
29,126
calculate_max_end_time
AnimationGroup
85,92
85,92
class AnimationGroup(Animation): def __init__( self, *args: AnimationType | Iterable[AnimationType], run_time: float = -1, # If negative, default to sum of inputed animation runtimes lag_ratio: float = 0.0, group: Optional[Mobject] = None, group_type: Optional[type] ...
class AnimationGroup(Animation): def __init__( self, *args: AnimationType | Iterable[AnimationType], run_time: float = -1, # If negative, default to sum of inputed animation runtimes lag_ratio: float = 0.0, group: Optional[Mobject] = None, group_type: Optional[type] ...
self.max_end_time = max( (awt[2] for awt in self.anims_with_timings), default=0, ) if self.run_time < 0: self.run_time = self.max_end_time
self.max_end_time = max( (awt[2] for awt in self.anims_with_timings), default=0, ) if self.run_time < 0: self.run_time = self.max_end_time
17
1,013
76
1,089
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.animation import prepare_animation from manimlib.mobject.mobject import _AnimationBuilder from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VG...
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.animation import prepare_animation from manimlib.mobject.mobject import _AnimationBuilder from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VG...
38
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/composition.py
135,136
126,158
begin
Succession
136,140
136,140
class Succession(AnimationGroup): def __init__( self, *animations: Animation, lag_ratio: float = 1.0, **kwargs ): super().__init__(*animations, lag_ratio=lag_ratio, **kwargs) def begin(self) -> None: FILL_FUNC_BODY def finish(self) -> None: self.active_ani...
class Succession(AnimationGroup): def __init__( self, *animations: Animation, lag_ratio: float = 1.0, **kwargs ): super().__init__(*animations, lag_ratio=lag_ratio, **kwargs) def begin(self) -> None: FILL_FUNC_BODY def finish(self) -> None: self.active_ani...
assert(len(self.animations) > 0) self.active_animation = self.animations[0] self.active_animation.begin()
assert(len(self.animations) > 0) self.active_animation = self.animations[0] self.active_animation.begin()
7
254
44
298
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.animation import prepare_animation from manimlib.mobject.mobject import _AnimationBuilder from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VG...
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.animation import prepare_animation from manimlib.mobject.mobject import _AnimationBuilder from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VG...
39
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/fading.py
41,42
37,49
create_starting_mobject
FadeIn
42,49
42,49
class FadeIn(Fade): def create_target(self) -> Mobject: return self.mobject.copy() def create_starting_mobject(self) -> Mobject: FILL_FUNC_BODY
class FadeIn(Fade): def create_target(self) -> Mobject: return self.mobject.copy() def create_starting_mobject(self) -> Mobject: FILL_FUNC_BODY
start = super().create_starting_mobject() start.set_opacity(0) start.scale(1.0 / self.scale_factor) start.shift(-self.shift_vect) return start
start = super().create_starting_mobject() start.set_opacity(0) start.scale(1.0 / self.scale_factor) start.shift(-self.shift_vect) return start
10
62
66
128
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
40
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/fading.py
65,66
49,73
create_target
FadeOut
66,73
66,73
class FadeOut(Fade): def __init__( self, mobject: Mobject, shift: Vect3 = ORIGIN, remover: bool = True, final_alpha_value: float = 0.0, # Put it back in original state when done, **kwargs ): super().__init__( mobject, shift, remove...
class FadeOut(Fade): def __init__( self, mobject: Mobject, shift: Vect3 = ORIGIN, remover: bool = True, final_alpha_value: float = 0.0, # Put it back in original state when done, **kwargs ): super().__init__( mobject, shift, remove...
result = self.mobject.copy() result.set_opacity(0) result.shift(self.shift_vect) result.scale(self.scale_factor) return result
result = self.mobject.copy() result.set_opacity(0) result.shift(self.shift_vect) result.scale(self.scale_factor) return result
8
149
59
208
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
41
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/fading.py
109,110
93,140
begin
FadeTransform
110,119
110,119
class FadeTransform(Transform): def __init__( self, mobject: Mobject, target_mobject: Mobject, stretch: bool = True, dim_to_match: int = 1, **kwargs ): self.to_add_on_completion = target_mobject self.stretch = stretch self.dim_to_match = di...
class FadeTransform(Transform): def __init__( self, mobject: Mobject, target_mobject: Mobject, stretch: bool = True, dim_to_match: int = 1, **kwargs ): self.to_add_on_completion = target_mobject self.stretch = stretch self.dim_to_match = di...
self.ending_mobject = self.mobject.copy() Animation.begin(self) # Both 'start' and 'end' consists of the source and target mobjects. # At the start, the traget should be faded replacing the source, # and at the end it should be the other way around. start, end = self.star...
self.ending_mobject = self.mobject.copy() Animation.begin(self) # Both 'start' and 'end' consists of the source and target mobjects. # At the start, the traget should be faded replacing the source, # and at the end it should be the other way around. start, end = self.star...
55
405
152
557
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
42
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/fading.py
145,146
140,150
ghost_to
FadeTransformPieces
146,150
146,150
class FadeTransformPieces(FadeTransform): def begin(self) -> None: self.mobject[0].align_family(self.mobject[1]) super().begin() def ghost_to(self, source: Mobject, target: Mobject) -> None: FILL_FUNC_BODY
class FadeTransformPieces(FadeTransform): def begin(self) -> None: self.mobject[0].align_family(self.mobject[1]) super().begin() def ghost_to(self, source: Mobject, target: Mobject) -> None: FILL_FUNC_BODY
for sm0, sm1 in zip(source.get_family(), target.get_family()): super().ghost_to(sm0, sm1)
for sm0, sm1 in zip(source.get_family(), target.get_family()): super().ghost_to(sm0, sm1)
8
84
45
129
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
43
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/fading.py
161,167
150,175
interpolate_submobject
VFadeIn
167,175
167,175
class VFadeIn(Animation): """ VFadeIn and VFadeOut only work for VMobjects, """ def __init__(self, vmobject: VMobject, suspend_mobject_updating: bool = False, **kwargs): super().__init__( vmobject, suspend_mobject_updating=suspend_mobject_updating, **kwargs ...
class VFadeIn(Animation): """ VFadeIn and VFadeOut only work for VMobjects, """ def __init__(self, vmobject: VMobject, suspend_mobject_updating: bool = False, **kwargs): super().__init__( vmobject, suspend_mobject_updating=suspend_mobject_updating, **kwargs ...
submob.set_stroke( opacity=interpolate(0, start.get_stroke_opacity(), alpha) ) submob.set_fill( opacity=interpolate(0, start.get_fill_opacity(), alpha) )
submob.set_stroke( opacity=interpolate(0, start.get_stroke_opacity(), alpha) ) submob.set_fill( opacity=interpolate(0, start.get_fill_opacity(), alpha) )
10
155
80
235
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
44
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/fading.py
190,196
175,199
interpolate_submobject
VFadeOut
196,199
196,199
class VFadeOut(VFadeIn): def __init__( self, vmobject: VMobject, remover: bool = True, final_alpha_value: float = 0.0, **kwargs ): super().__init__( vmobject, remover=remover, final_alpha_value=final_alpha_value, **k...
class VFadeOut(VFadeIn): def __init__( self, vmobject: VMobject, remover: bool = True, final_alpha_value: float = 0.0, **kwargs ): super().__init__( vmobject, remover=remover, final_alpha_value=final_alpha_value, **k...
super().interpolate_submobject(submob, start, 1 - alpha)
super().interpolate_submobject(submob, start, 1 - alpha)
5
155
28
183
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
from __future__ import annotations import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.transform import Transform from manimlib.constants import ORIGIN from manimlib.mobject.mobject import Group from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.mobj...
45
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/growing.py
31,32
16,40
create_starting_mobject
GrowFromPoint
32,40
32,40
class GrowFromPoint(Transform): def __init__( self, mobject: Mobject, point: np.ndarray, point_color: ManimColor = None, **kwargs ): self.point = point self.point_color = point_color super().__init__(mobject, **kwargs) def create_target(self) ...
class GrowFromPoint(Transform): def __init__( self, mobject: Mobject, point: np.ndarray, point_color: ManimColor = None, **kwargs ): self.point = point self.point_color = point_color super().__init__(mobject, **kwargs) def create_target(self) ...
start = super().create_starting_mobject() start.scale(0) start.move_to(self.point) if self.point_color is not None: start.set_color(self.point_color) return start
start = super().create_starting_mobject() start.scale(0) start.move_to(self.point) if self.point_color is not None: start.set_color(self.point_color) return start
13
140
74
214
from __future__ import annotations from manimlib.animation.transform import Transform from manimlib.constants import PI from typing import TYPE_CHECKING if TYPE_CHECKING: import numpy as np from manimlib.mobject.geometry import Arrow from manimlib.mobject.mobject import Mobject from manimlib.typing ...
from __future__ import annotations from manimlib.animation.transform import Transform from manimlib.constants import PI from typing import TYPE_CHECKING if TYPE_CHECKING: import numpy as np from manimlib.mobject.geometry import Arrow from manimlib.mobject.mobject import Mobject from manimlib.typing ...
46
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/indication.py
347,348
333,356
homotopy
ApplyWave
348,353
348,353
class ApplyWave(Homotopy): def __init__( self, mobject: Mobject, direction: np.ndarray = UP, amplitude: float = 0.2, run_time: float = 1.0, **kwargs ): left_x = mobject.get_left()[0] right_x = mobject.get_right()[0] vect = amplitude * dire...
class ApplyWave(Homotopy): def __init__( self, mobject: Mobject, direction: np.ndarray = UP, amplitude: float = 0.2, run_time: float = 1.0, **kwargs ): left_x = mobject.get_left()[0] right_x = mobject.get_right()[0] vect = amplitude * dire...
alpha = (x - left_x) / (right_x - left_x) power = np.exp(2.0 * (alpha - 0.5)) nudge = there_and_back(t**power) return np.array([x, y, z]) + nudge * vect
alpha = (x - left_x) / (right_x - left_x) power = np.exp(2.0 * (alpha - 0.5)) nudge = there_and_back(t**power) return np.array([x, y, z]) + nudge * vect
27
155
81
236
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
47
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/indication.py
137,138
95,144
create_line_anims
Flash
138,144
138,144
class Flash(AnimationGroup): def __init__( self, point: np.ndarray | Mobject, color: ManimColor = YELLOW, line_length: float = 0.2, num_lines: int = 12, flash_radius: float = 0.3, line_stroke_width: float = 3.0, run_time: float = 1.0, **kwargs ...
class Flash(AnimationGroup): def __init__( self, point: np.ndarray | Mobject, color: ManimColor = YELLOW, line_length: float = 0.2, num_lines: int = 12, flash_radius: float = 0.3, line_stroke_width: float = 3.0, run_time: float = 1.0, **kwargs ...
return [ ShowCreationThenDestruction(line) for line in self.lines ]
return [ ShowCreationThenDestruction(line) for line in self.lines ]
8
442
34
476
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
48
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/indication.py
276,277
256,280
get_path
FlashAround
277,280
277,280
class FlashAround(VShowPassingFlash): def __init__( self, mobject: Mobject, time_width: float = 1.0, taper_width: float = 0.0, stroke_width: float = 4.0, color: ManimColor = YELLOW, buff: float = SMALL_BUFF, n_inserted_curves: int = 100, **kwar...
class FlashAround(VShowPassingFlash): def __init__( self, mobject: Mobject, time_width: float = 1.0, taper_width: float = 0.0, stroke_width: float = 4.0, color: ManimColor = YELLOW, buff: float = SMALL_BUFF, n_inserted_curves: int = 100, **kwar...
return SurroundingRectangle(mobject, buff=buff)
return SurroundingRectangle(mobject, buff=buff)
3
278
21
299
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
49
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/indication.py
281,282
280,285
get_path
FlashUnder
282,285
282,285
class FlashUnder(FlashAround): def get_path(self, mobject: Mobject, buff: float) -> Underline: FILL_FUNC_BODY
class FlashUnder(FlashAround): def get_path(self, mobject: Mobject, buff: float) -> Underline: FILL_FUNC_BODY
return Underline(mobject, buff=buff, stretch_factor=1.0)
return Underline(mobject, buff=buff, stretch_factor=1.0)
4
44
26
70
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
50
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/indication.py
66,67
43,75
create_starting_mobject
FocusOn
67,75
67,75
class FocusOn(Transform): def __init__( self, focus_point: np.ndarray | Mobject, opacity: float = 0.2, color: ManimColor = GREY, run_time: float = 2, remover: bool = True, **kwargs ): self.focus_point = focus_point self.opacity = opacity ...
class FocusOn(Transform): def __init__( self, focus_point: np.ndarray | Mobject, opacity: float = 0.2, color: ManimColor = GREY, run_time: float = 2, remover: bool = True, **kwargs ): self.focus_point = focus_point self.opacity = opacity ...
return Dot( radius=FRAME_X_RADIUS + FRAME_Y_RADIUS, stroke_width=0, fill_color=self.color, fill_opacity=0, )
return Dot( radius=FRAME_X_RADIUS + FRAME_Y_RADIUS, stroke_width=0, fill_color=self.color, fill_opacity=0, )
9
271
70
341
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
51
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/indication.py
88,89
75,95
create_target
Indicate
89,95
89,95
class Indicate(Transform): def __init__( self, mobject: Mobject, scale_factor: float = 1.2, color: ManimColor = YELLOW, rate_func: Callable[[float], float] = there_and_back, **kwargs ): self.scale_factor = scale_factor self.color = color su...
class Indicate(Transform): def __init__( self, mobject: Mobject, scale_factor: float = 1.2, color: ManimColor = YELLOW, rate_func: Callable[[float], float] = there_and_back, **kwargs ): self.scale_factor = scale_factor self.color = color su...
target = self.mobject.copy() target.scale(self.scale_factor) target.set_color(self.color) return target
target = self.mobject.copy() target.scale(self.scale_factor) target.set_color(self.color) return target
7
142
47
189
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
52
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/indication.py
182,183
167,196
get_bounds
ShowPassingFlash
183,190
183,190
class ShowPassingFlash(ShowPartial): def __init__( self, mobject: Mobject, time_width: float = 0.1, remover: bool = True, **kwargs ): self.time_width = time_width super().__init__( mobject, remover=remover, **kwargs ...
class ShowPassingFlash(ShowPartial): def __init__( self, mobject: Mobject, time_width: float = 0.1, remover: bool = True, **kwargs ): self.time_width = time_width super().__init__( mobject, remover=remover, **kwargs ...
tw = self.time_width upper = interpolate(0, 1 + tw, alpha) lower = upper - tw upper = min(upper, 1) lower = max(lower, 0) return (lower, upper)
tw = self.time_width upper = interpolate(0, 1 + tw, alpha) lower = upper - tw upper = min(upper, 1) lower = max(lower, 0) return (lower, upper)
26
194
70
264
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
53
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/indication.py
402,403
398,409
create_target
TurnInsideOut
403,409
403,409
class TurnInsideOut(Transform): def __init__(self, mobject: Mobject, path_arc: float = 90 * DEGREES, **kwargs): super().__init__(mobject, path_arc=path_arc, **kwargs) def create_target(self) -> Mobject: FILL_FUNC_BODY
class TurnInsideOut(Transform): def __init__(self, mobject: Mobject, path_arc: float = 90 * DEGREES, **kwargs): super().__init__(mobject, path_arc=path_arc, **kwargs) def create_target(self) -> Mobject: FILL_FUNC_BODY
result = self.mobject.copy().reverse_points() if isinstance(result, VMobject): result.refresh_triangulation() return result
result = self.mobject.copy().reverse_points() if isinstance(result, VMobject): result.refresh_triangulation() return result
9
86
50
136
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
54
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/indication.py
210,211
196,256
taper_kernel
VShowPassingFlash
211,217
211,217
class VShowPassingFlash(Animation): def __init__( self, vmobject: VMobject, time_width: float = 0.3, taper_width: float = 0.05, remover: bool = True, **kwargs ): self.time_width = time_width self.taper_width = taper_width super().__init__(v...
class VShowPassingFlash(Animation): def __init__( self, vmobject: VMobject, time_width: float = 0.3, taper_width: float = 0.05, remover: bool = True, **kwargs ): self.time_width = time_width self.taper_width = taper_width super().__init__(v...
if x < self.taper_width: return x elif x > 1 - self.taper_width: return 1.0 - x return 1.0
if x < self.taper_width: return x elif x > 1 - self.taper_width: return 1.0 - x return 1.0
18
580
53
633
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
55
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/indication.py
381,387
356,398
interpolate_submobject
WiggleOutThenIn
387,398
387,398
class WiggleOutThenIn(Animation): def __init__( self, mobject: Mobject, scale_value: float = 1.1, rotation_angle: float = 0.01 * TAU, n_wiggles: int = 6, scale_about_point: np.ndarray | None = None, rotate_about_point: np.ndarray | None = None, run_tim...
class WiggleOutThenIn(Animation): def __init__( self, mobject: Mobject, scale_value: float = 1.1, rotation_angle: float = 0.01 * TAU, n_wiggles: int = 6, scale_about_point: np.ndarray | None = None, rotate_about_point: np.ndarray | None = None, run_tim...
submobject.match_points(starting_sumobject) submobject.scale( interpolate(1, self.scale_value, there_and_back(alpha)), about_point=self.get_scale_about_point() ) submobject.rotate( wiggle(alpha, self.n_wiggles) * self.rotation_angle, about_...
submobject.match_points(starting_sumobject) submobject.scale( interpolate(1, self.scale_value, there_and_back(alpha)), about_point=self.get_scale_about_point() ) submobject.rotate( wiggle(alpha, self.n_wiggles) * self.rotation_angle, about_...
14
351
130
481
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
from __future__ import annotations import math from os import remove import numpy as np from manimlib.animation.animation import Animation from manimlib.animation.composition import AnimationGroup from manimlib.animation.composition import Succession from manimlib.animation.creation import ShowCreation from manimlib....
56
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/numbers.py
31,32
14,37
interpolate_mobject
ChangingDecimal
32,37
32,37
class ChangingDecimal(Animation): def __init__( self, decimal_mob: DecimalNumber, number_update_func: Callable[[float], float], suspend_mobject_updating: bool = False, **kwargs ): assert(isinstance(decimal_mob, DecimalNumber)) self.number_update_func = num...
class ChangingDecimal(Animation): def __init__( self, decimal_mob: DecimalNumber, number_update_func: Callable[[float], float], suspend_mobject_updating: bool = False, **kwargs ): assert(isinstance(decimal_mob, DecimalNumber)) self.number_update_func = num...
self.mobject.set_value( self.number_update_func(alpha) )
self.mobject.set_value( self.number_update_func(alpha) )
3
183
33
216
from __future__ import annotations from manimlib.animation.animation import Animation from manimlib.mobject.numbers import DecimalNumber from manimlib.utils.bezier import interpolate from manimlib.utils.simple_functions import clip from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable ...
from __future__ import annotations from manimlib.animation.animation import Animation from manimlib.mobject.numbers import DecimalNumber from manimlib.utils.bezier import interpolate from manimlib.utils.simple_functions import clip from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable ...
57
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/rotation.py
42,43
17,58
interpolate_mobject
Rotating
43,58
43,58
class Rotating(Animation): def __init__( self, mobject: Mobject, angle: float = TAU, axis: np.ndarray = OUT, about_point: np.ndarray | None = None, about_edge: np.ndarray | None = None, run_time: float = 5.0, rate_func: Callable[[float], float] = linea...
class Rotating(Animation): def __init__( self, mobject: Mobject, angle: float = TAU, axis: np.ndarray = OUT, about_point: np.ndarray | None = None, about_edge: np.ndarray | None = None, run_time: float = 5.0, rate_func: Callable[[float], float] = linea...
pairs = zip( self.mobject.family_members_with_points(), self.starting_mobject.family_members_with_points(), ) for sm1, sm2 in pairs: for key in sm1.pointlike_data_keys: sm1.data[key][:] = sm2.data[key] self.mobject.rotate( s...
pairs = zip( self.mobject.family_members_with_points(), self.starting_mobject.family_members_with_points(), ) for sm1, sm2 in pairs: for key in sm1.pointlike_data_keys: sm1.data[key][:] = sm2.data[key] self.mobject.rotate( s...
26
252
163
415
from __future__ import annotations from manimlib.animation.animation import Animation from manimlib.constants import ORIGIN, OUT from manimlib.constants import PI, TAU from manimlib.utils.rate_functions import linear from manimlib.utils.rate_functions import smooth from typing import TYPE_CHECKING if TYPE_CHECKING: ...
from __future__ import annotations from manimlib.animation.animation import Animation from manimlib.constants import ORIGIN, OUT from manimlib.constants import PI, TAU from manimlib.utils.rate_functions import linear from manimlib.utils.rate_functions import smooth from typing import TYPE_CHECKING if TYPE_CHECKING: ...
58
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/update.py
63,64
52,67
interpolate_mobject
MaintainPositionRelativeTo
64,67
64,67
class MaintainPositionRelativeTo(Animation): def __init__( self, mobject: Mobject, tracked_mobject: Mobject, **kwargs ): self.tracked_mobject = tracked_mobject self.diff = mobject.get_center() - tracked_mobject.get_center() super().__init__(mobject, **kwar...
class MaintainPositionRelativeTo(Animation): def __init__( self, mobject: Mobject, tracked_mobject: Mobject, **kwargs ): self.tracked_mobject = tracked_mobject self.diff = mobject.get_center() - tracked_mobject.get_center() super().__init__(mobject, **kwar...
target = self.tracked_mobject.get_center() location = self.mobject.get_center() self.mobject.shift(target - location + self.diff)
target = self.tracked_mobject.get_center() location = self.mobject.get_center() self.mobject.shift(target - location + self.diff)
11
130
49
179
from __future__ import annotations from manimlib.animation.animation import Animation from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable from manimlib.mobject.mobject import Mobject class UpdateFromFunc(Animation): """ update_function of the form func(mobject), presumab...
from __future__ import annotations from manimlib.animation.animation import Animation from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable from manimlib.mobject.mobject import Mobject class UpdateFromFunc(Animation): """ update_function of the form func(mobject), presumab...
59
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/update.py
48,49
37,52
interpolate_mobject
UpdateFromAlphaFunc
49,52
49,52
class UpdateFromAlphaFunc(Animation): def __init__( self, mobject: Mobject, update_function: Callable[[Mobject, float], Mobject | None], suspend_mobject_updating: bool = False, **kwargs ): self.update_function = update_function super().__init__(mobject, su...
class UpdateFromAlphaFunc(Animation): def __init__( self, mobject: Mobject, update_function: Callable[[Mobject, float], Mobject | None], suspend_mobject_updating: bool = False, **kwargs ): self.update_function = update_function super().__init__(mobject, su...
self.update_function(self.mobject, alpha)
self.update_function(self.mobject, alpha)
2
143
20
163
from __future__ import annotations from manimlib.animation.animation import Animation from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable from manimlib.mobject.mobject import Mobject class UpdateFromFunc(Animation): """ update_function of the form func(mobject), presumab...
from __future__ import annotations from manimlib.animation.animation import Animation from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable from manimlib.mobject.mobject import Mobject class UpdateFromFunc(Animation): """ update_function of the form func(mobject), presumab...
60
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/animation/update.py
33,34
13,37
interpolate_mobject
UpdateFromFunc
34,37
34,37
class UpdateFromFunc(Animation): """ update_function of the form func(mobject), presumably to be used when the state of one mobject is dependent on another simultaneously animated mobject """ def __init__( self, mobject: Mobject, update_function: Callable[[Mobject], Mobje...
class UpdateFromFunc(Animation): """ update_function of the form func(mobject), presumably to be used when the state of one mobject is dependent on another simultaneously animated mobject """ def __init__( self, mobject: Mobject, update_function: Callable[[Mobject], Mobje...
self.update_function(self.mobject)
self.update_function(self.mobject)
1
190
18
208
from __future__ import annotations from manimlib.animation.animation import Animation from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable from manimlib.mobject.mobject import Mobject class UpdateFromFunc(Animation): """ update_function of the form func(mobject), presumab...
from __future__ import annotations from manimlib.animation.animation import Animation from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable from manimlib.mobject.mobject import Mobject class UpdateFromFunc(Animation): """ update_function of the form func(mobject), presumab...
62
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/event_handler/event_dispatcher.py
37,38
9,96
dispatch
EventDispatcher
38,80
38,80
class EventDispatcher(object): def __init__(self): self.event_listners: dict[ EventType, list[EventListener] ] = { event_type: [] for event_type in EventType } self.mouse_point = np.array((0., 0., 0.)) self.mouse_drag_point = np.array((0., ...
class EventDispatcher(object): def __init__(self): self.event_listners: dict[ EventType, list[EventListener] ] = { event_type: [] for event_type in EventType } self.mouse_point = np.array((0., 0., 0.)) self.mouse_drag_point = np.array((0., ...
if event_type == EventType.MouseMotionEvent: self.mouse_point = event_data["point"] elif event_type == EventType.MouseDragEvent: self.mouse_drag_point = event_data["point"] elif event_type == EventType.KeyPressEvent: self.pressed_keys.add(event_data["symbol"])...
if event_type == EventType.MouseMotionEvent: self.mouse_point = event_data["point"] elif event_type == EventType.MouseDragEvent: self.mouse_drag_point = event_data["point"] elif event_type == EventType.KeyPressEvent: self.pressed_keys.add(event_data["symbol"])...
125
523
578
1,101
from __future__ import annotations import numpy as np from manimlib.event_handler.event_listner import EventListener from manimlib.event_handler.event_type import EventType class EventDispatcher(object): def __init__(self): self.event_listners: dict[ EventType, list[EventListener] ] ...
from __future__ import annotations import numpy as np from manimlib.event_handler.event_listner import EventListener from manimlib.event_handler.event_type import EventType class EventDispatcher(object): def __init__(self): self.event_listners: dict[ EventType, list[EventListener] ] ...
63
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/extract_scene.py
126,127
1,136
main
127,136
127,136
import copy import inspect import sys from manimlib.config import get_custom_config from manimlib.logger import log from manimlib.scene.interactive_scene import InteractiveScene from manimlib.scene.scene import Scene class BlankScene(InteractiveScene): def construct(self): exec(get_custom_config()["unive...
import copy import inspect import sys from manimlib.config import get_custom_config from manimlib.logger import log from manimlib.scene.interactive_scene import InteractiveScene from manimlib.scene.scene import Scene class BlankScene(InteractiveScene): def construct(self): exec(get_custom_config()["unive...
module = config["module"] scene_config = get_scene_config(config) if module is None: # If no module was passed in, just play the blank scene return [BlankScene(**scene_config)] all_scene_classes = get_scene_classes_from_module(module) scenes = get_scenes_to_render(all_scene_classes,...
module = config["module"] scene_config = get_scene_config(config) if module is None: # If no module was passed in, just play the blank scene return [BlankScene(**scene_config)] all_scene_classes = get_scene_classes_from_module(module) scenes = get_scenes_to_render(all_scene_classes,...
34
1,298
122
1,420
import copy import inspect import sys from manimlib.config import get_custom_config from manimlib.logger import log from manimlib.scene.interactive_scene import InteractiveScene from manimlib.scene.scene import Scene class BlankScene(InteractiveScene): def construct(self): exec(get_custom_config()["unive...
import copy import inspect import sys from manimlib.config import get_custom_config from manimlib.logger import log from manimlib.scene.interactive_scene import InteractiveScene from manimlib.scene.scene import Scene class BlankScene(InteractiveScene): def construct(self): exec(get_custom_config()["unive...
64
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/extract_scene.py
12,13
11,17
construct
BlankScene
13,17
13,17
class BlankScene(InteractiveScene): def construct(self): FILL_FUNC_BODY
class BlankScene(InteractiveScene): def construct(self): FILL_FUNC_BODY
exec(get_custom_config()["universal_import_line"]) self.embed()
exec(get_custom_config()["universal_import_line"]) self.embed()
2
29
31
60
import copy import inspect import sys from manimlib.config import get_custom_config from manimlib.logger import log from manimlib.scene.interactive_scene import InteractiveScene from manimlib.scene.scene import Scene class BlankScene(InteractiveScene): def construct(self): FILL_FUNC_BODYdef is_child_scene(obj, m...
import copy import inspect import sys from manimlib.config import get_custom_config from manimlib.logger import log from manimlib.scene.interactive_scene import InteractiveScene from manimlib.scene.scene import Scene class BlankScene(InteractiveScene): def construct(self): FILL_FUNC_BODYdef is_child_scene(obj, m...
65
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/boolean_ops.py
26,30
1,122
_convert_skia_path_to_vmobject
30,52
30,52
from __future__ import annotations import numpy as np import pathops from manimlib.mobject.types.vectorized_mobject import VMobject # Boolean operations between 2D mobjects # Borrowed from from https://github.com/ManimCommunity/manim/ def _convert_vmobject_to_skia_path(vmobject: VMobject) -> pathops.Path: path...
from __future__ import annotations import numpy as np import pathops from manimlib.mobject.types.vectorized_mobject import VMobject # Boolean operations between 2D mobjects # Borrowed from from https://github.com/ManimCommunity/manim/ def _convert_vmobject_to_skia_path(vmobject: VMobject) -> pathops.Path: path...
PathVerb = pathops.PathVerb current_path_start = np.array([0.0, 0.0, 0.0]) for path_verb, points in path: if path_verb == PathVerb.CLOSE: vmobject.add_line_to(current_path_start) else: points = np.hstack((np.array(points), np.zeros((len(points), 1)))) if p...
PathVerb = pathops.PathVerb current_path_start = np.array([0.0, 0.0, 0.0]) for path_verb, points in path: if path_verb == PathVerb.CLOSE: vmobject.add_line_to(current_path_start) else: points = np.hstack((np.array(points), np.zeros((len(points), 1)))) if p...
57
1,082
303
1,385
from __future__ import annotations import numpy as np import pathops from manimlib.mobject.types.vectorized_mobject import VMobject # Boolean operations between 2D mobjects # Borrowed from from https://github.com/ManimCommunity/manim/ def _convert_vmobject_to_skia_path(vmobject: VMobject) -> pathops.Path: path...
from __future__ import annotations import numpy as np import pathops from manimlib.mobject.types.vectorized_mobject import VMobject # Boolean operations between 2D mobjects # Borrowed from from https://github.com/ManimCommunity/manim/ def _convert_vmobject_to_skia_path(vmobject: VMobject) -> pathops.Path: path...
66
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/changing.py
52,53
18,98
update_boundary_copies
AnimatedBoundary
53,84
53,84
class AnimatedBoundary(VGroup): def __init__( self, vmobject: VMobject, colors: List[ManimColor] = [BLUE_D, BLUE_B, BLUE_E, GREY_BROWN], max_stroke_width: float = 3.0, cycle_rate: float = 0.5, back_and_forth: bool = True, draw_rate_func: Callable[[float], floa...
class AnimatedBoundary(VGroup): def __init__( self, vmobject: VMobject, colors: List[ManimColor] = [BLUE_D, BLUE_B, BLUE_E, GREY_BROWN], max_stroke_width: float = 3.0, cycle_rate: float = 0.5, back_and_forth: bool = True, draw_rate_func: Callable[[float], floa...
# Not actual time, but something which passes at # an altered rate to make the implementation below # cleaner time = self.total_time * self.cycle_rate growing, fading = self.boundary_copies colors = self.colors msw = self.max_stroke_width vmobject = self.v...
# Not actual time, but something which passes at # an altered rate to make the implementation below # cleaner time = self.total_time * self.cycle_rate growing, fading = self.boundary_copies colors = self.colors msw = self.max_stroke_width vmobject = self.v...
101
524
352
876
from __future__ import annotations import numpy as np from manimlib.constants import BLUE_B, BLUE_D, BLUE_E, GREY_BROWN, WHITE from manimlib.mobject.mobject import Mobject from manimlib.mobject.types.vectorized_mobject import VGroup from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.utils.ra...
from __future__ import annotations import numpy as np from manimlib.constants import BLUE_B, BLUE_D, BLUE_E, GREY_BROWN, WHITE from manimlib.mobject.mobject import Mobject from manimlib.mobject.types.vectorized_mobject import VGroup from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.utils.ra...
67
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/changing.py
122,123
98,148
update_path
TracedPath
123,148
123,148
class TracedPath(VMobject): def __init__( self, traced_point_func: Callable[[], Vect3], time_traced: float = np.inf, time_per_anchor: float = 1.0 / 15, stroke_width: float | Iterable[float] = 2.0, stroke_color: ManimColor = WHITE, fill_opacity: float = 0.0, ...
class TracedPath(VMobject): def __init__( self, traced_point_func: Callable[[], Vect3], time_traced: float = np.inf, time_per_anchor: float = 1.0 / 15, stroke_width: float | Iterable[float] = 2.0, stroke_color: ManimColor = WHITE, fill_opacity: float = 0.0, ...
if dt == 0: return self point = self.traced_point_func().copy() self.traced_points.append(point) if self.time_traced < np.inf: n_relevant_points = int(self.time_traced / dt + 0.5) n_tps = len(self.traced_points) if n_tps < n_relevant_point...
if dt == 0: return self point = self.traced_point_func().copy() self.traced_points.append(point) if self.time_traced < np.inf: n_relevant_points = int(self.time_traced / dt + 0.5) n_tps = len(self.traced_points) if n_tps < n_relevant_point...
72
290
287
577
from __future__ import annotations import numpy as np from manimlib.constants import BLUE_B, BLUE_D, BLUE_E, GREY_BROWN, WHITE from manimlib.mobject.mobject import Mobject from manimlib.mobject.types.vectorized_mobject import VGroup from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.utils.ra...
from __future__ import annotations import numpy as np from manimlib.constants import BLUE_B, BLUE_D, BLUE_E, GREY_BROWN, WHITE from manimlib.mobject.mobject import Mobject from manimlib.mobject.types.vectorized_mobject import VGroup from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.utils.ra...
68
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/interactive.py
67,68
52,74
mob_on_mouse_press
Button
68,74
68,74
class Button(Mobject): """ Pass any mobject and register an on_click method The on_click method takes mobject as argument like updater """ def __init__(self, mobject: Mobject, on_click: Callable[[Mobject]], **kwargs): super().__init__(**kwargs) assert(isinstance(mobject, Mo...
class Button(Mobject): """ Pass any mobject and register an on_click method The on_click method takes mobject as argument like updater """ def __init__(self, mobject: Mobject, on_click: Callable[[Mobject]], **kwargs): super().__init__(**kwargs) assert(isinstance(mobject, Mo...
self.on_click(mob) return False # Controls
self.on_click(mob) return False # Controls
5
189
28
217
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
69
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/interactive.py
188,189
138,213
get_checkmark
Checkbox
189,200
189,200
class Checkbox(ControlMobject): def __init__( self, value: bool = True, value_type: np.dtype = np.dtype(bool), rect_kwargs: dict = { "width": 0.5, "height": 0.5, "fill_opacity": 0.0 }, checkmark_kwargs: dict = { "stroke_...
class Checkbox(ControlMobject): def __init__( self, value: bool = True, value_type: np.dtype = np.dtype(bool), rect_kwargs: dict = { "width": 0.5, "height": 0.5, "fill_opacity": 0.0 }, checkmark_kwargs: dict = { "stroke_...
checkmark = VGroup( Line(UP / 2 + 2 * LEFT, DOWN + LEFT, **self.checkmark_kwargs), Line(DOWN + LEFT, UP + RIGHT, **self.checkmark_kwargs) ) checkmark.stretch_to_fit_width(self.box.get_width()) checkmark.stretch_to_fit_height(self.box.get_height()) checkma...
checkmark = VGroup( Line(UP / 2 + 2 * LEFT, DOWN + LEFT, **self.checkmark_kwargs), Line(DOWN + LEFT, UP + RIGHT, **self.checkmark_kwargs) ) checkmark.stretch_to_fit_width(self.box.get_width()) checkmark.stretch_to_fit_height(self.box.get_height()) checkma...
28
658
148
806
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
70
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/interactive.py
366,367
277,382
get_value
ColorSliders
367,373
367,373
class ColorSliders(Group): def __init__( self, sliders_kwargs: dict = {}, rect_kwargs: dict = { "width": 2.0, "height": 0.5, "stroke_opacity": 1.0 }, background_grid_kwargs: dict = { "colors": [GREY_A, GREY_C], "sing...
class ColorSliders(Group): def __init__( self, sliders_kwargs: dict = {}, rect_kwargs: dict = { "width": 2.0, "height": 0.5, "stroke_opacity": 1.0 }, background_grid_kwargs: dict = { "colors": [GREY_A, GREY_C], "sing...
r = self.r_slider.get_value() / 255 g = self.g_slider.get_value() / 255 b = self.b_slider.get_value() / 255 alpha = self.a_slider.get_value() return np.array((r, g, b, alpha))
r = self.r_slider.get_value() / 255 g = self.g_slider.get_value() / 255 b = self.b_slider.get_value() / 255 alpha = self.a_slider.get_value() return np.array((r, g, b, alpha))
23
1,243
97
1,340
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
71
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/interactive.py
83,84
74,97
set_value
ControlMobject
84,88
84,88
class ControlMobject(ValueTracker): def __init__(self, value: float, *mobjects: Mobject, **kwargs): super().__init__(value=value, **kwargs) self.add(*mobjects) # To avoid lock_static_mobject_data while waiting in scene self.add_updater(lambda mob: None) self.fix_in_frame() ...
class ControlMobject(ValueTracker): def __init__(self, value: float, *mobjects: Mobject, **kwargs): super().__init__(value=value, **kwargs) self.add(*mobjects) # To avoid lock_static_mobject_data while waiting in scene self.add_updater(lambda mob: None) self.fix_in_frame() ...
self.assert_value(value) self.set_value_anim(value) return ValueTracker.set_value(self, value)
self.assert_value(value) self.set_value_anim(value) return ValueTracker.set_value(self, value)
5
173
42
215
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
72
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/interactive.py
520,521
467,569
move_panel_and_controls_to_panel_opener
ControlPanel
521,536
521,536
class ControlPanel(Group): def __init__( self, *controls: ControlMobject, panel_kwargs: dict = { "width": FRAME_WIDTH / 4, "height": MED_SMALL_BUFF + FRAME_HEIGHT, "fill_color": GREY_C, "fill_opacity": 1.0, "stroke_width": 0.0 ...
class ControlPanel(Group): def __init__( self, *controls: ControlMobject, panel_kwargs: dict = { "width": FRAME_WIDTH / 4, "height": MED_SMALL_BUFF + FRAME_HEIGHT, "fill_color": GREY_C, "fill_opacity": 1.0, "stroke_width": 0.0 ...
self.panel.next_to( self.panel_opener_rect, direction=UP, buff=0 ) controls_old_x = self.controls.get_x() self.controls.next_to( self.panel_opener_rect, direction=UP, buff=MED_SMALL_BUFF ) self.cont...
self.panel.next_to( self.panel_opener_rect, direction=UP, buff=0 ) controls_old_x = self.controls.get_x() self.controls.next_to( self.panel_opener_rect, direction=UP, buff=MED_SMALL_BUFF ) self.cont...
14
1,139
131
1,270
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
73
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/interactive.py
124,125
97,138
set_value_anim
EnableDisableButton
125,130
125,130
class EnableDisableButton(ControlMobject): def __init__( self, value: bool = True, value_type: np.dtype = np.dtype(bool), rect_kwargs: dict = { "width": 0.5, "height": 0.5, "fill_opacity": 1.0 }, enable_color: ManimColor = GREEN, ...
class EnableDisableButton(ControlMobject): def __init__( self, value: bool = True, value_type: np.dtype = np.dtype(bool), rect_kwargs: dict = { "width": 0.5, "height": 0.5, "fill_opacity": 1.0 }, enable_color: ManimColor = GREEN, ...
if value: self.box.set_fill(self.enable_color) else: self.box.set_fill(self.disable_color)
if value: self.box.set_fill(self.enable_color) else: self.box.set_fill(self.disable_color)
5
357
47
404
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
74
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/interactive.py
267,268
213,277
get_value_from_point
LinearNumberSlider
268,277
268,277
class LinearNumberSlider(ControlMobject): def __init__( self, value: float = 0, value_type: type = np.float64, min_value: float = -10.0, max_value: float = 10.0, step: float = 1.0, rounded_rect_kwargs: dict = { "height": 0.075, "width":...
class LinearNumberSlider(ControlMobject): def __init__( self, value: float = 0, value_type: type = np.float64, min_value: float = -10.0, max_value: float = 10.0, step: float = 1.0, rounded_rect_kwargs: dict = { "height": 0.075, "width":...
start, end = self.slider_axis.get_start_and_end() point_on_line = get_closest_point_on_line(start, end, point) prop = get_norm(point_on_line - start) / get_norm(end - start) value = self.min_value + prop * (self.max_value - self.min_value) no_of_steps = int((value - self.min_valu...
start, end = self.slider_axis.get_start_and_end() point_on_line = get_closest_point_on_line(start, end, point) prop = get_norm(point_on_line - start) / get_norm(end - start) value = self.min_value + prop * (self.max_value - self.min_value) no_of_steps = int((value - self.min_valu...
43
668
167
835
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
75
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/interactive.py
47,48
34,52
mob_on_mouse_drag
MotionMobject
48,52
48,52
class MotionMobject(Mobject): """ You could hold and drag this object to any position """ def __init__(self, mobject: Mobject, **kwargs): super().__init__(**kwargs) assert(isinstance(mobject, Mobject)) self.mobject = mobject self.mobject.add_mouse_drag_listner(self.mo...
class MotionMobject(Mobject): """ You could hold and drag this object to any position """ def __init__(self, mobject: Mobject, **kwargs): super().__init__(**kwargs) assert(isinstance(mobject, Mobject)) self.mobject = mobject self.mobject.add_mouse_drag_listner(self.mo...
mob.move_to(event_data["point"]) return False
mob.move_to(event_data["point"]) return False
3
192
25
217
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
76
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/interactive.py
445,446
382,467
on_key_press
Textbox
446,467
446,467
class Textbox(ControlMobject): def __init__( self, value: str = "", value_type: np.dtype = np.dtype(object), box_kwargs: dict = { "width": 2.0, "height": 1.0, "fill_color": WHITE, "fill_opacity": 1.0, }, text_kwargs: dic...
class Textbox(ControlMobject): def __init__( self, value: str = "", value_type: np.dtype = np.dtype(object), box_kwargs: dict = { "width": 2.0, "height": 1.0, "fill_color": WHITE, "fill_opacity": 1.0, }, text_kwargs: dic...
symbol = event_data["symbol"] modifiers = event_data["modifiers"] char = chr(symbol) if mob.isActive: old_value = mob.get_value() new_value = old_value if char.isalnum(): if (modifiers & PygletWindowKeys.MOD_SHIFT) or (modifiers & Pygle...
symbol = event_data["symbol"] modifiers = event_data["modifiers"] char = chr(symbol) if mob.isActive: old_value = mob.get_value() new_value = old_value if char.isalnum(): if (modifiers & PygletWindowKeys.MOD_SHIFT) or (modifiers & Pygle...
68
736
259
995
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
from __future__ import annotations import numpy as np from pyglet.window import key as PygletWindowKeys from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.constant...
77
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/mobject_update_utils.py
34,35
1,124
f_always
40,55
35,55
from __future__ import annotations import inspect from manimlib.constants import DEGREES from manimlib.constants import RIGHT from manimlib.mobject.mobject import Mobject from manimlib.utils.simple_functions import clip from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable import n...
from __future__ import annotations import inspect from manimlib.constants import DEGREES from manimlib.constants import RIGHT from manimlib.mobject.mobject import Mobject from manimlib.utils.simple_functions import clip from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable import n...
assert_is_mobject_method(method) mobject = method.__self__ func = method.__func__ def updater(mob): args = [ arg_generator() for arg_generator in arg_generators ] func(mob, *args, **kwargs) mobject.add_updater(updater) return mobject
""" More functional version of always, where instead of taking in args, it takes in functions which output the relevant arguments. """ assert_is_mobject_method(method) mobject = method.__self__ func = method.__func__ def updater(mob): args = [ arg_generator() ...
24
879
116
995
from __future__ import annotations import inspect from manimlib.constants import DEGREES from manimlib.constants import RIGHT from manimlib.mobject.mobject import Mobject from manimlib.utils.simple_functions import clip from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable import n...
from __future__ import annotations import inspect from manimlib.constants import DEGREES from manimlib.constants import RIGHT from manimlib.mobject.mobject import Mobject from manimlib.utils.simple_functions import clip from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable import n...
80
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/numbers.py
187,188
26,199
_handle_scale_side_effects
DecimalNumber
188,191
188,191
class DecimalNumber(VMobject): def __init__( self, number: float | complex = 0, color: ManimColor = WHITE, stroke_width: float = 0, fill_opacity: float = 1.0, num_decimal_places: int = 2, include_sign: bool = False, group_with_commas: bool = True, ...
class DecimalNumber(VMobject): def __init__( self, number: float | complex = 0, color: ManimColor = WHITE, stroke_width: float = 0, fill_opacity: float = 1.0, num_decimal_places: int = 2, include_sign: bool = False, group_with_commas: bool = True, ...
self.uniforms["font_size"] = scale_factor * self.uniforms["font_size"] return self
self.uniforms["font_size"] = scale_factor * self.uniforms["font_size"] return self
7
1,966
33
1,999
from __future__ import annotations from functools import lru_cache import numpy as np from manimlib.constants import DOWN, LEFT, RIGHT, UP from manimlib.constants import WHITE from manimlib.mobject.svg.tex_mobject import Tex from manimlib.mobject.svg.text_mobject import Text from manimlib.mobject.types.vectorized_mob...
from __future__ import annotations from functools import lru_cache import numpy as np from manimlib.constants import DOWN, LEFT, RIGHT, UP from manimlib.constants import WHITE from manimlib.mobject.svg.tex_mobject import Tex from manimlib.mobject.svg.text_mobject import Text from manimlib.mobject.types.vectorized_mob...
81
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/numbers.py
208,209
199,210
get_value
Integer
209,210
209,210
class Integer(DecimalNumber): def __init__( self, number: int = 0, num_decimal_places: int = 0, **kwargs, ): super().__init__(number, num_decimal_places=num_decimal_places, **kwargs) def get_value(self) -> int: FILL_FUNC_BODY
class Integer(DecimalNumber): def __init__( self, number: int = 0, num_decimal_places: int = 0, **kwargs, ): super().__init__(number, num_decimal_places=num_decimal_places, **kwargs) def get_value(self) -> int: FILL_FUNC_BODY
return int(np.round(super().get_value()))
return int(np.round(super().get_value()))
2
98
16
114
from __future__ import annotations from functools import lru_cache import numpy as np from manimlib.constants import DOWN, LEFT, RIGHT, UP from manimlib.constants import WHITE from manimlib.mobject.svg.tex_mobject import Tex from manimlib.mobject.svg.text_mobject import Text from manimlib.mobject.types.vectorized_mob...
from __future__ import annotations from functools import lru_cache import numpy as np from manimlib.constants import DOWN, LEFT, RIGHT, UP from manimlib.constants import WHITE from manimlib.mobject.svg.tex_mobject import Tex from manimlib.mobject.svg.text_mobject import Text from manimlib.mobject.types.vectorized_mob...
82
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/probability.py
239,240
195,308
add_axes
BarChart
240,276
240,276
class BarChart(VGroup): def __init__( self, values: Iterable[float], height: float = 4, width: float = 6, n_ticks: int = 4, include_x_ticks: bool = False, tick_width: float = 0.2, tick_height: float = 0.15, label_y_axis: bool = True, y_...
class BarChart(VGroup): def __init__( self, values: Iterable[float], height: float = 4, width: float = 6, n_ticks: int = 4, include_x_ticks: bool = False, tick_width: float = 0.2, tick_height: float = 0.15, label_y_axis: bool = True, y_...
x_axis = Line(self.tick_width * LEFT / 2, self.width * RIGHT) y_axis = Line(MED_LARGE_BUFF * DOWN, self.height * UP) y_ticks = VGroup() heights = np.linspace(0, self.height, self.n_ticks + 1) values = np.linspace(0, self.max_value, self.n_ticks + 1) for y, value in zip(he...
x_axis = Line(self.tick_width * LEFT / 2, self.width * RIGHT) y_axis = Line(MED_LARGE_BUFF * DOWN, self.height * UP) y_ticks = VGroup() heights = np.linspace(0, self.height, self.n_ticks + 1) values = np.linspace(0, self.max_value, self.n_ticks + 1) for y, value in zip(he...
119
899
574
1,473
from __future__ import annotations import numpy as np from manimlib.constants import BLUE, BLUE_E, GREEN_E, GREY_B, GREY_D, MAROON_B, YELLOW from manimlib.constants import DOWN, LEFT, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.mobject.geometry import Line from ma...
from __future__ import annotations import numpy as np from manimlib.constants import BLUE, BLUE_E, GREEN_E, GREY_B, GREY_D, MAROON_B, YELLOW from manimlib.constants import DOWN, LEFT, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.mobject.geometry import Line from ma...
83
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/probability.py
118,125
28,195
get_subdivision_braces_and_labels
SampleSpace
125,150
125,150
class SampleSpace(Rectangle): def __init__( self, width: float = 3, height: float = 3, fill_color: ManimColor = GREY_D, fill_opacity: float = 1, stroke_width: float = 0.5, stroke_color: ManimColor = GREY_B, default_label_scale_val: float = 1, *...
class SampleSpace(Rectangle): def __init__( self, width: float = 3, height: float = 3, fill_color: ManimColor = GREY_D, fill_opacity: float = 1, stroke_width: float = 0.5, stroke_color: ManimColor = GREY_B, default_label_scale_val: float = 1, *...
label_mobs = VGroup() braces = VGroup() for label, part in zip(labels, parts): brace = Brace( part, direction, buff=buff ) if isinstance(label, Mobject): label_mob = label else: label_...
label_mobs = VGroup() braces = VGroup() for label, part in zip(labels, parts): brace = Brace( part, direction, buff=buff ) if isinstance(label, Mobject): label_mob = label else: label_...
54
1,493
245
1,738
from __future__ import annotations import numpy as np from manimlib.constants import BLUE, BLUE_E, GREEN_E, GREY_B, GREY_D, MAROON_B, YELLOW from manimlib.constants import DOWN, LEFT, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.mobject.geometry import Line from ma...
from __future__ import annotations import numpy as np from manimlib.constants import BLUE, BLUE_E, GREEN_E, GREY_B, GREY_D, MAROON_B, YELLOW from manimlib.constants import DOWN, LEFT, RIGHT, UP from manimlib.constants import MED_LARGE_BUFF, MED_SMALL_BUFF, SMALL_BUFF from manimlib.mobject.geometry import Line from ma...
84
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/shape_matchers.py
94,95
48,98
get_fill_color
BackgroundRectangle
95,98
95,98
class BackgroundRectangle(SurroundingRectangle): def __init__( self, mobject: Mobject, color: ManimColor = None, stroke_width: float = 0, stroke_opacity: float = 0, fill_opacity: float = 0.75, buff: float = 0, **kwargs ): if color is None: ...
class BackgroundRectangle(SurroundingRectangle): def __init__( self, mobject: Mobject, color: ManimColor = None, stroke_width: float = 0, stroke_opacity: float = 0, fill_opacity: float = 0.75, buff: float = 0, **kwargs ): if color is None: ...
return Color(self.color)
return Color(self.color)
2
431
14
445
from __future__ import annotations from colour import Color from manimlib.constants import BLACK, RED, YELLOW, WHITE from manimlib.constants import DL, DOWN, DR, LEFT, RIGHT, UL, UR from manimlib.constants import SMALL_BUFF from manimlib.mobject.geometry import Line from manimlib.mobject.geometry import Rectangle fro...
from __future__ import annotations from colour import Color from manimlib.constants import BLACK, RED, YELLOW, WHITE from manimlib.constants import DL, DOWN, DR, LEFT, RIGHT, UL, UR from manimlib.constants import SMALL_BUFF from manimlib.mobject.geometry import Line from manimlib.mobject.geometry import Rectangle fro...
85
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/shape_matchers.py
36,37
22,48
surround
SurroundingRectangle
37,42
37,42
class SurroundingRectangle(Rectangle): def __init__( self, mobject: Mobject, buff: float = SMALL_BUFF, color: ManimColor = YELLOW, **kwargs ): super().__init__(color=color, **kwargs) self.buff = buff self.surround(mobject) if mobject.is_fix...
class SurroundingRectangle(Rectangle): def __init__( self, mobject: Mobject, buff: float = SMALL_BUFF, color: ManimColor = YELLOW, **kwargs ): super().__init__(color=color, **kwargs) self.buff = buff self.surround(mobject) if mobject.is_fix...
self.mobject = mobject self.buff = buff if buff is not None else self.buff super().surround(mobject, self.buff) return self
self.mobject = mobject self.buff = buff if buff is not None else self.buff super().surround(mobject, self.buff) return self
17
185
49
234
from __future__ import annotations from colour import Color from manimlib.constants import BLACK, RED, YELLOW, WHITE from manimlib.constants import DL, DOWN, DR, LEFT, RIGHT, UL, UR from manimlib.constants import SMALL_BUFF from manimlib.mobject.geometry import Line from manimlib.mobject.geometry import Rectangle fro...
from __future__ import annotations from colour import Color from manimlib.constants import BLACK, RED, YELLOW, WHITE from manimlib.constants import DL, DOWN, DR, LEFT, RIGHT, UL, UR from manimlib.constants import SMALL_BUFF from manimlib.mobject.geometry import Line from manimlib.mobject.geometry import Rectangle fro...
86
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/svg/brace.py
93,94
32,110
get_tex
Brace
94,99
94,99
class Brace(Tex): def __init__( self, mobject: Mobject, direction: Vect3 = DOWN, buff: float = 0.2, tex_string: str = R"\underbrace{\qquad}", **kwargs ): super().__init__(tex_string, **kwargs) angle = -math.atan2(*direction[:2]) + PI mobje...
class Brace(Tex): def __init__( self, mobject: Mobject, direction: Vect3 = DOWN, buff: float = 0.2, tex_string: str = R"\underbrace{\qquad}", **kwargs ): super().__init__(tex_string, **kwargs) angle = -math.atan2(*direction[:2]) + PI mobje...
buff = kwargs.pop("buff", SMALL_BUFF) tex_mob = Tex(*tex, **kwargs) self.put_at_tip(tex_mob, buff=buff) return tex_mob
buff = kwargs.pop("buff", SMALL_BUFF) tex_mob = Tex(*tex, **kwargs) self.put_at_tip(tex_mob, buff=buff) return tex_mob
12
816
66
882
from __future__ import annotations import math import copy import numpy as np from manimlib.constants import DEFAULT_MOBJECT_TO_MOBJECT_BUFFER, SMALL_BUFF from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP, DL, DR, UL from manimlib.constants import PI from manimlib.animation.composition import AnimationGro...
from __future__ import annotations import math import copy import numpy as np from manimlib.constants import DEFAULT_MOBJECT_TO_MOBJECT_BUFFER, SMALL_BUFF from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP, DL, DR, UL from manimlib.constants import PI from manimlib.animation.composition import AnimationGro...
87
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/svg/brace.py
161,162
110,175
change_brace_label
BraceLabel
162,166
162,166
class BraceLabel(VMobject): label_constructor: type = Tex def __init__( self, obj: VMobject | list[VMobject], text: str | Iterable[str], brace_direction: np.ndarray = DOWN, label_scale: float = 1.0, label_buff: float = DEFAULT_MOBJECT_TO_MOBJECT_BUFFER, *...
class BraceLabel(VMobject): label_constructor: type = Tex def __init__( self, obj: VMobject | list[VMobject], text: str | Iterable[str], brace_direction: np.ndarray = DOWN, label_scale: float = 1.0, label_buff: float = DEFAULT_MOBJECT_TO_MOBJECT_BUFFER, *...
self.shift_brace(obj) self.change_label(*text) return self
self.shift_brace(obj) self.change_label(*text) return self
4
657
29
686
from __future__ import annotations import math import copy import numpy as np from manimlib.constants import DEFAULT_MOBJECT_TO_MOBJECT_BUFFER, SMALL_BUFF from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP, DL, DR, UL from manimlib.constants import PI from manimlib.animation.composition import AnimationGro...
from __future__ import annotations import math import copy import numpy as np from manimlib.constants import DEFAULT_MOBJECT_TO_MOBJECT_BUFFER, SMALL_BUFF from manimlib.constants import DOWN, LEFT, ORIGIN, RIGHT, UP, DL, DR, UL from manimlib.constants import PI from manimlib.animation.composition import AnimationGro...
90
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/svg/svg_mobject.py
320,321
294,340
handle_commands
VMobjectFromSVGPath
321,340
321,340
class VMobjectFromSVGPath(VMobject): def __init__( self, path_obj: se.Path, **kwargs ): # Get rid of arcs path_obj.approximate_arcs_with_quads() self.path_obj = path_obj super().__init__(**kwargs) def init_points(self) -> None: # After a given...
class VMobjectFromSVGPath(VMobject): def __init__( self, path_obj: se.Path, **kwargs ): # Get rid of arcs path_obj.approximate_arcs_with_quads() self.path_obj = path_obj super().__init__(**kwargs) def init_points(self) -> None: # After a given...
segment_class_to_func_map = { se.Move: (self.start_new_path, ("end",)), se.Close: (self.close_path, ()), se.Line: (self.add_line_to, ("end",)), se.QuadraticBezier: (self.add_quadratic_bezier_curve_to, ("control", "end")), se.CubicBezier: (self.add_cubi...
segment_class_to_func_map = { se.Move: (self.start_new_path, ("end",)), se.Close: (self.close_path, ()), se.Line: (self.add_line_to, ("end",)), se.QuadraticBezier: (self.add_quadratic_bezier_curve_to, ("control", "end")), se.CubicBezier: (self.add_cubi...
60
293
304
597
from __future__ import annotations import os from xml.etree import ElementTree as ET import numpy as np import svgelements as se import io from manimlib.constants import RIGHT from manimlib.logger import log from manimlib.mobject.geometry import Circle from manimlib.mobject.geometry import Line from manimlib.mobject...
from __future__ import annotations import os from xml.etree import ElementTree as ET import numpy as np import svgelements as se import io from manimlib.constants import RIGHT from manimlib.logger import log from manimlib.mobject.geometry import Circle from manimlib.mobject.geometry import Line from manimlib.mobject...
91
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/types/image_mobject.py
39,40
20,76
init_data
ImageMobject
40,45
40,45
class ImageMobject(Mobject): shader_folder: str = "image" shader_dtype: Sequence[Tuple[str, type, Tuple[int]]] = [ ('point', np.float32, (3,)), ('im_coords', np.float32, (2,)), ('opacity', np.float32, (1,)), ] def __init__( self, filename: str, height: fl...
class ImageMobject(Mobject): shader_folder: str = "image" shader_dtype: Sequence[Tuple[str, type, Tuple[int]]] = [ ('point', np.float32, (3,)), ('im_coords', np.float32, (2,)), ('opacity', np.float32, (1,)), ] def __init__( self, filename: str, height: fl...
super().init_data(length=4) self.data["point"][:] = [UL, DL, UR, DR] self.data["im_coords"][:] = [(0, 0), (0, 1), (1, 0), (1, 1)] self.data["opacity"][:] = self.opacity
super().init_data(length=4) self.data["point"][:] = [UL, DL, UR, DR] self.data["im_coords"][:] = [(0, 0), (0, 1), (1, 0), (1, 1)] self.data["opacity"][:] = self.opacity
20
622
95
717
from __future__ import annotations import numpy as np from PIL import Image from manimlib.constants import DL, DR, UL, UR from manimlib.mobject.mobject import Mobject from manimlib.utils.bezier import inverse_interpolate from manimlib.utils.images import get_full_raster_image_path from manimlib.utils.iterables import...
from __future__ import annotations import numpy as np from PIL import Image from manimlib.constants import DL, DR, UL, UR from manimlib.mobject.mobject import Mobject from manimlib.utils.bezier import inverse_interpolate from manimlib.utils.images import get_full_raster_image_path from manimlib.utils.iterables import...
92
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/types/point_cloud_mobject.py
69,71
17,106
filter_out
PMobject
71,75
71,75
class PMobject(Mobject): def set_points(self, points: Vect3Array): if len(points) == 0: points = np.zeros((0, 3)) super().set_points(points) self.resize_points(len(points)) return self def add_points( self, points: Vect3Array, rgbas: Vect4Arra...
class PMobject(Mobject): def set_points(self, points: Vect3Array): if len(points) == 0: points = np.zeros((0, 3)) super().set_points(points) self.resize_points(len(points)) return self def add_points( self, points: Vect3Array, rgbas: Vect4Arra...
for mob in self.family_members_with_points(): mob.data = mob.data[~np.apply_along_axis(condition, 1, mob.get_points())] return self
for mob in self.family_members_with_points(): mob.data = mob.data[~np.apply_along_axis(condition, 1, mob.get_points())] return self
11
930
55
985
from __future__ import annotations import numpy as np from manimlib.mobject.mobject import Mobject from manimlib.utils.color import color_gradient from manimlib.utils.color import color_to_rgba from manimlib.utils.iterables import resize_with_interpolation from typing import TYPE_CHECKING if TYPE_CHECKING: from...
from __future__ import annotations import numpy as np from manimlib.mobject.mobject import Mobject from manimlib.utils.color import color_gradient from manimlib.utils.color import color_to_rgba from manimlib.utils.iterables import resize_with_interpolation from typing import TYPE_CHECKING if TYPE_CHECKING: from...
93
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/value_tracker.py
61,62
51,65
set_value
ExponentialValueTracker
62,65
62,65
class ExponentialValueTracker(ValueTracker): """ Operates just like ValueTracker, except it encodes the value as the exponential of a position coordinate, which changes how interpolation behaves """ def get_value(self) -> float | complex: return np.exp(ValueTracker.get_value(self)) ...
class ExponentialValueTracker(ValueTracker): """ Operates just like ValueTracker, except it encodes the value as the exponential of a position coordinate, which changes how interpolation behaves """ def get_value(self) -> float | complex: return np.exp(ValueTracker.get_value(self)) ...
return ValueTracker.set_value(self, np.log(value))
return ValueTracker.set_value(self, np.log(value))
3
112
24
136
from __future__ import annotations import numpy as np from manimlib.mobject.mobject import Mobject from manimlib.utils.iterables import listify from typing import TYPE_CHECKING if TYPE_CHECKING: from manimlib.typing import Self class ValueTracker(Mobject): """ Not meant to be displayed. Instead the po...
from __future__ import annotations import numpy as np from manimlib.mobject.mobject import Mobject from manimlib.utils.iterables import listify from typing import TYPE_CHECKING if TYPE_CHECKING: from manimlib.typing import Self class ValueTracker(Mobject): """ Not meant to be displayed. Instead the po...
94
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/value_tracker.py
30,31
13,51
init_uniforms
ValueTracker
31,37
31,37
class ValueTracker(Mobject): """ Not meant to be displayed. Instead the position encodes some number, often one which another animation or continual_animation uses for its update function, and by treating it as a mobject it can still be animated and manipulated just like anything else. """ ...
class ValueTracker(Mobject): """ Not meant to be displayed. Instead the position encodes some number, often one which another animation or continual_animation uses for its update function, and by treating it as a mobject it can still be animated and manipulated just like anything else. """ ...
super().init_uniforms() self.uniforms["value"] = np.array( listify(self.value), dtype=self.value_type, )
super().init_uniforms() self.uniforms["value"] = np.array( listify(self.value), dtype=self.value_type, )
7
301
53
354
from __future__ import annotations import numpy as np from manimlib.mobject.mobject import Mobject from manimlib.utils.iterables import listify from typing import TYPE_CHECKING if TYPE_CHECKING: from manimlib.typing import Self class ValueTracker(Mobject): """ Not meant to be displayed. Instead the po...
from __future__ import annotations import numpy as np from manimlib.mobject.mobject import Mobject from manimlib.utils.iterables import listify from typing import TYPE_CHECKING if TYPE_CHECKING: from manimlib.typing import Self class ValueTracker(Mobject): """ Not meant to be displayed. Instead the po...
96
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/vector_field.py
328,329
302,334
update
AnimatedStreamLines
329,334
329,334
class AnimatedStreamLines(VGroup): def __init__( self, stream_lines: StreamLines, lag_range: float = 4, line_anim_config: dict = dict( rate_func=linear, time_width=1.0, ), **kwargs ): super().__init__(**kwargs) self.stream_l...
class AnimatedStreamLines(VGroup): def __init__( self, stream_lines: StreamLines, lag_range: float = 4, line_anim_config: dict = dict( rate_func=linear, time_width=1.0, ), **kwargs ): super().__init__(**kwargs) self.stream_l...
stream_lines = self.stream_lines for line in stream_lines: line.time += dt adjusted_time = max(line.time, 0) % line.anim.run_time line.anim.update(adjusted_time / line.anim.run_time)
stream_lines = self.stream_lines for line in stream_lines: line.time += dt adjusted_time = max(line.time, 0) % line.anim.run_time line.anim.update(adjusted_time / line.anim.run_time)
19
240
77
317
from __future__ import annotations import itertools as it import numpy as np from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import WHITE from manimlib.animation.indication import VShowPassingFlash from manimlib.mobject.geometry import Arrow from manimlib.mobject.types.vectorized_mob...
from __future__ import annotations import itertools as it import numpy as np from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import WHITE from manimlib.animation.indication import VShowPassingFlash from manimlib.mobject.geometry import Arrow from manimlib.mobject.types.vectorized_mob...
97
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/vector_field.py
276,277
184,302
init_style
StreamLines
277,302
277,302
class StreamLines(VGroup): def __init__( self, func: Callable[[float, float], Sequence[float]], coordinate_system: CoordinateSystem, step_multiple: float = 0.5, n_repeats: int = 1, noise_factor: float | None = None, # Config for drawing lines dt: float...
class StreamLines(VGroup): def __init__( self, func: Callable[[float, float], Sequence[float]], coordinate_system: CoordinateSystem, step_multiple: float = 0.5, n_repeats: int = 1, noise_factor: float | None = None, # Config for drawing lines dt: float...
if self.color_by_magnitude: values_to_rgbs = get_vectorized_rgb_gradient_function( *self.magnitude_range, self.color_map, ) cs = self.coordinate_system for line in self.submobjects: norms = [ get_norm(self.func(*...
if self.color_by_magnitude: values_to_rgbs = get_vectorized_rgb_gradient_function( *self.magnitude_range, self.color_map, ) cs = self.coordinate_system for line in self.submobjects: norms = [ get_norm(self.func(*...
56
1,088
312
1,400
from __future__ import annotations import itertools as it import numpy as np from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import WHITE from manimlib.animation.indication import VShowPassingFlash from manimlib.mobject.geometry import Arrow from manimlib.mobject.types.vectorized_mob...
from __future__ import annotations import itertools as it import numpy as np from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import WHITE from manimlib.animation.indication import VShowPassingFlash from manimlib.mobject.geometry import Arrow from manimlib.mobject.types.vectorized_mob...
98
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/mobject/vector_field.py
157,158
121,184
get_vector
VectorField
158,184
158,184
class VectorField(VGroup): def __init__( self, func: Callable[[float, float], Sequence[float]], coordinate_system: CoordinateSystem, step_multiple: float = 0.5, magnitude_range: Tuple[float, float] = (0, 2), color_map: str = "3b1b_colormap", # Takes in actual ...
class VectorField(VGroup): def __init__( self, func: Callable[[float, float], Sequence[float]], coordinate_system: CoordinateSystem, step_multiple: float = 0.5, magnitude_range: Tuple[float, float] = (0, 2), color_map: str = "3b1b_colormap", # Takes in actual ...
vector_config = merge_dicts_recursively( self.vector_config, kwargs ) output = np.array(self.func(*coords)) norm = get_norm(output) if norm > 0: output *= self.length_func(norm) / norm origin = self.coordinate_system.get_origin() ...
vector_config = merge_dicts_recursively( self.vector_config, kwargs ) output = np.array(self.func(*coords)) norm = get_norm(output) if norm > 0: output *= self.length_func(norm) / norm origin = self.coordinate_system.get_origin() ...
47
406
246
652
from __future__ import annotations import itertools as it import numpy as np from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import WHITE from manimlib.animation.indication import VShowPassingFlash from manimlib.mobject.geometry import Arrow from manimlib.mobject.types.vectorized_mob...
from __future__ import annotations import itertools as it import numpy as np from manimlib.constants import FRAME_HEIGHT, FRAME_WIDTH from manimlib.constants import WHITE from manimlib.animation.indication import VShowPassingFlash from manimlib.mobject.geometry import Arrow from manimlib.mobject.types.vectorized_mob...
100
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/customization.py
11,12
1,25
get_customization
12,25
12,25
import os import tempfile from manimlib.config import get_custom_config from manimlib.config import get_manim_dir CUSTOMIZATION = {} def get_customization(): FILL_FUNC_BODY
import os import tempfile from manimlib.config import get_custom_config from manimlib.config import get_manim_dir CUSTOMIZATION = {} def get_customization(): FILL_FUNC_BODY
if not CUSTOMIZATION: CUSTOMIZATION.update(get_custom_config()) directories = CUSTOMIZATION["directories"] # Unless user has specified otherwise, use the system default temp # directory for storing tex files, mobject_data, etc. if not directories["temporary_storage"]: ...
if not CUSTOMIZATION: CUSTOMIZATION.update(get_custom_config()) directories = CUSTOMIZATION["directories"] # Unless user has specified otherwise, use the system default temp # directory for storing tex files, mobject_data, etc. if not directories["temporary_storage"]: ...
49
64
173
237
import os import tempfile from manimlib.config import get_custom_config from manimlib.config import get_manim_dir CUSTOMIZATION = {} def get_customization(): FILL_FUNC_BODY
import os import tempfile from manimlib.config import get_custom_config from manimlib.config import get_manim_dir CUSTOMIZATION = {} def get_customization(): FILL_FUNC_BODY
101
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/debug.py
21,25
1,33
index_labels
25,33
25,33
from __future__ import annotations from manimlib.constants import BLACK from manimlib.logger import log from manimlib.mobject.numbers import Integer from manimlib.mobject.types.vectorized_mobject import VGroup from typing import TYPE_CHECKING if TYPE_CHECKING: from manimlib.mobject.mobject import Mobject def p...
from __future__ import annotations from manimlib.constants import BLACK from manimlib.logger import log from manimlib.mobject.numbers import Integer from manimlib.mobject.types.vectorized_mobject import VGroup from typing import TYPE_CHECKING if TYPE_CHECKING: from manimlib.mobject.mobject import Mobject def p...
labels = VGroup() for n, submob in enumerate(mobject): label = Integer(n) label.set_height(label_height) label.move_to(submob) label.set_stroke(BLACK, 5, background=True) labels.add(label) return labels
labels = VGroup() for n, submob in enumerate(mobject): label = Integer(n) label.set_height(label_height) label.move_to(submob) label.set_stroke(BLACK, 5, background=True) labels.add(label) return labels
19
232
93
325
from __future__ import annotations from manimlib.constants import BLACK from manimlib.logger import log from manimlib.mobject.numbers import Integer from manimlib.mobject.types.vectorized_mobject import VGroup from typing import TYPE_CHECKING if TYPE_CHECKING: from manimlib.mobject.mobject import Mobject def p...
from __future__ import annotations from manimlib.constants import BLACK from manimlib.logger import log from manimlib.mobject.numbers import Integer from manimlib.mobject.types.vectorized_mobject import VGroup from typing import TYPE_CHECKING if TYPE_CHECKING: from manimlib.mobject.mobject import Mobject def p...
102
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/dict_ops.py
5,6
1,49
merge_dicts_recursively
15,25
6,25
import itertools as it import numpy as np def merge_dicts_recursively(*dicts): FILL_FUNC_BODYdef soft_dict_update(d1, d2): """ Adds key values pairs of d2 to d1 only when d1 doesn't already have that key """ for key, value in list(d2.items()): if key not in d1: d1[key] = value ...
import itertools as it import numpy as np def merge_dicts_recursively(*dicts): """ Creates a dict whose keyset is the union of all the input dictionaries. The value for each key is based on the first dict in the list with that key. dicts later in the list have higher priority When values ar...
result = dict() all_items = it.chain(*[d.items() for d in dicts]) for key, value in all_items: if key in result and isinstance(result[key], dict) and isinstance(value, dict): result[key] = merge_dicts_recursively(result[key], value) else: result[key] = value retur...
""" Creates a dict whose keyset is the union of all the input dictionaries. The value for each key is based on the first dict in the list with that key. dicts later in the list have higher priority When values are dictionaries, it is applied recursively """ result = dict() all_ite...
35
332
112
444
import itertools as it import numpy as np def merge_dicts_recursively(*dicts): FILL_FUNC_BODYdef soft_dict_update(d1, d2): """ Adds key values pairs of d2 to d1 only when d1 doesn't already have that key """ for key, value in list(d2.items()): if key not in d1: d1[key] = value ...
import itertools as it import numpy as np def merge_dicts_recursively(*dicts): """ Creates a dict whose keyset is the union of all the input dictionaries. The value for each key is based on the first dict in the list with that key. dicts later in the list have higher priority When values ar...
103
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/directories.py
17,18
1,51
get_tex_dir
18,21
18,21
from __future__ import annotations import os from manimlib.utils.customization import get_customization from manimlib.utils.file_ops import guarantee_existence def get_directories() -> dict[str, str]: return get_customization()["directories"] def get_temp_dir() -> str: return get_directories()["temporary_...
from __future__ import annotations import os from manimlib.utils.customization import get_customization from manimlib.utils.file_ops import guarantee_existence def get_directories() -> dict[str, str]: return get_customization()["directories"] def get_temp_dir() -> str: return get_directories()["temporary_...
return guarantee_existence(os.path.join(get_temp_dir(), "Tex"))
return guarantee_existence(os.path.join(get_temp_dir(), "Tex"))
3
389
29
418
from __future__ import annotations import os from manimlib.utils.customization import get_customization from manimlib.utils.file_ops import guarantee_existence def get_directories() -> dict[str, str]: return get_customization()["directories"] def get_temp_dir() -> str: return get_directories()["temporary_...
from __future__ import annotations import os from manimlib.utils.customization import get_customization from manimlib.utils.file_ops import guarantee_existence def get_directories() -> dict[str, str]: return get_customization()["directories"] def get_temp_dir() -> str: return get_directories()["temporary_...
104
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/family_ops.py
23,24
1,49
recursive_mobject_remove
33,49
24,49
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Iterable, List, Set, Tuple from manimlib.mobject.mobject import Mobject def extract_mobject_family_members( mobject_list: Iterable[Mobject], exclude_pointless: bool = False ) -> list[Mobject]: ...
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Iterable, List, Set, Tuple from manimlib.mobject.mobject import Mobject def extract_mobject_family_members( mobject_list: Iterable[Mobject], exclude_pointless: bool = False ) -> list[Mobject]: ...
result = [] found_in_list = False for mob in mobjects: if mob in to_remove: found_in_list = True continue # Recursive call sub_list, found_in_submobjects = recursive_mobject_remove( mob.submobjects, to_remove ) if found_in_submobjec...
""" Takes in a list of mobjects, together with a set of mobjects to remove. The first component of what's removed is a new list such that any mobject with one of the elements from `to_remove` in its family is no longer in the list, and in its place are its family members which aren't in `to_remove`...
39
305
154
459
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Iterable, List, Set, Tuple from manimlib.mobject.mobject import Mobject def extract_mobject_family_members( mobject_list: Iterable[Mobject], exclude_pointless: bool = False ) -> list[Mobject]: ...
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Iterable, List, Set, Tuple from manimlib.mobject.mobject import Mobject def extract_mobject_family_members( mobject_list: Iterable[Mobject], exclude_pointless: bool = False ) -> list[Mobject]: ...
105
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/file_ops.py
28,33
1,92
find_file
33,62
33,62
from __future__ import annotations import os import numpy as np import validators from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Iterable def add_extension_if_not_present(file_name: str, extension: str) -> str: # This could conceivably be smarter about handling existing differing ex...
from __future__ import annotations import os import numpy as np import validators from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Iterable def add_extension_if_not_present(file_name: str, extension: str) -> str: # This could conceivably be smarter about handling existing differing ex...
# Check if this is a file online first, and if so, download # it to a temporary directory if validators.url(file_name): import urllib.request from manimlib.utils.directories import get_downloads_dir stem, name = os.path.split(file_name) folder = get_downloads_dir() pa...
# Check if this is a file online first, and if so, download # it to a temporary directory if validators.url(file_name): import urllib.request from manimlib.utils.directories import get_downloads_dir stem, name = os.path.split(file_name) folder = get_downloads_dir() pa...
106
577
300
877
from __future__ import annotations import os import numpy as np import validators from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Iterable def add_extension_if_not_present(file_name: str, extension: str) -> str: # This could conceivably be smarter about handling existing differing ex...
from __future__ import annotations import os import numpy as np import validators from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Iterable def add_extension_if_not_present(file_name: str, extension: str) -> str: # This could conceivably be smarter about handling existing differing ex...
106
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/images.py
24,25
1,36
get_full_vector_image_path
25,32
25,32
from __future__ import annotations import numpy as np from PIL import Image from manimlib.utils.directories import get_raster_image_dir from manimlib.utils.directories import get_vector_image_dir from manimlib.utils.file_ops import find_file from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import ...
from __future__ import annotations import numpy as np from PIL import Image from manimlib.utils.directories import get_raster_image_dir from manimlib.utils.directories import get_vector_image_dir from manimlib.utils.file_ops import find_file from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import ...
return find_file( image_file_name, directories=[get_vector_image_dir()], extensions=[".svg", ".xdv", ""], )
return find_file( image_file_name, directories=[get_vector_image_dir()], extensions=[".svg", ".xdv", ""], )
8
278
55
333
from __future__ import annotations import numpy as np from PIL import Image from manimlib.utils.directories import get_raster_image_dir from manimlib.utils.directories import get_vector_image_dir from manimlib.utils.file_ops import find_file from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import ...
from __future__ import annotations import numpy as np from PIL import Image from manimlib.utils.directories import get_raster_image_dir from manimlib.utils.directories import get_vector_image_dir from manimlib.utils.file_ops import find_file from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import ...
107
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/init_config.py
35,36
1,155
init_customization
36,155
36,155
from __future__ import annotations import importlib import inspect import os import yaml from rich import box from rich.console import Console from rich.prompt import Confirm from rich.prompt import Prompt from rich.rule import Rule from rich.table import Table from typing import TYPE_CHECKING if TYPE_CHECKING: ...
from __future__ import annotations import importlib import inspect import os import yaml from rich import box from rich.console import Console from rich.prompt import Confirm from rich.prompt import Prompt from rich.rule import Rule from rich.table import Table from typing import TYPE_CHECKING if TYPE_CHECKING: ...
configuration = { "directories": { "mirror_module_path": False, "output": "", "raster_images": "", "vector_images": "", "sounds": "", "temporary_storage": "", }, "universal_import_line": "from manimlib import *", ...
configuration = { "directories": { "mirror_module_path": False, "output": "", "raster_images": "", "vector_images": "", "sounds": "", "temporary_storage": "", }, "universal_import_line": "from manimlib import *", ...
344
282
1,438
1,720
from __future__ import annotations import importlib import inspect import os import yaml from rich import box from rich.console import Console from rich.prompt import Confirm from rich.prompt import Prompt from rich.rule import Rule from rich.table import Table from typing import TYPE_CHECKING if TYPE_CHECKING: ...
from __future__ import annotations import importlib import inspect import os import yaml from rich import box from rich.console import Console from rich.prompt import Confirm from rich.prompt import Prompt from rich.rule import Rule from rich.table import Table from typing import TYPE_CHECKING if TYPE_CHECKING: ...
108
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/paths.py
36,40
1,67
path_along_arc
44,61
40,61
from __future__ import annotations import math import numpy as np from manimlib.constants import OUT from manimlib.utils.bezier import interpolate from manimlib.utils.space_ops import get_norm from manimlib.utils.space_ops import rotation_matrix_transpose from typing import TYPE_CHECKING if TYPE_CHECKING: from...
from __future__ import annotations import math import numpy as np from manimlib.constants import OUT from manimlib.utils.bezier import interpolate from manimlib.utils.space_ops import get_norm from manimlib.utils.space_ops import rotation_matrix_transpose from typing import TYPE_CHECKING if TYPE_CHECKING: from...
if abs(arc_angle) < STRAIGHT_PATH_THRESHOLD: return straight_path if get_norm(axis) == 0: axis = OUT unit_axis = axis / get_norm(axis) def path(start_points, end_points, alpha): vects = end_points - start_points centers = start_points + 0.5 * vects if arc_angle !...
""" If vect is vector from start to end, [vect[:,1], -vect[:,0]] is perpendicular to vect in the left direction. """ if abs(arc_angle) < STRAIGHT_PATH_THRESHOLD: return straight_path if get_norm(axis) == 0: axis = OUT unit_axis = axis / get_norm(axis) def path(start_poin...
63
443
217
660
from __future__ import annotations import math import numpy as np from manimlib.constants import OUT from manimlib.utils.bezier import interpolate from manimlib.utils.space_ops import get_norm from manimlib.utils.space_ops import rotation_matrix_transpose from typing import TYPE_CHECKING if TYPE_CHECKING: from...
from __future__ import annotations import math import numpy as np from manimlib.constants import OUT from manimlib.utils.bezier import interpolate from manimlib.utils.space_ops import get_norm from manimlib.utils.space_ops import rotation_matrix_transpose from typing import TYPE_CHECKING if TYPE_CHECKING: from...
109
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/rate_functions.py
32,33
1,110
slow_into
33,36
33,36
from __future__ import annotations import numpy as np from manimlib.utils.bezier import bezier from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable def linear(t: float) -> float: return t def smooth(t: float) -> float: # Zero first and second derivatives at t=0 and t=1. ...
from __future__ import annotations import numpy as np from manimlib.utils.bezier import bezier from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable def linear(t: float) -> float: return t def smooth(t: float) -> float: # Zero first and second derivatives at t=0 and t=1. ...
return np.sqrt(1 - (1 - t) * (1 - t))
return np.sqrt(1 - (1 - t) * (1 - t))
10
1,001
25
1,026
from __future__ import annotations import numpy as np from manimlib.utils.bezier import bezier from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable def linear(t: float) -> float: return t def smooth(t: float) -> float: # Zero first and second derivatives at t=0 and t=1. ...
from __future__ import annotations import numpy as np from manimlib.utils.bezier import bezier from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable def linear(t: float) -> float: return t def smooth(t: float) -> float: # Zero first and second derivatives at t=0 and t=1. ...
110
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/simple_functions.py
36,37
1,103
get_parameters
37,46
37,46
from __future__ import annotations from functools import lru_cache import hashlib import inspect import math import numpy as np from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable, TypeVar, Iterable from manimlib.typing import FloatArray Scalable = TypeVar("Scalable", float, F...
from __future__ import annotations from functools import lru_cache import hashlib import inspect import math import numpy as np from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable, TypeVar, Iterable from manimlib.typing import FloatArray Scalable = TypeVar("Scalable", float, F...
return inspect.signature(function).parameters.keys() # Just to have a less heavyweight name for this extremely common operation # # We may wish to have more fine-grained control over division by zero behavior # in the future (separate specifiable values for 0/0 and x/0 with x != 0), # but for now, we just allow th...
return inspect.signature(function).parameters.keys() # Just to have a less heavyweight name for this extremely common operation # # We may wish to have more fine-grained control over division by zero behavior # in the future (separate specifiable values for 0/0 and x/0 with x != 0), # but for now, we just allow th...
58
837
107
944
from __future__ import annotations from functools import lru_cache import hashlib import inspect import math import numpy as np from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable, TypeVar, Iterable from manimlib.typing import FloatArray Scalable = TypeVar("Scalable", float, F...
from __future__ import annotations from functools import lru_cache import hashlib import inspect import math import numpy as np from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Callable, TypeVar, Iterable from manimlib.typing import FloatArray Scalable = TypeVar("Scalable", float, F...
111
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim
/home/hieuvd/dung_repo/raw/stars_01/3b1b_manim/manim/manimlib/utils/sounds.py
7,8
1,13
get_full_sound_file_path
8,13
8,13
from __future__ import annotations from manimlib.utils.directories import get_sound_dir from manimlib.utils.file_ops import find_file def get_full_sound_file_path(sound_file_name: str) -> str: FILL_FUNC_BODY
from __future__ import annotations from manimlib.utils.directories import get_sound_dir from manimlib.utils.file_ops import find_file def get_full_sound_file_path(sound_file_name: str) -> str: FILL_FUNC_BODY
return find_file( sound_file_name, directories=[get_sound_dir()], extensions=[".wav", ".mp3", ""] )
return find_file( sound_file_name, directories=[get_sound_dir()], extensions=[".wav", ".mp3", ""] )
8
76
50
126
from __future__ import annotations from manimlib.utils.directories import get_sound_dir from manimlib.utils.file_ops import find_file def get_full_sound_file_path(sound_file_name: str) -> str: FILL_FUNC_BODY
from __future__ import annotations from manimlib.utils.directories import get_sound_dir from manimlib.utils.file_ops import find_file def get_full_sound_file_path(sound_file_name: str) -> str: FILL_FUNC_BODY