class_docstr: A class for partitioning a sequence using a map.
docstr: Returns the pth partition of q partitions of seq.
  
  The length can be specified as `n`,
  otherwise it is the value of `len(seq)`
docstr_tok: ["Returns","the","pth","partition","of","q","partitions","of","seq",".","The","length","can","be","specified","as","`","n","`",",","otherwise","it","is","the","value","of","`","len","(","seq",")","`"]
code: def getPartition(self, seq, p, q, n=None):
      """Returns the pth partition of q partitions of seq.
  
      The length can be specified as `n`,
      otherwise it is the value of `len(seq)`
      """
      n = len(seq) if n is None else n
      # Test for error conditions here
      if p < 0 or p >= q:
          raise ValueError(
              f"must have 0 <= p <= q, but have p={p},q={q}"
          )
  
      remainder = n % q
      basesize = n // q
  
      if p < remainder:
          low = p * (basesize + 1)
          high = low + basesize + 1
      else:
          low = p * basesize + remainder
          high = low + basesize
  
      try:
          result = seq[low:high]
      except TypeError:
          # some objects (iterators) can't be sliced,
          # use islice:
          result = list(islice(seq, low, high))
  
      return result
  
file_path: ipyparallel/ipyparallel/client/map.py
imports: import sys
  from itertools import chain, islice
label_desc: Use image node_id 1 for calling the Map obj's underlying member method code with example usage: obj.getPartition(seq, p, q, n) and returns: result