Skip to content

Commit

Permalink
updated copyright for 2024 (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckerns authored Jan 1, 2024
1 parent 06c707c commit e8fc4f6
Show file tree
Hide file tree
Showing 34 changed files with 96 additions and 41 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) 2004-2016 California Institute of Technology.
Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
All rights reserved.

This software is available subject to the conditions and terms laid
Expand Down
2 changes: 1 addition & 1 deletion klepto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/_abc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2021-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2021-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand Down
27 changes: 20 additions & 7 deletions klepto/_archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand Down Expand Up @@ -53,7 +53,7 @@ def __import_pandas__():
#DEAD = "D_" # indicates 'deleted' key


def _to_frame(archive):
def _to_frame(archive):#, keymap=None):
'''convert a klepto archive to a pandas DataFrame'''
if not pandas:
raise ValueError('install pandas for dataframe support')
Expand All @@ -73,14 +73,27 @@ def _to_frame(archive):
#df.sort_index(axis=1, ascending=False, inplace=True)
df.columns.name = d.archive.__class__.__name__#.rsplit('_archive')[0]
df.index.name = repr(d.archive.state)
'''
if len(df) and keymap is not None:
#FIXME: need a generalized inverse of keymap
#HACK: only works in certain special cases
from klepto.keymaps import _stub_decoder
#if isinstance(df.index[0], bytes): keymap = 'pickle'
#elif isinstance(df.index[0], (str, (u'').__class__)): keymap = 'repr'
#else: keymap = None
inv = _stub_decoder(keymap)
df.index = df.index.map(inv)#lambda k: list(inv(k))) #FIXME: correct?
#HACK end
'''
return df


def _from_frame(dataframe):
def _from_frame(dataframe):#, keymap=None):
'''convert a (formatted) pandas dataframe to a klepto archive'''
if not pandas:
raise ValueError('install pandas for dataframe support')
df = dataframe
#if keymap is None: keymap = lambda x:x #XXX: or keymap()?
df = dataframe #XXX: apply keymap here?
d = df.to_dict()
# is cached if has more than one column, one of which is named 'cache'
cached = True if len(df.columns) > 1 else False
Expand All @@ -94,9 +107,9 @@ def _from_frame(dataframe):
index = {}
# should have at least one column; if so, get the name of the column
name = df.columns[0] if len(df.columns) else None
# get the name of the column -- this will be our cached data
# get the name of the column -- this will be our cached data
store = df.columns[1] if cached else cache
# get the data from the first column
# get the data from the first column #XXX: apply keymap here?
data = {} if name is None else dict((k,v) for (k,v) in d[name].items() if repr(v) not in ['nan','NaN'])
# get the archive type, defaulting to dict_archive
col = df.columns.name
Expand All @@ -108,7 +121,7 @@ def _from_frame(dataframe):
d_ = getattr(archives, col, archives.dict_archive)
# get the archive instance
d_ = d_(name, data, cached, **index)
# if cached, add the cache data
# if cached, add the cache data #XXX: apply keymap here?
if cached: d_.archive.update((k,v) for (k,v) in d.get(store,{}).items() if repr(v) not in ['nan','NaN'])
return d_

Expand Down
2 changes: 1 addition & 1 deletion klepto/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand Down
2 changes: 1 addition & 1 deletion klepto/_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Forked by: Mike McKerns (December 2013)
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand Down
2 changes: 1 addition & 1 deletion klepto/archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand Down
2 changes: 1 addition & 1 deletion klepto/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
30 changes: 29 additions & 1 deletion klepto/keymaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand All @@ -28,6 +28,34 @@ def __repr__(self):
from copy import copy
from klepto.crypto import hash, string, pickle

def _stub_decoder(keymap=None):
"generate a keymap decoder from information in the keymap stub"
#FIXME: need to implement generalized inverse of keymap
#HACK: only works in certain special cases
if isinstance(keymap, (str, (u'').__class__)):
from klepto.crypto import algorithms, encodings, serializers
if keymap in serializers(): #FIXME: ignores all config options
import importlib
inv = lambda k: importlib.import_module(keymap).loads(k)
elif keymap in algorithms() or encodings(): #FIXME always assumes repr
inv = lambda k: eval(k)
else: #FIXME: give up, ignore keymap
inv = lambda k: k
return inv
kind = getattr(keymap, '__stub__', '')
if kind in ('encoding', 'algorithm'): #FIXME always assumes repr
inv = lambda k: eval(k)
elif kind in ('serializer', ): #FIXME: ignores all config options
if keymap.__type__ is None:
inv = lambda k: eval(k)
else:
import importlib
inv = lambda k: importlib.import_module(keymap.__type__).loads(k)
else: #FIXME: give up, ignore keymap
inv = lambda k: k
return inv


def __chain__(x, y):
"chain two keymaps: calls 'x' then 'y' on object to produce y(x(object))"
if x is None:
Expand Down
2 changes: 1 addition & 1 deletion klepto/rounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand Down
2 changes: 1 addition & 1 deletion klepto/safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2018-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2018-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2018-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2018-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_alchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_bigdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_cache_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE
"""
Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_cachekeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2014-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_chaining.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_frame.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2019-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2019-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
16 changes: 15 additions & 1 deletion klepto/tests/test_keymaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down Expand Up @@ -53,9 +53,23 @@ def test_picklemap():
encode = picklemap(typed=True, flat=False, serializer='dill')
assert loads(encode(*args, **kwds)) == loads(dumps( (args, kwds, (type(1), type(2)), (type(3), type(4))) ))

def test_stub_decode():
key = [1,2,3,4,5]
from klepto.keymaps import _stub_decoder
k = picklemap(serializer='pickle')
assert _stub_decoder(k)(k(key))[0] == key
assert _stub_decoder('pickle')(k(key))[0] == key
k = picklemap()
assert _stub_decoder(k)(k(key))[0] == key
assert _stub_decoder('repr')(k(key))[0] == key
k = keymap()
assert _stub_decoder(k)(k(key))[0] == key
assert _stub_decoder(None)(k(key))[0] == key


if __name__ == '__main__':
test_keymap()
test_hashmap()
test_stringmap()
test_picklemap()
#test_stub_decode()
2 changes: 1 addition & 1 deletion klepto/tests/test_pickles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_rounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
2 changes: 1 addition & 1 deletion klepto/tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2013-2016 California Institute of Technology.
# Copyright (c) 2016-2023 The Uncertainty Quantification Foundation.
# Copyright (c) 2016-2024 The Uncertainty Quantification Foundation.
# License: 3-clause BSD. The full license text is available at:
# - https://github.com/uqfoundation/klepto/blob/master/LICENSE

Expand Down
Loading

0 comments on commit e8fc4f6

Please sign in to comment.