Rewrite some docstrings in NumpyDoc

This commit is contained in:
David Vierra 2016-06-26 12:15:43 -10:00
parent 55b0dc9aae
commit 042bfa739b
4 changed files with 106 additions and 55 deletions

View File

@ -19,13 +19,18 @@ class BrushShape(QtCore.QObject):
to the widget, and for signaling its client that the user has changed these options. It also
provides an internal string ID and an icon to display in the shape chooser widget.
:cvar ID: String identifier
:type ID: str
:cvar icon: Path to icon file, relative to `mcedit2/assets/mcedit2/icons`
:type icon: basestring
:cvar optionsChanged: This signal should be emitted whenever the options in the BrushShape's
options widget are changed, to notify the shape's client that it should redraw the shape.
:type optionsChanged: Signal
Attributes
----------
ID : unicode
Textual identifier for this shape. Used for preference saving, etc.
icon : unicode
Path to icon file, relative to `mcedit2/assets/mcedit2/icons`
optionsChanged : Signal
This signal should be emitted whenever the options in the BrushShape's
options widget are changed, to notify the shape's client that it should redraw the shape.
"""
ID = NotImplemented
@ -41,12 +46,18 @@ class BrushShape(QtCore.QObject):
TODO: BitmapSelectionBox
:param box: Bounding box of the selection
:type box: BoundingBox
:param dimension: Dimension to create the shaped selection for.
:type dimension: WorldEditorDimension
:return: SelectionBox object that selects all blocks inside this shape
:rtype: SelectionBox
Parameters
----------
box : BoundingBox
Bounding box of the selection
dimension : WorldEditorDimension
Dimension to create the shaped selection for.
Returns
-------
box: SelectionBox
SelectionBox object that selects all blocks inside this shape
"""
return selection.ShapeFuncSelection(box, self.shapeFunc)
@ -70,12 +81,18 @@ class BrushShape(QtCore.QObject):
The size of the shape's bounding box is given by selectionSize.
:param blockPositions: Coordinates of requested blocks relative to Shape's bounding box.
:type blockPositions: numpy.ndarray[ndims=4,dtype=float32]
:param selectionSize: Size of the Shape's bounding box.
:type selectionSize: (int, int, int)
:return: Boolean array of the same shape as blockPositions[0] where selected blocks are True
:rtype: numpy.ndarray[ndims=3,dtype=bool]
Parameters
----------
blockPositions : numpy.ndarray[ndims=4,dtype=float32]
Coordinates of requested blocks relative to Shape's bounding box.
selectionSize : (int, int, int)
Size of the Shape's bounding box.
Returns
-------
mask : numpy.ndarray[ndims=3,dtype=bool]
Boolean array of the same shape as blockPositions[0] where selected blocks are True
"""
raise NotImplementedError
@ -85,11 +102,14 @@ class BrushShape(QtCore.QObject):
If there are no options to present, return None. This is the default implementation.
:return: Options widget
:rtype: QWidget | NoneType
Returns
-------
widget : QWidget | NoneType
"""
return None
class Round(BrushShape):
ID = "Round"
icon = "shapes/round.png"

View File

@ -39,8 +39,10 @@ class IChunkLoaderClient(object):
Return None to request no chunks.
:rtype: (cx, cz)
:return: Chunk coordinates
Returns
-------
chunkPos : (int, int) | None
"""
pass
@ -51,7 +53,10 @@ class IChunkLoaderClient(object):
Return False to skip loading the chunk at the given position.
If all clients return False, the chunk is not loaded.
:rtype: boolean
Returns
-------
wantsChunk : bool
"""
def recieveChunk(self, chunk):
@ -63,10 +68,16 @@ class IChunkLoaderClient(object):
long-running operations on a single chunk to be split over multiple calls to
ChunkLoader.next()
:param chunk: returned by level.getChunk()
:type chunk: WorldEditorChunk
:return: See description
:rtype: Iterable | None
Parameters
----------
chunk : WorldEditorChunk
The chunk returned by level.getChunk()
Returns
-------
worker : Iterable | None
"""
def chunkNotLoaded(self, (cx, cz), exc):
@ -75,8 +86,12 @@ class IChunkLoaderClient(object):
Notifies each client of the chunk's position and the thrown exception.
:param (cx, cz): chunk position
:param exc: The exception that was thrown, usually IOError or LevelFormatError
Parameters
----------
(cx, cz) : (int, int)
Position of the failed chunk.
exc : The Exception object thrown by the world, usually IOError or LevelFormatError
"""
def chunkNotPresent(self, (cx, cz)):
@ -85,7 +100,10 @@ class IChunkLoaderClient(object):
Notifies each client of the chunk's position.
:param (cx, cz): chunk position
Parameters
----------
(cx, cz) : (int, int)
chunk position
"""
def chunkInvalid(self, (cx, cz), deleted):
@ -122,7 +140,11 @@ class ChunkLoader(QtCore.QObject):
to load and process chunks. `StopIteration` will be raised when all clients return None when
requestChunk is called.
:param dimension: WorldEditorDimension
Parameters
----------
dimension : WorldEditorDimension
The dimension to load chunks from.
"""
QtCore.QObject.__init__(self, *args, **kwargs)
@ -149,14 +171,20 @@ class ChunkLoader(QtCore.QObject):
def addClient(self, client, index=-1):
"""
:type client: IChunkLoaderClient
Parameters
----------
client : IChunkLoaderClient
"""
self.clients.insert(index, weakref.ref(client))
log.info("Added: client %s", client)
def removeClient(self, client):
"""
:type client: IChunkLoaderClient
Parameters
----------
client : IChunkLoaderClient
"""
try:
self.clients[:] = [c for c in self.clients if c() is not client]

View File

@ -54,9 +54,11 @@ class SceneUpdateTask(object):
def __init__(self, worldScene, textureAtlas):
"""
:type worldScene: WorldScene
:type bounds: BoundingBox
:type textureAtlas: TextureAtlas
Parameters
----------
worldScene : WorldScene
textureAtlas : TextureAtlas
"""
self.worldScene = worldScene

View File

@ -1,6 +1,7 @@
'''
Base classes for all Minecraft levels.
'''
"""
Classes used in implementing adapters for worlds physically stored as a single array.
Slices of this array are presented as virtual chunks.
"""
from __future__ import absolute_import
from collections import namedtuple
@ -95,7 +96,8 @@ class FakeChunkData(object):
class FakeChunkedLevelAdapter(object):
""" FakeChunkedLevelAdapter is an abstract class for implementing fixed size, non-chunked storage formats.
"""
FakeChunkedLevelAdapter is an abstract class for implementing fixed size, non-chunked storage formats.
Classic, Indev, and Schematic formats inherit from this class. FakeChunkedLevelAdapter has dummy functions for
pretending to have Players, Entities and TileEntities. If Entities and TileEntities already present, provides
a working `getEntities` and `getTileEntities`.
@ -105,22 +107,21 @@ class FakeChunkedLevelAdapter(object):
FakeChunkedLevelAdapter implements IWorld and ISectionWorld.
Required attributes:
Attributes
----------
:ivar Height: int
:ivar Length: int
:ivar Width: int
:ivar Blocks: ndarray of any shape, indexed [x, z, y]
:ivar blocktypes: BlockTypeSet
Height : int
Length : int
Width : int
Blocks : ndarray of any shape, indexed [x, z, y]
blocktypes : BlockTypeSet
Optional attributes:
:ivar Entities: list or TAG_List
:ivar TileEntities: list or TAG_List
:ivar Data: ndarray, same shape and indexes as Blocks
:ivar BlockLight: ndarray, same shape and indexes as Blocks
:ivar SkyLight: ndarray, same shape and indexes as Blocks
:ivar Biomes: ndarray, same x and z sizes as Blocks, indexed [x, z]
Entities : list or TAG_List
TileEntities : list or TAG_List
Data : ndarray, same shape and indexes as Blocks
BlockLight : ndarray, same shape and indexes as Blocks
SkyLight : ndarray, same shape and indexes as Blocks
Biomes : ndarray, same x and z sizes as Blocks, indexed [x, z]
"""