repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
bukun/TorCMS
torcms/script/tmplchecker/__init__.py
do_for_dir
def do_for_dir(inws, begin): ''' do something in the directory. ''' inws = os.path.abspath(inws) for wroot, wdirs, wfiles in os.walk(inws): for wfile in wfiles: if wfile.endswith('.html'): if 'autogen' in wroot: continue check_h...
python
def do_for_dir(inws, begin): ''' do something in the directory. ''' inws = os.path.abspath(inws) for wroot, wdirs, wfiles in os.walk(inws): for wfile in wfiles: if wfile.endswith('.html'): if 'autogen' in wroot: continue check_h...
[ "def", "do_for_dir", "(", "inws", ",", "begin", ")", ":", "inws", "=", "os", ".", "path", ".", "abspath", "(", "inws", ")", "for", "wroot", ",", "wdirs", ",", "wfiles", "in", "os", ".", "walk", "(", "inws", ")", ":", "for", "wfile", "in", "wfiles...
do something in the directory.
[ "do", "something", "in", "the", "directory", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/tmplchecker/__init__.py#L99-L109
bukun/TorCMS
torcms/script/tmplchecker/__init__.py
run_checkit
def run_checkit(srws=None): ''' do check it. ''' begin = len(os.path.abspath('templates')) + 1 inws = os.path.abspath(os.getcwd()) if srws: do_for_dir(srws[0], begin) else: do_for_dir(os.path.join(inws, 'templates'), begin) DOT_OBJ.render('xxtmpl', view=True)
python
def run_checkit(srws=None): ''' do check it. ''' begin = len(os.path.abspath('templates')) + 1 inws = os.path.abspath(os.getcwd()) if srws: do_for_dir(srws[0], begin) else: do_for_dir(os.path.join(inws, 'templates'), begin) DOT_OBJ.render('xxtmpl', view=True)
[ "def", "run_checkit", "(", "srws", "=", "None", ")", ":", "begin", "=", "len", "(", "os", ".", "path", ".", "abspath", "(", "'templates'", ")", ")", "+", "1", "inws", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "getcwd", "(", ")", "...
do check it.
[ "do", "check", "it", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/tmplchecker/__init__.py#L112-L123
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.query_all
def query_all(): ''' Query all the records from TabPost2Tag. ''' recs = TabPost2Tag.select( TabPost2Tag, TabTag.kind.alias('tag_kind'), ).join( TabTag, on=(TabPost2Tag.tag_id == TabTag.uid) ) return recs
python
def query_all(): ''' Query all the records from TabPost2Tag. ''' recs = TabPost2Tag.select( TabPost2Tag, TabTag.kind.alias('tag_kind'), ).join( TabTag, on=(TabPost2Tag.tag_id == TabTag.uid) ) return recs
[ "def", "query_all", "(", ")", ":", "recs", "=", "TabPost2Tag", ".", "select", "(", "TabPost2Tag", ",", "TabTag", ".", "kind", ".", "alias", "(", "'tag_kind'", ")", ",", ")", ".", "join", "(", "TabTag", ",", "on", "=", "(", "TabPost2Tag", ".", "tag_id...
Query all the records from TabPost2Tag.
[ "Query", "all", "the", "records", "from", "TabPost2Tag", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L21-L32
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.remove_relation
def remove_relation(post_id, tag_id): ''' Delete the record of post 2 tag. ''' entry = TabPost2Tag.delete().where( (TabPost2Tag.post_id == post_id) & (TabPost2Tag.tag_id == tag_id) ) entry.execute() MCategory.update_count(tag_id)
python
def remove_relation(post_id, tag_id): ''' Delete the record of post 2 tag. ''' entry = TabPost2Tag.delete().where( (TabPost2Tag.post_id == post_id) & (TabPost2Tag.tag_id == tag_id) ) entry.execute() MCategory.update_count(tag_id)
[ "def", "remove_relation", "(", "post_id", ",", "tag_id", ")", ":", "entry", "=", "TabPost2Tag", ".", "delete", "(", ")", ".", "where", "(", "(", "TabPost2Tag", ".", "post_id", "==", "post_id", ")", "&", "(", "TabPost2Tag", ".", "tag_id", "==", "tag_id", ...
Delete the record of post 2 tag.
[ "Delete", "the", "record", "of", "post", "2", "tag", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L35-L44
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.remove_tag
def remove_tag(tag_id): ''' Delete the records of certain tag. ''' entry = TabPost2Tag.delete().where( TabPost2Tag.tag_id == tag_id ) entry.execute()
python
def remove_tag(tag_id): ''' Delete the records of certain tag. ''' entry = TabPost2Tag.delete().where( TabPost2Tag.tag_id == tag_id ) entry.execute()
[ "def", "remove_tag", "(", "tag_id", ")", ":", "entry", "=", "TabPost2Tag", ".", "delete", "(", ")", ".", "where", "(", "TabPost2Tag", ".", "tag_id", "==", "tag_id", ")", "entry", ".", "execute", "(", ")" ]
Delete the records of certain tag.
[ "Delete", "the", "records", "of", "certain", "tag", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L47-L54
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.query_by_post
def query_by_post(postid): ''' Query records by post. ''' return TabPost2Tag.select().where( TabPost2Tag.post_id == postid ).order_by(TabPost2Tag.order)
python
def query_by_post(postid): ''' Query records by post. ''' return TabPost2Tag.select().where( TabPost2Tag.post_id == postid ).order_by(TabPost2Tag.order)
[ "def", "query_by_post", "(", "postid", ")", ":", "return", "TabPost2Tag", ".", "select", "(", ")", ".", "where", "(", "TabPost2Tag", ".", "post_id", "==", "postid", ")", ".", "order_by", "(", "TabPost2Tag", ".", "order", ")" ]
Query records by post.
[ "Query", "records", "by", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L78-L84
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.__get_by_info
def __get_by_info(post_id, catalog_id): ''' Geo the record by post and catalog. ''' recs = TabPost2Tag.select().where( (TabPost2Tag.post_id == post_id) & (TabPost2Tag.tag_id == catalog_id) ) if recs.count() == 1: return recs.get() ...
python
def __get_by_info(post_id, catalog_id): ''' Geo the record by post and catalog. ''' recs = TabPost2Tag.select().where( (TabPost2Tag.post_id == post_id) & (TabPost2Tag.tag_id == catalog_id) ) if recs.count() == 1: return recs.get() ...
[ "def", "__get_by_info", "(", "post_id", ",", "catalog_id", ")", ":", "recs", "=", "TabPost2Tag", ".", "select", "(", ")", ".", "where", "(", "(", "TabPost2Tag", ".", "post_id", "==", "post_id", ")", "&", "(", "TabPost2Tag", ".", "tag_id", "==", "catalog_...
Geo the record by post and catalog.
[ "Geo", "the", "record", "by", "post", "and", "catalog", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L87-L110
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.query_count
def query_count(): ''' The count of post2tag. ''' recs = TabPost2Tag.select( TabPost2Tag.tag_id, peewee.fn.COUNT(TabPost2Tag.tag_id).alias('num') ).group_by( TabPost2Tag.tag_id ) return recs
python
def query_count(): ''' The count of post2tag. ''' recs = TabPost2Tag.select( TabPost2Tag.tag_id, peewee.fn.COUNT(TabPost2Tag.tag_id).alias('num') ).group_by( TabPost2Tag.tag_id ) return recs
[ "def", "query_count", "(", ")", ":", "recs", "=", "TabPost2Tag", ".", "select", "(", "TabPost2Tag", ".", "tag_id", ",", "peewee", ".", "fn", ".", "COUNT", "(", "TabPost2Tag", ".", "tag_id", ")", ".", "alias", "(", "'num'", ")", ")", ".", "group_by", ...
The count of post2tag.
[ "The", "count", "of", "post2tag", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L113-L123
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.update_field
def update_field(uid, post_id=None, tag_id=None, par_id=None): ''' Update the field of post2tag. ''' if post_id: entry = TabPost2Tag.update( post_id=post_id ).where(TabPost2Tag.uid == uid) entry.execute() if tag_id: ...
python
def update_field(uid, post_id=None, tag_id=None, par_id=None): ''' Update the field of post2tag. ''' if post_id: entry = TabPost2Tag.update( post_id=post_id ).where(TabPost2Tag.uid == uid) entry.execute() if tag_id: ...
[ "def", "update_field", "(", "uid", ",", "post_id", "=", "None", ",", "tag_id", "=", "None", ",", "par_id", "=", "None", ")", ":", "if", "post_id", ":", "entry", "=", "TabPost2Tag", ".", "update", "(", "post_id", "=", "post_id", ")", ".", "where", "("...
Update the field of post2tag.
[ "Update", "the", "field", "of", "post2tag", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L126-L146
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.add_record
def add_record(post_id, catalog_id, order=0): ''' Create the record of post 2 tag, and update the count in g_tag. ''' rec = MPost2Catalog.__get_by_info(post_id, catalog_id) if rec: entry = TabPost2Tag.update( order=order, # For migrati...
python
def add_record(post_id, catalog_id, order=0): ''' Create the record of post 2 tag, and update the count in g_tag. ''' rec = MPost2Catalog.__get_by_info(post_id, catalog_id) if rec: entry = TabPost2Tag.update( order=order, # For migrati...
[ "def", "add_record", "(", "post_id", ",", "catalog_id", ",", "order", "=", "0", ")", ":", "rec", "=", "MPost2Catalog", ".", "__get_by_info", "(", "post_id", ",", "catalog_id", ")", "if", "rec", ":", "entry", "=", "TabPost2Tag", ".", "update", "(", "order...
Create the record of post 2 tag, and update the count in g_tag.
[ "Create", "the", "record", "of", "post", "2", "tag", "and", "update", "the", "count", "in", "g_tag", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L149-L171
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.count_of_certain_category
def count_of_certain_category(cat_id, tag=''): ''' Get the count of certain category. ''' if cat_id.endswith('00'): # The first level category, using the code bellow. cat_con = TabPost2Tag.par_id == cat_id else: cat_con = TabPost2Tag.tag_id ==...
python
def count_of_certain_category(cat_id, tag=''): ''' Get the count of certain category. ''' if cat_id.endswith('00'): # The first level category, using the code bellow. cat_con = TabPost2Tag.par_id == cat_id else: cat_con = TabPost2Tag.tag_id ==...
[ "def", "count_of_certain_category", "(", "cat_id", ",", "tag", "=", "''", ")", ":", "if", "cat_id", ".", "endswith", "(", "'00'", ")", ":", "# The first level category, using the code bellow.", "cat_con", "=", "TabPost2Tag", ".", "par_id", "==", "cat_id", "else", ...
Get the count of certain category.
[ "Get", "the", "count", "of", "certain", "category", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L174-L200
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.query_pager_by_slug
def query_pager_by_slug(slug, current_page_num=1, tag='', order=False): ''' Query pager via category slug. ''' cat_rec = MCategory.get_by_slug(slug) if cat_rec: cat_id = cat_rec.uid else: return None # The flowing code is valid. if...
python
def query_pager_by_slug(slug, current_page_num=1, tag='', order=False): ''' Query pager via category slug. ''' cat_rec = MCategory.get_by_slug(slug) if cat_rec: cat_id = cat_rec.uid else: return None # The flowing code is valid. if...
[ "def", "query_pager_by_slug", "(", "slug", ",", "current_page_num", "=", "1", ",", "tag", "=", "''", ",", "order", "=", "False", ")", ":", "cat_rec", "=", "MCategory", ".", "get_by_slug", "(", "slug", ")", "if", "cat_rec", ":", "cat_id", "=", "cat_rec", ...
Query pager via category slug.
[ "Query", "pager", "via", "category", "slug", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L203-L251
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.query_by_entity_uid
def query_by_entity_uid(idd, kind=''): ''' Query post2tag by certain post. ''' if kind == '': return TabPost2Tag.select( TabPost2Tag, TabTag.slug.alias('tag_slug'), TabTag.name.alias('tag_name') ).join( ...
python
def query_by_entity_uid(idd, kind=''): ''' Query post2tag by certain post. ''' if kind == '': return TabPost2Tag.select( TabPost2Tag, TabTag.slug.alias('tag_slug'), TabTag.name.alias('tag_name') ).join( ...
[ "def", "query_by_entity_uid", "(", "idd", ",", "kind", "=", "''", ")", ":", "if", "kind", "==", "''", ":", "return", "TabPost2Tag", ".", "select", "(", "TabPost2Tag", ",", "TabTag", ".", "slug", ".", "alias", "(", "'tag_slug'", ")", ",", "TabTag", ".",...
Query post2tag by certain post.
[ "Query", "post2tag", "by", "certain", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L254-L281
bukun/TorCMS
torcms/model/post2catalog_model.py
MPost2Catalog.get_first_category
def get_first_category(app_uid): ''' Get the first, as the uniqe category of post. ''' recs = MPost2Catalog.query_by_entity_uid(app_uid).objects() if recs.count() > 0: return recs.get() return None
python
def get_first_category(app_uid): ''' Get the first, as the uniqe category of post. ''' recs = MPost2Catalog.query_by_entity_uid(app_uid).objects() if recs.count() > 0: return recs.get() return None
[ "def", "get_first_category", "(", "app_uid", ")", ":", "recs", "=", "MPost2Catalog", ".", "query_by_entity_uid", "(", "app_uid", ")", ".", "objects", "(", ")", "if", "recs", ".", "count", "(", ")", ">", "0", ":", "return", "recs", ".", "get", "(", ")",...
Get the first, as the uniqe category of post.
[ "Get", "the", "first", "as", "the", "uniqe", "category", "of", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post2catalog_model.py#L291-L299
bukun/TorCMS
torcms/modules/info_modules.py
InfoCategory.render
def render(self, *args, **kwargs): ''' fun(uid_with_str) fun(uid_with_str, slug = val1, glyph = val2) ''' uid_with_str = args[0] slug = kwargs.get('slug', False) with_title = kwargs.get('with_title', False) glyph = kwargs.get('glyph', '') kwd ...
python
def render(self, *args, **kwargs): ''' fun(uid_with_str) fun(uid_with_str, slug = val1, glyph = val2) ''' uid_with_str = args[0] slug = kwargs.get('slug', False) with_title = kwargs.get('with_title', False) glyph = kwargs.get('glyph', '') kwd ...
[ "def", "render", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "uid_with_str", "=", "args", "[", "0", "]", "slug", "=", "kwargs", ".", "get", "(", "'slug'", ",", "False", ")", "with_title", "=", "kwargs", ".", "get", "(", "'wi...
fun(uid_with_str) fun(uid_with_str, slug = val1, glyph = val2)
[ "fun", "(", "uid_with_str", ")", "fun", "(", "uid_with_str", "slug", "=", "val1", "glyph", "=", "val2", ")" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/modules/info_modules.py#L25-L56
bukun/TorCMS
torcms/modules/info_modules.py
InforUserMost.render
def render(self, *args, **kwargs): ''' fun(user_name, kind) fun(user_name, kind, num) fun(user_name, kind, num, with_tag = val1, glyph = val2) fun(user_name = vala, kind = valb, num = valc, with_tag = val1, glyph = val2) ''' user_name = kwargs.get('user_name', arg...
python
def render(self, *args, **kwargs): ''' fun(user_name, kind) fun(user_name, kind, num) fun(user_name, kind, num, with_tag = val1, glyph = val2) fun(user_name = vala, kind = valb, num = valc, with_tag = val1, glyph = val2) ''' user_name = kwargs.get('user_name', arg...
[ "def", "render", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "user_name", "=", "kwargs", ".", "get", "(", "'user_name'", ",", "args", "[", "0", "]", ")", "kind", "=", "kwargs", ".", "get", "(", "'kind'", ",", "args", "[", ...
fun(user_name, kind) fun(user_name, kind, num) fun(user_name, kind, num, with_tag = val1, glyph = val2) fun(user_name = vala, kind = valb, num = valc, with_tag = val1, glyph = val2)
[ "fun", "(", "user_name", "kind", ")", "fun", "(", "user_name", "kind", "num", ")", "fun", "(", "user_name", "kind", "num", "with_tag", "=", "val1", "glyph", "=", "val2", ")", "fun", "(", "user_name", "=", "vala", "kind", "=", "valb", "num", "=", "val...
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/modules/info_modules.py#L64-L85
bukun/TorCMS
torcms/modules/info_modules.py
InfoMostUsed.render_it
def render_it(self, *args, **kwargs): ''' Render without userinfo. fun(kind, num) fun(kind, num, with_tag = val1) fun(kind, num, with_tag = val1, glyph = val2) ''' kind = kwargs.get('kind', args[0]) num = kwargs.get('num', args[1] if len(args) > 1 else 6) ...
python
def render_it(self, *args, **kwargs): ''' Render without userinfo. fun(kind, num) fun(kind, num, with_tag = val1) fun(kind, num, with_tag = val1, glyph = val2) ''' kind = kwargs.get('kind', args[0]) num = kwargs.get('num', args[1] if len(args) > 1 else 6) ...
[ "def", "render_it", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kind", "=", "kwargs", ".", "get", "(", "'kind'", ",", "args", "[", "0", "]", ")", "num", "=", "kwargs", ".", "get", "(", "'num'", ",", "args", "[", "1", "]...
Render without userinfo. fun(kind, num) fun(kind, num, with_tag = val1) fun(kind, num, with_tag = val1, glyph = val2)
[ "Render", "without", "userinfo", ".", "fun", "(", "kind", "num", ")", "fun", "(", "kind", "num", "with_tag", "=", "val1", ")", "fun", "(", "kind", "num", "with_tag", "=", "val1", "glyph", "=", "val2", ")" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/modules/info_modules.py#L112-L132
bukun/TorCMS
torcms/modules/info_modules.py
InfoRecentUsed.render_it
def render_it(self, kind, num, with_tag=False, glyph=''): ''' render, no user logged in ''' all_cats = MPost.query_recent(num, kind=kind) kwd = { 'with_tag': with_tag, 'router': router_post[kind], 'glyph': glyph } return self.re...
python
def render_it(self, kind, num, with_tag=False, glyph=''): ''' render, no user logged in ''' all_cats = MPost.query_recent(num, kind=kind) kwd = { 'with_tag': with_tag, 'router': router_post[kind], 'glyph': glyph } return self.re...
[ "def", "render_it", "(", "self", ",", "kind", ",", "num", ",", "with_tag", "=", "False", ",", "glyph", "=", "''", ")", ":", "all_cats", "=", "MPost", ".", "query_recent", "(", "num", ",", "kind", "=", "kind", ")", "kwd", "=", "{", "'with_tag'", ":"...
render, no user logged in
[ "render", "no", "user", "logged", "in" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/modules/info_modules.py#L185-L197
bukun/TorCMS
torcms/modules/info_modules.py
InfoRecentUsed.render_user
def render_user(self, *args, **kwargs): ''' render, with userinfo fun(kind, num) fun(kind, num, with_tag = val1) fun(kind, num, with_tag = val1, user_id = val2) fun(kind, num, with_tag = val1, user_id = val2, glyph = val3) ''' kind = kwargs.get('kind', ar...
python
def render_user(self, *args, **kwargs): ''' render, with userinfo fun(kind, num) fun(kind, num, with_tag = val1) fun(kind, num, with_tag = val1, user_id = val2) fun(kind, num, with_tag = val1, user_id = val2, glyph = val3) ''' kind = kwargs.get('kind', ar...
[ "def", "render_user", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kind", "=", "kwargs", ".", "get", "(", "'kind'", ",", "args", "[", "0", "]", ")", "num", "=", "kwargs", ".", "get", "(", "'num'", ",", "args", "[", "1", ...
render, with userinfo fun(kind, num) fun(kind, num, with_tag = val1) fun(kind, num, with_tag = val1, user_id = val2) fun(kind, num, with_tag = val1, user_id = val2, glyph = val3)
[ "render", "with", "userinfo", "fun", "(", "kind", "num", ")", "fun", "(", "kind", "num", "with_tag", "=", "val1", ")", "fun", "(", "kind", "num", "with_tag", "=", "val1", "user_id", "=", "val2", ")", "fun", "(", "kind", "num", "with_tag", "=", "val1"...
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/modules/info_modules.py#L199-L228
bukun/TorCMS
torcms/handlers/link_handler.py
LinkHandler.recent
def recent(self): ''' Recent links. ''' kwd = { 'pager': '', 'title': '最近文档', } if self.is_p: self.render('admin/link_ajax/link_list.html', kwd=kwd, view=MLink.query_link(20), ...
python
def recent(self): ''' Recent links. ''' kwd = { 'pager': '', 'title': '最近文档', } if self.is_p: self.render('admin/link_ajax/link_list.html', kwd=kwd, view=MLink.query_link(20), ...
[ "def", "recent", "(", "self", ")", ":", "kwd", "=", "{", "'pager'", ":", "''", ",", "'title'", ":", "'最近文档',", "", "}", "if", "self", ".", "is_p", ":", "self", ".", "render", "(", "'admin/link_ajax/link_list.html'", ",", "kwd", "=", "kwd", ",", "view...
Recent links.
[ "Recent", "links", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/link_handler.py#L58-L78
bukun/TorCMS
torcms/handlers/link_handler.py
LinkHandler.to_add_link
def to_add_link(self, ): ''' To add link ''' if self.check_post_role()['ADD']: pass else: return False kwd = { 'pager': '', 'uid': '', } self.render('misc/link/link_add.html', topmenu='', ...
python
def to_add_link(self, ): ''' To add link ''' if self.check_post_role()['ADD']: pass else: return False kwd = { 'pager': '', 'uid': '', } self.render('misc/link/link_add.html', topmenu='', ...
[ "def", "to_add_link", "(", "self", ",", ")", ":", "if", "self", ".", "check_post_role", "(", ")", "[", "'ADD'", "]", ":", "pass", "else", ":", "return", "False", "kwd", "=", "{", "'pager'", ":", "''", ",", "'uid'", ":", "''", ",", "}", "self", "....
To add link
[ "To", "add", "link" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/link_handler.py#L80-L95
bukun/TorCMS
torcms/handlers/link_handler.py
LinkHandler.update
def update(self, uid): ''' Update the link. ''' if self.userinfo.role[1] >= '3': pass else: return False post_data = self.get_post_data() post_data['user_name'] = self.get_current_user() if self.is_p: if MLink.update(u...
python
def update(self, uid): ''' Update the link. ''' if self.userinfo.role[1] >= '3': pass else: return False post_data = self.get_post_data() post_data['user_name'] = self.get_current_user() if self.is_p: if MLink.update(u...
[ "def", "update", "(", "self", ",", "uid", ")", ":", "if", "self", ".", "userinfo", ".", "role", "[", "1", "]", ">=", "'3'", ":", "pass", "else", ":", "return", "False", "post_data", "=", "self", ".", "get_post_data", "(", ")", "post_data", "[", "'u...
Update the link.
[ "Update", "the", "link", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/link_handler.py#L98-L122
bukun/TorCMS
torcms/handlers/link_handler.py
LinkHandler.to_modify
def to_modify(self, uid): ''' Try to edit the link. ''' if self.userinfo.role[1] >= '3': pass else: return False self.render('misc/link/link_edit.html', kwd={}, postinfo=MLink.get_by_uid(uid), ...
python
def to_modify(self, uid): ''' Try to edit the link. ''' if self.userinfo.role[1] >= '3': pass else: return False self.render('misc/link/link_edit.html', kwd={}, postinfo=MLink.get_by_uid(uid), ...
[ "def", "to_modify", "(", "self", ",", "uid", ")", ":", "if", "self", ".", "userinfo", ".", "role", "[", "1", "]", ">=", "'3'", ":", "pass", "else", ":", "return", "False", "self", ".", "render", "(", "'misc/link/link_edit.html'", ",", "kwd", "=", "{"...
Try to edit the link.
[ "Try", "to", "edit", "the", "link", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/link_handler.py#L125-L137
bukun/TorCMS
torcms/handlers/link_handler.py
LinkHandler.viewit
def viewit(self, post_id): ''' View the link. ''' rec = MLink.get_by_uid(post_id) if not rec: kwd = {'info': '您要找的分类不存在。'} self.render('misc/html/404.html', kwd=kwd) return False kwd = { 'pager': '', 'editable...
python
def viewit(self, post_id): ''' View the link. ''' rec = MLink.get_by_uid(post_id) if not rec: kwd = {'info': '您要找的分类不存在。'} self.render('misc/html/404.html', kwd=kwd) return False kwd = { 'pager': '', 'editable...
[ "def", "viewit", "(", "self", ",", "post_id", ")", ":", "rec", "=", "MLink", ".", "get_by_uid", "(", "post_id", ")", "if", "not", "rec", ":", "kwd", "=", "{", "'info'", ":", "'您要找的分类不存在。'}", "", "self", ".", "render", "(", "'misc/html/404.html'", ",", ...
View the link.
[ "View", "the", "link", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/link_handler.py#L140-L161
bukun/TorCMS
torcms/handlers/link_handler.py
LinkHandler.p_user_add_link
def p_user_add_link(self): ''' user add link. ''' if self.check_post_role()['ADD']: pass else: return False post_data = self.get_post_data() post_data['user_name'] = self.get_current_user() cur_uid = tools.get_uudd(2) whil...
python
def p_user_add_link(self): ''' user add link. ''' if self.check_post_role()['ADD']: pass else: return False post_data = self.get_post_data() post_data['user_name'] = self.get_current_user() cur_uid = tools.get_uudd(2) whil...
[ "def", "p_user_add_link", "(", "self", ")", ":", "if", "self", ".", "check_post_role", "(", ")", "[", "'ADD'", "]", ":", "pass", "else", ":", "return", "False", "post_data", "=", "self", ".", "get_post_data", "(", ")", "post_data", "[", "'user_name'", "]...
user add link.
[ "user", "add", "link", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/link_handler.py#L164-L188
bukun/TorCMS
torcms/handlers/link_handler.py
LinkHandler.user_add_link
def user_add_link(self): ''' Create link by user. ''' if self.check_post_role()['ADD']: pass else: return False post_data = self.get_post_data() post_data['user_name'] = self.get_current_user() cur_uid = tools.get_uudd(2) ...
python
def user_add_link(self): ''' Create link by user. ''' if self.check_post_role()['ADD']: pass else: return False post_data = self.get_post_data() post_data['user_name'] = self.get_current_user() cur_uid = tools.get_uudd(2) ...
[ "def", "user_add_link", "(", "self", ")", ":", "if", "self", ".", "check_post_role", "(", ")", "[", "'ADD'", "]", ":", "pass", "else", ":", "return", "False", "post_data", "=", "self", ".", "get_post_data", "(", ")", "post_data", "[", "'user_name'", "]",...
Create link by user.
[ "Create", "link", "by", "user", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/link_handler.py#L191-L209
bukun/TorCMS
torcms/handlers/link_handler.py
LinkHandler.delete_by_id
def delete_by_id(self, del_id): ''' Delete a link by id. ''' if self.check_post_role()['DELETE']: pass else: return False if self.is_p: if MLink.delete(del_id): output = {'del_link': 1} else: ...
python
def delete_by_id(self, del_id): ''' Delete a link by id. ''' if self.check_post_role()['DELETE']: pass else: return False if self.is_p: if MLink.delete(del_id): output = {'del_link': 1} else: ...
[ "def", "delete_by_id", "(", "self", ",", "del_id", ")", ":", "if", "self", ".", "check_post_role", "(", ")", "[", "'DELETE'", "]", ":", "pass", "else", ":", "return", "False", "if", "self", ".", "is_p", ":", "if", "MLink", ".", "delete", "(", "del_id...
Delete a link by id.
[ "Delete", "a", "link", "by", "id", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/link_handler.py#L212-L229
bukun/TorCMS
torcms/model/rating_model.py
MRating.get_rating
def get_rating(postid, userid): ''' Get the rating of certain post and user. ''' try: recs = TabRating.select().where( (TabRating.post_id == postid) & (TabRating.user_id == userid) ) except: return False if recs.count() ...
python
def get_rating(postid, userid): ''' Get the rating of certain post and user. ''' try: recs = TabRating.select().where( (TabRating.post_id == postid) & (TabRating.user_id == userid) ) except: return False if recs.count() ...
[ "def", "get_rating", "(", "postid", ",", "userid", ")", ":", "try", ":", "recs", "=", "TabRating", ".", "select", "(", ")", ".", "where", "(", "(", "TabRating", ".", "post_id", "==", "postid", ")", "&", "(", "TabRating", ".", "user_id", "==", "userid...
Get the rating of certain post and user.
[ "Get", "the", "rating", "of", "certain", "post", "and", "user", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/rating_model.py#L31-L44
bukun/TorCMS
torcms/model/rating_model.py
MRating.update
def update(postid, userid, rating): ''' Update the rating of certain post and user. The record will be created if no record exists. ''' rating_recs = TabRating.select().where( (TabRating.post_id == postid) & (TabRating.user_id == userid) ) if rating_re...
python
def update(postid, userid, rating): ''' Update the rating of certain post and user. The record will be created if no record exists. ''' rating_recs = TabRating.select().where( (TabRating.post_id == postid) & (TabRating.user_id == userid) ) if rating_re...
[ "def", "update", "(", "postid", ",", "userid", ",", "rating", ")", ":", "rating_recs", "=", "TabRating", ".", "select", "(", ")", ".", "where", "(", "(", "TabRating", ".", "post_id", "==", "postid", ")", "&", "(", "TabRating", ".", "user_id", "==", "...
Update the rating of certain post and user. The record will be created if no record exists.
[ "Update", "the", "rating", "of", "certain", "post", "and", "user", ".", "The", "record", "will", "be", "created", "if", "no", "record", "exists", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/rating_model.py#L47-L58
bukun/TorCMS
torcms/model/rating_model.py
MRating.__update_rating
def __update_rating(uid, rating): ''' Update rating. ''' entry = TabRating.update( rating=rating ).where(TabRating.uid == uid) entry.execute()
python
def __update_rating(uid, rating): ''' Update rating. ''' entry = TabRating.update( rating=rating ).where(TabRating.uid == uid) entry.execute()
[ "def", "__update_rating", "(", "uid", ",", "rating", ")", ":", "entry", "=", "TabRating", ".", "update", "(", "rating", "=", "rating", ")", ".", "where", "(", "TabRating", ".", "uid", "==", "uid", ")", "entry", ".", "execute", "(", ")" ]
Update rating.
[ "Update", "rating", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/rating_model.py#L61-L68
bukun/TorCMS
torcms/model/rating_model.py
MRating.__insert_data
def __insert_data(postid, userid, rating): ''' Inert new record. ''' uid = tools.get_uuid() TabRating.create( uid=uid, post_id=postid, user_id=userid, rating=rating, timestamp=tools.timestamp(), ) return ...
python
def __insert_data(postid, userid, rating): ''' Inert new record. ''' uid = tools.get_uuid() TabRating.create( uid=uid, post_id=postid, user_id=userid, rating=rating, timestamp=tools.timestamp(), ) return ...
[ "def", "__insert_data", "(", "postid", ",", "userid", ",", "rating", ")", ":", "uid", "=", "tools", ".", "get_uuid", "(", ")", "TabRating", ".", "create", "(", "uid", "=", "uid", ",", "post_id", "=", "postid", ",", "user_id", "=", "userid", ",", "rat...
Inert new record.
[ "Inert", "new", "record", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/rating_model.py#L71-L83
bukun/TorCMS
helper_scripts/script_meta_xlsx_import.py
update_category
def update_category(uid, postdata, kwargs): ''' Update the category of the post. ''' catid = kwargs['catid'] if ('catid' in kwargs and MCategory.get_by_uid(kwargs['catid'])) else None post_data = postdata current_infos = MPost2Catalog.query_by_entity_uid(uid, kind='').objects() new_catego...
python
def update_category(uid, postdata, kwargs): ''' Update the category of the post. ''' catid = kwargs['catid'] if ('catid' in kwargs and MCategory.get_by_uid(kwargs['catid'])) else None post_data = postdata current_infos = MPost2Catalog.query_by_entity_uid(uid, kind='').objects() new_catego...
[ "def", "update_category", "(", "uid", ",", "postdata", ",", "kwargs", ")", ":", "catid", "=", "kwargs", "[", "'catid'", "]", "if", "(", "'catid'", "in", "kwargs", "and", "MCategory", ".", "get_by_uid", "(", "kwargs", "[", "'catid'", "]", ")", ")", "els...
Update the category of the post.
[ "Update", "the", "category", "of", "the", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/helper_scripts/script_meta_xlsx_import.py#L19-L72
bukun/TorCMS
ext_script/command.py
entry
def entry(argv): ''' Command entry ''' command_dic = { 'init': run_init, } try: # 这里的 h 就表示该选项无参数,i:表示 i 选项后需要有参数 opts, args = getopt.getopt(argv, "hi:") except getopt.GetoptError: print('Error: helper.py -i cmd') sys.exit(2) for opt, arg in opt...
python
def entry(argv): ''' Command entry ''' command_dic = { 'init': run_init, } try: # 这里的 h 就表示该选项无参数,i:表示 i 选项后需要有参数 opts, args = getopt.getopt(argv, "hi:") except getopt.GetoptError: print('Error: helper.py -i cmd') sys.exit(2) for opt, arg in opt...
[ "def", "entry", "(", "argv", ")", ":", "command_dic", "=", "{", "'init'", ":", "run_init", ",", "}", "try", ":", "# 这里的 h 就表示该选项无参数,i:表示 i 选项后需要有参数", "opts", ",", "args", "=", "getopt", ".", "getopt", "(", "argv", ",", "\"hi:\"", ")", "except", "getopt", ...
Command entry
[ "Command", "entry" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext_script/command.py#L16-L47
bukun/TorCMS
torcms/model/relation_model.py
MRelation.add_relation
def add_relation(app_f, app_t, weight=1): ''' Adding relation between two posts. ''' recs = TabRel.select().where( (TabRel.post_f_id == app_f) & (TabRel.post_t_id == app_t) ) if recs.count() > 1: for record in recs: MRelation.delete...
python
def add_relation(app_f, app_t, weight=1): ''' Adding relation between two posts. ''' recs = TabRel.select().where( (TabRel.post_f_id == app_f) & (TabRel.post_t_id == app_t) ) if recs.count() > 1: for record in recs: MRelation.delete...
[ "def", "add_relation", "(", "app_f", ",", "app_t", ",", "weight", "=", "1", ")", ":", "recs", "=", "TabRel", ".", "select", "(", ")", ".", "where", "(", "(", "TabRel", ".", "post_f_id", "==", "app_f", ")", "&", "(", "TabRel", ".", "post_t_id", "=="...
Adding relation between two posts.
[ "Adding", "relation", "between", "two", "posts", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/relation_model.py#L15-L38
bukun/TorCMS
torcms/model/relation_model.py
MRelation.get_app_relations
def get_app_relations(app_id, num=20, kind='1'): ''' The the related infors. ''' info_tag = MInfor2Catalog.get_first_category(app_id) if info_tag: return TabPost2Tag.select( TabPost2Tag, TabPost.title.alias('post_title'), ...
python
def get_app_relations(app_id, num=20, kind='1'): ''' The the related infors. ''' info_tag = MInfor2Catalog.get_first_category(app_id) if info_tag: return TabPost2Tag.select( TabPost2Tag, TabPost.title.alias('post_title'), ...
[ "def", "get_app_relations", "(", "app_id", ",", "num", "=", "20", ",", "kind", "=", "'1'", ")", ":", "info_tag", "=", "MInfor2Catalog", ".", "get_first_category", "(", "app_id", ")", "if", "info_tag", ":", "return", "TabPost2Tag", ".", "select", "(", "TabP...
The the related infors.
[ "The", "the", "related", "infors", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/relation_model.py#L63-L89
bukun/TorCMS
torcms/handlers/label_handler.py
LabelHandler.get
def get(self, *args, **kwargs): ''' /label/s/view ''' url_arr = self.parse_url(args[0]) if len(url_arr) == 2: if url_arr[0] == 'remove': self.remove_redis_keyword(url_arr[1]) else: self.list(url_arr[0], url_arr[1]) ...
python
def get(self, *args, **kwargs): ''' /label/s/view ''' url_arr = self.parse_url(args[0]) if len(url_arr) == 2: if url_arr[0] == 'remove': self.remove_redis_keyword(url_arr[1]) else: self.list(url_arr[0], url_arr[1]) ...
[ "def", "get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "url_arr", "=", "self", ".", "parse_url", "(", "args", "[", "0", "]", ")", "if", "len", "(", "url_arr", ")", "==", "2", ":", "if", "url_arr", "[", "0", "]", "==",...
/label/s/view
[ "/", "label", "/", "s", "/", "view" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/label_handler.py#L27-L41
bukun/TorCMS
torcms/handlers/label_handler.py
LabelHandler.remove_redis_keyword
def remove_redis_keyword(self, keyword): ''' Remove the keyword for redis. ''' redisvr.srem(CMS_CFG['redis_kw'] + self.userinfo.user_name, keyword) return json.dump({}, self)
python
def remove_redis_keyword(self, keyword): ''' Remove the keyword for redis. ''' redisvr.srem(CMS_CFG['redis_kw'] + self.userinfo.user_name, keyword) return json.dump({}, self)
[ "def", "remove_redis_keyword", "(", "self", ",", "keyword", ")", ":", "redisvr", ".", "srem", "(", "CMS_CFG", "[", "'redis_kw'", "]", "+", "self", ".", "userinfo", ".", "user_name", ",", "keyword", ")", "return", "json", ".", "dump", "(", "{", "}", ","...
Remove the keyword for redis.
[ "Remove", "the", "keyword", "for", "redis", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/label_handler.py#L44-L49
bukun/TorCMS
torcms/handlers/label_handler.py
LabelHandler.list
def list(self, kind, tag_slug, cur_p=''): ''' 根据 cat_handler.py 中的 def view_cat_new(self, cat_slug, cur_p = '') ''' # 下面用来使用关键字过滤信息,如果网站信息量不是很大不要开启 # Todo: # if self.get_current_user(): # redisvr.sadd(config.redis_kw + self.userinfo.user_name, tag_slug) ...
python
def list(self, kind, tag_slug, cur_p=''): ''' 根据 cat_handler.py 中的 def view_cat_new(self, cat_slug, cur_p = '') ''' # 下面用来使用关键字过滤信息,如果网站信息量不是很大不要开启 # Todo: # if self.get_current_user(): # redisvr.sadd(config.redis_kw + self.userinfo.user_name, tag_slug) ...
[ "def", "list", "(", "self", ",", "kind", ",", "tag_slug", ",", "cur_p", "=", "''", ")", ":", "# 下面用来使用关键字过滤信息,如果网站信息量不是很大不要开启", "# Todo:", "# if self.get_current_user():", "# redisvr.sadd(config.redis_kw + self.userinfo.user_name, tag_slug)", "if", "cur_p", "==", "''", ...
根据 cat_handler.py 中的 def view_cat_new(self, cat_slug, cur_p = '')
[ "根据", "cat_handler", ".", "py", "中的", "def", "view_cat_new", "(", "self", "cat_slug", "cur_p", "=", ")" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/label_handler.py#L51-L98
bukun/TorCMS
torcms/handlers/label_handler.py
LabelHandler.gen_pager
def gen_pager(self, kind, cat_slug, page_num, current): ''' cat_slug 分类 page_num 页面总数 current 当前页面 ''' if page_num == 1: return '' pager_shouye = '''<li class="{0}"> <a href="/label/{1}/{2}">&lt;&lt; 首页</a> </li>'''.format( 'hidd...
python
def gen_pager(self, kind, cat_slug, page_num, current): ''' cat_slug 分类 page_num 页面总数 current 当前页面 ''' if page_num == 1: return '' pager_shouye = '''<li class="{0}"> <a href="/label/{1}/{2}">&lt;&lt; 首页</a> </li>'''.format( 'hidd...
[ "def", "gen_pager", "(", "self", ",", "kind", ",", "cat_slug", ",", "page_num", ",", "current", ")", ":", "if", "page_num", "==", "1", ":", "return", "''", "pager_shouye", "=", "'''<li class=\"{0}\"> <a href=\"/label/{1}/{2}\">&lt;&lt; 首页</a>\n </li>'''", "."...
cat_slug 分类 page_num 页面总数 current 当前页面
[ "cat_slug", "分类", "page_num", "页面总数", "current", "当前页面" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/label_handler.py#L100-L134
bukun/TorCMS
torcms/script/script_funcs.py
build_directory
def build_directory(): ''' Build the directory for Whoosh database, and locale. ''' if os.path.exists('locale'): pass else: os.mkdir('locale') if os.path.exists(WHOOSH_DB_DIR): pass else: os.makedirs(WHOOSH_DB_DIR)
python
def build_directory(): ''' Build the directory for Whoosh database, and locale. ''' if os.path.exists('locale'): pass else: os.mkdir('locale') if os.path.exists(WHOOSH_DB_DIR): pass else: os.makedirs(WHOOSH_DB_DIR)
[ "def", "build_directory", "(", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "'locale'", ")", ":", "pass", "else", ":", "os", ".", "mkdir", "(", "'locale'", ")", "if", "os", ".", "path", ".", "exists", "(", "WHOOSH_DB_DIR", ")", ":", "pass...
Build the directory for Whoosh database, and locale.
[ "Build", "the", "directory", "for", "Whoosh", "database", "and", "locale", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_funcs.py#L22-L33
bukun/TorCMS
torcms/script/script_funcs.py
run_check_kind
def run_check_kind(_): ''' Running the script. ''' for kindv in router_post: for rec_cat in MCategory.query_all(kind=kindv): catid = rec_cat.uid catinfo = MCategory.get_by_uid(catid) for rec_post2tag in MPost2Catalog.query_by_catid(catid): post...
python
def run_check_kind(_): ''' Running the script. ''' for kindv in router_post: for rec_cat in MCategory.query_all(kind=kindv): catid = rec_cat.uid catinfo = MCategory.get_by_uid(catid) for rec_post2tag in MPost2Catalog.query_by_catid(catid): post...
[ "def", "run_check_kind", "(", "_", ")", ":", "for", "kindv", "in", "router_post", ":", "for", "rec_cat", "in", "MCategory", ".", "query_all", "(", "kind", "=", "kindv", ")", ":", "catid", "=", "rec_cat", ".", "uid", "catinfo", "=", "MCategory", ".", "g...
Running the script.
[ "Running", "the", "script", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_funcs.py#L36-L49
bukun/TorCMS
torcms/script/script_funcs.py
run_create_admin
def run_create_admin(*args): ''' creating the default administrator. ''' post_data = { 'user_name': 'giser', 'user_email': 'giser@osgeo.cn', 'user_pass': '131322', 'role': '3300', } if MUser.get_by_name(post_data['user_name']): print('User {user_name} alre...
python
def run_create_admin(*args): ''' creating the default administrator. ''' post_data = { 'user_name': 'giser', 'user_email': 'giser@osgeo.cn', 'user_pass': '131322', 'role': '3300', } if MUser.get_by_name(post_data['user_name']): print('User {user_name} alre...
[ "def", "run_create_admin", "(", "*", "args", ")", ":", "post_data", "=", "{", "'user_name'", ":", "'giser'", ",", "'user_email'", ":", "'giser@osgeo.cn'", ",", "'user_pass'", ":", "'131322'", ",", "'role'", ":", "'3300'", ",", "}", "if", "MUser", ".", "get...
creating the default administrator.
[ "creating", "the", "default", "administrator", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_funcs.py#L52-L65
bukun/TorCMS
torcms/script/script_funcs.py
run_update_cat
def run_update_cat(_): ''' Update the catagery. ''' recs = MPost2Catalog.query_all().objects() for rec in recs: if rec.tag_kind != 'z': print('-' * 40) print(rec.uid) print(rec.tag_id) print(rec.par_id) MPost2Catalog.update_field(r...
python
def run_update_cat(_): ''' Update the catagery. ''' recs = MPost2Catalog.query_all().objects() for rec in recs: if rec.tag_kind != 'z': print('-' * 40) print(rec.uid) print(rec.tag_id) print(rec.par_id) MPost2Catalog.update_field(r...
[ "def", "run_update_cat", "(", "_", ")", ":", "recs", "=", "MPost2Catalog", ".", "query_all", "(", ")", ".", "objects", "(", ")", "for", "rec", "in", "recs", ":", "if", "rec", ".", "tag_kind", "!=", "'z'", ":", "print", "(", "'-'", "*", "40", ")", ...
Update the catagery.
[ "Update", "the", "catagery", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_funcs.py#L75-L87
bukun/TorCMS
torcms/handlers/rating_handler.py
RatingHandler.update_post
def update_post(self, postid): ''' The rating of Post should be updaed if the count is greater than 10 ''' voted_recs = MRating.query_by_post(postid) if voted_recs.count() > 10: rating = MRating.query_average_rating(postid) else: rating = 5 ...
python
def update_post(self, postid): ''' The rating of Post should be updaed if the count is greater than 10 ''' voted_recs = MRating.query_by_post(postid) if voted_recs.count() > 10: rating = MRating.query_average_rating(postid) else: rating = 5 ...
[ "def", "update_post", "(", "self", ",", "postid", ")", ":", "voted_recs", "=", "MRating", ".", "query_by_post", "(", "postid", ")", "if", "voted_recs", ".", "count", "(", ")", ">", "10", ":", "rating", "=", "MRating", ".", "query_average_rating", "(", "p...
The rating of Post should be updaed if the count is greater than 10
[ "The", "rating", "of", "Post", "should", "be", "updaed", "if", "the", "count", "is", "greater", "than", "10" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/rating_handler.py#L35-L49
bukun/TorCMS
torcms/handlers/rating_handler.py
RatingHandler.update_rating
def update_rating(self, postid): ''' only the used who logged in would voting. ''' post_data = self.get_post_data() rating = float(post_data['rating']) postinfo = MPost.get_by_uid(postid) if postinfo and self.userinfo: MRating.update(postinfo.uid, self...
python
def update_rating(self, postid): ''' only the used who logged in would voting. ''' post_data = self.get_post_data() rating = float(post_data['rating']) postinfo = MPost.get_by_uid(postid) if postinfo and self.userinfo: MRating.update(postinfo.uid, self...
[ "def", "update_rating", "(", "self", ",", "postid", ")", ":", "post_data", "=", "self", ".", "get_post_data", "(", ")", "rating", "=", "float", "(", "post_data", "[", "'rating'", "]", ")", "postinfo", "=", "MPost", ".", "get_by_uid", "(", "postid", ")", ...
only the used who logged in would voting.
[ "only", "the", "used", "who", "logged", "in", "would", "voting", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/rating_handler.py#L52-L63
bukun/TorCMS
torcms/script/script_review.py
__get_diff_recent
def __get_diff_recent(): ''' Generate the difference of posts. recently. ''' diff_str = '' for key in router_post: recent_posts = MPost.query_recent_edited(tools.timestamp() - TIME_LIMIT, kind=key) for recent_post in recent_posts: hist_rec = MPostHist.get_last(recent_pos...
python
def __get_diff_recent(): ''' Generate the difference of posts. recently. ''' diff_str = '' for key in router_post: recent_posts = MPost.query_recent_edited(tools.timestamp() - TIME_LIMIT, kind=key) for recent_post in recent_posts: hist_rec = MPostHist.get_last(recent_pos...
[ "def", "__get_diff_recent", "(", ")", ":", "diff_str", "=", "''", "for", "key", "in", "router_post", ":", "recent_posts", "=", "MPost", ".", "query_recent_edited", "(", "tools", ".", "timestamp", "(", ")", "-", "TIME_LIMIT", ",", "kind", "=", "key", ")", ...
Generate the difference of posts. recently.
[ "Generate", "the", "difference", "of", "posts", ".", "recently", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_review.py#L23-L50
bukun/TorCMS
torcms/script/script_review.py
__get_wiki_review
def __get_wiki_review(email_cnt, idx): ''' Review for wikis. ''' recent_posts = MWiki.query_recent_edited(tools.timestamp() - TIME_LIMIT, kind='2') for recent_post in recent_posts: hist_rec = MWikiHist.get_last(recent_post.uid) if hist_rec: foo_str = ''' ...
python
def __get_wiki_review(email_cnt, idx): ''' Review for wikis. ''' recent_posts = MWiki.query_recent_edited(tools.timestamp() - TIME_LIMIT, kind='2') for recent_post in recent_posts: hist_rec = MWikiHist.get_last(recent_post.uid) if hist_rec: foo_str = ''' ...
[ "def", "__get_wiki_review", "(", "email_cnt", ",", "idx", ")", ":", "recent_posts", "=", "MWiki", ".", "query_recent_edited", "(", "tools", ".", "timestamp", "(", ")", "-", "TIME_LIMIT", ",", "kind", "=", "'2'", ")", "for", "recent_post", "in", "recent_posts...
Review for wikis.
[ "Review", "for", "wikis", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_review.py#L53-L76
bukun/TorCMS
torcms/script/script_review.py
__get_post_review
def __get_post_review(email_cnt, idx): ''' Review for posts. ''' for key in router_post: recent_posts = MPost.query_recent_edited(tools.timestamp() - TIME_LIMIT, kind=key) for recent_post in recent_posts: hist_rec = MPostHist.get_last(recent_post.uid) if hist_rec:...
python
def __get_post_review(email_cnt, idx): ''' Review for posts. ''' for key in router_post: recent_posts = MPost.query_recent_edited(tools.timestamp() - TIME_LIMIT, kind=key) for recent_post in recent_posts: hist_rec = MPostHist.get_last(recent_post.uid) if hist_rec:...
[ "def", "__get_post_review", "(", "email_cnt", ",", "idx", ")", ":", "for", "key", "in", "router_post", ":", "recent_posts", "=", "MPost", ".", "query_recent_edited", "(", "tools", ".", "timestamp", "(", ")", "-", "TIME_LIMIT", ",", "kind", "=", "key", ")",...
Review for posts.
[ "Review", "for", "posts", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_review.py#L105-L131
bukun/TorCMS
torcms/script/script_review.py
run_review
def run_review(*args): ''' Get the difference of recents modification, and send the Email. For: wiki, page, and post. ''' email_cnt = '''<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> table.diff {font-family:C...
python
def run_review(*args): ''' Get the difference of recents modification, and send the Email. For: wiki, page, and post. ''' email_cnt = '''<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> table.diff {font-family:C...
[ "def", "run_review", "(", "*", "args", ")", ":", "email_cnt", "=", "'''<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <title></title>\n <style type=\"text/css\">\n table.diff {font-family:Courier; border:medium;}\n .diff_header {backgrou...
Get the difference of recents modification, and send the Email. For: wiki, page, and post.
[ "Get", "the", "difference", "of", "recents", "modification", "and", "send", "the", "Email", ".", "For", ":", "wiki", "page", "and", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_review.py#L134-L168
bukun/TorCMS
torcms/model/category_model.py
MCategory.get_qian2
def get_qian2(qian2): ''' 用于首页。根据前两位,找到所有的大类与小类。 :param qian2: 分类id的前两位 :return: 数组,包含了找到的分类 ''' return TabTag.select().where( TabTag.uid.startswith(qian2) ).order_by(TabTag.order)
python
def get_qian2(qian2): ''' 用于首页。根据前两位,找到所有的大类与小类。 :param qian2: 分类id的前两位 :return: 数组,包含了找到的分类 ''' return TabTag.select().where( TabTag.uid.startswith(qian2) ).order_by(TabTag.order)
[ "def", "get_qian2", "(", "qian2", ")", ":", "return", "TabTag", ".", "select", "(", ")", ".", "where", "(", "TabTag", ".", "uid", ".", "startswith", "(", "qian2", ")", ")", ".", "order_by", "(", "TabTag", ".", "order", ")" ]
用于首页。根据前两位,找到所有的大类与小类。 :param qian2: 分类id的前两位 :return: 数组,包含了找到的分类
[ "用于首页。根据前两位,找到所有的大类与小类。", ":", "param", "qian2", ":", "分类id的前两位", ":", "return", ":", "数组,包含了找到的分类" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/category_model.py#L31-L39
bukun/TorCMS
torcms/model/category_model.py
MCategory.query_all
def query_all(kind='1', by_count=False, by_order=True): ''' Qeury all the categories, order by count or defined order. ''' if by_count: recs = TabTag.select().where(TabTag.kind == kind).order_by(TabTag.count.desc()) elif by_order: recs = TabTag.select().wh...
python
def query_all(kind='1', by_count=False, by_order=True): ''' Qeury all the categories, order by count or defined order. ''' if by_count: recs = TabTag.select().where(TabTag.kind == kind).order_by(TabTag.count.desc()) elif by_order: recs = TabTag.select().wh...
[ "def", "query_all", "(", "kind", "=", "'1'", ",", "by_count", "=", "False", ",", "by_order", "=", "True", ")", ":", "if", "by_count", ":", "recs", "=", "TabTag", ".", "select", "(", ")", ".", "where", "(", "TabTag", ".", "kind", "==", "kind", ")", ...
Qeury all the categories, order by count or defined order.
[ "Qeury", "all", "the", "categories", "order", "by", "count", "or", "defined", "order", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/category_model.py#L69-L79
bukun/TorCMS
torcms/model/category_model.py
MCategory.query_field_count
def query_field_count(limit_num, kind='1'): ''' Query the posts count of certain category. ''' return TabTag.select().where( TabTag.kind == kind ).order_by( TabTag.count.desc() ).limit(limit_num)
python
def query_field_count(limit_num, kind='1'): ''' Query the posts count of certain category. ''' return TabTag.select().where( TabTag.kind == kind ).order_by( TabTag.count.desc() ).limit(limit_num)
[ "def", "query_field_count", "(", "limit_num", ",", "kind", "=", "'1'", ")", ":", "return", "TabTag", ".", "select", "(", ")", ".", "where", "(", "TabTag", ".", "kind", "==", "kind", ")", ".", "order_by", "(", "TabTag", ".", "count", ".", "desc", "(",...
Query the posts count of certain category.
[ "Query", "the", "posts", "count", "of", "certain", "category", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/category_model.py#L82-L90
bukun/TorCMS
torcms/model/category_model.py
MCategory.get_by_slug
def get_by_slug(slug): ''' return the category record . ''' rec = TabTag.select().where(TabTag.slug == slug) if rec.count() > 0: return rec.get() return None
python
def get_by_slug(slug): ''' return the category record . ''' rec = TabTag.select().where(TabTag.slug == slug) if rec.count() > 0: return rec.get() return None
[ "def", "get_by_slug", "(", "slug", ")", ":", "rec", "=", "TabTag", ".", "select", "(", ")", ".", "where", "(", "TabTag", ".", "slug", "==", "slug", ")", "if", "rec", ".", "count", "(", ")", ">", "0", ":", "return", "rec", ".", "get", "(", ")", ...
return the category record .
[ "return", "the", "category", "record", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/category_model.py#L93-L100
bukun/TorCMS
torcms/model/category_model.py
MCategory.update_count
def update_count(cat_id): ''' Update the count of certain category. ''' # Todo: the record not valid should not be counted. entry2 = TabTag.update( count=TabPost2Tag.select().where( TabPost2Tag.tag_id == cat_id ).count() ).where(Tab...
python
def update_count(cat_id): ''' Update the count of certain category. ''' # Todo: the record not valid should not be counted. entry2 = TabTag.update( count=TabPost2Tag.select().where( TabPost2Tag.tag_id == cat_id ).count() ).where(Tab...
[ "def", "update_count", "(", "cat_id", ")", ":", "# Todo: the record not valid should not be counted.", "entry2", "=", "TabTag", ".", "update", "(", "count", "=", "TabPost2Tag", ".", "select", "(", ")", ".", "where", "(", "TabPost2Tag", ".", "tag_id", "==", "cat_...
Update the count of certain category.
[ "Update", "the", "count", "of", "certain", "category", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/category_model.py#L103-L113
bukun/TorCMS
torcms/model/category_model.py
MCategory.update
def update(uid, post_data): ''' Update the category. ''' raw_rec = TabTag.get(TabTag.uid == uid) entry = TabTag.update( name=post_data['name'] if 'name' in post_data else raw_rec.name, slug=post_data['slug'] if 'slug' in post_data else raw_rec.slug, ...
python
def update(uid, post_data): ''' Update the category. ''' raw_rec = TabTag.get(TabTag.uid == uid) entry = TabTag.update( name=post_data['name'] if 'name' in post_data else raw_rec.name, slug=post_data['slug'] if 'slug' in post_data else raw_rec.slug, ...
[ "def", "update", "(", "uid", ",", "post_data", ")", ":", "raw_rec", "=", "TabTag", ".", "get", "(", "TabTag", ".", "uid", "==", "uid", ")", "entry", "=", "TabTag", ".", "update", "(", "name", "=", "post_data", "[", "'name'", "]", "if", "'name'", "i...
Update the category.
[ "Update", "the", "category", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/category_model.py#L116-L128
bukun/TorCMS
torcms/model/category_model.py
MCategory.add_or_update
def add_or_update(uid, post_data): ''' Add or update the data by the given ID of post. ''' catinfo = MCategory.get_by_uid(uid) if catinfo: MCategory.update(uid, post_data) else: TabTag.create( uid=uid, name=post_data...
python
def add_or_update(uid, post_data): ''' Add or update the data by the given ID of post. ''' catinfo = MCategory.get_by_uid(uid) if catinfo: MCategory.update(uid, post_data) else: TabTag.create( uid=uid, name=post_data...
[ "def", "add_or_update", "(", "uid", ",", "post_data", ")", ":", "catinfo", "=", "MCategory", ".", "get_by_uid", "(", "uid", ")", "if", "catinfo", ":", "MCategory", ".", "update", "(", "uid", ",", "post_data", ")", "else", ":", "TabTag", ".", "create", ...
Add or update the data by the given ID of post.
[ "Add", "or", "update", "the", "data", "by", "the", "given", "ID", "of", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/category_model.py#L131-L147
bukun/TorCMS
torcms/handlers/category_handler.py
CategoryAjaxHandler.list_catalog
def list_catalog(self, kind): ''' listing the category. ''' kwd = { 'pager': '', 'title': '最近文档', 'kind': kind, 'router': config.router_post[kind] } self.render('admin/{0}/category_list.html'.format(self.tmpl_router), ...
python
def list_catalog(self, kind): ''' listing the category. ''' kwd = { 'pager': '', 'title': '最近文档', 'kind': kind, 'router': config.router_post[kind] } self.render('admin/{0}/category_list.html'.format(self.tmpl_router), ...
[ "def", "list_catalog", "(", "self", ",", "kind", ")", ":", "kwd", "=", "{", "'pager'", ":", "''", ",", "'title'", ":", "'最近文档',", "", "'kind'", ":", "kind", ",", "'router'", ":", "config", ".", "router_post", "[", "kind", "]", "}", "self", ".", "re...
listing the category.
[ "listing", "the", "category", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/category_handler.py#L38-L53
bukun/TorCMS
torcms/handlers/post_list_handler.py
PostListHandler.recent
def recent(self, with_catalog=True, with_date=True): ''' List posts that recent edited. ''' kwd = { 'pager': '', 'title': 'Recent posts.', 'with_catalog': with_catalog, 'with_date': with_date, } self.render('list/post_list.h...
python
def recent(self, with_catalog=True, with_date=True): ''' List posts that recent edited. ''' kwd = { 'pager': '', 'title': 'Recent posts.', 'with_catalog': with_catalog, 'with_date': with_date, } self.render('list/post_list.h...
[ "def", "recent", "(", "self", ",", "with_catalog", "=", "True", ",", "with_date", "=", "True", ")", ":", "kwd", "=", "{", "'pager'", ":", "''", ",", "'title'", ":", "'Recent posts.'", ",", "'with_catalog'", ":", "with_catalog", ",", "'with_date'", ":", "...
List posts that recent edited.
[ "List", "posts", "that", "recent", "edited", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_list_handler.py#L40-L56
bukun/TorCMS
torcms/handlers/post_list_handler.py
PostListHandler.errcat
def errcat(self): ''' List the posts to be modified. ''' post_recs = MPost.query_random(limit=1000) outrecs = [] errrecs = [] idx = 0 for postinfo in post_recs: if idx > 16: break cat = MPost2Catalog.get_first_catego...
python
def errcat(self): ''' List the posts to be modified. ''' post_recs = MPost.query_random(limit=1000) outrecs = [] errrecs = [] idx = 0 for postinfo in post_recs: if idx > 16: break cat = MPost2Catalog.get_first_catego...
[ "def", "errcat", "(", "self", ")", ":", "post_recs", "=", "MPost", ".", "query_random", "(", "limit", "=", "1000", ")", "outrecs", "=", "[", "]", "errrecs", "=", "[", "]", "idx", "=", "0", "for", "postinfo", "in", "post_recs", ":", "if", "idx", ">"...
List the posts to be modified.
[ "List", "the", "posts", "to", "be", "modified", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_list_handler.py#L58-L87
bukun/TorCMS
torcms/handlers/post_list_handler.py
PostListHandler.refresh
def refresh(self): ''' List the post of dated. ''' kwd = { 'pager': '', 'title': '', } self.render('list/post_list.html', kwd=kwd, userinfo=self.userinfo, view=MPost.query_dated(10), ...
python
def refresh(self): ''' List the post of dated. ''' kwd = { 'pager': '', 'title': '', } self.render('list/post_list.html', kwd=kwd, userinfo=self.userinfo, view=MPost.query_dated(10), ...
[ "def", "refresh", "(", "self", ")", ":", "kwd", "=", "{", "'pager'", ":", "''", ",", "'title'", ":", "''", ",", "}", "self", ".", "render", "(", "'list/post_list.html'", ",", "kwd", "=", "kwd", ",", "userinfo", "=", "self", ".", "userinfo", ",", "v...
List the post of dated.
[ "List", "the", "post", "of", "dated", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_list_handler.py#L89-L103
bukun/TorCMS
torcms/script/autocrud/base_crud.py
build_dir
def build_dir(): ''' Build the directory used for templates. ''' tag_arr = ['add', 'edit', 'view', 'list', 'infolist'] path_arr = [os.path.join(CRUD_PATH, x) for x in tag_arr] for wpath in path_arr: if os.path.exists(wpath): continue os.makedirs(wpath)
python
def build_dir(): ''' Build the directory used for templates. ''' tag_arr = ['add', 'edit', 'view', 'list', 'infolist'] path_arr = [os.path.join(CRUD_PATH, x) for x in tag_arr] for wpath in path_arr: if os.path.exists(wpath): continue os.makedirs(wpath)
[ "def", "build_dir", "(", ")", ":", "tag_arr", "=", "[", "'add'", ",", "'edit'", ",", "'view'", ",", "'list'", ",", "'infolist'", "]", "path_arr", "=", "[", "os", ".", "path", ".", "join", "(", "CRUD_PATH", ",", "x", ")", "for", "x", "in", "tag_arr"...
Build the directory used for templates.
[ "Build", "the", "directory", "used", "for", "templates", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/autocrud/base_crud.py#L31-L40
bukun/TorCMS
torcms/model/reply_model.py
MReply.create_reply
def create_reply(post_data): ''' Create the reply. ''' uid = tools.get_uuid() TabReply.create( uid=uid, post_id=post_data['post_id'], user_name=post_data['user_name'], user_id=post_data['user_id'], timestamp=tools.timest...
python
def create_reply(post_data): ''' Create the reply. ''' uid = tools.get_uuid() TabReply.create( uid=uid, post_id=post_data['post_id'], user_name=post_data['user_name'], user_id=post_data['user_id'], timestamp=tools.timest...
[ "def", "create_reply", "(", "post_data", ")", ":", "uid", "=", "tools", ".", "get_uuid", "(", ")", "TabReply", ".", "create", "(", "uid", "=", "uid", ",", "post_id", "=", "post_data", "[", "'post_id'", "]", ",", "user_name", "=", "post_data", "[", "'us...
Create the reply.
[ "Create", "the", "reply", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/reply_model.py#L33-L49
bukun/TorCMS
torcms/model/reply_model.py
MReply.query_by_post
def query_by_post(postid): ''' Get reply list of certain post. ''' return TabReply.select().where( TabReply.post_id == postid ).order_by(TabReply.timestamp.desc())
python
def query_by_post(postid): ''' Get reply list of certain post. ''' return TabReply.select().where( TabReply.post_id == postid ).order_by(TabReply.timestamp.desc())
[ "def", "query_by_post", "(", "postid", ")", ":", "return", "TabReply", ".", "select", "(", ")", ".", "where", "(", "TabReply", ".", "post_id", "==", "postid", ")", ".", "order_by", "(", "TabReply", ".", "timestamp", ".", "desc", "(", ")", ")" ]
Get reply list of certain post.
[ "Get", "reply", "list", "of", "certain", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/reply_model.py#L52-L58
bukun/TorCMS
ext_script/autocrud/fetch_html_dic.py
__write_filter_dic
def __write_filter_dic(wk_sheet, column): ''' return filter dic for certain column ''' row1_val = wk_sheet['{0}1'.format(column)].value row2_val = wk_sheet['{0}2'.format(column)].value row3_val = wk_sheet['{0}3'.format(column)].value row4_val = wk_sheet['{0}4'.format(column)].value if r...
python
def __write_filter_dic(wk_sheet, column): ''' return filter dic for certain column ''' row1_val = wk_sheet['{0}1'.format(column)].value row2_val = wk_sheet['{0}2'.format(column)].value row3_val = wk_sheet['{0}3'.format(column)].value row4_val = wk_sheet['{0}4'.format(column)].value if r...
[ "def", "__write_filter_dic", "(", "wk_sheet", ",", "column", ")", ":", "row1_val", "=", "wk_sheet", "[", "'{0}1'", ".", "format", "(", "column", ")", "]", ".", "value", "row2_val", "=", "wk_sheet", "[", "'{0}2'", ".", "format", "(", "column", ")", "]", ...
return filter dic for certain column
[ "return", "filter", "dic", "for", "certain", "column" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext_script/autocrud/fetch_html_dic.py#L17-L67
bukun/TorCMS
torcms/model/wiki_hist_model.py
MWikiHist.get_last
def get_last(postid): ''' Get the last wiki in history. ''' recs = TabWikiHist.select().where( TabWikiHist.wiki_id == postid ).order_by(TabWikiHist.time_update.desc()) return None if recs.count() == 0 else recs.get()
python
def get_last(postid): ''' Get the last wiki in history. ''' recs = TabWikiHist.select().where( TabWikiHist.wiki_id == postid ).order_by(TabWikiHist.time_update.desc()) return None if recs.count() == 0 else recs.get()
[ "def", "get_last", "(", "postid", ")", ":", "recs", "=", "TabWikiHist", ".", "select", "(", ")", ".", "where", "(", "TabWikiHist", ".", "wiki_id", "==", "postid", ")", ".", "order_by", "(", "TabWikiHist", ".", "time_update", ".", "desc", "(", ")", ")",...
Get the last wiki in history.
[ "Get", "the", "last", "wiki", "in", "history", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/wiki_hist_model.py#L11-L19
bukun/TorCMS
torcms/core/privilege.py
is_prived
def is_prived(usr_rule, def_rule): ''' Compare between two role string. ''' for iii in range(4): if def_rule[iii] == '0': continue if usr_rule[iii] >= def_rule[iii]: return True return False
python
def is_prived(usr_rule, def_rule): ''' Compare between two role string. ''' for iii in range(4): if def_rule[iii] == '0': continue if usr_rule[iii] >= def_rule[iii]: return True return False
[ "def", "is_prived", "(", "usr_rule", ",", "def_rule", ")", ":", "for", "iii", "in", "range", "(", "4", ")", ":", "if", "def_rule", "[", "iii", "]", "==", "'0'", ":", "continue", "if", "usr_rule", "[", "iii", "]", ">=", "def_rule", "[", "iii", "]", ...
Compare between two role string.
[ "Compare", "between", "two", "role", "string", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/core/privilege.py#L10-L20
bukun/TorCMS
torcms/core/privilege.py
auth_view
def auth_view(method): ''' role for view. ''' def wrapper(self, *args, **kwargs): ''' wrapper. ''' if ROLE_CFG['view'] == '': return method(self, *args, **kwargs) elif self.current_user: if is_prived(self.userinfo.role, ROLE_CFG['view']):...
python
def auth_view(method): ''' role for view. ''' def wrapper(self, *args, **kwargs): ''' wrapper. ''' if ROLE_CFG['view'] == '': return method(self, *args, **kwargs) elif self.current_user: if is_prived(self.userinfo.role, ROLE_CFG['view']):...
[ "def", "auth_view", "(", "method", ")", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "'''\n wrapper.\n '''", "if", "ROLE_CFG", "[", "'view'", "]", "==", "''", ":", "return", "method", "(", "self",...
role for view.
[ "role", "for", "view", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/core/privilege.py#L23-L54
bukun/TorCMS
torcms/script/script_drop_tabels.py
run_drop_tables
def run_drop_tables(_): ''' Running the script. ''' print('--') drop_the_table(TabPost) drop_the_table(TabTag) drop_the_table(TabMember) drop_the_table(TabWiki) drop_the_table(TabLink) drop_the_table(TabEntity) drop_the_table(TabPostHist) drop_the_table(TabWikiHist) ...
python
def run_drop_tables(_): ''' Running the script. ''' print('--') drop_the_table(TabPost) drop_the_table(TabTag) drop_the_table(TabMember) drop_the_table(TabWiki) drop_the_table(TabLink) drop_the_table(TabEntity) drop_the_table(TabPostHist) drop_the_table(TabWikiHist) ...
[ "def", "run_drop_tables", "(", "_", ")", ":", "print", "(", "'--'", ")", "drop_the_table", "(", "TabPost", ")", "drop_the_table", "(", "TabTag", ")", "drop_the_table", "(", "TabMember", ")", "drop_the_table", "(", "TabWiki", ")", "drop_the_table", "(", "TabLin...
Running the script.
[ "Running", "the", "script", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_drop_tabels.py#L22-L43
shon/httpagentparser
httpagentparser/__init__.py
detect
def detect(agent, fill_none=False): """ fill_none: if name/version is not detected respective key is still added to the result with value None """ result = dict(platform=dict(name=None, version=None)) _suggested_detectors = [] for info_type in detectorshub: detectors = _suggested_detect...
python
def detect(agent, fill_none=False): """ fill_none: if name/version is not detected respective key is still added to the result with value None """ result = dict(platform=dict(name=None, version=None)) _suggested_detectors = [] for info_type in detectorshub: detectors = _suggested_detect...
[ "def", "detect", "(", "agent", ",", "fill_none", "=", "False", ")", ":", "result", "=", "dict", "(", "platform", "=", "dict", "(", "name", "=", "None", ",", "version", "=", "None", ")", ")", "_suggested_detectors", "=", "[", "]", "for", "info_type", ...
fill_none: if name/version is not detected respective key is still added to the result with value None
[ "fill_none", ":", "if", "name", "/", "version", "is", "not", "detected", "respective", "key", "is", "still", "added", "to", "the", "result", "with", "value", "None" ]
train
https://github.com/shon/httpagentparser/blob/c08489408a9b9e67c83eb850d15e108c5270c97f/httpagentparser/__init__.py#L637-L658
shon/httpagentparser
httpagentparser/__init__.py
simple_detect
def simple_detect(agent): """ -> (os, browser) # tuple of strings """ result = detect(agent) os_list = [] if 'flavor' in result: os_list.append(result['flavor']['name']) if 'dist' in result: os_list.append(result['dist']['name']) if 'os' in result: os_list.append(...
python
def simple_detect(agent): """ -> (os, browser) # tuple of strings """ result = detect(agent) os_list = [] if 'flavor' in result: os_list.append(result['flavor']['name']) if 'dist' in result: os_list.append(result['dist']['name']) if 'os' in result: os_list.append(...
[ "def", "simple_detect", "(", "agent", ")", ":", "result", "=", "detect", "(", "agent", ")", "os_list", "=", "[", "]", "if", "'flavor'", "in", "result", ":", "os_list", ".", "append", "(", "result", "[", "'flavor'", "]", "[", "'name'", "]", ")", "if",...
-> (os, browser) # tuple of strings
[ "-", ">", "(", "os", "browser", ")", "#", "tuple", "of", "strings" ]
train
https://github.com/shon/httpagentparser/blob/c08489408a9b9e67c83eb850d15e108c5270c97f/httpagentparser/__init__.py#L661-L683
shon/httpagentparser
httpagentparser/__init__.py
DetectorBase.getVersion
def getVersion(self, agent, word): """ => version string /None """ version_markers = self.version_markers if \ isinstance(self.version_markers[0], (list, tuple)) else [self.version_markers] version_part = agent.split(word, 1)[-1] for start, end in version_mark...
python
def getVersion(self, agent, word): """ => version string /None """ version_markers = self.version_markers if \ isinstance(self.version_markers[0], (list, tuple)) else [self.version_markers] version_part = agent.split(word, 1)[-1] for start, end in version_mark...
[ "def", "getVersion", "(", "self", ",", "agent", ",", "word", ")", ":", "version_markers", "=", "self", ".", "version_markers", "if", "isinstance", "(", "self", ".", "version_markers", "[", "0", "]", ",", "(", "list", ",", "tuple", ")", ")", "else", "["...
=> version string /None
[ "=", ">", "version", "string", "/", "None" ]
train
https://github.com/shon/httpagentparser/blob/c08489408a9b9e67c83eb850d15e108c5270c97f/httpagentparser/__init__.py#L84-L98
ylogx/universal
universal/builder.py
compile_files
def compile_files(args, mem_test=False): ''' Copiles the files and runs memory tests if needed. PARAM args: list of files passed as CMD args to be compiled. PARAM mem_test: Weither to perform memory test ? ''' for filename in args: if not os.path.isfile(fi...
python
def compile_files(args, mem_test=False): ''' Copiles the files and runs memory tests if needed. PARAM args: list of files passed as CMD args to be compiled. PARAM mem_test: Weither to perform memory test ? ''' for filename in args: if not os.path.isfile(fi...
[ "def", "compile_files", "(", "args", ",", "mem_test", "=", "False", ")", ":", "for", "filename", "in", "args", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "print", "(", "'The file doesn\\'t exits'", ")", "return", "buil...
Copiles the files and runs memory tests if needed. PARAM args: list of files passed as CMD args to be compiled. PARAM mem_test: Weither to perform memory test ?
[ "Copiles", "the", "files", "and", "runs", "memory", "tests", "if", "needed", ".", "PARAM", "args", ":", "list", "of", "files", "passed", "as", "CMD", "args", "to", "be", "compiled", ".", "PARAM", "mem_test", ":", "Weither", "to", "perform", "memory", "te...
train
https://github.com/ylogx/universal/blob/1be04c2e828d9f97a94d48bff64031b14c2b8463/universal/builder.py#L41-L53
ylogx/universal
universal/builder.py
build_and_run_file
def build_and_run_file(filename): ''' Builds and runs the filename specified according to the extension PARAM filename: name of file to build and run ''' (directory, name, extension) = get_file_tuple(filename) if extension == 'c': print(" = = = = = = ", YELLOW, "GCC: Compiling " ...
python
def build_and_run_file(filename): ''' Builds and runs the filename specified according to the extension PARAM filename: name of file to build and run ''' (directory, name, extension) = get_file_tuple(filename) if extension == 'c': print(" = = = = = = ", YELLOW, "GCC: Compiling " ...
[ "def", "build_and_run_file", "(", "filename", ")", ":", "(", "directory", ",", "name", ",", "extension", ")", "=", "get_file_tuple", "(", "filename", ")", "if", "extension", "==", "'c'", ":", "print", "(", "\" = = = = = = \"", ",", "YELLOW", ",", "\"GCC: Com...
Builds and runs the filename specified according to the extension PARAM filename: name of file to build and run
[ "Builds", "and", "runs", "the", "filename", "specified", "according", "to", "the", "extension", "PARAM", "filename", ":", "name", "of", "file", "to", "build", "and", "run" ]
train
https://github.com/ylogx/universal/blob/1be04c2e828d9f97a94d48bff64031b14c2b8463/universal/builder.py#L56-L104
ylogx/universal
universal/util.py
check_exec_installed
def check_exec_installed(exec_list): """ Check the required programs are installed. PARAM exec_list: list of programs to check RETURN: True if all installed else False """ all_installed = True for exe in exec_list: if not is_tool(exe): print("Executable: " + e...
python
def check_exec_installed(exec_list): """ Check the required programs are installed. PARAM exec_list: list of programs to check RETURN: True if all installed else False """ all_installed = True for exe in exec_list: if not is_tool(exe): print("Executable: " + e...
[ "def", "check_exec_installed", "(", "exec_list", ")", ":", "all_installed", "=", "True", "for", "exe", "in", "exec_list", ":", "if", "not", "is_tool", "(", "exe", ")", ":", "print", "(", "\"Executable: \"", "+", "exe", "+", "\" is not installed\"", ")", "all...
Check the required programs are installed. PARAM exec_list: list of programs to check RETURN: True if all installed else False
[ "Check", "the", "required", "programs", "are", "installed", ".", "PARAM", "exec_list", ":", "list", "of", "programs", "to", "check", "RETURN", ":", "True", "if", "all", "installed", "else", "False" ]
train
https://github.com/ylogx/universal/blob/1be04c2e828d9f97a94d48bff64031b14c2b8463/universal/util.py#L23-L34
ylogx/universal
universal/main.py
parse_known_args
def parse_known_args(): """ Parse command line arguments """ parser = ArgumentParser() parser.add_argument("-l", "--loop", type=int, help="Loop every X seconds") parser.add_argument('-V', '--version', action='store_true', dest='version', ...
python
def parse_known_args(): """ Parse command line arguments """ parser = ArgumentParser() parser.add_argument("-l", "--loop", type=int, help="Loop every X seconds") parser.add_argument('-V', '--version', action='store_true', dest='version', ...
[ "def", "parse_known_args", "(", ")", ":", "parser", "=", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"-l\"", ",", "\"--loop\"", ",", "type", "=", "int", ",", "help", "=", "\"Loop every X seconds\"", ")", "parser", ".", "add_argument", "...
Parse command line arguments
[ "Parse", "command", "line", "arguments" ]
train
https://github.com/ylogx/universal/blob/1be04c2e828d9f97a94d48bff64031b14c2b8463/universal/main.py#L43-L65
xieqihui/pandas-multiprocess
pandas_multiprocess/multiprocess.py
multi_process
def multi_process(func, data, num_process=None, verbose=True, **args): '''Function to use multiprocessing to process pandas Dataframe. This function applies a function on each row of the input DataFrame by multiprocessing. Args: func (function): The function to apply on each row of the input ...
python
def multi_process(func, data, num_process=None, verbose=True, **args): '''Function to use multiprocessing to process pandas Dataframe. This function applies a function on each row of the input DataFrame by multiprocessing. Args: func (function): The function to apply on each row of the input ...
[ "def", "multi_process", "(", "func", ",", "data", ",", "num_process", "=", "None", ",", "verbose", "=", "True", ",", "*", "*", "args", ")", ":", "# Check arguments value", "assert", "isinstance", "(", "data", ",", "pd", ".", "DataFrame", ")", ",", "'Inpu...
Function to use multiprocessing to process pandas Dataframe. This function applies a function on each row of the input DataFrame by multiprocessing. Args: func (function): The function to apply on each row of the input Dataframe. The func must accept pandas.Series as the first ...
[ "Function", "to", "use", "multiprocessing", "to", "process", "pandas", "Dataframe", "." ]
train
https://github.com/xieqihui/pandas-multiprocess/blob/b4d1b7357a446ded93183fb7b3e0d464ac7cc784/pandas_multiprocess/multiprocess.py#L125-L186
xieqihui/pandas-multiprocess
pandas_multiprocess/multiprocess.py
Consumer.run
def run(self): '''Define the job of each process to run. ''' while True: next_task = self._task_queue.get() # If there is any error, only consume data but not run the job if self._error_queue.qsize() > 0: self._task_queue.task_done() ...
python
def run(self): '''Define the job of each process to run. ''' while True: next_task = self._task_queue.get() # If there is any error, only consume data but not run the job if self._error_queue.qsize() > 0: self._task_queue.task_done() ...
[ "def", "run", "(", "self", ")", ":", "while", "True", ":", "next_task", "=", "self", ".", "_task_queue", ".", "get", "(", ")", "# If there is any error, only consume data but not run the job", "if", "self", ".", "_error_queue", ".", "qsize", "(", ")", ">", "0"...
Define the job of each process to run.
[ "Define", "the", "job", "of", "each", "process", "to", "run", "." ]
train
https://github.com/xieqihui/pandas-multiprocess/blob/b4d1b7357a446ded93183fb7b3e0d464ac7cc784/pandas_multiprocess/multiprocess.py#L57-L78
xieqihui/pandas-multiprocess
pandas_multiprocess/multiprocess.py
TaskTracker.run
def run(self): '''Define the job of each process to run. ''' if self.verbose: pbar = tqdm(total=100) while True: task_remain = self._task_queue.qsize() task_finished = int((float(self.total_task - task_remain) / float(s...
python
def run(self): '''Define the job of each process to run. ''' if self.verbose: pbar = tqdm(total=100) while True: task_remain = self._task_queue.qsize() task_finished = int((float(self.total_task - task_remain) / float(s...
[ "def", "run", "(", "self", ")", ":", "if", "self", ".", "verbose", ":", "pbar", "=", "tqdm", "(", "total", "=", "100", ")", "while", "True", ":", "task_remain", "=", "self", ".", "_task_queue", ".", "qsize", "(", ")", "task_finished", "=", "int", "...
Define the job of each process to run.
[ "Define", "the", "job", "of", "each", "process", "to", "run", "." ]
train
https://github.com/xieqihui/pandas-multiprocess/blob/b4d1b7357a446ded93183fb7b3e0d464ac7cc784/pandas_multiprocess/multiprocess.py#L106-L122
xieqihui/pandas-multiprocess
examples/example.py
func
def func(data_row, wait): ''' A sample function It takes 'wait' seconds to calculate the sum of each row ''' time.sleep(wait) data_row['sum'] = data_row['col_1'] + data_row['col_2'] return data_row
python
def func(data_row, wait): ''' A sample function It takes 'wait' seconds to calculate the sum of each row ''' time.sleep(wait) data_row['sum'] = data_row['col_1'] + data_row['col_2'] return data_row
[ "def", "func", "(", "data_row", ",", "wait", ")", ":", "time", ".", "sleep", "(", "wait", ")", "data_row", "[", "'sum'", "]", "=", "data_row", "[", "'col_1'", "]", "+", "data_row", "[", "'col_2'", "]", "return", "data_row" ]
A sample function It takes 'wait' seconds to calculate the sum of each row
[ "A", "sample", "function", "It", "takes", "wait", "seconds", "to", "calculate", "the", "sum", "of", "each", "row" ]
train
https://github.com/xieqihui/pandas-multiprocess/blob/b4d1b7357a446ded93183fb7b3e0d464ac7cc784/examples/example.py#L7-L13
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
me
def me(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the mean error of the simulated and observed data. .. image:: /pictures/ME.png **Range:** -inf < MAE < inf, data units, closer to zero is better, indicates bias. **Notes...
python
def me(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the mean error of the simulated and observed data. .. image:: /pictures/ME.png **Range:** -inf < MAE < inf, data units, closer to zero is better, indicates bias. **Notes...
[ "def", "me", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Treating missing values", "simulated_array", ",", "obser...
Compute the mean error of the simulated and observed data. .. image:: /pictures/ME.png **Range:** -inf < MAE < inf, data units, closer to zero is better, indicates bias. **Notes:** The mean error (ME) measures the difference between the simulated data and the observed data. For the mean error, a smal...
[ "Compute", "the", "mean", "error", "of", "the", "simulated", "and", "observed", "data", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L39-L114
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
mae
def mae(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the mean absolute error of the simulated and observed data. .. image:: /pictures/MAE.png **Range:** 0 ≤ MAE < inf, data units, smaller is better. **Notes:** The ME mea...
python
def mae(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the mean absolute error of the simulated and observed data. .. image:: /pictures/MAE.png **Range:** 0 ≤ MAE < inf, data units, smaller is better. **Notes:** The ME mea...
[ "def", "mae", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Checking and cleaning the data", "simulated_array", ",", ...
Compute the mean absolute error of the simulated and observed data. .. image:: /pictures/MAE.png **Range:** 0 ≤ MAE < inf, data units, smaller is better. **Notes:** The ME measures the absolute difference between the simulated data and the observed data. For the mean abolute error, a smaller number i...
[ "Compute", "the", "mean", "absolute", "error", "of", "the", "simulated", "and", "observed", "data", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L117-L193
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
mle
def mle(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """ Compute the mean log error of the simulated and observed data. .. image:: /pictures/MLE.png **Range:** -inf < MLE < inf, data units, closer to zero is better. **Notes** S...
python
def mle(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """ Compute the mean log error of the simulated and observed data. .. image:: /pictures/MLE.png **Range:** -inf < MLE < inf, data units, closer to zero is better. **Notes** S...
[ "def", "mle", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Checking and cleaning the data", "simulated_array", ",", ...
Compute the mean log error of the simulated and observed data. .. image:: /pictures/MLE.png **Range:** -inf < MLE < inf, data units, closer to zero is better. **Notes** Same as the mean erro (ME) only use log ratios as the error term. Limits the impact of outliers, more evenly weights high and low da...
[ "Compute", "the", "mean", "log", "error", "of", "the", "simulated", "and", "observed", "data", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L271-L348
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
mde
def mde(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """ Compute the median error (MdE) between the simulated and observed data. .. image:: /pictures/MdE.png **Range** -inf < MdE < inf, closer to zero is better. **Notes** This ...
python
def mde(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """ Compute the median error (MdE) between the simulated and observed data. .. image:: /pictures/MdE.png **Range** -inf < MdE < inf, closer to zero is better. **Notes** This ...
[ "def", "mde", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Checking and cleaning the data", "simulated_array", ",", ...
Compute the median error (MdE) between the simulated and observed data. .. image:: /pictures/MdE.png **Range** -inf < MdE < inf, closer to zero is better. **Notes** This metric indicates bias. It is similar to the mean error (ME), only it takes the median rather than the mean. Median measures reduces...
[ "Compute", "the", "median", "error", "(", "MdE", ")", "between", "the", "simulated", "and", "observed", "data", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L511-L582
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
mdae
def mdae(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """ Compute the median absolute error (MdAE) between the simulated and observed data. .. image:: /pictures/MdAE.png **Range** 0 ≤ MdAE < inf, closer to zero is better. **No...
python
def mdae(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """ Compute the median absolute error (MdAE) between the simulated and observed data. .. image:: /pictures/MdAE.png **Range** 0 ≤ MdAE < inf, closer to zero is better. **No...
[ "def", "mdae", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Checking and cleaning the data", "simulated_array", ",",...
Compute the median absolute error (MdAE) between the simulated and observed data. .. image:: /pictures/MdAE.png **Range** 0 ≤ MdAE < inf, closer to zero is better. **Notes** Random errors (noise) do not cancel. It is the same as the mean absolute error (MAE), only it takes the median rather than the ...
[ "Compute", "the", "median", "absolute", "error", "(", "MdAE", ")", "between", "the", "simulated", "and", "observed", "data", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L585-L656
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
ed
def ed(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """ Compute the Euclidean distance between predicted and observed values in vector space. .. image:: /pictures/ED.png **Range** 0 ≤ ED < inf, smaller is better. **Notes** Also s...
python
def ed(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """ Compute the Euclidean distance between predicted and observed values in vector space. .. image:: /pictures/ED.png **Range** 0 ≤ ED < inf, smaller is better. **Notes** Also s...
[ "def", "ed", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Checking and cleaning the data", "simulated_array", ",", ...
Compute the Euclidean distance between predicted and observed values in vector space. .. image:: /pictures/ED.png **Range** 0 ≤ ED < inf, smaller is better. **Notes** Also sometimes referred to as the L2-norm. Parameters ---------- simulated_array: one dimensional ndarray An array of ...
[ "Compute", "the", "Euclidean", "distance", "between", "predicted", "and", "observed", "values", "in", "vector", "space", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L733-L805
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
ned
def ned(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """ Compute the normalized Euclidian distance between the simulated and observed data in vector space. .. image:: /pictures/NED.png **Range** 0 ≤ NED < inf, smaller is better....
python
def ned(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """ Compute the normalized Euclidian distance between the simulated and observed data in vector space. .. image:: /pictures/NED.png **Range** 0 ≤ NED < inf, smaller is better....
[ "def", "ned", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Checking and cleaning the data", "simulated_array", ",", ...
Compute the normalized Euclidian distance between the simulated and observed data in vector space. .. image:: /pictures/NED.png **Range** 0 ≤ NED < inf, smaller is better. **Notes** Also sometimes referred to as the squared L2-norm. Parameters ---------- simulated_array: one dimensional ...
[ "Compute", "the", "normalized", "Euclidian", "distance", "between", "the", "simulated", "and", "observed", "data", "in", "vector", "space", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L808-L883
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
nrmse_range
def nrmse_range(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the range normalized root mean square error between the simulated and observed data. .. image:: /pictures/NRMSE_Range.png **Range:** 0 ≤ NRMSE < inf. *...
python
def nrmse_range(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the range normalized root mean square error between the simulated and observed data. .. image:: /pictures/NRMSE_Range.png **Range:** 0 ≤ NRMSE < inf. *...
[ "def", "nrmse_range", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Checking and cleaning the data", "simulated_array",...
Compute the range normalized root mean square error between the simulated and observed data. .. image:: /pictures/NRMSE_Range.png **Range:** 0 ≤ NRMSE < inf. **Notes:** This metric is the RMSE normalized by the range of the observed time series (x). Normalizing allows comparison between data sets wit...
[ "Compute", "the", "range", "normalized", "root", "mean", "square", "error", "between", "the", "simulated", "and", "observed", "data", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L1044-L1121
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
nrmse_mean
def nrmse_mean(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the mean normalized root mean square error between the simulated and observed data. .. image:: /pictures/NRMSE_Mean.png **Range:** 0 ≤ NRMSE < inf. **Not...
python
def nrmse_mean(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the mean normalized root mean square error between the simulated and observed data. .. image:: /pictures/NRMSE_Mean.png **Range:** 0 ≤ NRMSE < inf. **Not...
[ "def", "nrmse_mean", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Checking and cleaning the data", "simulated_array", ...
Compute the mean normalized root mean square error between the simulated and observed data. .. image:: /pictures/NRMSE_Mean.png **Range:** 0 ≤ NRMSE < inf. **Notes:** This metric is the RMSE normalized by the mean of the observed time series (x). Normalizing allows comparison between data sets with d...
[ "Compute", "the", "mean", "normalized", "root", "mean", "square", "error", "between", "the", "simulated", "and", "observed", "data", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L1124-L1200
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
nrmse_iqr
def nrmse_iqr(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the IQR normalized root mean square error between the simulated and observed data. .. image:: /pictures/NRMSE_IQR.png **Range:** 0 ≤ NRMSE < inf. **Notes:*...
python
def nrmse_iqr(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the IQR normalized root mean square error between the simulated and observed data. .. image:: /pictures/NRMSE_IQR.png **Range:** 0 ≤ NRMSE < inf. **Notes:*...
[ "def", "nrmse_iqr", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Checking and cleaning the data", "simulated_array", ...
Compute the IQR normalized root mean square error between the simulated and observed data. .. image:: /pictures/NRMSE_IQR.png **Range:** 0 ≤ NRMSE < inf. **Notes:** This metric is the RMSE normalized by the interquartile range of the observed time series (x). Normalizing allows comparison between dat...
[ "Compute", "the", "IQR", "normalized", "root", "mean", "square", "error", "between", "the", "simulated", "and", "observed", "data", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L1203-L1282
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
mase
def mase(simulated_array, observed_array, m=1, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the mean absolute scaled error between the simulated and observed data. .. image:: /pictures/MASE.png **Range:** **Notes:** Parameters ---------- s...
python
def mase(simulated_array, observed_array, m=1, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the mean absolute scaled error between the simulated and observed data. .. image:: /pictures/MASE.png **Range:** **Notes:** Parameters ---------- s...
[ "def", "mase", "(", "simulated_array", ",", "observed_array", ",", "m", "=", "1", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Checking and cleaning the data",...
Compute the mean absolute scaled error between the simulated and observed data. .. image:: /pictures/MASE.png **Range:** **Notes:** Parameters ---------- simulated_array: one dimensional ndarray An array of simulated data from the time series. observed_array: one dimensional nda...
[ "Compute", "the", "mean", "absolute", "scaled", "error", "between", "the", "simulated", "and", "observed", "data", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L1372-L1450
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
maape
def maape(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the the Mean Arctangent Absolute Percentage Error (MAAPE). .. image:: /pictures/MAAPE.png **Range:** 0 ≤ MAAPE < π/2, does not indicate bias, smaller is better. **...
python
def maape(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the the Mean Arctangent Absolute Percentage Error (MAAPE). .. image:: /pictures/MAAPE.png **Range:** 0 ≤ MAAPE < π/2, does not indicate bias, smaller is better. **...
[ "def", "maape", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Treats data", "simulated_array", ",", "observed_array...
Compute the the Mean Arctangent Absolute Percentage Error (MAAPE). .. image:: /pictures/MAAPE.png **Range:** 0 ≤ MAAPE < π/2, does not indicate bias, smaller is better. **Notes:** Represents the mean absolute error as a percentage of the observed values. Handles 0s in the observed data. This metric i...
[ "Compute", "the", "the", "Mean", "Arctangent", "Absolute", "Percentage", "Error", "(", "MAAPE", ")", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L1937-L2010
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
drel
def drel(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the the relative index of agreement (drel). .. image:: /pictures/drel.png **Range:** 0 ≤ drel < 1, does not indicate bias, larger is better. **Notes:** Instead of ab...
python
def drel(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the the relative index of agreement (drel). .. image:: /pictures/drel.png **Range:** 0 ≤ drel < 1, does not indicate bias, larger is better. **Notes:** Instead of ab...
[ "def", "drel", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Treats data", "simulated_array", ",", "observed_array"...
Compute the the relative index of agreement (drel). .. image:: /pictures/drel.png **Range:** 0 ≤ drel < 1, does not indicate bias, larger is better. **Notes:** Instead of absolute differences, this metric uses relative differences. Parameters ---------- simulated_array: one dimensional ndarr...
[ "Compute", "the", "the", "relative", "index", "of", "agreement", "(", "drel", ")", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L2425-L2499
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
watt_m
def watt_m(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute Watterson's M (M). .. image:: /pictures/M.png **Range:** -1 ≤ M < 1, does not indicate bias, larger is better. **Notes:** Parameters ---------- simu...
python
def watt_m(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute Watterson's M (M). .. image:: /pictures/M.png **Range:** -1 ≤ M < 1, does not indicate bias, larger is better. **Notes:** Parameters ---------- simu...
[ "def", "watt_m", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Treats data", "simulated_array", ",", "observed_arra...
Compute Watterson's M (M). .. image:: /pictures/M.png **Range:** -1 ≤ M < 1, does not indicate bias, larger is better. **Notes:** Parameters ---------- simulated_array: one dimensional ndarray An array of simulated data from the time series. observed_array: one dimensional ndarr...
[ "Compute", "Watterson", "s", "M", "(", "M", ")", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L2593-L2668
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
kge_2009
def kge_2009(simulated_array, observed_array, s=(1, 1, 1), replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False, return_all=False): """Compute the Kling-Gupta efficiency (2009). .. image:: /pictures/KGE_2009.png **Range:** -inf < KGE (2009) < 1, larger is better. **Not...
python
def kge_2009(simulated_array, observed_array, s=(1, 1, 1), replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False, return_all=False): """Compute the Kling-Gupta efficiency (2009). .. image:: /pictures/KGE_2009.png **Range:** -inf < KGE (2009) < 1, larger is better. **Not...
[ "def", "kge_2009", "(", "simulated_array", ",", "observed_array", ",", "s", "=", "(", "1", ",", "1", ",", "1", ")", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ","...
Compute the Kling-Gupta efficiency (2009). .. image:: /pictures/KGE_2009.png **Range:** -inf < KGE (2009) < 1, larger is better. **Notes:** Gupta et al. (2009) created this metric to demonstrate the relative importance of the three components of the NSE, which are correlation, bias and variability. T...
[ "Compute", "the", "Kling", "-", "Gupta", "efficiency", "(", "2009", ")", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L3023-L3151
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
sa
def sa(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the Spectral Angle (SA). .. image:: /pictures/SA.png **Range:** -π/2 ≤ SA < π/2, closer to 0 is better. **Notes:** The spectral angle metric measures the angle between t...
python
def sa(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the Spectral Angle (SA). .. image:: /pictures/SA.png **Range:** -π/2 ≤ SA < π/2, closer to 0 is better. **Notes:** The spectral angle metric measures the angle between t...
[ "def", "sa", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Treats data", "simulated_array", ",", "observed_array", ...
Compute the Spectral Angle (SA). .. image:: /pictures/SA.png **Range:** -π/2 ≤ SA < π/2, closer to 0 is better. **Notes:** The spectral angle metric measures the angle between the two vectors in hyperspace. It indicates how well the shape of the two series match – not magnitude. Parameters -...
[ "Compute", "the", "Spectral", "Angle", "(", "SA", ")", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L3538-L3612
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
sc
def sc(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the Spectral Correlation (SC). .. image:: /pictures/SC.png **Range:** -π/2 ≤ SA < π/2, closer to 0 is better. **Notes:** The spectral correlation metric measures the ang...
python
def sc(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the Spectral Correlation (SC). .. image:: /pictures/SC.png **Range:** -π/2 ≤ SA < π/2, closer to 0 is better. **Notes:** The spectral correlation metric measures the ang...
[ "def", "sc", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Treats data", "simulated_array", ",", "observed_array", ...
Compute the Spectral Correlation (SC). .. image:: /pictures/SC.png **Range:** -π/2 ≤ SA < π/2, closer to 0 is better. **Notes:** The spectral correlation metric measures the angle between the two vectors in hyperspace. It indicates how well the shape of the two series match – not magnitude. Para...
[ "Compute", "the", "Spectral", "Correlation", "(", "SC", ")", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L3615-L3691
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
sid
def sid(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the Spectral Information Divergence (SID). .. image:: /pictures/SID.png **Range:** -π/2 ≤ SID < π/2, closer to 0 is better. **Notes:** The spectral information diverge...
python
def sid(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the Spectral Information Divergence (SID). .. image:: /pictures/SID.png **Range:** -π/2 ≤ SID < π/2, closer to 0 is better. **Notes:** The spectral information diverge...
[ "def", "sid", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Treats data", "simulated_array", ",", "observed_array",...
Compute the Spectral Information Divergence (SID). .. image:: /pictures/SID.png **Range:** -π/2 ≤ SID < π/2, closer to 0 is better. **Notes:** The spectral information divergence measures the angle between the two vectors in hyperspace. It indicates how well the shape of the two series match – not ma...
[ "Compute", "the", "Spectral", "Information", "Divergence", "(", "SID", ")", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L3694-L3770
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
sga
def sga(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the Spectral Gradient Angle (SGA). .. image:: /pictures/SGA.png **Range:** -π/2 ≤ SID < π/2, closer to 0 is better. **Notes:** The spectral gradient angle measures the...
python
def sga(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the Spectral Gradient Angle (SGA). .. image:: /pictures/SGA.png **Range:** -π/2 ≤ SID < π/2, closer to 0 is better. **Notes:** The spectral gradient angle measures the...
[ "def", "sga", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Treats data", "simulated_array", ",", "observed_array",...
Compute the Spectral Gradient Angle (SGA). .. image:: /pictures/SGA.png **Range:** -π/2 ≤ SID < π/2, closer to 0 is better. **Notes:** The spectral gradient angle measures the angle between the two vectors in hyperspace. It indicates how well the shape of the two series match – not magnitude. SG ...
[ "Compute", "the", "Spectral", "Gradient", "Angle", "(", "SGA", ")", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L3773-L3850
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
h1_mhe
def h1_mhe(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the H1 mean error. .. image:: /pictures/H1.png .. image:: /pictures/MHE.png **Range:** **Notes:** Parameters ---------- simulated_array: one dim...
python
def h1_mhe(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the H1 mean error. .. image:: /pictures/H1.png .. image:: /pictures/MHE.png **Range:** **Notes:** Parameters ---------- simulated_array: one dim...
[ "def", "h1_mhe", "(", "simulated_array", ",", "observed_array", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Treats data", "simulated_array", ",", "observed_arra...
Compute the H1 mean error. .. image:: /pictures/H1.png .. image:: /pictures/MHE.png **Range:** **Notes:** Parameters ---------- simulated_array: one dimensional ndarray An array of simulated data from the time series. observed_array: one dimensional ndarray An array ...
[ "Compute", "the", "H1", "mean", "error", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L3858-L3930
BYU-Hydroinformatics/HydroErr
HydroErr/HydroErr.py
h6_mahe
def h6_mahe(simulated_array, observed_array, k=1, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the H6 mean absolute error. .. image:: /pictures/H6.png .. image:: /pictures/AHE.png **Range:** **Notes:** Parameters ---------- ...
python
def h6_mahe(simulated_array, observed_array, k=1, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False): """Compute the H6 mean absolute error. .. image:: /pictures/H6.png .. image:: /pictures/AHE.png **Range:** **Notes:** Parameters ---------- ...
[ "def", "h6_mahe", "(", "simulated_array", ",", "observed_array", ",", "k", "=", "1", ",", "replace_nan", "=", "None", ",", "replace_inf", "=", "None", ",", "remove_neg", "=", "False", ",", "remove_zero", "=", "False", ")", ":", "# Treats data", "simulated_ar...
Compute the H6 mean absolute error. .. image:: /pictures/H6.png .. image:: /pictures/AHE.png **Range:** **Notes:** Parameters ---------- simulated_array: one dimensional ndarray An array of simulated data from the time series. observed_array: one dimensional ndarray ...
[ "Compute", "the", "H6", "mean", "absolute", "error", "." ]
train
https://github.com/BYU-Hydroinformatics/HydroErr/blob/42a84f3e006044f450edc7393ed54d59f27ef35b/HydroErr/HydroErr.py#L5110-L5189