From 73ffa646f00c21ddecb9080a224422e4ed16dae2 Mon Sep 17 00:00:00 2001 From: ac-optimus Date: Wed, 1 Apr 2020 19:36:41 +0530 Subject: [PATCH 01/13] numpydoc style --- signac/contrib/schema.py | 76 +++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index ced941d7a..3b0d2d7a5 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -9,12 +9,18 @@ class _Vividict(dict): + """ """ def __missing__(self, key): value = self[key] = type(self)() return value def _collect_by_type(values): + """ + + :param values: + + """ values_by_type = ddict(set) for v in values: values_by_type[type(v)].add(v) @@ -22,6 +28,13 @@ def _collect_by_type(values): def _build_job_statepoint_index(jobs, exclude_const, index): + """ + + :param jobs: + :param exclude_const: + :param index: + + """ from .collection import Collection from .collection import _DictPlaceholder from .utility import _nested_dicts_to_dotted_keys @@ -36,6 +49,11 @@ def _build_job_statepoint_index(jobs, exclude_const, index): def strip_prefix(key): return k[len('statepoint.'):] def remove_dict_placeholder(x): + """ + + :param key): return k[len('statepoint.': + + """ return {k: v for k, v in x.items() if k is not _DictPlaceholder} for k in sorted(tmp, key=lambda k: (len(tmp[k]), k)): @@ -46,6 +64,7 @@ def remove_dict_placeholder(x): class ProjectSchema(object): + """ """ "A description of a project's state point schema." def __init__(self, schema=None): @@ -55,26 +74,25 @@ def __init__(self, schema=None): @classmethod def detect(cls, statepoint_index): + """ + + :param statepoint_index: + + """ return cls({k: _collect_by_type(v) for k, v in statepoint_index}) def format(self, depth=None, precision=None, max_num_range=None): """Format the schema for printing. - :param depth: - A non-zero value will return a nested formatting up to the specified depth, + :param depth: A non-zero value will return a nested formatting up to the specified depth, defaults to 0. - :type depth: - int - :param precision: - Round numerical values up the give precision, defaults to unlimited precision. - :type precision: - int - :param max_num_range: - The maximum number of entries shown for a value range, defaults to 5. - :type max_num_range: - int - :returns: - A formatted representation of the project schema. + :type depth: int + :param precision: Round numerical values up the give precision, defaults to unlimited precision. + :type precision: int + :param max_num_range: The maximum number of entries shown for a value range, defaults to 5. + :type max_num_range: int + :returns: A formatted representation of the project schema. + """ if depth is None: depth = 0 @@ -82,12 +100,23 @@ def format(self, depth=None, precision=None, max_num_range=None): max_num_range = 5 def _fmt_value(x): + """ + + :param x: + + """ if precision is not None and isinstance(x, Number): return str(round(x, precision)) else: return str(x) def _fmt_range(type_, values): + """ + + :param type_: + :param values: + + """ try: sorted_values = sorted(values) except TypeError: @@ -104,6 +133,11 @@ def _fmt_range(type_, values): type_name=type_.__name__, values_string=values_string, length=len(values)) def _fmt_values(values): + """ + + :param values: + + """ return ', '.join(_fmt_range(*v) for v in values.items()) if depth > 0: @@ -151,12 +185,15 @@ def __iter__(self): return iter(self._schema) def keys(self): + """ """ return self._schema.keys() def values(self): + """ """ return self._schema.values() def items(self): + """ """ return self._schema.items() def __eq__(self, other): @@ -165,12 +202,11 @@ def __eq__(self, other): def difference(self, other, ignore_values=False): """Determine the difference between this and another project schema. - :param ignore_values: - Ignore if the value (range) of a specific keys differ, only return missing keys. - :type ignore_values: - bool - :returns: - A set of key tuples that are either missing or different in the other schema. + :param ignore_values: Ignore if the value (range) of a specific keys differ, only return missing keys. (Default value = False) + :type ignore_values: bool + :param other: + :returns: A set of key tuples that are either missing or different in the other schema. + """ ret = set(self.keys()).difference(other.keys()) From 72367aee7900ded8579e8c31649582310c217a37 Mon Sep 17 00:00:00 2001 From: ac-optimus Date: Wed, 1 Apr 2020 20:08:56 +0530 Subject: [PATCH 02/13] changing to numpydoc style --- signac/contrib/schema.py | 96 +++++++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 21 deletions(-) diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index 3b0d2d7a5..87cd6852c 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -18,7 +18,12 @@ def __missing__(self, key): def _collect_by_type(values): """ - :param values: + Parameters + ---------- + values : + + Returns + ------- """ values_by_type = ddict(set) @@ -30,9 +35,16 @@ def _collect_by_type(values): def _build_job_statepoint_index(jobs, exclude_const, index): """ - :param jobs: - :param exclude_const: - :param index: + Parameters + ---------- + jobs : + param exclude_const: + index : + + exclude_const : + + Returns + ------- """ from .collection import Collection @@ -51,7 +63,14 @@ def strip_prefix(key): return k[len('statepoint.'):] def remove_dict_placeholder(x): """ - :param key): return k[len('statepoint.': + Parameters + ---------- + key : + return k[len('statepoint.': + key): return k[len('statepoint.' : + + Returns + ------- """ return {k: v for k, v in x.items() if k is not _DictPlaceholder} @@ -76,7 +95,12 @@ def __init__(self, schema=None): def detect(cls, statepoint_index): """ - :param statepoint_index: + Parameters + ---------- + statepoint_index : + + Returns + ------- """ return cls({k: _collect_by_type(v) for k, v in statepoint_index}) @@ -84,14 +108,20 @@ def detect(cls, statepoint_index): def format(self, depth=None, precision=None, max_num_range=None): """Format the schema for printing. - :param depth: A non-zero value will return a nested formatting up to the specified depth, + Parameters + ---------- + depth : int + A non-zero value will return a nested formatting up to the specified depth, defaults to 0. - :type depth: int - :param precision: Round numerical values up the give precision, defaults to unlimited precision. - :type precision: int - :param max_num_range: The maximum number of entries shown for a value range, defaults to 5. - :type max_num_range: int - :returns: A formatted representation of the project schema. + precision : int + Round numerical values up the give precision, defaults to unlimited precision. + max_num_range : int + The maximum number of entries shown for a value range, defaults to 5. + + Returns + ------- + type + A formatted representation of the project schema. """ if depth is None: @@ -102,7 +132,12 @@ def format(self, depth=None, precision=None, max_num_range=None): def _fmt_value(x): """ - :param x: + Parameters + ---------- + x : + + Returns + ------- """ if precision is not None and isinstance(x, Number): @@ -113,8 +148,14 @@ def _fmt_value(x): def _fmt_range(type_, values): """ - :param type_: - :param values: + Parameters + ---------- + type_ : + param values: + values : + + Returns + ------- """ try: @@ -135,7 +176,12 @@ def _fmt_range(type_, values): def _fmt_values(values): """ - :param values: + Parameters + ---------- + values : + + Returns + ------- """ return ', '.join(_fmt_range(*v) for v in values.items()) @@ -202,10 +248,18 @@ def __eq__(self, other): def difference(self, other, ignore_values=False): """Determine the difference between this and another project schema. - :param ignore_values: Ignore if the value (range) of a specific keys differ, only return missing keys. (Default value = False) - :type ignore_values: bool - :param other: - :returns: A set of key tuples that are either missing or different in the other schema. + Parameters + ---------- + ignore_values : bool + Ignore if the value (range) of a specific keys differ, + only return missing keys. (Default value = False) + other : + returns: A set of key tuples that are either missing or different in the other schema. + + Returns + ------- + type + A set of key tuples that are either missing or different in the other schema. """ From 5dc999f375242feb3f6f0e3930a1e927c0c4266d Mon Sep 17 00:00:00 2001 From: ac-optimus Date: Sat, 4 Apr 2020 22:35:19 +0530 Subject: [PATCH 03/13] updating with changes suggested by @bdice --- signac/contrib/schema.py | 44 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index 87cd6852c..2dea2e952 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -9,23 +9,28 @@ class _Vividict(dict): - """ """ + """A dict that returns an empty _Vividict for keys that are missing. + + Useful for automatically nesting keys with ``vividict['a']['b']['c'] = 'd'``. + """ + def __missing__(self, key): value = self[key] = type(self)() return value def _collect_by_type(values): - """ + """Constructs a mapping of types to a set of elements drawn from the input values. Parameters ---------- - values : + values : An iterable of values. Returns ------- - + A mapping of types to a set of input values of that type. """ + values_by_type = ddict(set) for v in values: values_by_type[type(v)].add(v) @@ -47,6 +52,7 @@ def _build_job_statepoint_index(jobs, exclude_const, index): ------- """ + from .collection import Collection from .collection import _DictPlaceholder from .utility import _nested_dicts_to_dotted_keys @@ -61,18 +67,8 @@ def _build_job_statepoint_index(jobs, exclude_const, index): def strip_prefix(key): return k[len('statepoint.'):] def remove_dict_placeholder(x): - """ + """Removes _DictPlaceholder elements from a mapping.""" - Parameters - ---------- - key : - return k[len('statepoint.': - key): return k[len('statepoint.' : - - Returns - ------- - - """ return {k: v for k, v in x.items() if k is not _DictPlaceholder} for k in sorted(tmp, key=lambda k: (len(tmp[k]), k)): @@ -83,8 +79,7 @@ def remove_dict_placeholder(x): class ProjectSchema(object): - """ """ - "A description of a project's state point schema." + """A description of a project's state point schema.""" def __init__(self, schema=None): if schema is None: @@ -231,15 +226,18 @@ def __iter__(self): return iter(self._schema) def keys(self): - """ """ + """Returns schema keys.""" + return self._schema.keys() def values(self): - """ """ + """Returns schema values.""" + return self._schema.values() def items(self): - """ """ + """Returns schema items.""" + return self._schema.items() def __eq__(self, other): @@ -253,12 +251,12 @@ def difference(self, other, ignore_values=False): ignore_values : bool Ignore if the value (range) of a specific keys differ, only return missing keys. (Default value = False) - other : - returns: A set of key tuples that are either missing or different in the other schema. + other : ProjectSchema + Other project schema. Returns ------- - type + set A set of key tuples that are either missing or different in the other schema. """ From d0ba50389e80cf1ff7281f5878ebb8f05ee1abc2 Mon Sep 17 00:00:00 2001 From: ac-optimus Date: Tue, 7 Apr 2020 01:01:11 +0530 Subject: [PATCH 04/13] numpydoc style conversion --- signac/contrib/schema.py | 49 +++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index 2dea2e952..1222564c5 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -12,8 +12,8 @@ class _Vividict(dict): """A dict that returns an empty _Vividict for keys that are missing. Useful for automatically nesting keys with ``vividict['a']['b']['c'] = 'd'``. - """ + """ def __missing__(self, key): value = self[key] = type(self)() return value @@ -29,8 +29,8 @@ def _collect_by_type(values): Returns ------- A mapping of types to a set of input values of that type. - """ + """ values_by_type = ddict(set) for v in values: values_by_type[type(v)].add(v) @@ -48,11 +48,7 @@ def _build_job_statepoint_index(jobs, exclude_const, index): exclude_const : - Returns - ------- - """ - from .collection import Collection from .collection import _DictPlaceholder from .utility import _nested_dicts_to_dotted_keys @@ -67,8 +63,16 @@ def _build_job_statepoint_index(jobs, exclude_const, index): def strip_prefix(key): return k[len('statepoint.'):] def remove_dict_placeholder(x): - """Removes _DictPlaceholder elements from a mapping.""" + """Removes _DictPlaceholder elements from a mapping. + + Parameters + ---------- + x : + Yields + ------- + + """ return {k: v for k, v in x.items() if k is not _DictPlaceholder} for k in sorted(tmp, key=lambda k: (len(tmp[k]), k)): @@ -79,8 +83,13 @@ def remove_dict_placeholder(x): class ProjectSchema(object): - """A description of a project's state point schema.""" + """A description of a project's state point schema. + Parameters + ---------- + schema : + + """ def __init__(self, schema=None): if schema is None: schema = dict() @@ -227,20 +236,25 @@ def __iter__(self): def keys(self): """Returns schema keys.""" - return self._schema.keys() def values(self): """Returns schema values.""" - return self._schema.values() def items(self): """Returns schema items.""" - return self._schema.items() def __eq__(self, other): + """Check if two schemas are the same. + + Returns + ------- + bool + True if both the schema has has the same values. + + """ return self._schema == other._schema def difference(self, other, ignore_values=False): @@ -260,14 +274,23 @@ def difference(self, other, ignore_values=False): A set of key tuples that are either missing or different in the other schema. """ - ret = set(self.keys()).difference(other.keys()) if not ignore_values: ret.update({k for k, v in self.items() if k in other and other[k] != v}) return ret def __call__(self, jobs_or_statepoints): - "Evaluate the schema for the given state points." + """Evaluate the schema for the given state points. + + Parameters + ---------- + jobs_or_statepoints : + + Returns + ------- + Schema of the project. + + """ s = dict() iterators = itertools.tee(jobs_or_statepoints, len(self)) for key, it in zip(self, iterators): From 8fec64ce4d1c4dcc917bb6995be67a3ef6bde7a6 Mon Sep 17 00:00:00 2001 From: ac-optimus Date: Fri, 10 Apr 2020 16:47:44 +0530 Subject: [PATCH 05/13] adding some more docstrings and schema.py to setup.cfg --- setup.cfg | 4 +-- signac/contrib/schema.py | 62 +++++++++++++++++++++++++++------------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/setup.cfg b/setup.cfg index d9858ae0a..f29f1698e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,8 +15,8 @@ max-line-length = 100 exclude = configobj,passlib,cite.py,conf.py [pydocstyle] -match = jsondict.py -ignore = D105, D107, D203, D213 +match = (jsondict|schema).py +ignore = D105, D107, D203, D204, D213 [coverage:run] source = signac diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index 1222564c5..459c05839 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -1,6 +1,7 @@ -# Copyright (c) 2017 The Regents of the University of Michigan +# Copyright (c) 2017 The Regents of the University of Michigan. # All rights reserved. # This software is licensed under the BSD 3-Clause License. +"""Project Schema.""" from pprint import pformat from collections import defaultdict as ddict from numbers import Number @@ -20,11 +21,12 @@ def __missing__(self, key): def _collect_by_type(values): - """Constructs a mapping of types to a set of elements drawn from the input values. + """Construct a mapping of types to a set of elements drawn from the input values. Parameters ---------- - values : An iterable of values. + values : + An iterable of values. Returns ------- @@ -38,15 +40,22 @@ def _collect_by_type(values): def _build_job_statepoint_index(jobs, exclude_const, index): - """ + """Build index for job statepoints. Parameters ---------- - jobs : - param exclude_const: + jobs : class:`~signac.contrib.job.Job` + Job. index : + A document index. + + exclude_const : bool + Exclude all state point keys that are shared by all jobs within this project. - exclude_const : + Yields + ------ + tupple + Job statepoint index. """ from .collection import Collection @@ -63,14 +72,16 @@ def _build_job_statepoint_index(jobs, exclude_const, index): def strip_prefix(key): return k[len('statepoint.'):] def remove_dict_placeholder(x): - """Removes _DictPlaceholder elements from a mapping. + """Remove _DictPlaceholder elements from a mapping. Parameters ---------- x : + dictionary values. - Yields + Returns ------- + dict """ return {k: v for k, v in x.items() if k is not _DictPlaceholder} @@ -87,7 +98,8 @@ class ProjectSchema(object): Parameters ---------- - schema : + schema : dict + Project schema. """ def __init__(self, schema=None): @@ -97,14 +109,17 @@ def __init__(self, schema=None): @classmethod def detect(cls, statepoint_index): - """ + """Detect Project's state point schema. Parameters ---------- statepoint_index : + statepoint index. Returns ------- + type : `signac.contrib.schema.ProjectSchema` + The detected project schema. """ return cls({k: _collect_by_type(v) for k, v in statepoint_index}) @@ -124,7 +139,7 @@ def format(self, depth=None, precision=None, max_num_range=None): Returns ------- - type + str A formatted representation of the project schema. """ @@ -134,14 +149,16 @@ def format(self, depth=None, precision=None, max_num_range=None): max_num_range = 5 def _fmt_value(x): - """ + """Convert x to string. Parameters ---------- - x : + x : int + integer value to convert to string. Returns ------- + str """ if precision is not None and isinstance(x, Number): @@ -150,16 +167,18 @@ def _fmt_value(x): return str(x) def _fmt_range(type_, values): - """ + """Convert range of values into a single string. Parameters ---------- type_ : - param values: + param values. values : + An iterable of values. Returns ------- + str """ try: @@ -178,14 +197,16 @@ def _fmt_range(type_, values): type_name=type_.__name__, values_string=values_string, length=len(values)) def _fmt_values(values): - """ + """Convert values into a single string. Parameters ---------- values : + An iterable of values. Returns ------- + str """ return ', '.join(_fmt_range(*v) for v in values.items()) @@ -235,15 +256,15 @@ def __iter__(self): return iter(self._schema) def keys(self): - """Returns schema keys.""" + """Return schema keys.""" return self._schema.keys() def values(self): - """Returns schema values.""" + """Return schema values.""" return self._schema.values() def items(self): - """Returns schema items.""" + """Return schema items.""" return self._schema.items() def __eq__(self, other): @@ -285,6 +306,7 @@ def __call__(self, jobs_or_statepoints): Parameters ---------- jobs_or_statepoints : + jobs or statepoints of Project. Returns ------- From 55182b638ec67baf580f210698b8e2d5a6aab6ef Mon Sep 17 00:00:00 2001 From: ac-optimus Date: Sat, 11 Apr 2020 00:25:15 +0530 Subject: [PATCH 06/13] adding changes suggested by @bdice --- signac/contrib/schema.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index 459c05839..add2431eb 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -1,7 +1,8 @@ -# Copyright (c) 2017 The Regents of the University of Michigan. +# Copyright (c) 2017 The Regents of the University of Michigan # All rights reserved. # This software is licensed under the BSD 3-Clause License. """Project Schema.""" + from pprint import pformat from collections import defaultdict as ddict from numbers import Number @@ -30,7 +31,8 @@ def _collect_by_type(values): Returns ------- - A mapping of types to a set of input values of that type. + defaultdict(set) + A mapping of types to a set of input values of that type. """ values_by_type = ddict(set) @@ -54,7 +56,7 @@ def _build_job_statepoint_index(jobs, exclude_const, index): Yields ------ - tupple + tuple Job statepoint index. """ @@ -82,6 +84,7 @@ def remove_dict_placeholder(x): Returns ------- dict + Dictionary with ``_DictPlaceholder`` keys removed. """ return {k: v for k, v in x.items() if k is not _DictPlaceholder} @@ -114,7 +117,7 @@ def detect(cls, statepoint_index): Parameters ---------- statepoint_index : - statepoint index. + State point index. Returns ------- @@ -133,7 +136,7 @@ def format(self, depth=None, precision=None, max_num_range=None): A non-zero value will return a nested formatting up to the specified depth, defaults to 0. precision : int - Round numerical values up the give precision, defaults to unlimited precision. + Round numerical values to the given precision, defaults to unlimited precision. max_num_range : int The maximum number of entries shown for a value range, defaults to 5. @@ -149,16 +152,17 @@ def format(self, depth=None, precision=None, max_num_range=None): max_num_range = 5 def _fmt_value(x): - """Convert x to string. + """Convert a value to a string, rounded to a given precision. Parameters ---------- - x : int - integer value to convert to string. + x : float or int + Value to convert to string. Returns ------- str + Formatted value. """ if precision is not None and isinstance(x, Number): @@ -167,7 +171,9 @@ def _fmt_value(x): return str(x) def _fmt_range(type_, values): - """Convert range of values into a single string. + """Convert sequence of values into a comma-separated string. + + Inserts an ellipsis (...) if the number of values exceeds ``max_num_range``. Parameters ---------- @@ -179,6 +185,7 @@ def _fmt_range(type_, values): Returns ------- str + Comma-separated string for squence of values passed. """ try: @@ -310,7 +317,8 @@ def __call__(self, jobs_or_statepoints): Returns ------- - Schema of the project. + type : `signac.contrib.schema.ProjectSchema` + Schema of the project. """ s = dict() From 032a7f1556bc068aa17c45cf8bc080bddb21441e Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 13 Apr 2020 13:31:46 -0400 Subject: [PATCH 07/13] Remove unused 'jobs' argument and update docstrings for _build_job_statepoint_index. --- signac/contrib/import_export.py | 2 +- signac/contrib/project.py | 6 ++---- signac/contrib/schema.py | 21 ++++++++++----------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/signac/contrib/import_export.py b/signac/contrib/import_export.py index 9c20b6f6d..0ad956a8d 100644 --- a/signac/contrib/import_export.py +++ b/signac/contrib/import_export.py @@ -49,7 +49,7 @@ def _make_schema_based_path_function(jobs, exclude_keys=None, delimiter_nested=' return lambda job, sep=None: '' index = [{'_id': job._id, 'statepoint': job.sp()} for job in jobs] - jsi = _build_job_statepoint_index(jobs=jobs, exclude_const=True, index=index) + jsi = _build_job_statepoint_index(exclude_const=True, index=index) sp_index = OrderedDict(jsi) paths = dict() diff --git a/signac/contrib/project.py b/signac/contrib/project.py index 105c0cc09..20b4f075b 100644 --- a/signac/contrib/project.py +++ b/signac/contrib/project.py @@ -551,8 +551,7 @@ def build_job_statepoint_index(self, exclude_const=False, index=None): from .schema import _build_job_statepoint_index if index is None: index = [{'_id': job._id, 'statepoint': job.sp()} for job in self] - for x, y in _build_job_statepoint_index( - jobs=self, exclude_const=exclude_const, index=index): + for x, y in _build_job_statepoint_index(exclude_const=exclude_const, index=index): yield tuple(x.split('.')), y def detect_schema(self, exclude_const=False, subset=None, index=None): @@ -578,8 +577,7 @@ def detect_schema(self, exclude_const=False, subset=None, index=None): if subset is not None: subset = {str(s) for s in subset} index = [doc for doc in index if doc['_id'] in subset] - statepoint_index = _build_job_statepoint_index( - jobs=self, exclude_const=exclude_const, index=index) + statepoint_index = _build_job_statepoint_index(exclude_const=exclude_const, index=index) return ProjectSchema.detect(statepoint_index) @deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__, diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index add2431eb..efa413b75 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -41,24 +41,23 @@ def _collect_by_type(values): return values_by_type -def _build_job_statepoint_index(jobs, exclude_const, index): - """Build index for job statepoints. +def _build_job_statepoint_index(exclude_const, index): + """Build index for job state points. Parameters ---------- - jobs : class:`~signac.contrib.job.Job` - Job. - index : - A document index. - exclude_const : bool - Exclude all state point keys that are shared by all jobs within this project. + Excludes state point keys whose values are constant across the index. + index : + An iterable of state points. Yields ------ - tuple - Job statepoint index. - + statepoint_key : str + State point key. + statepoint_values : dict + Dictionary mapping from a state point value to the set of job ids + with that state point value. """ from .collection import Collection from .collection import _DictPlaceholder From 92433ec22cde0759f9a48c7971b8e19a06772725 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 13 Apr 2020 13:34:48 -0400 Subject: [PATCH 08/13] Add missing blank line. --- signac/contrib/schema.py | 1 + 1 file changed, 1 insertion(+) diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index efa413b75..a9fe8b3b0 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -58,6 +58,7 @@ def _build_job_statepoint_index(exclude_const, index): statepoint_values : dict Dictionary mapping from a state point value to the set of job ids with that state point value. + """ from .collection import Collection from .collection import _DictPlaceholder From 591bd0ee476520f8d093d36ab916fdbb34edd400 Mon Sep 17 00:00:00 2001 From: ac-optimus Date: Tue, 14 Apr 2020 20:47:21 +0530 Subject: [PATCH 09/13] adding changes as suggested by @bdice --- signac/contrib/schema.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index a9fe8b3b0..a473725bf 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -79,7 +79,7 @@ def remove_dict_placeholder(x): Parameters ---------- x : - dictionary values. + Dictionary from which ``_DictPlaceholder`` values will be removed. Returns ------- @@ -121,7 +121,7 @@ def detect(cls, statepoint_index): Returns ------- - type : `signac.contrib.schema.ProjectSchema` + ProjectSchema The detected project schema. """ @@ -156,7 +156,7 @@ def _fmt_value(x): Parameters ---------- - x : float or int + x : Value to convert to string. Returns @@ -177,15 +177,15 @@ def _fmt_range(type_, values): Parameters ---------- - type_ : - param values. + type_ : type + Type of values. values : An iterable of values. Returns ------- str - Comma-separated string for squence of values passed. + Comma-separated string of the input values. """ try: @@ -280,7 +280,7 @@ def __eq__(self, other): Returns ------- bool - True if both the schema has has the same values. + True if both schemas have the same keys and values. """ return self._schema == other._schema @@ -292,7 +292,7 @@ def difference(self, other, ignore_values=False): ---------- ignore_values : bool Ignore if the value (range) of a specific keys differ, - only return missing keys. (Default value = False) + only return missing keys (Default value = False). other : ProjectSchema Other project schema. @@ -313,11 +313,11 @@ def __call__(self, jobs_or_statepoints): Parameters ---------- jobs_or_statepoints : - jobs or statepoints of Project. + An iterable of jobs or state points. Returns ------- - type : `signac.contrib.schema.ProjectSchema` + ProjectSchema Schema of the project. """ From 250530a38762f5b51bc00a1574e75eace9cc52dd Mon Sep 17 00:00:00 2001 From: ac-optimus Date: Thu, 16 Apr 2020 13:38:06 +0530 Subject: [PATCH 10/13] adding one more doc string --- signac/contrib/schema.py | 1 + 1 file changed, 1 insertion(+) diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index a473725bf..d4460b92b 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -214,6 +214,7 @@ def _fmt_values(values): Returns ------- str + Comma-separated string of the input values. """ return ', '.join(_fmt_range(*v) for v in values.items()) From 3232138db57f31788324380041a9a7b280654aec Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 16 Apr 2020 09:34:16 -0400 Subject: [PATCH 11/13] Use variable names matching the return names. --- signac/contrib/schema.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index d4460b92b..c4542a46b 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -93,7 +93,9 @@ def remove_dict_placeholder(x): if exclude_const and len(tmp[k]) == 1 \ and len(tmp[k][list(tmp[k].keys())[0]]) == len(collection): continue - yield strip_prefix(k), remove_dict_placeholder(tmp[k]) + statepoint_key = strip_prefix(k) + statepoint_values = remove_dict_placeholder(tmp[k]) + yield statepoint_key, statepoint_values class ProjectSchema(object): From 4f8462680ec8dea0e09557f55369519cd94bc79c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 21 Apr 2020 17:18:58 -0400 Subject: [PATCH 12/13] Switch to using napoleon to enable rendering of numpy docstrings. --- doc/conf.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 4138066ce..6a9e8bbe8 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -46,11 +46,9 @@ def __getattr__(cls, name): # ones. extensions = [ 'sphinx.ext.autodoc', - 'sphinx.ext.coverage', - #'sphinx.ext.viewcode', 'sphinx.ext.intersphinx', - 'sphinx.ext.mathjax', 'nbsphinx', + 'sphinx.ext.napoleon', 'IPython.sphinxext.ipython_console_highlighting', 'sphinx.ext.autosummary', ] From be9530bb943a51510434bb30a658908408774109 Mon Sep 17 00:00:00 2001 From: ac-optimus Date: Wed, 22 Apr 2020 14:38:39 +0530 Subject: [PATCH 13/13] correcting link to ProjectSchema class --- signac/contrib/schema.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/signac/contrib/schema.py b/signac/contrib/schema.py index c4542a46b..bc12bc6f4 100644 --- a/signac/contrib/schema.py +++ b/signac/contrib/schema.py @@ -123,7 +123,7 @@ def detect(cls, statepoint_index): Returns ------- - ProjectSchema + :class:`~ProjectSchema` The detected project schema. """ @@ -296,7 +296,7 @@ def difference(self, other, ignore_values=False): ignore_values : bool Ignore if the value (range) of a specific keys differ, only return missing keys (Default value = False). - other : ProjectSchema + other : :class:`~ProjectSchema` Other project schema. Returns @@ -320,7 +320,7 @@ def __call__(self, jobs_or_statepoints): Returns ------- - ProjectSchema + :class:`~ProjectSchema` Schema of the project. """