Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
api_github_webhook
( request: HttpRequest, user_profile: UserProfile, payload: Dict[str, Any] = REQ(argument_type="body"), branches: Optional[str] = REQ(default=None), user_specified_topic: Optional[str] = REQ("topic", default=None), )
GitHub sends the event as an HTTP header. We have our own Zulip-specific concept of an event that often maps directly to the X_GITHUB_EVENT header's event, but we sometimes refine it based on the payload.
GitHub sends the event as an HTTP header. We have our own Zulip-specific concept of an event that often maps directly to the X_GITHUB_EVENT header's event, but we sometimes refine it based on the payload.
def api_github_webhook( request: HttpRequest, user_profile: UserProfile, payload: Dict[str, Any] = REQ(argument_type="body"), branches: Optional[str] = REQ(default=None), user_specified_topic: Optional[str] = REQ("topic", default=None), ) -> HttpResponse: """ GitHub sends the event as an HTT...
[ "def", "api_github_webhook", "(", "request", ":", "HttpRequest", ",", "user_profile", ":", "UserProfile", ",", "payload", ":", "Dict", "[", "str", ",", "Any", "]", "=", "REQ", "(", "argument_type", "=", "\"body\"", ")", ",", "branches", ":", "Optional", "[...
[ 677, 0 ]
[ 712, 25 ]
python
en
['en', 'error', 'th']
False
get_zulip_event_name
( header_event: str, payload: Dict[str, Any], branches: Optional[str], )
Usually, we return an event name that is a key in EVENT_FUNCTION_MAPPER. We return None for an event that we know we don't want to handle.
Usually, we return an event name that is a key in EVENT_FUNCTION_MAPPER.
def get_zulip_event_name( header_event: str, payload: Dict[str, Any], branches: Optional[str], ) -> Optional[str]: """ Usually, we return an event name that is a key in EVENT_FUNCTION_MAPPER. We return None for an event that we know we don't want to handle. """ if header_event == "pull_...
[ "def", "get_zulip_event_name", "(", "header_event", ":", "str", ",", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ",", "branches", ":", "Optional", "[", "str", "]", ",", ")", "->", "Optional", "[", "str", "]", ":", "if", "header_event", "==", ...
[ 715, 0 ]
[ 773, 53 ]
python
en
['en', 'error', 'th']
False
_ActorCriticSeparateWeights._core_rnn
(self, head_output, rnn_states)
This is actually pretty slow due to all these split and cat operations. Consider using shared weights when training RNN policies.
This is actually pretty slow due to all these split and cat operations. Consider using shared weights when training RNN policies.
def _core_rnn(self, head_output, rnn_states): """ This is actually pretty slow due to all these split and cat operations. Consider using shared weights when training RNN policies. """ num_cores = len(self.cores) head_outputs_split = head_output.chunk(num_cores, dim=1) ...
[ "def", "_core_rnn", "(", "self", ",", "head_output", ",", "rnn_states", ")", ":", "num_cores", "=", "len", "(", "self", ".", "cores", ")", "head_outputs_split", "=", "head_output", ".", "chunk", "(", "num_cores", ",", "dim", "=", "1", ")", "rnn_states_spli...
[ 277, 4 ]
[ 295, 38 ]
python
en
['en', 'error', 'th']
False
_ActorCriticSeparateWeights._core_empty
(head_output, fake_rnn_states)
Optimization for the feed-forward case.
Optimization for the feed-forward case.
def _core_empty(head_output, fake_rnn_states): """Optimization for the feed-forward case.""" return head_output, fake_rnn_states
[ "def", "_core_empty", "(", "head_output", ",", "fake_rnn_states", ")", ":", "return", "head_output", ",", "fake_rnn_states" ]
[ 298, 4 ]
[ 300, 43 ]
python
en
['en', 'en', 'en']
True
test_categorical_feature_create_raw_mapping
( data_classification_balanced, expected_raw_mapping, column_name )
Testing if ._create_raw_mapping function correctly extracts unique values in the Series and maps them.
Testing if ._create_raw_mapping function correctly extracts unique values in the Series and maps them.
def test_categorical_feature_create_raw_mapping( data_classification_balanced, expected_raw_mapping, column_name ): """Testing if ._create_raw_mapping function correctly extracts unique values in the Series and maps them.""" X = data_classification_balanced[0] y = data_classification_balanced[1] ...
[ "def", "test_categorical_feature_create_raw_mapping", "(", "data_classification_balanced", ",", "expected_raw_mapping", ",", "column_name", ")", ":", "X", "=", "data_classification_balanced", "[", "0", "]", "y", "=", "data_classification_balanced", "[", "1", "]", "df", ...
[ 16, 0 ]
[ 30, 45 ]
python
en
['en', 'en', 'en']
True
test_categorical_feature_create_mapped_series
( data_classification_balanced, expected_raw_mapping, column_name )
Testing if Series values are correctly replaced with a "raw" mapping.
Testing if Series values are correctly replaced with a "raw" mapping.
def test_categorical_feature_create_mapped_series( data_classification_balanced, expected_raw_mapping, column_name ): """Testing if Series values are correctly replaced with a "raw" mapping.""" X = data_classification_balanced[0] y = data_classification_balanced[1] df = pd.concat([X, y], axis=1)...
[ "def", "test_categorical_feature_create_mapped_series", "(", "data_classification_balanced", ",", "expected_raw_mapping", ",", "column_name", ")", ":", "X", "=", "data_classification_balanced", "[", "0", "]", "y", "=", "data_classification_balanced", "[", "1", "]", "df", ...
[ 43, 0 ]
[ 57, 48 ]
python
en
['en', 'en', 'en']
True
test_categorical_features_create_descriptive_mapping
( data_classification_balanced, expected_mapping, column_name, feature_descriptor )
Testing if ._create_descriptive_mapping() correctly creates mapping between raw mapping and descriptions.
Testing if ._create_descriptive_mapping() correctly creates mapping between raw mapping and descriptions.
def test_categorical_features_create_descriptive_mapping( data_classification_balanced, expected_mapping, column_name, feature_descriptor ): """Testing if ._create_descriptive_mapping() correctly creates mapping between raw mapping and descriptions.""" X = data_classification_balanced[0] y = data_cl...
[ "def", "test_categorical_features_create_descriptive_mapping", "(", "data_classification_balanced", ",", "expected_mapping", ",", "column_name", ",", "feature_descriptor", ")", ":", "X", "=", "data_classification_balanced", "[", "0", "]", "y", "=", "data_classification_balanc...
[ 70, 0 ]
[ 82, 58 ]
python
en
['en', 'en', 'en']
True
test_categorical_features_create_descriptive_mapping_changed_keys
( data_classification_balanced, feature_descriptor_broken, expected_mapping, column_name )
Testing if ._create_descriptive_mapping() creates correct output when the keys are incorrect: descriptions provided as str, yet the data itself is int/float.
Testing if ._create_descriptive_mapping() creates correct output when the keys are incorrect: descriptions provided as str, yet the data itself is int/float.
def test_categorical_features_create_descriptive_mapping_changed_keys( data_classification_balanced, feature_descriptor_broken, expected_mapping, column_name ): """Testing if ._create_descriptive_mapping() creates correct output when the keys are incorrect: descriptions provided as str, yet the data its...
[ "def", "test_categorical_features_create_descriptive_mapping_changed_keys", "(", "data_classification_balanced", ",", "feature_descriptor_broken", ",", "expected_mapping", ",", "column_name", ")", ":", "X", "=", "data_classification_balanced", "[", "0", "]", "y", "=", "data_c...
[ 92, 0 ]
[ 106, 58 ]
python
en
['en', 'en', 'en']
True
test_numerical_features_no_mapping
( data_classification_balanced, column_name )
Testing if .mapping() from NumericalFeature returns None.
Testing if .mapping() from NumericalFeature returns None.
def test_numerical_features_no_mapping( data_classification_balanced, column_name ): """Testing if .mapping() from NumericalFeature returns None.""" X = data_classification_balanced[0] y = data_classification_balanced[1] df = pd.concat([X, y], axis=1) series = df[column_name] feature = ...
[ "def", "test_numerical_features_no_mapping", "(", "data_classification_balanced", ",", "column_name", ")", ":", "X", "=", "data_classification_balanced", "[", "0", "]", "y", "=", "data_classification_balanced", "[", "1", "]", "df", "=", "pd", ".", "concat", "(", "...
[ 116, 0 ]
[ 127, 36 ]
python
en
['en', 'en', 'en']
True
test_features_impute_column_type
(data_classification_balanced, column_name, expected_type)
Testing if imputing column type works correctly.
Testing if imputing column type works correctly.
def test_features_impute_column_type(data_classification_balanced, column_name, expected_type): """Testing if imputing column type works correctly.""" X = data_classification_balanced[0] y = data_classification_balanced[1] df = pd.concat([X, y], axis=1) f = Features(X, y) cat = f._categorical ...
[ "def", "test_features_impute_column_type", "(", "data_classification_balanced", ",", "column_name", ",", "expected_type", ")", ":", "X", "=", "data_classification_balanced", "[", "0", "]", "y", "=", "data_classification_balanced", "[", "1", "]", "df", "=", "pd", "."...
[ 143, 0 ]
[ 165, 29 ]
python
en
['en', 'zu', 'en']
True
test_features_analyze_features
(data_classification_balanced, feature_descriptor)
Testing if .analyze_features() method of Features class returns a dictionary with a correct content
Testing if .analyze_features() method of Features class returns a dictionary with a correct content
def test_features_analyze_features(data_classification_balanced, feature_descriptor): """Testing if .analyze_features() method of Features class returns a dictionary with a correct content""" n = NumericalFeature c = CategoricalFeature expected = { "Sex": c, "AgeGroup": c, "Heigh...
[ "def", "test_features_analyze_features", "(", "data_classification_balanced", ",", "feature_descriptor", ")", ":", "n", "=", "NumericalFeature", "c", "=", "CategoricalFeature", "expected", "=", "{", "\"Sex\"", ":", "c", ",", "\"AgeGroup\"", ":", "c", ",", "\"Height\...
[ 168, 0 ]
[ 190, 44 ]
python
en
['en', 'en', 'en']
True
test_features_analyze_features_forced_category
(data_classification_balanced, feature_descriptor_forced_categories)
Testing if .analyze_features() method of Features class returns a dictionary with a correct content when categories are forced by the FeatureDescriptor
Testing if .analyze_features() method of Features class returns a dictionary with a correct content when categories are forced by the FeatureDescriptor
def test_features_analyze_features_forced_category(data_classification_balanced, feature_descriptor_forced_categories): """Testing if .analyze_features() method of Features class returns a dictionary with a correct content when categories are forced by the FeatureDescriptor""" n = NumericalFeature c = C...
[ "def", "test_features_analyze_features_forced_category", "(", "data_classification_balanced", ",", "feature_descriptor_forced_categories", ")", ":", "n", "=", "NumericalFeature", "c", "=", "CategoricalFeature", "expected", "=", "{", "\"Sex\"", ":", "c", ",", "\"AgeGroup\"",...
[ 193, 0 ]
[ 216, 44 ]
python
en
['en', 'en', 'en']
True
test_features_analyze_features_transformed_features
( data_classification_balanced, feature_descriptor, transformed_features )
Testing if creating features properly assigns Transformed flag based on provided transformed_features sequence.
Testing if creating features properly assigns Transformed flag based on provided transformed_features sequence.
def test_features_analyze_features_transformed_features( data_classification_balanced, feature_descriptor, transformed_features ): """Testing if creating features properly assigns Transformed flag based on provided transformed_features sequence.""" X, y = data_classification_balanced f = Feature...
[ "def", "test_features_analyze_features_transformed_features", "(", "data_classification_balanced", ",", "feature_descriptor", ",", "transformed_features", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",", "y", ",", "featu...
[ 227, 0 ]
[ 242, 50 ]
python
en
['en', 'en', 'en']
True
test_features_create_features
( data_classification_balanced, feature_descriptor_type, feature_descriptor, feature_descriptor_forced_categories )
Testing if ._create_features() returns correct values depending on the Features provided.
Testing if ._create_features() returns correct values depending on the Features provided.
def test_features_create_features( data_classification_balanced, feature_descriptor_type, feature_descriptor, feature_descriptor_forced_categories ): """Testing if ._create_features() returns correct values depending on the Features provided.""" expected = ["AgeGroup", "bool", "Height", "Price", "Produc...
[ "def", "test_features_create_features", "(", "data_classification_balanced", ",", "feature_descriptor_type", ",", "feature_descriptor", ",", "feature_descriptor_forced_categories", ")", ":", "expected", "=", "[", "\"AgeGroup\"", ",", "\"bool\"", ",", "\"Height\"", ",", "\"P...
[ 252, 0 ]
[ 271, 29 ]
python
en
['en', 'en', 'en']
True
test_features_features_list_no_target
( data_classification_balanced, feature_descriptor_type, feature_descriptor, feature_descriptor_forced_categories )
Testing if .features() returns correct values when drop_target = True (without Target feature name).
Testing if .features() returns correct values when drop_target = True (without Target feature name).
def test_features_features_list_no_target( data_classification_balanced, feature_descriptor_type, feature_descriptor, feature_descriptor_forced_categories ): """Testing if .features() returns correct values when drop_target = True (without Target feature name).""" expected = ["AgeGroup", "bool", "Height...
[ "def", "test_features_features_list_no_target", "(", "data_classification_balanced", ",", "feature_descriptor_type", ",", "feature_descriptor", ",", "feature_descriptor_forced_categories", ")", ":", "expected", "=", "[", "\"AgeGroup\"", ",", "\"bool\"", ",", "\"Height\"", ","...
[ 281, 0 ]
[ 299, 29 ]
python
en
['en', 'en', 'en']
True
test_features_features_list_exclude_transformed
( data_classification_balanced, feature_descriptor, transformed_features )
Testing if returning feature list with transformed columns excluded works properly.
Testing if returning feature list with transformed columns excluded works properly.
def test_features_features_list_exclude_transformed( data_classification_balanced, feature_descriptor, transformed_features ): """Testing if returning feature list with transformed columns excluded works properly.""" col_list = ["AgeGroup", "bool", "Height", "Price", "Product", "Sex", "Target"] X, y...
[ "def", "test_features_features_list_exclude_transformed", "(", "data_classification_balanced", ",", "feature_descriptor", ",", "transformed_features", ")", ":", "col_list", "=", "[", "\"AgeGroup\"", ",", "\"bool\"", ",", "\"Height\"", ",", "\"Price\"", ",", "\"Product\"", ...
[ 311, 0 ]
[ 325, 43 ]
python
en
['en', 'en', 'en']
True
test_features_create_numerical_features
( data_classification_balanced, feature_descriptor_type, expected, feature_descriptor, feature_descriptor_forced_categories )
Testing if ._create_numerical_features() returns correct values depending on the Features provided.
Testing if ._create_numerical_features() returns correct values depending on the Features provided.
def test_features_create_numerical_features( data_classification_balanced, feature_descriptor_type, expected, feature_descriptor, feature_descriptor_forced_categories ): """Testing if ._create_numerical_features() returns correct values depending on the Features provided.""" X, y = data_classifi...
[ "def", "test_features_create_numerical_features", "(", "data_classification_balanced", ",", "feature_descriptor_type", ",", "expected", ",", "feature_descriptor", ",", "feature_descriptor_forced_categories", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "# could...
[ 335, 0 ]
[ 354, 29 ]
python
en
['en', 'en', 'en']
True
test_features_numerical_features_no_target
( feature_list, target, expected, data_classification_balanced, feature_descriptor )
Testing if .numerical_features() returns correct values when drop_target = True (without Target feature name).
Testing if .numerical_features() returns correct values when drop_target = True (without Target feature name).
def test_features_numerical_features_no_target( feature_list, target, expected, data_classification_balanced, feature_descriptor ): """Testing if .numerical_features() returns correct values when drop_target = True (without Target feature name).""" X, y = data_classification_balanced f = Features(X,...
[ "def", "test_features_numerical_features_no_target", "(", "feature_list", ",", "target", ",", "expected", ",", "data_classification_balanced", ",", "feature_descriptor", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",",...
[ 365, 0 ]
[ 376, 29 ]
python
en
['en', 'en', 'en']
True
test_features_numerical_features_exclude_transformed
( data_classification_balanced, feature_descriptor, transformed_features )
Testing if returning numerical features list with transformed columns excluded works properly.
Testing if returning numerical features list with transformed columns excluded works properly.
def test_features_numerical_features_exclude_transformed( data_classification_balanced, feature_descriptor, transformed_features ): """Testing if returning numerical features list with transformed columns excluded works properly.""" col_list = ["Height", "Price"] X, y = data_classification_balanced ...
[ "def", "test_features_numerical_features_exclude_transformed", "(", "data_classification_balanced", ",", "feature_descriptor", ",", "transformed_features", ")", ":", "col_list", "=", "[", "\"Height\"", ",", "\"Price\"", "]", "X", ",", "y", "=", "data_classification_balanced...
[ 389, 0 ]
[ 403, 43 ]
python
en
['en', 'en', 'en']
True
test_features_create_categorical_features
( data_classification_balanced, feature_descriptor_type, expected, feature_descriptor, feature_descriptor_forced_categories )
Testing if ._create_categorical_features() returns correct values depending on the Features provided.
Testing if ._create_categorical_features() returns correct values depending on the Features provided.
def test_features_create_categorical_features( data_classification_balanced, feature_descriptor_type, expected, feature_descriptor, feature_descriptor_forced_categories ): """Testing if ._create_categorical_features() returns correct values depending on the Features provided.""" X, y = data_clas...
[ "def", "test_features_create_categorical_features", "(", "data_classification_balanced", ",", "feature_descriptor_type", ",", "expected", ",", "feature_descriptor", ",", "feature_descriptor_forced_categories", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "# cou...
[ 413, 0 ]
[ 432, 29 ]
python
en
['en', 'en', 'en']
True
test_features_categorical_features_no_target
( feature_list, target, expected, data_classification_balanced, feature_descriptor )
Testing if .categorical_features() returns correct values when drop_target = True (without Target feature name).
Testing if .categorical_features() returns correct values when drop_target = True (without Target feature name).
def test_features_categorical_features_no_target( feature_list, target, expected, data_classification_balanced, feature_descriptor ): """Testing if .categorical_features() returns correct values when drop_target = True (without Target feature name). """ X, y = data_classification_balanced f = Fe...
[ "def", "test_features_categorical_features_no_target", "(", "feature_list", ",", "target", ",", "expected", ",", "data_classification_balanced", ",", "feature_descriptor", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",...
[ 443, 0 ]
[ 455, 29 ]
python
en
['en', 'en', 'en']
True
test_features_categorical_features_exclude_transformed
( data_classification_balanced, feature_descriptor, transformed_features )
Testing if returning categorical features list with transformed columns excluded works properly.
Testing if returning categorical features list with transformed columns excluded works properly.
def test_features_categorical_features_exclude_transformed( data_classification_balanced, feature_descriptor, transformed_features ): """Testing if returning categorical features list with transformed columns excluded works properly.""" col_list = ["AgeGroup", "bool", "Product", "Sex", "Target"] X, ...
[ "def", "test_features_categorical_features_exclude_transformed", "(", "data_classification_balanced", ",", "feature_descriptor", ",", "transformed_features", ")", ":", "col_list", "=", "[", "\"AgeGroup\"", ",", "\"bool\"", ",", "\"Product\"", ",", "\"Sex\"", ",", "\"Target\...
[ 468, 0 ]
[ 482, 43 ]
python
en
['en', 'en', 'en']
True
test_features_unused_features
(data_classification_balanced, feature_descriptor)
Testing if unused_features() returns correct values.
Testing if unused_features() returns correct values.
def test_features_unused_features(data_classification_balanced, feature_descriptor): """Testing if unused_features() returns correct values.""" X, y = data_classification_balanced f = Features(X, y, feature_descriptor) assert f.unused_features() == ["Date"]
[ "def", "test_features_unused_features", "(", "data_classification_balanced", ",", "feature_descriptor", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",", "y", ",", "feature_descriptor", ")", "assert", "f", ".", "unu...
[ 485, 0 ]
[ 490, 42 ]
python
en
['en', 'en', 'en']
True
test_features_create_raw_dataframe
(data_classification_balanced, feature_descriptor)
Testing if .create_raw_dataframe returns correct dataframe (the same that was provided as input to the object).
Testing if .create_raw_dataframe returns correct dataframe (the same that was provided as input to the object).
def test_features_create_raw_dataframe(data_classification_balanced, feature_descriptor): """Testing if .create_raw_dataframe returns correct dataframe (the same that was provided as input to the object). """ X, y = data_classification_balanced f = Features(X, y, feature_descriptor) expected_df = p...
[ "def", "test_features_create_raw_dataframe", "(", "data_classification_balanced", ",", "feature_descriptor", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",", "y", ",", "feature_descriptor", ")", "expected_df", "=", "...
[ 493, 0 ]
[ 504, 40 ]
python
en
['en', 'en', 'en']
True
test_features_create_raw_dataframe_preserving_index
(data_classification_balanced, feature_descriptor)
Testing if create_raw_dataframe preserves the index of the DataFrame.
Testing if create_raw_dataframe preserves the index of the DataFrame.
def test_features_create_raw_dataframe_preserving_index(data_classification_balanced, feature_descriptor): """Testing if create_raw_dataframe preserves the index of the DataFrame.""" X, y = data_classification_balanced not_expected_df = pd.concat([X, y], axis=1).drop(["Date"], axis=1) length = X.shape[...
[ "def", "test_features_create_raw_dataframe_preserving_index", "(", "data_classification_balanced", ",", "feature_descriptor", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "not_expected_df", "=", "pd", ".", "concat", "(", "[", "X", ",", "y", "]", ",", ...
[ 507, 0 ]
[ 524, 40 ]
python
en
['en', 'en', 'en']
True
test_features_raw_data_no_target
(data_classification_balanced, feature_descriptor)
Testing if raw_dataframe() drops Target column when drop_target=True.
Testing if raw_dataframe() drops Target column when drop_target=True.
def test_features_raw_data_no_target(data_classification_balanced, feature_descriptor): """Testing if raw_dataframe() drops Target column when drop_target=True.""" X, y = data_classification_balanced f = Features(X, y, feature_descriptor) expected_df = X.drop(["Date"], axis=1) cols = expected_df.co...
[ "def", "test_features_raw_data_no_target", "(", "data_classification_balanced", ",", "feature_descriptor", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",", "y", ",", "feature_descriptor", ")", "expected_df", "=", "X"...
[ 527, 0 ]
[ 537, 40 ]
python
en
['en', 'lb', 'en']
True
test_features_raw_data_excluded_transformed
(data_classification_balanced, feature_descriptor, transformed_columns)
Testing if raw_data returns correct dataframe without transformed columns when excluded_transformed is set to True.
Testing if raw_data returns correct dataframe without transformed columns when excluded_transformed is set to True.
def test_features_raw_data_excluded_transformed(data_classification_balanced, feature_descriptor, transformed_columns): """Testing if raw_data returns correct dataframe without transformed columns when excluded_transformed is set to True.""" X, y = data_classification_balanced f = Features(X, y, feature...
[ "def", "test_features_raw_data_excluded_transformed", "(", "data_classification_balanced", ",", "feature_descriptor", ",", "transformed_columns", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",", "y", ",", "feature_descri...
[ 550, 0 ]
[ 564, 40 ]
python
en
['en', 'en', 'en']
True
test_features_create_mapped_dataframe
(data_classification_balanced, feature_descriptor, expected_raw_mapping)
Testing if ._create_mapped_dataframe correctly returns mapped dataframe (with replaced values according to mapping).
Testing if ._create_mapped_dataframe correctly returns mapped dataframe (with replaced values according to mapping).
def test_features_create_mapped_dataframe(data_classification_balanced, feature_descriptor, expected_raw_mapping): """Testing if ._create_mapped_dataframe correctly returns mapped dataframe (with replaced values according to mapping). """ X, y = data_classification_balanced f = Features(X, y, feature_de...
[ "def", "test_features_create_mapped_dataframe", "(", "data_classification_balanced", ",", "feature_descriptor", ",", "expected_raw_mapping", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",", "y", ",", "feature_descriptor"...
[ 567, 0 ]
[ 578, 40 ]
python
en
['en', 'en', 'en']
True
test_features_data
(data_classification_balanced, feature_descriptor, expected_raw_mapping)
Testing if .data() returns mapped df (with replaced values according to mapping) but without Target column ( when drop_target=True).
Testing if .data() returns mapped df (with replaced values according to mapping) but without Target column ( when drop_target=True).
def test_features_data(data_classification_balanced, feature_descriptor, expected_raw_mapping): """Testing if .data() returns mapped df (with replaced values according to mapping) but without Target column ( when drop_target=True). """ X, y = data_classification_balanced f = Features(X, y, feature_descr...
[ "def", "test_features_data", "(", "data_classification_balanced", ",", "feature_descriptor", ",", "expected_raw_mapping", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",", "y", ",", "feature_descriptor", ")", "expecte...
[ 581, 0 ]
[ 592, 40 ]
python
en
['en', 'en', 'en']
True
test_features_data_excluded_transformed
( data_classification_balanced, feature_descriptor, transformed_columns, expected_raw_mapping )
Testing if data returns correctly mapped dataframe without transformed columns when excluded_transformed is set to True.
Testing if data returns correctly mapped dataframe without transformed columns when excluded_transformed is set to True.
def test_features_data_excluded_transformed( data_classification_balanced, feature_descriptor, transformed_columns, expected_raw_mapping ): """Testing if data returns correctly mapped dataframe without transformed columns when excluded_transformed is set to True.""" X, y = data_classification_balanc...
[ "def", "test_features_data_excluded_transformed", "(", "data_classification_balanced", ",", "feature_descriptor", ",", "transformed_columns", ",", "expected_raw_mapping", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",", ...
[ 605, 0 ]
[ 621, 40 ]
python
en
['en', 'en', 'en']
True
test_features_create_mapping
(data_classification_balanced, feature_descriptor, expected_mapping)
Testing if ._create_mapping() creates a correct mapping dictionary.
Testing if ._create_mapping() creates a correct mapping dictionary.
def test_features_create_mapping(data_classification_balanced, feature_descriptor, expected_mapping): """Testing if ._create_mapping() creates a correct mapping dictionary.""" X, y = data_classification_balanced f = Features(X, y, feature_descriptor) expected = expected_mapping for feat in ["Height...
[ "def", "test_features_create_mapping", "(", "data_classification_balanced", ",", "feature_descriptor", ",", "expected_mapping", ")", ":", "X", ",", "y", "=", "data_classification_balanced", "f", "=", "Features", "(", "X", ",", "y", ",", "feature_descriptor", ")", "e...
[ 624, 0 ]
[ 635, 29 ]
python
en
['en', 'en', 'en']
True
test_features_create_descriptions
(data_classification_balanced, feature_descriptions, feature_descriptor)
Testing if ._create_descriptions creates a correct descriptions dictionary.
Testing if ._create_descriptions creates a correct descriptions dictionary.
def test_features_create_descriptions(data_classification_balanced, feature_descriptions, feature_descriptor): """Testing if ._create_descriptions creates a correct descriptions dictionary.""" placeholder = Features._description_not_available d = FeatureDescriptor._description assert True expected_d...
[ "def", "test_features_create_descriptions", "(", "data_classification_balanced", ",", "feature_descriptions", ",", "feature_descriptor", ")", ":", "placeholder", "=", "Features", ".", "_description_not_available", "d", "=", "FeatureDescriptor", ".", "_description", "assert", ...
[ 638, 0 ]
[ 654, 55 ]
python
ca
['ca', 'ca', 'en']
True
_Feature.getOptionalRelease
(self)
Return first release in which this feature was recognized. This is a 5-tuple, of the same form as sys.version_info.
Return first release in which this feature was recognized.
def getOptionalRelease(self): """Return first release in which this feature was recognized. This is a 5-tuple, of the same form as sys.version_info. """ return self.optional
[ "def", "getOptionalRelease", "(", "self", ")", ":", "return", "self", ".", "optional" ]
[ 83, 4 ]
[ 89, 28 ]
python
en
['en', 'en', 'en']
True
_Feature.getMandatoryRelease
(self)
Return release in which this feature will become mandatory. This is a 5-tuple, of the same form as sys.version_info, or, if the feature was dropped, is None.
Return release in which this feature will become mandatory.
def getMandatoryRelease(self): """Return release in which this feature will become mandatory. This is a 5-tuple, of the same form as sys.version_info, or, if the feature was dropped, is None. """ return self.mandatory
[ "def", "getMandatoryRelease", "(", "self", ")", ":", "return", "self", ".", "mandatory" ]
[ 91, 4 ]
[ 98, 29 ]
python
en
['en', 'en', 'en']
True
enc_eq
(e1, e2)
check if two encodings are equal
check if two encodings are equal
def enc_eq(e1, e2): ''' check if two encodings are equal ''' return ( codecs.lookup(e1).name == codecs.lookup(e2).name )
[ "def", "enc_eq", "(", "e1", ",", "e2", ")", ":", "return", "(", "codecs", ".", "lookup", "(", "e1", ")", ".", "name", "==", "codecs", ".", "lookup", "(", "e2", ")", ".", "name", ")" ]
[ 28, 0 ]
[ 35, 5 ]
python
en
['en', 'error', 'th']
False
get_encoding
()
get locale encoding (from sys.stdout); upgrade ASCII to UTF-8
get locale encoding (from sys.stdout); upgrade ASCII to UTF-8
def get_encoding(): ''' get locale encoding (from sys.stdout); upgrade ASCII to UTF-8 ''' locale_encoding = sys.stdout.encoding if enc_eq(locale_encoding, 'ASCII'): return 'UTF-8' else: return locale_encoding
[ "def", "get_encoding", "(", ")", ":", "locale_encoding", "=", "sys", ".", "stdout", ".", "encoding", "if", "enc_eq", "(", "locale_encoding", ",", "'ASCII'", ")", ":", "return", "'UTF-8'", "else", ":", "return", "locale_encoding" ]
[ 37, 0 ]
[ 46, 30 ]
python
en
['en', 'error', 'th']
False
open_file
(path, *, encoding, errors)
open() with special case for "-"
open() with special case for "-"
def open_file(path, *, encoding, errors): ''' open() with special case for "-" ''' if path == '-': return io.TextIOWrapper( sys.stdin.buffer, encoding=encoding, errors=errors, ) else: return open( # pylint: disable=consider-using-with ...
[ "def", "open_file", "(", "path", ",", "*", ",", "encoding", ",", "errors", ")", ":", "if", "path", "==", "'-'", ":", "return", "io", ".", "TextIOWrapper", "(", "sys", ".", "stdin", ".", "buffer", ",", "encoding", "=", "encoding", ",", "errors", "=", ...
[ 48, 0 ]
[ 63, 9 ]
python
en
['en', 'error', 'th']
False
MakeSound
(saveSTR, filename)
try: encText = urllib.parse.quote(saveSTR) urllib.request.urlretrieve("https://clova.ai/proxy/voice/api/tts?text=" + encText + "%0A&voicefont=1&format=wav",filename + '.wav') except Exception as e: print (e) tts = gTTS(saveSTR, lang = 'ko') tts.save('./' + filename + '.wav') pass
try: encText = urllib.parse.quote(saveSTR) urllib.request.urlretrieve("https://clova.ai/proxy/voice/api/tts?text=" + encText + "%0A&voicefont=1&format=wav",filename + '.wav') except Exception as e: print (e) tts = gTTS(saveSTR, lang = 'ko') tts.save('./' + filename + '.wav') pass
async def MakeSound(saveSTR, filename): tts = gTTS(saveSTR, lang = 'ko') tts.save('./' + filename + '.wav') ''' try: encText = urllib.parse.quote(saveSTR) urllib.request.urlretrieve("https://clova.ai/proxy/voice/api/tts?text=" + encText + "%0A&voicefont=1&format=wav",filename + '.wav') except Exce...
[ "async", "def", "MakeSound", "(", "saveSTR", ",", "filename", ")", ":", "tts", "=", "gTTS", "(", "saveSTR", ",", "lang", "=", "'ko'", ")", "tts", ".", "save", "(", "'./'", "+", "filename", "+", "'.wav'", ")" ]
[ 678, 0 ]
[ 692, 4 ]
python
en
['en', 'ja', 'th']
False
_try_weakref
(arg, remove_callback)
Return a weak reference to arg if possible, or arg itself if not.
Return a weak reference to arg if possible, or arg itself if not.
def _try_weakref(arg, remove_callback): """Return a weak reference to arg if possible, or arg itself if not.""" try: arg = weakref.ref(arg, remove_callback) except TypeError: # Not all types can have a weakref. That includes strings # and floats and such, so just pass them through di...
[ "def", "_try_weakref", "(", "arg", ",", "remove_callback", ")", ":", "try", ":", "arg", "=", "weakref", ".", "ref", "(", "arg", ",", "remove_callback", ")", "except", "TypeError", ":", "# Not all types can have a weakref. That includes strings", "# and floats and such...
[ 27, 0 ]
[ 35, 14 ]
python
en
['en', 'en', 'en']
True
_get_key
(args, kwargs, remove_callback)
Calculate the cache key, using weak references where possible.
Calculate the cache key, using weak references where possible.
def _get_key(args, kwargs, remove_callback): """Calculate the cache key, using weak references where possible.""" # Use tuples, because lists are not hashable. weak_args = tuple(_try_weakref(arg, remove_callback) for arg in args) # Use a tuple of (key, values) pairs, because dict is not hashable. # ...
[ "def", "_get_key", "(", "args", ",", "kwargs", ",", "remove_callback", ")", ":", "# Use tuples, because lists are not hashable.", "weak_args", "=", "tuple", "(", "_try_weakref", "(", "arg", ",", "remove_callback", ")", "for", "arg", "in", "args", ")", "# Use a tup...
[ 38, 0 ]
[ 47, 33 ]
python
en
['en', 'en', 'en']
True
memoized
(func=None, max_size=None)
Decorator that caches function calls. Caches the decorated function's return value the first time it is called with the given arguments. If called later with the same arguments, the cached value is returned instead of calling the decorated function again. It operates as a LRU cache and keeps up to th...
Decorator that caches function calls.
def memoized(func=None, max_size=None): """Decorator that caches function calls. Caches the decorated function's return value the first time it is called with the given arguments. If called later with the same arguments, the cached value is returned instead of calling the decorated function again. ...
[ "def", "memoized", "(", "func", "=", "None", ",", "max_size", "=", "None", ")", ":", "def", "decorate", "(", "func", ")", ":", "# The dictionary in which all the data will be cached. This is a", "# separate instance for every decorated function, and it's stored in a", "# clos...
[ 50, 0 ]
[ 131, 19 ]
python
en
['en', 'en', 'en']
True
start
(io_loop=None, check_time=500)
Begins watching source files for changes. .. versionchanged:: 4.1 The ``io_loop`` argument is deprecated.
Begins watching source files for changes.
def start(io_loop=None, check_time=500): """Begins watching source files for changes. .. versionchanged:: 4.1 The ``io_loop`` argument is deprecated. """ io_loop = io_loop or ioloop.IOLoop.current() if io_loop in _io_loops: return _io_loops[io_loop] = True if len(_io_loops) >...
[ "def", "start", "(", "io_loop", "=", "None", ",", "check_time", "=", "500", ")", ":", "io_loop", "=", "io_loop", "or", "ioloop", ".", "IOLoop", ".", "current", "(", ")", "if", "io_loop", "in", "_io_loops", ":", "return", "_io_loops", "[", "io_loop", "]...
[ 83, 0 ]
[ 98, 21 ]
python
en
['en', 'en', 'en']
True
wait
()
Wait for a watched file to change, then restart the process. Intended to be used at the end of scripts like unit test runners, to run the tests again after any source file changes (but see also the command-line interface in `main`)
Wait for a watched file to change, then restart the process.
def wait(): """Wait for a watched file to change, then restart the process. Intended to be used at the end of scripts like unit test runners, to run the tests again after any source file changes (but see also the command-line interface in `main`) """ io_loop = ioloop.IOLoop() start(io_loop)...
[ "def", "wait", "(", ")", ":", "io_loop", "=", "ioloop", ".", "IOLoop", "(", ")", "start", "(", "io_loop", ")", "io_loop", ".", "start", "(", ")" ]
[ 101, 0 ]
[ 110, 19 ]
python
en
['en', 'en', 'en']
True
watch
(filename)
Add a file to the watch list. All imported modules are watched by default.
Add a file to the watch list.
def watch(filename): """Add a file to the watch list. All imported modules are watched by default. """ _watched_files.add(filename)
[ "def", "watch", "(", "filename", ")", ":", "_watched_files", ".", "add", "(", "filename", ")" ]
[ 113, 0 ]
[ 118, 32 ]
python
en
['en', 'en', 'en']
True
add_reload_hook
(fn)
Add a function to be called before reloading the process. Note that for open file and socket handles it is generally preferable to set the ``FD_CLOEXEC`` flag (using `fcntl` or ``tornado.platform.auto.set_close_exec``) instead of using a reload hook to close them.
Add a function to be called before reloading the process.
def add_reload_hook(fn): """Add a function to be called before reloading the process. Note that for open file and socket handles it is generally preferable to set the ``FD_CLOEXEC`` flag (using `fcntl` or ``tornado.platform.auto.set_close_exec``) instead of using a reload hook to close them. ""...
[ "def", "add_reload_hook", "(", "fn", ")", ":", "_reload_hooks", ".", "append", "(", "fn", ")" ]
[ 121, 0 ]
[ 129, 28 ]
python
en
['en', 'en', 'en']
True
trim_note_sequence
(sequence, start_time, end_time)
Trim notes from a NoteSequence to lie within a specified time range. Notes starting before `start_time` are not included. Notes ending after `end_time` are truncated. Args: sequence: The NoteSequence for which to trim notes. start_time: The float time in seconds after which all notes should begin. e...
Trim notes from a NoteSequence to lie within a specified time range.
def trim_note_sequence(sequence, start_time, end_time): """Trim notes from a NoteSequence to lie within a specified time range. Notes starting before `start_time` are not included. Notes ending after `end_time` are truncated. Args: sequence: The NoteSequence for which to trim notes. start_time: The fl...
[ "def", "trim_note_sequence", "(", "sequence", ",", "start_time", ",", "end_time", ")", ":", "if", "is_quantized_sequence", "(", "sequence", ")", ":", "raise", "QuantizationStatusError", "(", "'Can only trim notes and chords for unquantized NoteSequence.'", ")", "subsequence...
[ 88, 0 ]
[ 123, 20 ]
python
en
['en', 'en', 'en']
True
_extract_subsequences
(sequence, split_times, preserve_control_numbers=None)
Extracts multiple subsequences from a NoteSequence. Args: sequence: The NoteSequence to extract subsequences from. split_times: A Python list of subsequence boundary times. The first subsequence will start at `split_times[0]` and end at `split_times[1]`, the next subsequence will start at `split_...
Extracts multiple subsequences from a NoteSequence.
def _extract_subsequences(sequence, split_times, preserve_control_numbers=None): """Extracts multiple subsequences from a NoteSequence. Args: sequence: The NoteSequence to extract subsequences from. split_times: A Python list of subsequence boundary times. The first subseque...
[ "def", "_extract_subsequences", "(", "sequence", ",", "split_times", ",", "preserve_control_numbers", "=", "None", ")", ":", "if", "is_quantized_sequence", "(", "sequence", ")", ":", "raise", "QuantizationStatusError", "(", "'Can only extract subsequences from unquantized N...
[ 133, 0 ]
[ 328, 21 ]
python
en
['en', 'en', 'en']
True
extract_subsequence
(sequence, start_time, end_time, preserve_control_numbers=None)
Extracts a subsequence from a NoteSequence. Notes starting before `start_time` are not included. Notes ending after `end_time` are truncated. Time signature, tempo, key signature, chord changes, and sustain pedal events outside the specified time range are removed; however, the most recent event of each of the...
Extracts a subsequence from a NoteSequence.
def extract_subsequence(sequence, start_time, end_time, preserve_control_numbers=None): """Extracts a subsequence from a NoteSequence. Notes starting before `start_time` are not included. Notes ending after `end_time` are truncated. Time sig...
[ "def", "extract_subsequence", "(", "sequence", ",", "start_time", ",", "end_time", ",", "preserve_control_numbers", "=", "None", ")", ":", "return", "_extract_subsequences", "(", "sequence", ",", "split_times", "=", "[", "start_time", ",", "end_time", "]", ",", ...
[ 331, 0 ]
[ 370, 59 ]
python
en
['en', 'en', 'en']
True
shift_sequence_times
(sequence, shift_seconds)
Shifts times in a notesequence. Only forward shifts are supported. Args: sequence: The NoteSequence to shift. shift_seconds: The amount to shift. Returns: A new NoteSequence with shifted times. Raises: ValueError: If the shift amount is invalid. QuantizationStatusError: If the sequence h...
Shifts times in a notesequence.
def shift_sequence_times(sequence, shift_seconds): """Shifts times in a notesequence. Only forward shifts are supported. Args: sequence: The NoteSequence to shift. shift_seconds: The amount to shift. Returns: A new NoteSequence with shifted times. Raises: ValueError: If the shift amount is...
[ "def", "shift_sequence_times", "(", "sequence", ",", "shift_seconds", ")", ":", "if", "shift_seconds", "<=", "0", ":", "raise", "ValueError", "(", "'Invalid shift amount: {}'", ".", "format", "(", "shift_seconds", ")", ")", "if", "is_quantized_sequence", "(", "seq...
[ 373, 0 ]
[ 417, 16 ]
python
en
['en', 'en', 'en']
True
remove_redundant_data
(sequence)
Returns a copy of the sequence with redundant data removed. An event is considered redundant if it is a time signature, a key signature, or a tempo that differs from the previous event of the same type only by time. For example, a tempo mark of 120 qpm at 5 seconds would be considered redundant if it followed ...
Returns a copy of the sequence with redundant data removed.
def remove_redundant_data(sequence): """Returns a copy of the sequence with redundant data removed. An event is considered redundant if it is a time signature, a key signature, or a tempo that differs from the previous event of the same type only by time. For example, a tempo mark of 120 qpm at 5 seconds would...
[ "def", "remove_redundant_data", "(", "sequence", ")", ":", "fixed_sequence", "=", "copy", ".", "deepcopy", "(", "sequence", ")", "for", "events", "in", "[", "fixed_sequence", ".", "time_signatures", ",", "fixed_sequence", ".", "key_signatures", ",", "fixed_sequenc...
[ 420, 0 ]
[ 467, 23 ]
python
en
['en', 'en', 'en']
True
concatenate_sequences
(sequences, sequence_durations=None)
Concatenate a series of NoteSequences together. Individual sequences will be shifted using shift_sequence_times and then merged together using the protobuf MergeFrom method. This means that any global values (e.g., ticks_per_quarter) will be overwritten by each sequence and only the final value will be used. A...
Concatenate a series of NoteSequences together.
def concatenate_sequences(sequences, sequence_durations=None): """Concatenate a series of NoteSequences together. Individual sequences will be shifted using shift_sequence_times and then merged together using the protobuf MergeFrom method. This means that any global values (e.g., ticks_per_quarter) will be ove...
[ "def", "concatenate_sequences", "(", "sequences", ",", "sequence_durations", "=", "None", ")", ":", "if", "sequence_durations", "and", "len", "(", "sequences", ")", "!=", "len", "(", "sequence_durations", ")", ":", "raise", "ValueError", "(", "'sequences and seque...
[ 470, 0 ]
[ 518, 39 ]
python
en
['en', 'en', 'en']
True
repeat_sequence_to_duration
(sequence, duration, sequence_duration=None)
Repeat a sequence until it is a given duration, trimming any extra. Args: sequence: the sequence to repeat duration: the desired duration sequence_duration: If provided, will be used instead of sequence.total_time Returns: The repeated and possibly trimmed sequence.
Repeat a sequence until it is a given duration, trimming any extra.
def repeat_sequence_to_duration(sequence, duration, sequence_duration=None): """Repeat a sequence until it is a given duration, trimming any extra. Args: sequence: the sequence to repeat duration: the desired duration sequence_duration: If provided, will be used instead of sequence.total_time Return...
[ "def", "repeat_sequence_to_duration", "(", "sequence", ",", "duration", ",", "sequence_duration", "=", "None", ")", ":", "if", "not", "sequence_duration", ":", "sequence_duration", "=", "sequence", ".", "total_time", "num_repeats", "=", "int", "(", "math", ".", ...
[ 521, 0 ]
[ 541, 16 ]
python
en
['en', 'en', 'en']
True
expand_section_groups
(sequence)
Expands a NoteSequence based on its section_groups. Args: sequence: The sequence to expand. Returns: A copy of the original sequence, expanded based on its section_groups. If the sequence has no section_groups, a copy of the original sequence will be returned.
Expands a NoteSequence based on its section_groups.
def expand_section_groups(sequence): """Expands a NoteSequence based on its section_groups. Args: sequence: The sequence to expand. Returns: A copy of the original sequence, expanded based on its section_groups. If the sequence has no section_groups, a copy of the original sequence will be retur...
[ "def", "expand_section_groups", "(", "sequence", ")", ":", "if", "not", "sequence", ".", "section_groups", ":", "return", "copy", ".", "deepcopy", "(", "sequence", ")", "sections", "=", "{", "}", "section_durations", "=", "{", "}", "for", "i", "in", "range...
[ 544, 0 ]
[ 596, 57 ]
python
en
['en', 'en', 'en']
True
is_quantized_sequence
(note_sequence)
Returns whether or not a NoteSequence proto has been quantized. Args: note_sequence: A music_pb2.NoteSequence proto. Returns: True if `note_sequence` is quantized, otherwise False.
Returns whether or not a NoteSequence proto has been quantized.
def is_quantized_sequence(note_sequence): """Returns whether or not a NoteSequence proto has been quantized. Args: note_sequence: A music_pb2.NoteSequence proto. Returns: True if `note_sequence` is quantized, otherwise False. """ # If the QuantizationInfo message has a non-zero steps_per_quarter or ...
[ "def", "is_quantized_sequence", "(", "note_sequence", ")", ":", "# If the QuantizationInfo message has a non-zero steps_per_quarter or", "# steps_per_second, assume that the proto has been quantized.", "return", "(", "note_sequence", ".", "quantization_info", ".", "steps_per_quarter", ...
[ 603, 0 ]
[ 615, 63 ]
python
en
['en', 'en', 'en']
True
is_relative_quantized_sequence
(note_sequence)
Returns whether a NoteSequence proto has been quantized relative to tempo. Args: note_sequence: A music_pb2.NoteSequence proto. Returns: True if `note_sequence` is quantized relative to tempo, otherwise False.
Returns whether a NoteSequence proto has been quantized relative to tempo.
def is_relative_quantized_sequence(note_sequence): """Returns whether a NoteSequence proto has been quantized relative to tempo. Args: note_sequence: A music_pb2.NoteSequence proto. Returns: True if `note_sequence` is quantized relative to tempo, otherwise False. """ # If the QuantizationInfo messag...
[ "def", "is_relative_quantized_sequence", "(", "note_sequence", ")", ":", "# If the QuantizationInfo message has a non-zero steps_per_quarter, assume", "# that the proto has been quantized relative to tempo.", "return", "note_sequence", ".", "quantization_info", ".", "steps_per_quarter", ...
[ 618, 0 ]
[ 629, 62 ]
python
en
['en', 'en', 'en']
True
is_absolute_quantized_sequence
(note_sequence)
Returns whether a NoteSequence proto has been quantized by absolute time. Args: note_sequence: A music_pb2.NoteSequence proto. Returns: True if `note_sequence` is quantized by absolute time, otherwise False.
Returns whether a NoteSequence proto has been quantized by absolute time.
def is_absolute_quantized_sequence(note_sequence): """Returns whether a NoteSequence proto has been quantized by absolute time. Args: note_sequence: A music_pb2.NoteSequence proto. Returns: True if `note_sequence` is quantized by absolute time, otherwise False. """ # If the QuantizationInfo message ...
[ "def", "is_absolute_quantized_sequence", "(", "note_sequence", ")", ":", "# If the QuantizationInfo message has a non-zero steps_per_second, assume", "# that the proto has been quantized by absolute time.", "return", "note_sequence", ".", "quantization_info", ".", "steps_per_second", ">"...
[ 632, 0 ]
[ 643, 61 ]
python
en
['en', 'en', 'en']
True
assert_is_quantized_sequence
(note_sequence)
Confirms that the given NoteSequence proto has been quantized. Args: note_sequence: A music_pb2.NoteSequence proto. Raises: QuantizationStatusError: If the sequence is not quantized.
Confirms that the given NoteSequence proto has been quantized.
def assert_is_quantized_sequence(note_sequence): """Confirms that the given NoteSequence proto has been quantized. Args: note_sequence: A music_pb2.NoteSequence proto. Raises: QuantizationStatusError: If the sequence is not quantized. """ if not is_quantized_sequence(note_sequence): raise Quanti...
[ "def", "assert_is_quantized_sequence", "(", "note_sequence", ")", ":", "if", "not", "is_quantized_sequence", "(", "note_sequence", ")", ":", "raise", "QuantizationStatusError", "(", "'NoteSequence %s is not quantized.'", "%", "note_sequence", ".", "id", ")" ]
[ 646, 0 ]
[ 657, 63 ]
python
en
['en', 'en', 'en']
True
assert_is_relative_quantized_sequence
(note_sequence)
Confirms that a NoteSequence proto has been quantized relative to tempo. Args: note_sequence: A music_pb2.NoteSequence proto. Raises: QuantizationStatusError: If the sequence is not quantized relative to tempo.
Confirms that a NoteSequence proto has been quantized relative to tempo.
def assert_is_relative_quantized_sequence(note_sequence): """Confirms that a NoteSequence proto has been quantized relative to tempo. Args: note_sequence: A music_pb2.NoteSequence proto. Raises: QuantizationStatusError: If the sequence is not quantized relative to tempo. """ if not is_relati...
[ "def", "assert_is_relative_quantized_sequence", "(", "note_sequence", ")", ":", "if", "not", "is_relative_quantized_sequence", "(", "note_sequence", ")", ":", "raise", "QuantizationStatusError", "(", "'NoteSequence %s is not quantized or is '", "'quantized based on absolute timing....
[ 660, 0 ]
[ 673, 65 ]
python
en
['en', 'en', 'en']
True
assert_is_absolute_quantized_sequence
(note_sequence)
Confirms that a NoteSequence proto has been quantized by absolute time. Args: note_sequence: A music_pb2.NoteSequence proto. Raises: QuantizationStatusError: If the sequence is not quantized by absolute time.
Confirms that a NoteSequence proto has been quantized by absolute time.
def assert_is_absolute_quantized_sequence(note_sequence): """Confirms that a NoteSequence proto has been quantized by absolute time. Args: note_sequence: A music_pb2.NoteSequence proto. Raises: QuantizationStatusError: If the sequence is not quantized by absolute time. """ if not is_absolute_qua...
[ "def", "assert_is_absolute_quantized_sequence", "(", "note_sequence", ")", ":", "if", "not", "is_absolute_quantized_sequence", "(", "note_sequence", ")", ":", "raise", "QuantizationStatusError", "(", "'NoteSequence %s is not quantized or is '", "'quantized based on relative timing....
[ 676, 0 ]
[ 689, 65 ]
python
en
['en', 'en', 'en']
True
steps_per_bar_in_quantized_sequence
(note_sequence)
Calculates steps per bar in a NoteSequence that has been quantized. Args: note_sequence: The NoteSequence to examine. Returns: Steps per bar as a floating point number.
Calculates steps per bar in a NoteSequence that has been quantized.
def steps_per_bar_in_quantized_sequence(note_sequence): """Calculates steps per bar in a NoteSequence that has been quantized. Args: note_sequence: The NoteSequence to examine. Returns: Steps per bar as a floating point number. """ assert_is_relative_quantized_sequence(note_sequence) quarters_per...
[ "def", "steps_per_bar_in_quantized_sequence", "(", "note_sequence", ")", ":", "assert_is_relative_quantized_sequence", "(", "note_sequence", ")", "quarters_per_beat", "=", "4.0", "/", "note_sequence", ".", "time_signatures", "[", "0", "]", ".", "denominator", "quarters_pe...
[ 692, 0 ]
[ 708, 28 ]
python
en
['en', 'en', 'en']
True
split_note_sequence
(note_sequence, hop_size_seconds, skip_splits_inside_notes=False)
Split one NoteSequence into many at specified time intervals. If `hop_size_seconds` is a scalar, this function splits a NoteSequence into multiple NoteSequences, all of fixed size (unless `split_notes` is False, in which case splits that would have truncated notes will be skipped; i.e. each split will either h...
Split one NoteSequence into many at specified time intervals.
def split_note_sequence(note_sequence, hop_size_seconds, skip_splits_inside_notes=False): """Split one NoteSequence into many at specified time intervals. If `hop_size_seconds` is a scalar, this function splits a NoteSequence into multiple NoteSequences, all of fix...
[ "def", "split_note_sequence", "(", "note_sequence", ",", "hop_size_seconds", ",", "skip_splits_inside_notes", "=", "False", ")", ":", "notes_by_start_time", "=", "sorted", "(", "list", "(", "note_sequence", ".", "notes", ")", ",", "key", "=", "lambda", "note", "...
[ 711, 0 ]
[ 772, 13 ]
python
en
['en', 'en', 'en']
True
split_note_sequence_on_time_changes
(note_sequence, skip_splits_inside_notes=False)
Split one NoteSequence into many around time signature and tempo changes. This function splits a NoteSequence into multiple NoteSequences, each of which contains only a single time signature and tempo, unless `split_notes` is False in which case all time signature and tempo changes occur within sustained notes...
Split one NoteSequence into many around time signature and tempo changes.
def split_note_sequence_on_time_changes(note_sequence, skip_splits_inside_notes=False): """Split one NoteSequence into many around time signature and tempo changes. This function splits a NoteSequence into multiple NoteSequences, each of which contains only a single time s...
[ "def", "split_note_sequence_on_time_changes", "(", "note_sequence", ",", "skip_splits_inside_notes", "=", "False", ")", ":", "current_numerator", "=", "4", "current_denominator", "=", "4", "current_qpm", "=", "constants", ".", "DEFAULT_QUARTERS_PER_MINUTE", "time_signatures...
[ 775, 0 ]
[ 851, 13 ]
python
en
['en', 'en', 'en']
True
split_note_sequence_on_silence
(note_sequence, gap_seconds=3.0)
Split one NoteSequence into many around gaps of silence. This function splits a NoteSequence into multiple NoteSequences, each of which contains no gaps of silence longer than `gap_seconds`. Each of the resulting NoteSequences is shifted such that the first note starts at time zero. Args: note_sequence: T...
Split one NoteSequence into many around gaps of silence.
def split_note_sequence_on_silence(note_sequence, gap_seconds=3.0): """Split one NoteSequence into many around gaps of silence. This function splits a NoteSequence into multiple NoteSequences, each of which contains no gaps of silence longer than `gap_seconds`. Each of the resulting NoteSequences is shifted su...
[ "def", "split_note_sequence_on_silence", "(", "note_sequence", ",", "gap_seconds", "=", "3.0", ")", ":", "notes_by_start_time", "=", "sorted", "(", "list", "(", "note_sequence", ".", "notes", ")", ",", "key", "=", "lambda", "note", ":", "note", ".", "start_tim...
[ 854, 0 ]
[ 886, 13 ]
python
en
['en', 'en', 'en']
True
quantize_to_step
(unquantized_seconds, steps_per_second, quantize_cutoff=QUANTIZE_CUTOFF)
Quantizes seconds to the nearest step, given steps_per_second. See the comments above `QUANTIZE_CUTOFF` for details on how the quantizing algorithm works. Args: unquantized_seconds: Seconds to quantize. steps_per_second: Quantizing resolution. quantize_cutoff: Value to use for quantizing cutoff. ...
Quantizes seconds to the nearest step, given steps_per_second.
def quantize_to_step(unquantized_seconds, steps_per_second, quantize_cutoff=QUANTIZE_CUTOFF): """Quantizes seconds to the nearest step, given steps_per_second. See the comments above `QUANTIZE_CUTOFF` for details on how the quantizing algorithm works. Args: unquan...
[ "def", "quantize_to_step", "(", "unquantized_seconds", ",", "steps_per_second", ",", "quantize_cutoff", "=", "QUANTIZE_CUTOFF", ")", ":", "unquantized_steps", "=", "unquantized_seconds", "*", "steps_per_second", "return", "int", "(", "unquantized_steps", "+", "(", "1", ...
[ 889, 0 ]
[ 906, 55 ]
python
en
['en', 'en', 'en']
True
steps_per_quarter_to_steps_per_second
(steps_per_quarter, qpm)
Calculates steps per second given steps_per_quarter and a qpm.
Calculates steps per second given steps_per_quarter and a qpm.
def steps_per_quarter_to_steps_per_second(steps_per_quarter, qpm): """Calculates steps per second given steps_per_quarter and a qpm.""" return steps_per_quarter * qpm / 60.0
[ "def", "steps_per_quarter_to_steps_per_second", "(", "steps_per_quarter", ",", "qpm", ")", ":", "return", "steps_per_quarter", "*", "qpm", "/", "60.0" ]
[ 909, 0 ]
[ 911, 39 ]
python
en
['en', 'ca', 'en']
True
_quantize_notes
(note_sequence, steps_per_second)
Quantize the notes and chords of a NoteSequence proto in place. Note start and end times, and chord times are snapped to a nearby quantized step, and the resulting times are stored in a separate field (e.g., quantized_start_step). See the comments above `QUANTIZE_CUTOFF` for details on how the quantizing algor...
Quantize the notes and chords of a NoteSequence proto in place.
def _quantize_notes(note_sequence, steps_per_second): """Quantize the notes and chords of a NoteSequence proto in place. Note start and end times, and chord times are snapped to a nearby quantized step, and the resulting times are stored in a separate field (e.g., quantized_start_step). See the comments above ...
[ "def", "_quantize_notes", "(", "note_sequence", ",", "steps_per_second", ")", ":", "for", "note", "in", "note_sequence", ".", "notes", ":", "# Quantize the start and end times of the note.", "note", ".", "quantized_start_step", "=", "quantize_to_step", "(", "note", ".",...
[ 914, 0 ]
[ 956, 70 ]
python
en
['en', 'en', 'en']
True
quantize_note_sequence
(note_sequence, steps_per_quarter)
Quantize a NoteSequence proto relative to tempo. The input NoteSequence is copied and quantization-related fields are populated. Sets the `steps_per_quarter` field in the `quantization_info` message in the NoteSequence. Note start and end times, and chord times are snapped to a nearby quantized step, and th...
Quantize a NoteSequence proto relative to tempo.
def quantize_note_sequence(note_sequence, steps_per_quarter): """Quantize a NoteSequence proto relative to tempo. The input NoteSequence is copied and quantization-related fields are populated. Sets the `steps_per_quarter` field in the `quantization_info` message in the NoteSequence. Note start and end time...
[ "def", "quantize_note_sequence", "(", "note_sequence", ",", "steps_per_quarter", ")", ":", "qns", "=", "copy", ".", "deepcopy", "(", "note_sequence", ")", "qns", ".", "quantization_info", ".", "steps_per_quarter", "=", "steps_per_quarter", "if", "qns", ".", "time_...
[ 959, 0 ]
[ 1068, 12 ]
python
en
['en', 'pt', 'it']
False
quantize_note_sequence_absolute
(note_sequence, steps_per_second)
Quantize a NoteSequence proto using absolute event times. The input NoteSequence is copied and quantization-related fields are populated. Sets the `steps_per_second` field in the `quantization_info` message in the NoteSequence. Note start and end times, and chord times are snapped to a nearby quantized step...
Quantize a NoteSequence proto using absolute event times.
def quantize_note_sequence_absolute(note_sequence, steps_per_second): """Quantize a NoteSequence proto using absolute event times. The input NoteSequence is copied and quantization-related fields are populated. Sets the `steps_per_second` field in the `quantization_info` message in the NoteSequence. Note st...
[ "def", "quantize_note_sequence_absolute", "(", "note_sequence", ",", "steps_per_second", ")", ":", "qns", "=", "copy", ".", "deepcopy", "(", "note_sequence", ")", "qns", ".", "quantization_info", ".", "steps_per_second", "=", "steps_per_second", "qns", ".", "total_q...
[ 1071, 0 ]
[ 1102, 12 ]
python
en
['en', 'en', 'en']
True
transpose_note_sequence
(ns, amount, min_allowed_pitch=constants.MIN_MIDI_PITCH, max_allowed_pitch=constants.MAX_MIDI_PITCH, transpose_chords=True, in_place=False)
Transposes note sequence specified amount, deleting out-of-bound notes. Args: ns: The NoteSequence proto to be transposed. amount: Number of half-steps to transpose up or down. min_allowed_pitch: Minimum pitch allowed in transposed NoteSequence. Notes assigned lower pitches will be deleted. max...
Transposes note sequence specified amount, deleting out-of-bound notes.
def transpose_note_sequence(ns, amount, min_allowed_pitch=constants.MIN_MIDI_PITCH, max_allowed_pitch=constants.MAX_MIDI_PITCH, transpose_chords=True, in_place=False): """Transpo...
[ "def", "transpose_note_sequence", "(", "ns", ",", "amount", ",", "min_allowed_pitch", "=", "constants", ".", "MIN_MIDI_PITCH", ",", "max_allowed_pitch", "=", "constants", ".", "MAX_MIDI_PITCH", ",", "transpose_chords", "=", "True", ",", "in_place", "=", "False", "...
[ 1105, 0 ]
[ 1181, 31 ]
python
en
['en', 'en', 'en']
True
_clamp_transpose
(transpose_amount, ns_min_pitch, ns_max_pitch, min_allowed_pitch, max_allowed_pitch)
Clamps the specified transpose amount to keep a ns in the desired bounds. Args: transpose_amount: Number of steps to transpose up or down. ns_min_pitch: The lowest pitch in the target note sequence. ns_max_pitch: The highest pitch in the target note sequence. min_allowed_pitch: The lowest pitch that ...
Clamps the specified transpose amount to keep a ns in the desired bounds.
def _clamp_transpose(transpose_amount, ns_min_pitch, ns_max_pitch, min_allowed_pitch, max_allowed_pitch): """Clamps the specified transpose amount to keep a ns in the desired bounds. Args: transpose_amount: Number of steps to transpose up or down. ns_min_pitch: The lowest pitch in the ...
[ "def", "_clamp_transpose", "(", "transpose_amount", ",", "ns_min_pitch", ",", "ns_max_pitch", ",", "min_allowed_pitch", ",", "max_allowed_pitch", ")", ":", "if", "transpose_amount", "<", "0", ":", "transpose_amount", "=", "-", "min", "(", "ns_min_pitch", "-", "min...
[ 1184, 0 ]
[ 1206, 25 ]
python
en
['en', 'en', 'en']
True
augment_note_sequence
(ns, min_stretch_factor, max_stretch_factor, min_transpose, max_transpose, min_allowed_pitch=constants.MIN_MIDI_PITCH, max_allowed_pitch=constants.MAX_MIDI_PITCH, ...
Modifed a NoteSequence with random stretching and transposition. This method can be used to augment a dataset for training neural nets. Note that the provided ns is modified in place. Args: ns: A NoteSequence proto to be augmented. min_stretch_factor: Minimum amount to stretch/compress the NoteSequence....
Modifed a NoteSequence with random stretching and transposition.
def augment_note_sequence(ns, min_stretch_factor, max_stretch_factor, min_transpose, max_transpose, min_allowed_pitch=constants.MIN_MIDI_PITCH, max_allowed_pitch=co...
[ "def", "augment_note_sequence", "(", "ns", ",", "min_stretch_factor", ",", "max_stretch_factor", ",", "min_transpose", ",", "max_transpose", ",", "min_allowed_pitch", "=", "constants", ".", "MIN_MIDI_PITCH", ",", "max_allowed_pitch", "=", "constants", ".", "MAX_MIDI_PIT...
[ 1209, 0 ]
[ 1292, 11 ]
python
en
['en', 'en', 'en']
True
stretch_note_sequence
(note_sequence, stretch_factor, in_place=False)
Apply a constant temporal stretch to a NoteSequence proto. Args: note_sequence: The NoteSequence to stretch. stretch_factor: How much to stretch the NoteSequence. Values greater than one increase the length of the NoteSequence (making it "slower"). Values less than one decrease the length of the ...
Apply a constant temporal stretch to a NoteSequence proto.
def stretch_note_sequence(note_sequence, stretch_factor, in_place=False): """Apply a constant temporal stretch to a NoteSequence proto. Args: note_sequence: The NoteSequence to stretch. stretch_factor: How much to stretch the NoteSequence. Values greater than one increase the length of the NoteSequen...
[ "def", "stretch_note_sequence", "(", "note_sequence", ",", "stretch_factor", ",", "in_place", "=", "False", ")", ":", "if", "is_quantized_sequence", "(", "note_sequence", ")", ":", "raise", "QuantizationStatusError", "(", "'Can only stretch unquantized NoteSequence.'", ")...
[ 1295, 0 ]
[ 1344, 27 ]
python
en
['en', 'en', 'en']
True
adjust_notesequence_times
(ns, time_func, minimum_duration=None)
Adjusts notesequence timings given an adjustment function. Note that only notes, control changes, and pitch bends are adjusted. All other events are ignored. If the adjusted version of a note ends before or at the same time it begins, it will be skipped. Args: ns: The NoteSequence to adjust. time_f...
Adjusts notesequence timings given an adjustment function.
def adjust_notesequence_times(ns, time_func, minimum_duration=None): """Adjusts notesequence timings given an adjustment function. Note that only notes, control changes, and pitch bends are adjusted. All other events are ignored. If the adjusted version of a note ends before or at the same time it begins, i...
[ "def", "adjust_notesequence_times", "(", "ns", ",", "time_func", ",", "minimum_duration", "=", "None", ")", ":", "adjusted_ns", "=", "copy", ".", "deepcopy", "(", "ns", ")", "# Iterate through the original NoteSequence notes to make it easier to drop", "# skipped notes from...
[ 1347, 0 ]
[ 1448, 35 ]
python
en
['en', 'en', 'en']
True
rectify_beats
(sequence, beats_per_minute)
Warps a NoteSequence so that beats happen at regular intervals. Args: sequence: The source NoteSequence. Will not be modified. beats_per_minute: Desired BPM of the rectified sequence. Returns: rectified_sequence: A copy of `sequence` with times adjusted so that beats occur at regular intervals...
Warps a NoteSequence so that beats happen at regular intervals.
def rectify_beats(sequence, beats_per_minute): """Warps a NoteSequence so that beats happen at regular intervals. Args: sequence: The source NoteSequence. Will not be modified. beats_per_minute: Desired BPM of the rectified sequence. Returns: rectified_sequence: A copy of `sequence` with times adjus...
[ "def", "rectify_beats", "(", "sequence", ",", "beats_per_minute", ")", ":", "if", "is_quantized_sequence", "(", "sequence", ")", ":", "raise", "QuantizationStatusError", "(", "'Cannot rectify beat times for quantized NoteSequence.'", ")", "beat_times", "=", "[", "ta", "...
[ 1451, 0 ]
[ 1504, 63 ]
python
en
['en', 'lb', 'en']
True
apply_sustain_control_changes
(note_sequence, sustain_control_number=64)
Returns a new NoteSequence with sustain pedal control changes applied. Extends each note within a sustain to either the beginning of the next note of the same pitch or the end of the sustain period, whichever happens first. This is done on a per instrument basis, so notes are only affected by sustain events fo...
Returns a new NoteSequence with sustain pedal control changes applied.
def apply_sustain_control_changes(note_sequence, sustain_control_number=64): """Returns a new NoteSequence with sustain pedal control changes applied. Extends each note within a sustain to either the beginning of the next note of the same pitch or the end of the sustain period, whichever happens first. This is...
[ "def", "apply_sustain_control_changes", "(", "note_sequence", ",", "sustain_control_number", "=", "64", ")", ":", "if", "is_quantized_sequence", "(", "note_sequence", ")", ":", "raise", "QuantizationStatusError", "(", "'Can only apply sustain to unquantized NoteSequence.'", "...
[ 1517, 0 ]
[ 1636, 17 ]
python
en
['en', 'en', 'en']
True
infer_dense_chords_for_sequence
(sequence, instrument=None, min_notes_per_chord=3)
Infers chords for a NoteSequence and adds them as TextAnnotations. For each set of simultaneously-active notes in a NoteSequence (optionally for only one instrument), infers a chord symbol and adds it to NoteSequence as a TextAnnotation. Every change in the set of active notes will result in a new chord symbol...
Infers chords for a NoteSequence and adds them as TextAnnotations.
def infer_dense_chords_for_sequence(sequence, instrument=None, min_notes_per_chord=3): """Infers chords for a NoteSequence and adds them as TextAnnotations. For each set of simultaneously-active notes in a NoteSequence (optionally for only o...
[ "def", "infer_dense_chords_for_sequence", "(", "sequence", ",", "instrument", "=", "None", ",", "min_notes_per_chord", "=", "3", ")", ":", "notes", "=", "[", "note", "for", "note", "in", "sequence", ".", "notes", "if", "not", "note", ".", "is_drum", "and", ...
[ 1639, 0 ]
[ 1722, 25 ]
python
en
['en', 'en', 'en']
True
sequence_to_pianoroll
( sequence, frames_per_second, min_pitch, max_pitch, # pylint: disable=unused-argument min_velocity=constants.MIN_MIDI_PITCH, # pylint: enable=unused-argument max_velocity=constants.MAX_MIDI_PITCH, add_blank_frame_before_onset=False, onset_upweight=ONSET_UPWEIGHT, onset_windo...
Transforms a NoteSequence to a pianoroll assuming a single instrument. This function uses floating point internally and may return different results on different platforms or with different compiler settings or with different compilers. Args: sequence: The NoteSequence to convert. frames_per_second: H...
Transforms a NoteSequence to a pianoroll assuming a single instrument.
def sequence_to_pianoroll( sequence, frames_per_second, min_pitch, max_pitch, # pylint: disable=unused-argument min_velocity=constants.MIN_MIDI_PITCH, # pylint: enable=unused-argument max_velocity=constants.MAX_MIDI_PITCH, add_blank_frame_before_onset=False, onset_upweight=ONSET_...
[ "def", "sequence_to_pianoroll", "(", "sequence", ",", "frames_per_second", ",", "min_pitch", ",", "max_pitch", ",", "# pylint: disable=unused-argument", "min_velocity", "=", "constants", ".", "MIN_MIDI_PITCH", ",", "# pylint: enable=unused-argument", "max_velocity", "=", "c...
[ 1731, 0 ]
[ 1898, 38 ]
python
en
['en', 'en', 'en']
True
_unscale_velocity
(velocity, scale, bias)
Translates a velocity estimate to a MIDI velocity value. Note that this scaling is totally arbitrary and was chosen only because it sounded decent when synthesized. Args: velocity: Velocity estimate. Should be in [0, 1]. scale: Scale to use for conversion to MIDI velocity. bias: Bias to use for conv...
Translates a velocity estimate to a MIDI velocity value.
def _unscale_velocity(velocity, scale, bias): """Translates a velocity estimate to a MIDI velocity value. Note that this scaling is totally arbitrary and was chosen only because it sounded decent when synthesized. Args: velocity: Velocity estimate. Should be in [0, 1]. scale: Scale to use for conversi...
[ "def", "_unscale_velocity", "(", "velocity", ",", "scale", ",", "bias", ")", ":", "unscaled", "=", "max", "(", "min", "(", "velocity", ",", "1.", ")", ",", "0", ")", "*", "scale", "+", "bias", "if", "math", ".", "isnan", "(", "unscaled", ")", ":", ...
[ 1901, 0 ]
[ 1918, 22 ]
python
en
['en', 'it', 'en']
True
pianoroll_to_note_sequence
(frames, frames_per_second, min_duration_ms, velocity=70, instrument=0, program=0, qpm=constants.DEFAULT_QUARTERS_PER_MINUTE, ...
Convert frames (with optional onsets, offsets, velocities) to NoteSequence. Args: frames: Numpy array of active frames. Expected shape is (time, pitch). frames_per_second: Frames per second. min_duration_ms: Notes active for less than this duration will be ignored. velocity: Default note velocity if ...
Convert frames (with optional onsets, offsets, velocities) to NoteSequence.
def pianoroll_to_note_sequence(frames, frames_per_second, min_duration_ms, velocity=70, instrument=0, program=0, qpm=constants.DEFAULT...
[ "def", "pianoroll_to_note_sequence", "(", "frames", ",", "frames_per_second", ",", "min_duration_ms", ",", "velocity", "=", "70", ",", "instrument", "=", "0", ",", "program", "=", "0", ",", "qpm", "=", "constants", ".", "DEFAULT_QUARTERS_PER_MINUTE", ",", "min_m...
[ 1921, 0 ]
[ 2045, 17 ]
python
en
['en', 'en', 'en']
True
pianoroll_onsets_to_note_sequence
(onsets, frames_per_second, note_duration_seconds=0.05, velocity=70, instrument=0, program=0, ...
Convert onsets to a NoteSequence. This converts an matrix of onsets into a NoteSequence. Every active onset is considered to be a new note with a fixed duration of note_duration_seconds. This is different from pianoroll_to_note_sequence, which considers onsets in consecutive frames to represent a single new no...
Convert onsets to a NoteSequence.
def pianoroll_onsets_to_note_sequence(onsets, frames_per_second, note_duration_seconds=0.05, velocity=70, instrument=0, program=0,...
[ "def", "pianoroll_onsets_to_note_sequence", "(", "onsets", ",", "frames_per_second", ",", "note_duration_seconds", "=", "0.05", ",", "velocity", "=", "70", ",", "instrument", "=", "0", ",", "program", "=", "0", ",", "qpm", "=", "constants", ".", "DEFAULT_QUARTER...
[ 2048, 0 ]
[ 2112, 17 ]
python
en
['en', 'en', 'nl']
True
sequence_to_valued_intervals
(note_sequence, min_midi_pitch=constants.MIN_MIDI_PITCH, max_midi_pitch=constants.MAX_MIDI_PITCH, restrict_to_pitch=None)
Convert a NoteSequence to valued intervals. Value intervals are intended to be used with mir_eval metrics methods. Args: note_sequence: sequence to convert. min_midi_pitch: notes lower than this will be discarded. max_midi_pitch: notes higher than this will be discarded. restrict_to_pitch: notes t...
Convert a NoteSequence to valued intervals.
def sequence_to_valued_intervals(note_sequence, min_midi_pitch=constants.MIN_MIDI_PITCH, max_midi_pitch=constants.MAX_MIDI_PITCH, restrict_to_pitch=None): """Convert a NoteSequence to valued intervals. Value interval...
[ "def", "sequence_to_valued_intervals", "(", "note_sequence", ",", "min_midi_pitch", "=", "constants", ".", "MIN_MIDI_PITCH", ",", "max_midi_pitch", "=", "constants", ".", "MAX_MIDI_PITCH", ",", "restrict_to_pitch", "=", "None", ")", ":", "intervals", "=", "[", "]", ...
[ 2115, 0 ]
[ 2157, 39 ]
python
en
['en', 'en', 'en']
True
colab_play
(array_of_floats, sample_rate, ephemeral=True, autoplay=False)
Creates an HTML5 audio widget to play a sound in Colab. This function should only be called from a Colab notebook. Args: array_of_floats: A 1D or 2D array-like container of float sound samples. Values outside of the range [-1, 1] will be clipped. sample_rate: Sample rate in samples per second. e...
Creates an HTML5 audio widget to play a sound in Colab.
def colab_play(array_of_floats, sample_rate, ephemeral=True, autoplay=False): """Creates an HTML5 audio widget to play a sound in Colab. This function should only be called from a Colab notebook. Args: array_of_floats: A 1D or 2D array-like container of float sound samples. Values outside of the range...
[ "def", "colab_play", "(", "array_of_floats", ",", "sample_rate", ",", "ephemeral", "=", "True", ",", "autoplay", "=", "False", ")", ":", "from", "google", ".", "colab", ".", "output", "import", "_js_builder", "as", "js", "# pylint:disable=import-outside-toplevel,g...
[ 39, 0 ]
[ 76, 39 ]
python
en
['en', 'en', 'en']
True
play_sequence
(sequence, synth=midi_synth.synthesize, sample_rate=_DEFAULT_SAMPLE_RATE, colab_ephemeral=True, **synth_args)
Creates an interactive player for a synthesized note sequence. This function should only be called from a Jupyter or Colab notebook. Args: sequence: A music_pb2.NoteSequence to synthesize and play. synth: A synthesis function that takes a sequence and sample rate as input. sample_rate: The sample rate...
Creates an interactive player for a synthesized note sequence.
def play_sequence(sequence, synth=midi_synth.synthesize, sample_rate=_DEFAULT_SAMPLE_RATE, colab_ephemeral=True, **synth_args): """Creates an interactive player for a synthesized note sequence. This function should only be called from a Jupyte...
[ "def", "play_sequence", "(", "sequence", ",", "synth", "=", "midi_synth", ".", "synthesize", ",", "sample_rate", "=", "_DEFAULT_SAMPLE_RATE", ",", "colab_ephemeral", "=", "True", ",", "*", "*", "synth_args", ")", ":", "array_of_floats", "=", "synth", "(", "seq...
[ 79, 0 ]
[ 103, 69 ]
python
en
['en', 'en', 'en']
True
plot_sequence
(sequence, show_figure=True)
Creates an interactive pianoroll for a NoteSequence. Example usage: plot a random melody. sequence = mm.Melody(np.random.randint(36, 72, 30)).to_sequence() bokeh_pianoroll(sequence) Args: sequence: A NoteSequence. show_figure: A boolean indicating whether or not to show the figure. Returns: ...
Creates an interactive pianoroll for a NoteSequence.
def plot_sequence(sequence, show_figure=True): """Creates an interactive pianoroll for a NoteSequence. Example usage: plot a random melody. sequence = mm.Melody(np.random.randint(36, 72, 30)).to_sequence() bokeh_pianoroll(sequence) Args: sequence: A NoteSequence. show_figure: A boolean indicat...
[ "def", "plot_sequence", "(", "sequence", ",", "show_figure", "=", "True", ")", ":", "def", "_sequence_to_pandas_dataframe", "(", "sequence", ")", ":", "\"\"\"Generates a pandas dataframe from a sequence.\"\"\"", "pd_dict", "=", "collections", ".", "defaultdict", "(", "l...
[ 106, 0 ]
[ 181, 12 ]
python
en
['en', 'en', 'en']
True
download_bundle
(bundle_name, target_dir, force_reload=False)
Downloads a Magenta bundle to target directory. Target directory target_dir will be created if it does not already exist. Args: bundle_name: A string Magenta bundle name to download. target_dir: A string local directory in which to write the bundle. force_reload: A boolean that when True, reloads t...
Downloads a Magenta bundle to target directory.
def download_bundle(bundle_name, target_dir, force_reload=False): """Downloads a Magenta bundle to target directory. Target directory target_dir will be created if it does not already exist. Args: bundle_name: A string Magenta bundle name to download. target_dir: A string local directory in which to w...
[ "def", "download_bundle", "(", "bundle_name", ",", "target_dir", ",", "force_reload", "=", "False", ")", ":", "makedirs", "(", "target_dir", ")", "bundle_target", "=", "os", ".", "path", ".", "join", "(", "target_dir", ",", "bundle_name", ")", "if", "not", ...
[ 184, 0 ]
[ 202, 22 ]
python
en
['en', 'en', 'en']
True
get_available_images
(request, project_id=None, images_cache=None)
Returns a list of available images Returns a list of images that are public, shared, community or owned by the given project_id. If project_id is not specified, only public and community images are returned. :param images_cache: An optional dict-like object in which to cache public and per-project...
Returns a list of available images
def get_available_images(request, project_id=None, images_cache=None): """Returns a list of available images Returns a list of images that are public, shared, community or owned by the given project_id. If project_id is not specified, only public and community images are returned. :param images_ca...
[ "def", "get_available_images", "(", "request", ",", "project_id", "=", "None", ",", "images_cache", "=", "None", ")", ":", "if", "images_cache", "is", "None", ":", "images_cache", "=", "{", "}", "public_images", "=", "images_cache", ".", "get", "(", "'public...
[ 20, 0 ]
[ 103, 23 ]
python
en
['en', 'en', 'en']
True
image_field_data
(request, include_empty_option=False)
Returns a list of tuples of all images. Generates a sorted list of images available. And returns a list of (id, name) tuples. :param request: django http request object :param include_empty_option: flag to include a empty tuple in the front of the list :return: list of (id, name) tuples ...
Returns a list of tuples of all images.
def image_field_data(request, include_empty_option=False): """Returns a list of tuples of all images. Generates a sorted list of images available. And returns a list of (id, name) tuples. :param request: django http request object :param include_empty_option: flag to include a empty tuple in the f...
[ "def", "image_field_data", "(", "request", ",", "include_empty_option", "=", "False", ")", ":", "try", ":", "images", "=", "get_available_images", "(", "request", ",", "request", ".", "user", ".", "project_id", ")", "except", "Exception", ":", "exceptions", "....
[ 106, 0 ]
[ 132, 22 ]
python
en
['en', 'en', 'en']
True
test_search_conftest_up_to_inifile
(testdir, confcutdir, passed, error)
Test that conftest files are detected only up to a ini file, unless an explicit --confcutdir option is given.
Test that conftest files are detected only up to a ini file, unless an explicit --confcutdir option is given.
def test_search_conftest_up_to_inifile(testdir, confcutdir, passed, error): """Test that conftest files are detected only up to a ini file, unless an explicit --confcutdir option is given. """ root = testdir.tmpdir src = root.join('src').ensure(dir=1) src.join('pytest.ini').write('[pytest]') ...
[ "def", "test_search_conftest_up_to_inifile", "(", "testdir", ",", "confcutdir", ",", "passed", ",", "error", ")", ":", "root", "=", "testdir", ".", "tmpdir", "src", "=", "root", ".", "join", "(", "'src'", ")", ".", "ensure", "(", "dir", "=", "1", ")", ...
[ 374, 0 ]
[ 407, 38 ]
python
en
['en', 'en', 'en']
True
test_hook_proxy
(testdir)
Session's gethookproxy() would cache conftests incorrectly (#2016). It was decided to remove the cache altogether.
Session's gethookproxy() would cache conftests incorrectly (#2016). It was decided to remove the cache altogether.
def test_hook_proxy(testdir): """Session's gethookproxy() would cache conftests incorrectly (#2016). It was decided to remove the cache altogether. """ testdir.makepyfile(**{ 'root/demo-0/test_foo1.py': "def test1(): pass", 'root/demo-a/test_foo2.py': "def test1(): pass", 'root/...
[ "def", "test_hook_proxy", "(", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "*", "*", "{", "'root/demo-0/test_foo1.py'", ":", "\"def test1(): pass\"", ",", "'root/demo-a/test_foo2.py'", ":", "\"def test1(): pass\"", ",", "'root/demo-a/conftest.py'", ":", "\"\...
[ 439, 0 ]
[ 461, 6 ]
python
en
['en', 'en', 'en']
True
EditMessageTest.check_message
(self, msg_id: int, topic_name: str, content: str)
We assume our caller just edited a message. Next, we will make sure we properly cached the messages. We still have to do a query to hydrate recipient info, but we won't need to hit the zerver_message table.
We assume our caller just edited a message.
def check_message(self, msg_id: int, topic_name: str, content: str) -> None: # Make sure we saved the message correctly to the DB. msg = Message.objects.get(id=msg_id) self.assertEqual(msg.topic_name(), topic_name) self.assertEqual(msg.content, content) """ We assume our...
[ "def", "check_message", "(", "self", ",", "msg_id", ":", "int", ",", "topic_name", ":", "str", ",", "content", ":", "str", ")", "->", "None", ":", "# Make sure we saved the message correctly to the DB.", "msg", "=", "Message", ".", "objects", ".", "get", "(", ...
[ 29, 4 ]
[ 74, 13 ]
python
en
['en', 'error', 'th']
False
EditMessageTest.test_save_message
(self)
This is also tested by a client test, but here we can verify the cache against the database
This is also tested by a client test, but here we can verify the cache against the database
def test_save_message(self) -> None: """This is also tested by a client test, but here we can verify the cache against the database""" self.login("hamlet") msg_id = self.send_stream_message( self.example_user("hamlet"), "Scotland", topic_name="editing", content="before edit" ...
[ "def", "test_save_message", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "msg_id", "=", "self", ".", "send_stream_message", "(", "self", ".", "example_user", "(", "\"hamlet\"", ")", ",", "\"Scotland\"", ",", "topic_name"...
[ 111, 4 ]
[ 136, 53 ]
python
en
['en', 'en', 'en']
True
EditMessageTest.test_edit_cases
(self)
This test verifies the accuracy of construction of Zulip's edit history data structures.
This test verifies the accuracy of construction of Zulip's edit history data structures.
def test_edit_cases(self) -> None: """This test verifies the accuracy of construction of Zulip's edit history data structures.""" self.login("hamlet") hamlet = self.example_user("hamlet") msg_id = self.send_stream_message( self.example_user("hamlet"), "Scotland", topi...
[ "def", "test_edit_cases", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "msg_id", "=", "self", ".", "send_stream_message", "(", "self", ".", "example_u...
[ 473, 4 ]
[ 613, 64 ]
python
en
['en', 'en', 'en']
True
EditMessageTest.test_inaccessible_msg_after_stream_change
(self)
Simulates the case where message is moved to a stream where user is not a subscribed
Simulates the case where message is moved to a stream where user is not a subscribed
def test_inaccessible_msg_after_stream_change(self) -> None: """Simulates the case where message is moved to a stream where user is not a subscribed""" (user_profile, old_stream, new_stream, msg_id, msg_id_lt) = self.prepare_move_topics( "iago", "test move stream", "new stream", "test" ...
[ "def", "test_inaccessible_msg_after_stream_change", "(", "self", ")", "->", "None", ":", "(", "user_profile", ",", "old_stream", ",", "new_stream", ",", "msg_id", ",", "msg_id_lt", ")", "=", "self", ".", "prepare_move_topics", "(", "\"iago\"", ",", "\"test move st...
[ 1548, 4 ]
[ 1660, 9 ]
python
en
['en', 'en', 'en']
True
RoleAPITests.test_remove_tenant_user
(self, mock_keystoneclient)
Tests api.keystone.remove_tenant_user Verifies that remove_tenant_user is called with the right arguments after iterating the user's roles.
Tests api.keystone.remove_tenant_user
def test_remove_tenant_user(self, mock_keystoneclient): """Tests api.keystone.remove_tenant_user Verifies that remove_tenant_user is called with the right arguments after iterating the user's roles. """ keystoneclient = mock_keystoneclient.return_value tenant = self.tena...
[ "def", "test_remove_tenant_user", "(", "self", ",", "mock_keystoneclient", ")", ":", "keystoneclient", "=", "mock_keystoneclient", ".", "return_value", "tenant", "=", "self", ".", "tenants", ".", "first", "(", ")", "keystoneclient", ".", "roles", ".", "roles_for_u...
[ 34, 4 ]
[ 57, 9 ]
python
en
['en', 'sq', 'en']
False
BlockProcessor.lastChild
(self, parent)
Return the last child of an etree element.
Return the last child of an etree element.
def lastChild(self, parent): """ Return the last child of an etree element. """ if len(parent): return parent[-1] else: return None
[ "def", "lastChild", "(", "self", ",", "parent", ")", ":", "if", "len", "(", "parent", ")", ":", "return", "parent", "[", "-", "1", "]", "else", ":", "return", "None" ]
[ 31, 4 ]
[ 36, 23 ]
python
en
['en', 'en', 'en']
True
BlockProcessor.detab
(self, text)
Remove a tab from the front of each line of the given text.
Remove a tab from the front of each line of the given text.
def detab(self, text): """ Remove a tab from the front of each line of the given text. """ newtext = [] lines = text.split('\n') for line in lines: if line.startswith(' '*markdown.TAB_LENGTH): newtext.append(line[markdown.TAB_LENGTH:]) elif not lin...
[ "def", "detab", "(", "self", ",", "text", ")", ":", "newtext", "=", "[", "]", "lines", "=", "text", ".", "split", "(", "'\\n'", ")", "for", "line", "in", "lines", ":", "if", "line", ".", "startswith", "(", "' '", "*", "markdown", ".", "TAB_LENGTH",...
[ 38, 4 ]
[ 49, 66 ]
python
en
['en', 'en', 'en']
True
BlockProcessor.looseDetab
(self, text, level=1)
Remove a tab from front of lines but allowing dedented lines.
Remove a tab from front of lines but allowing dedented lines.
def looseDetab(self, text, level=1): """ Remove a tab from front of lines but allowing dedented lines. """ lines = text.split('\n') for i in range(len(lines)): if lines[i].startswith(' '*markdown.TAB_LENGTH*level): lines[i] = lines[i][markdown.TAB_LENGTH*level:] ...
[ "def", "looseDetab", "(", "self", ",", "text", ",", "level", "=", "1", ")", ":", "lines", "=", "text", ".", "split", "(", "'\\n'", ")", "for", "i", "in", "range", "(", "len", "(", "lines", ")", ")", ":", "if", "lines", "[", "i", "]", ".", "st...
[ 51, 4 ]
[ 57, 31 ]
python
en
['en', 'en', 'en']
True
BlockProcessor.test
(self, parent, block)
Test for block type. Must be overridden by subclasses. As the parser loops through processors, it will call the ``test`` method on each to determine if the given block of text is of that type. This method must return a boolean ``True`` or ``False``. The actual method of testing is left...
Test for block type. Must be overridden by subclasses.
def test(self, parent, block): """ Test for block type. Must be overridden by subclasses. As the parser loops through processors, it will call the ``test`` method on each to determine if the given block of text is of that type. This method must return a boolean ``True`` or ``False``. Th...
[ "def", "test", "(", "self", ",", "parent", ",", "block", ")", ":", "pass" ]
[ 59, 4 ]
[ 77, 12 ]
python
en
['en', 'en', 'en']
True
BlockProcessor.run
(self, parent, blocks)
Run processor. Must be overridden by subclasses. When the parser determines the appropriate type of a block, the parser will call the corresponding processor's ``run`` method. This method should parse the individual lines of the block and append them to the etree. Note that bo...
Run processor. Must be overridden by subclasses.
def run(self, parent, blocks): """ Run processor. Must be overridden by subclasses. When the parser determines the appropriate type of a block, the parser will call the corresponding processor's ``run`` method. This method should parse the individual lines of the block and append them t...
[ "def", "run", "(", "self", ",", "parent", ",", "blocks", ")", ":", "pass" ]
[ 79, 4 ]
[ 101, 12 ]
python
en
['en', 'en', 'en']
True
ListIndentProcessor.create_item
(self, parent, block)
Create a new li and parse the block with it as the parent.
Create a new li and parse the block with it as the parent.
def create_item(self, parent, block): """ Create a new li and parse the block with it as the parent. """ li = markdown.etree.SubElement(parent, 'li') self.parser.parseBlocks(li, [block])
[ "def", "create_item", "(", "self", ",", "parent", ",", "block", ")", ":", "li", "=", "markdown", ".", "etree", ".", "SubElement", "(", "parent", ",", "'li'", ")", "self", ".", "parser", ".", "parseBlocks", "(", "li", ",", "[", "block", "]", ")" ]
[ 152, 4 ]
[ 155, 44 ]
python
en
['en', 'en', 'en']
True