Sourcery refactored main branch#6
Conversation
|
|
||
| def plot_most_freq_search_term(n=10): | ||
| title='<b> Top '+str(n)+' Most Frequent Search Terms </b>' | ||
| title = f'<b> Top {str(n)} Most Frequent Search Terms </b>' |
There was a problem hiding this comment.
Function plot_most_freq_search_term refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| else: | ||
| df_search=pd.DataFrame.from_dict(rsp['hits']['hits']) | ||
| df_search=pd.concat([df_search['_source'].apply(pd.Series)['pennsieve'].apply(pd.Series)[['identifier']], | ||
| df_search[['_id']],#df_search[['_id','_score']], | ||
| df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)[['name','description']], | ||
| df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)['published'].apply(pd.Series)['status'], | ||
| ], axis=1) | ||
| df_search['link']= 'https://sparc.science/datasets/'+df_search['identifier'] | ||
| df_search=df_search[['_id','name','description','status','link']] | ||
| return df_search | ||
| df_search=pd.DataFrame.from_dict(rsp['hits']['hits']) | ||
| df_search=pd.concat([df_search['_source'].apply(pd.Series)['pennsieve'].apply(pd.Series)[['identifier']], | ||
| df_search[['_id']],#df_search[['_id','_score']], | ||
| df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)[['name','description']], | ||
| df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)['published'].apply(pd.Series)['status'], | ||
| ], axis=1) | ||
| df_search['link']= 'https://sparc.science/datasets/'+df_search['identifier'] | ||
| df_search=df_search[['_id','name','description','status','link']] | ||
| return df_search |
There was a problem hiding this comment.
Function retrieve_search_to_df refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else)
| f = open(fileName, "r") | ||
| htmlText = f.read() | ||
| f.close() | ||
| with open(fileName, "r") as f: | ||
| htmlText = f.read() | ||
| except: | ||
| return html("We are sorry,there was an error ..., %s is not found" % fileName) | ||
| return html(f"We are sorry,there was an error ..., {fileName} is not found") |
There was a problem hiding this comment.
Function loadMain refactored with the following changes:
- Use
withwhen opening file to ensure closure (ensure-file-closed) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| summary = {} | ||
| url = 'https://scicrunch.org/api/1/elastic/SPARC_PortalDatasets_pr/_search?api_key='+api_key | ||
| url = f'https://scicrunch.org/api/1/elastic/SPARC_PortalDatasets_pr/_search?api_key={api_key}' | ||
|
|
There was a problem hiding this comment.
Function getSearch refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| url = 'https://scicrunch.org/api/1/scigraph/vocabulary/suggestions/'+query | ||
| url = f'https://scicrunch.org/api/1/scigraph/vocabulary/suggestions/{query}' |
There was a problem hiding this comment.
Function __getSuggestions refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| url = 'https://scicrunch.org/api/1/scigraph/vocabulary/autocomplete/'+query | ||
| url = f'https://scicrunch.org/api/1/scigraph/vocabulary/autocomplete/{query}' |
There was a problem hiding this comment.
Function __getAutoComplete_sc refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| else: | ||
| df_search=pd.DataFrame.from_dict(rsp['hits']['hits']) | ||
| df_search=pd.concat([ | ||
| df_search['_source'].apply(pd.Series)['pennsieve'].apply(pd.Series)[['identifier']], | ||
| df_search[['_id','_score']], | ||
| df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)[['name','description']], | ||
| df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)['published'].apply(pd.Series)['status'], | ||
| ], axis=1) | ||
| df_search['link']= 'https://sparc.science/datasets/'+df_search['identifier'] | ||
|
|
||
| return df_search | ||
| df_search=pd.DataFrame.from_dict(rsp['hits']['hits']) | ||
| df_search=pd.concat([ | ||
| df_search['_source'].apply(pd.Series)['pennsieve'].apply(pd.Series)[['identifier']], | ||
| df_search[['_id','_score']], | ||
| df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)[['name','description']], | ||
| df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)['published'].apply(pd.Series)['status'], | ||
| ], axis=1) | ||
| df_search['link']= 'https://sparc.science/datasets/'+df_search['identifier'] | ||
|
|
||
| return df_search |
There was a problem hiding this comment.
Function retrieve_search_to_df refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.31%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Branch
mainrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
mainbranch, then run:Help us improve this pull request!