Skip to content

Commit 848fe17

Browse files
committed
fix #832 : implemented CheckedSession, CheckedParameters and CheckedArray classes (based on preliminary code written by gdementen)
1 parent f3921b7 commit 848fe17

14 files changed

+1442
-129
lines changed

README.rst

+6
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ For plotting
129129
- `matplotlib <http://matplotlib.org/>`__:
130130
required for plotting.
131131

132+
Miscellaneous
133+
~~~~~~~~~~~~~
134+
135+
- `pydantic <https://github.com/samuelcolvin/pydantic>`__:
136+
required to use `CheckedSession`.
137+
132138
.. _start-documentation:
133139

134140
Documentation

doc/source/api.rst

+24-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,6 @@ Modifying
795795

796796
Session.add
797797
Session.update
798-
Session.get
799798
Session.apply
800799
Session.transpose
801800

@@ -821,6 +820,30 @@ Load/Save
821820
Session.to_hdf
822821
Session.to_pickle
823822

823+
CheckedArray
824+
============
825+
826+
.. autosummary::
827+
:toctree: _generated/
828+
829+
CheckedArray
830+
831+
CheckedSession
832+
==============
833+
834+
.. autosummary::
835+
:toctree: _generated/
836+
837+
CheckedSession
838+
839+
CheckedParameters
840+
=================
841+
842+
.. autosummary::
843+
:toctree: _generated/
844+
845+
CheckedParameters
846+
824847
.. _api-editor:
825848

826849
Editor

environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ dependencies:
1111
- xlsxwriter
1212
- pytest>=3.5
1313
- flake8
14+
- pydantic<=1.5
1415
- pip:
1516
- pytest-flake8

larray/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
eye, all, any, sum, prod, cumsum, cumprod, min, max, mean, ptp, var,
99
std, median, percentile, stack, zip_array_values, zip_array_items)
1010
from larray.core.session import Session, local_arrays, global_arrays, arrays
11+
from larray.core.checked import CheckedArray, CheckedSession, CheckedParameters
1112
from larray.core.constants import nan, inf, pi, e, euler_gamma
1213
from larray.core.metadata import Metadata
1314
from larray.core.ufuncs import wrap_elementwise_array_func, maximum, minimum, where
@@ -55,6 +56,8 @@
5556
'median', 'percentile', 'stack', 'zip_array_values', 'zip_array_items',
5657
# session
5758
'Session', 'local_arrays', 'global_arrays', 'arrays',
59+
# constrained
60+
'CheckedArray', 'CheckedSession', 'CheckedParameters',
5861
# constants
5962
'nan', 'inf', 'pi', 'e', 'euler_gamma',
6063
# metadata

larray/core/axis.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ def __getitem__(self, key):
839839
-----
840840
key is label-based (slice and fancy indexing are supported)
841841
"""
842-
# if isinstance(key, basestring):
842+
# if isinstance(key, str):
843843
# key = to_keys(key)
844844

845845
def isscalar(k):
@@ -862,7 +862,7 @@ def isscalar(k):
862862
and key.name in self
863863
):
864864
return LGroup(key.name, None, self)
865-
# elif isinstance(key, basestring) and key in self:
865+
# elif isinstance(key, str) and key in self:
866866
# TODO: this is an awful workaround to avoid the "processing" of string keys which exist as is in the axis
867867
# (probably because the string was used in an aggregate function to create the label)
868868
# res = LGroup(slice(None), None, self)

0 commit comments

Comments
 (0)