Skip to content

Commit

Permalink
Merge pull request #353 from sciris/rc2.0.0d
Browse files Browse the repository at this point in the history
Rc2.0.0d
  • Loading branch information
cliffckerr committed Aug 18, 2022
2 parents 6dde4ed + bb90f2e commit bf01fd6
Show file tree
Hide file tree
Showing 25 changed files with 890 additions and 651 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ New functions and methods
#. ``sc.loadyaml()`` and ``sc.saveyaml()`` load and save YAML files, respectively.
#. ``sc.download()`` downloads multiple files in parallel.
#. ``sc.LazyModule()`` handles lazily loaded modules (see ``sc.importbyname()`` for usage).
#. ``sc.parse_env()`` parses environment variables into common types (e.g., will interpret ``'False'`` as ``False``).

Bugfixes
~~~~~~~~
Expand All @@ -34,6 +35,7 @@ Bugfixes
Improvements
~~~~~~~~~~~~
#. If a copy/deepcopy is not possible, ``sc.cp()``/``sc.dcp()`` now raise an exception by default (previously, they silenced it).
#. ``sc.dataframe()`` has been completely revamped, and is now a backwards-compatible extension of ``pd.DataFrame()``.
#. ``sc.timer()`` now has ``plot()`` and ``total()`` methods, as well as ``indivtimings`` and ``cumtimings`` properties.
#. ``sc.strsplit()`` will automatically split common types of delimited strings (e.g. ``sc.strsplit('a b c')``).
#. ``sc.parallelize()`` now supports additional parallelization options, e.g. ``concurrent.futures``, and new ``maxcpu``/``maxmem`` arguments.
Expand All @@ -56,6 +58,7 @@ Improvements
#. ``sc.date()`` can now read ``np.datetime64`` objects.
#. ``sc.wget()`` can now save to files.
#. ``sc.importbyname()`` can now load multiple modules, and load them lazily.
#. ``sc.prettyobj()`` and ``sc.dictobj()`` now both take either positional or keyword arguments, e.g. ``sc.prettyobj(a=3)`` or ``sc.dictobj({'a':3})``.

Housekeeping
~~~~~~~~~~~~
Expand All @@ -66,6 +69,7 @@ Housekeeping
#. Added style and contributing guides.
#. Added official support for Python 3.7-3.10.
#. ``sc.wget()`` was renamed ``sc.urlopen()``.
#. Sciris now has a "lazy loading" option, which does not import submodules, meaning loading is effectively instant. To use, set the environment variable ``SCIRIS_LAZY=1``, then load submodules via e.g. ``from sciris import sc_odict as sco``.

Regression information
~~~~~~~~~~~~~~~~~~~~~~
Expand Down
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ Array operations

File I/O
~~~~~~~~
- ``sc.saveobj()/sc.loadobj()``: efficiently save/load any Python object (via pickling)
- ``sc.save()/sc.load()``: efficiently save/load any Python object (via pickling)
- ``sc.savejson()/sc.loadjson()``: likewise, for JSONs
- ``sc.thisdir()``: get current folder
- ``sc.getfilelist()``: easy way to access glob

Plotting
~~~~~~~~
- ``sc.hex2grb()/sc.rgb2hex()``: convert between different color conventions
- ``sc.hex2rgb()/sc.rgb2hex()``: convert between different color conventions
- ``sc.vectocolor()``: map a list of sequential values onto a list of colors
- ``sc.gridcolors()``: map a list of qualitative categories onto a list of colors
- ``sc.plot3d()/sc.surf3d()``: easy way to render 3D plots
Expand Down Expand Up @@ -117,12 +117,12 @@ Installation and run instructions
2. Use Sciris: ``import sciris as sc``


20-second quick start guide
~~~~~~~~~~~~~~~~~~~~~~~~~~~
20-second quick start guide (for ScirisWeb)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1. Download ScirisWeb (e.g. ``git clone http://github.com/sciris/scirisweb``)

2. Install ScirisWeb (which will install Sciris as well): ``cd scirisweb; python setup.py develop``
2. Install ScirisWeb (which will install Sciris as well): ``cd scirisweb; pip install -e .``

3. Change to the Hello World folder: ``cd examples/helloworld``

Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#

# You can set these variables from the command line.
SPHINXOPTS = -j4
SPHINXOPTS = -jauto
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build
Expand Down
39 changes: 23 additions & 16 deletions sciris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@
of ``sc.sc_parallel.parallelize()``.
"""

# Import everything
from .sc_version import *
from .sc_utils import *
from .sc_printing import *
from .sc_nested import *
from .sc_odict import *
from .sc_settings import *
from .sc_datetime import *
from .sc_math import *
from .sc_dataframe import *
from .sc_fileio import *
from .sc_profiling import *
from .sc_parallel import *
from .sc_asd import *
from .sc_plotting import *
from .sc_colors import *
# Optionally allow lazy loading
import os as _os
_lazy = _os.getenv('SCIRIS_LAZY', False)

# Otherwise, import everything
if not _lazy:
from .sc_version import *
from .sc_utils import *
from .sc_printing import *
from .sc_nested import *
from .sc_odict import *
from .sc_settings import *
from .sc_datetime import *
from .sc_math import *
from .sc_dataframe import *
from .sc_fileio import *
from .sc_profiling import *
from .sc_parallel import *
from .sc_asd import *
from .sc_plotting import *
from .sc_colors import *

del _os, _lazy
26 changes: 15 additions & 11 deletions sciris/ansicolors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
'''
Copy of the ansicolors Python module. Included here to avoid an additional dependency.
Copy of Jonathan Eunice and Georgios Verigakis' ansicolors Python module:
https://pypi.org/project/ansicolors/
Included here to avoid an additional dependency.
Functions here are not intended for direct use by the user, but of course they can be.
New in version 2.0.0.
'''

# Copyright (c) 2012 Giorgos Verigakis <verigak@gmail.com>
Expand All @@ -20,7 +25,6 @@

import re
from functools import partial
from . import sc_utils as scu

# ANSI color names. There is also a "default"
COLORS = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white')
Expand Down Expand Up @@ -48,16 +52,15 @@ def _color_code(spec, base):
try looking up look CSS color names or parsing CSS hex and rgb color
specifications.
:param str|int|tuple|list spec: Unparsed color specification
:param int base: Either 30 or 40, signifying the base value
for color encoding (foreground and background respectively).
Low values are added directly to the base. Higher values use `
base + 8` (i.e. 38 or 48) then extended codes.
:returns: Discovered ANSI color encoding.
:rtype: str
:raises: ValueError if cannot parse the color spec.
"Base" is either 30 or 40, signifying the base value for color encoding
(foreground and background respectively). Low values are added directly
to the base. Higher values use ``base + 8`` (i.e. 38 or 48) then extended codes.
Args:
spec (str|int|tuple|list): Unparsed color specification
base (int): see above
"""
if scu.isstring(spec):
if isinstance(spec, str):
spec = spec.strip().lower()

if spec == 'default':
Expand Down Expand Up @@ -305,6 +308,7 @@ def ansilen(s):


def parse_rgb(s):
''' Convert string to an RGB color '''
if not isinstance(s, str):
raise ValueError(f"Could not parse color '{s}'")
s = s.strip().replace(' ', '').lower()
Expand Down
2 changes: 1 addition & 1 deletion sciris/sc_asd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Adaptive stochastic descent optimization algorithm, building on scipy.optimize.
This algorithm is published as "Optimization by adaptive stochastic descent" by
Kerr et al. (2018).
Kerr et al. (2018) (DOI: https://doi.org/10.1371/journal.pone.0192944).
'''

import numpy as np
Expand Down
8 changes: 4 additions & 4 deletions sciris/sc_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Handle colors and colormaps.
Highlights:
- Adds colormaps including 'turbo', 'parula', and 'orangeblue'
- ``sc.hex2grb()/sc.rgb2hex()``: convert between different color conventions
- ``sc.vectocolor()``: map a list of sequential values onto a list of colors
- ``sc.gridcolors()``: map a list of qualitative categories onto a list of colors
- Adds colormaps including ``'turbo'``, ``'parula'``, and ``'orangeblue'``
- :func:`hex2rgb`/:func:`rgb2hex`: convert between different color conventions
- :func:`vectocolor`: map a list of sequential values onto a list of colors
- :func:`gridcolors`: map a list of qualitative categories onto a list of colors
'''

##############################################################################
Expand Down

0 comments on commit bf01fd6

Please sign in to comment.