https://github.com/havakv/safescope

Prevent access to global variables in functions

https://github.com/havakv/safescope

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 4 committers (25.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.3%) to scientific vocabulary

Keywords

jupyter python

Keywords from Contributors

survival-analysis
Last synced: 5 months ago · JSON representation

Repository

Prevent access to global variables in functions

Basic Info
  • Host: GitHub
  • Owner: havakv
  • License: bsd-2-clause
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 48.8 KB
Statistics
  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • Open Issues: 3
  • Releases: 0
Topics
jupyter python
Created about 8 years ago · Last pushed over 6 years ago
Metadata Files
Readme License

README.md

safescope

Build Status PyPI PyPI - Python Version Downloads License

safescope is a small python package useful for development in jupyter notebooks. The goal is to prevent functions from using global variables and instead raise a NameError. This is achieved by mimicking a module, and define all functions in that module (named side_scope).

Example

The main part of safescope is the decorator @safescope. This mimics writing the function in a file side_scope.py and importing this function to the notebook. Hence, functions decorated with @safescope will not have access to variables declared in the notebook environment.

In the example below, only foo(1) will execute, as bar(1) returns a NameError. ```python from safescope import safescope

x = 9

def foo(y): return x + y

@safescope def bar(y): return x + y

foo(1) # Returns 10 bar(1) # Raise "NameError: name 'x' is not defined" ```

By using Imports, the imports are added to both the main scope and the side_scope, making them available for the functions decorated with @safescope. ```python from safescope import safescope, Imports

with Imports(): import numpy as np

@safescope def arange(n): return np.arange(n)

arange(4) # Returns array([0, 1, 2, 3]) ```

Installation

safescope can either be installed from pypi with pip/pip3: bash pip install safescope or from github with: bash pip install git+git://github.com/havakv/safescope.git or from source by cloning the repo: bash git clone https://github.com/havakv/safescope.git cd safescope python setup.py install

Owner

  • Name: Haavard Kvamme
  • Login: havakv
  • Kind: user
  • Company: University of Oslo

GitHub Events

Total
Last Year

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 57
  • Total Committers: 4
  • Avg Commits per committer: 14.25
  • Development Distribution Score (DDS): 0.509
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
havakv h****e@g****m 28
Havard h****d@H****l 20
Havard h****d@h****u 6
Haavard Kvamme h****e@g****m 3
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 4
  • Total pull requests: 0
  • Average time to close issues: 14 days
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 0.5
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • havakv (4)
Pull Request Authors
Top Labels
Issue Labels
enhancement (3) bug (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 18 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 11
  • Total maintainers: 1
pypi.org: safescope

Python package for preventing use of variables from global scope.

  • Versions: 11
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 18 Last month
Rankings
Dependent packages count: 10.0%
Average: 21.7%
Dependent repos count: 21.7%
Stargazers count: 23.1%
Downloads: 23.7%
Forks count: 29.8%
Maintainers (1)
Last synced: 5 months ago