Exemple #1
0
 def _test_delete_param(self, *pdescs):
     """General method  to test whether the delete_params method works"""
     all_pdescs = [simple_param, simple_param2, complex_param,
                   very_complex_param, simple_multiline_param]
     ds = docrep.DocstringProcessor()
     ds.params['all'] = ref = '\n'.join(all_pdescs)
     params = [pdesc.splitlines()[0].split(':')[0].strip()
               for pdesc in pdescs]
     ds.delete_params('all', *params)
     for pdesc in pdescs:
         ref = re.sub('\n?' + pdesc + '\n?', '\n', ref).strip()
     self.assertEqual(ds.params['all.no_' + '|'.join(params)], ref,
                      msg='Wrong description for params {}'.format(params))
Exemple #2
0
 def _test_delete_types(self, *tdescs):
     """Test whether it works to keep return types"""
     all_tdescs = [simple_return_type, complex_return_type,
                   very_complex_return_type, simple_multiline_return_type]
     types = [tdesc.splitlines()[0].strip()
              for tdesc in tdescs]
     ds = docrep.DocstringProcessor()
     # full check
     ds.params['all'] = ref = '\n'.join(all_tdescs)
     ds.delete_types('all', 'deleted', *types)
     for tdesc in tdescs:
         ref = re.sub('\n?' + tdesc + '\n?', '\n', ref).strip()
     self.assertEqual(ds.params['all.deleted'], ref,
                      msg='Wrong description for return types {}'.format(
                         types))
Exemple #3
0
 def test_keep_params_s(self):
     all_pdescs = [
         simple_param, simple_param2, complex_param, very_complex_param,
         simple_multiline_param
     ]
     pdescs = [simple_param, very_complex_param]
     params = [
         pdesc.splitlines()[0].split(':')[0].strip() for pdesc in pdescs
     ]
     joined_pdescs = '\n'.join(pdescs)
     ds = docrep.DocstringProcessor()
     with self.assertWarnsRegex(DeprecationWarning, 'keep_params_s'):
         txt = ds.keep_params_s('\n'.join(all_pdescs), params)
     # check single
     self.assertEqual(txt,
                      joined_pdescs,
                      msg='Wrong description for params {}'.format(params))
Exemple #4
0
 def _test_keep_types(self, *tdescs):
     """Test whether it works to keep return types"""
     all_tdescs = [simple_return_type, complex_return_type,
                   very_complex_return_type, simple_multiline_return_type]
     types = [tdesc.splitlines()[0].strip()
              for tdesc in tdescs]
     joined_tdescs = '\n'.join(tdescs)
     ds = docrep.DocstringProcessor()
     ds.params['selected'] = joined_tdescs
     ds.keep_types('selected', 'kept', *types)
     # check single
     self.assertEqual(ds.params['selected.kept'], joined_tdescs,
                      msg='Wrong description for return types {}'.format(
                         types))
     # full check
     ds.params['all'] = '\n'.join(all_tdescs)
     ds.keep_types('all', 'kept', *types)
     self.assertEqual(ds.params['all.kept'], joined_tdescs,
                      msg='Wrong description for return types {}'.format(
                         types))
Exemple #5
0
 def _test_keep_params(self, *pdescs):
     """Test whether it works to keep parameters"""
     all_pdescs = [simple_param, simple_param2, complex_param,
                   very_complex_param, simple_multiline_param]
     params = [pdesc.splitlines()[0].split(':')[0].strip()
               for pdesc in pdescs]
     joined_pdescs = '\n'.join(pdescs)
     ds = docrep.DocstringProcessor()
     ds.params['selected'] = joined_pdescs
     ds.keep_params('selected', *params)
     # check single
     self.assertEqual(ds.params['selected.' + '|'.join(params)],
                      joined_pdescs,
                      msg='Wrong description for params {}'.format(params))
     # full check
     ds.params['all'] = '\n'.join(all_pdescs)
     ds.keep_params('all', *params)
     self.assertEqual(ds.params['all.' + '|'.join(params)],
                      joined_pdescs,
                      msg='Wrong description for params {}'.format(params))
Exemple #6
0
 def setUp(self):
     self.ds = docrep.DocstringProcessor()
Exemple #7
0
from __future__ import print_function
from __future__ import absolute_import
from future.utils import iteritems
from collections import OrderedDict
import docrep
import xarray as xr
import numpy as np

from . import comodo
from .duck_array_ops import _pad_array, _apply_boundary_condition, concatenate

docstrings = docrep.DocstringProcessor(doc_key='My doc string')


class Axis:
    """
    An object that represents a group of coodinates that all lie along the same
    physical dimension but at different positions with respect to a grid cell.
    There are four possible positions::

         Center
         |------o-------|------o-------|------o-------|------o-------|
               [0]            [1]            [2]            [3]

         Left
         |------o-------|------o-------|------o-------|------o-------|
        [0]            [1]            [2]            [3]

         Right
         |------o-------|------o-------|------o-------|------o-------|
                       [0]            [1]            [2]            [3]
Exemple #8
0
from __future__ import print_function
from __future__ import absolute_import
from future.utils import iteritems
from collections import OrderedDict
import functools
import itertools
import operator

import docrep
import xarray as xr
import numpy as np

from . import comodo
from .duck_array_ops import _pad_array, _apply_boundary_condition, concatenate

docstrings = docrep.DocstringProcessor(doc_key="My doc string")


def _maybe_promote_str_to_list(a):
    # TODO: improve this
    if isinstance(a, str):
        return [a]
    else:
        return a


class Axis:
    """
    An object that represents a group of coodinates that all lie along the same
    physical dimension but at different positions with respect to a grid cell.
    There are four possible positions::
Exemple #9
0
import sys
import warnings
from collections import OrderedDict
from contextlib import contextmanager

import six

import dask
import docrep
from .deploy import ClusterManager
from distributed import LocalCluster
from distributed.diagnostics.plugin import SchedulerPlugin
from distributed.utils import format_bytes, parse_bytes, tmpfile, get_ip_interface

logger = logging.getLogger(__name__)
docstrings = docrep.DocstringProcessor()

threads_deprecation_message = """
The threads keyword has been removed and the memory keyword has changed.

Please specify job size with the following keywords:

-  cores: total cores per job, across all processes
-  memory: total memory per job, across all processes
-  processes: number of processes to launch, splitting the quantities above
""".strip()


def _job_id_from_worker_name(name):
    """ utility to parse the job ID from the worker name