| name | sciris-utils |
| description | Use when working with Sciris miscellaneous utilities — sc.mergedicts, sc.mergelists, sc.tolist, sc.toarray, sc.isnumber, sc.suggest, sc.download, sc.runcommand, sc.importbypath, sc.loadtext, sc.help, sc.traceback, sc.autolist, sc.pp, or type checking/conversion. |
Sciris Miscellaneous Utilities
Reference for type handling, downloading, and other tools. See full tutorial: docs/tutorials/tut_utils.ipynb.
If you need more detail, use your MCP tools (Context7 or GitMCP) to look up current Sciris documentation, or consult the other Sciris skills.
Type Conversion
Merge dicts (handles None)
def my_func(json=None, **kwargs):
default = dict(a=1, b=2)
output = sc.mergedicts(default, json, kwargs)
return output
Merge lists (auto append/extend)
sc.mergelists(['a', 'b'], 'c', None, {'d': 1})
Flexible conversion
sc.tolist('single')
sc.tolist(['already'])
sc.toarray(2)
sc.toarray([1, 2, 3])
sc.cat(1, [2, 3], np.array([4, 5]))
Auto-incrementing list
output = sc.autolist()
for item in data:
output += f'Result: {item}'
Type Checking
sc.isnumber(3)
sc.isnumber(3.14j)
sc.isnumber('3')
Fuzzy Matching
sc.suggest('Scirys', ['Python', 'NumPy', 'Sciris'], n=2)
Downloading
data = sc.download(urls, save=False)
sc.download(urls, save=True)
Running Shell Commands
out = sc.runcommand('ls *.py', printoutput=True)
Import by Path
old = sc.importbypath('sim_v1/sim.py')
new = sc.importbypath('sim_v2/sim.py')
Help and Debugging
sc.help('interpol')
sc.help('interpol', context=True)
sc.traceback()
sc.loadtext('file.py')
sc.pp(obj)