uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8d13342adea8a119e68de7cf | train | function | def easeInOutQuart(t, b, c, d):
# t is the current time (or position) of the tween.
# b is the beginning value of the property.
# c is the change between the beginning and destination value of the property.
# d is the total time of the tween.
t /= d/2
if t < 1:
return c/2*t*t*t*t + b
t -= 2
return... | def easeInOutQuart(t, b, c, d):
# t is the current time (or position) of the tween.
# b is the beginning value of the property.
# c is the change between the beginning and destination value of the property.
# d is the total time of the tween.
| t /= d/2
if t < 1:
return c/2*t*t*t*t + b
t -= 2
return -c/2 * (t*t*t*t - 2) + b
| def easeInOutQuart(t, b, c, d):
# t is the current time (or position) of the tween.
# b is the beginning value of the property.
# c is the change between the beginning and destination value of the property.
# d is the total time of the tween.
| 66 | 64 | 113 | 66 | 0 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | easeInOutQuart | easeInOutQuart | 208 | 217 | 208 | 212 | 56162f3d5755e2470998f125a903be6714f250a0 | bigcode/the-stack | train |
449f3dad288892946e004e18 | train | function | def setBlockHeights():
# calculate height of text
for textBlock in textBlocks:
tbHeight = (textBlock['textSize'] * heightOffsetPct)
textBlock['height'] = tbHeight
| def setBlockHeights():
# calculate height of text
| for textBlock in textBlocks:
tbHeight = (textBlock['textSize'] * heightOffsetPct)
textBlock['height'] = tbHeight
| , textBlock['keyframes']))
maxKeyframe = list(filter(lambda x: x['frameIndex'] >= frameIndex, textBlock['keyframes']))
return minKeyframe[len(minKeyframe)-1], maxKeyframe[0]
def setBlockHeights():
# calculate height of text
| 63 | 64 | 47 | 13 | 50 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | setBlockHeights | setBlockHeights | 239 | 243 | 239 | 240 | e73f64ac945e0277c1ba27ae0b166496e5e1ee6e | bigcode/the-stack | train |
1fce43cfd323ad9f2f914f82 | train | function | def equalizeKeyframePct():
for textBlock in textBlocks:
i = 0
for keyframe in textBlock['keyframes']:
keyframe['pct'] = i / (len(textBlock['keyframes']) - 1)
i += 1
| def equalizeKeyframePct():
| for textBlock in textBlocks:
i = 0
for keyframe in textBlock['keyframes']:
keyframe['pct'] = i / (len(textBlock['keyframes']) - 1)
i += 1
| ()
addIndexesToTextBlocks()
def addIndexesToTextBlocks():
for textBlock in textBlocks:
for keyframe in textBlock['keyframes']:
keyframe['frameIndex'] = int((numFrames-1) * keyframe['pct'])
def equalizeKeyframePct():
| 63 | 64 | 59 | 7 | 56 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | equalizeKeyframePct | equalizeKeyframePct | 157 | 162 | 157 | 157 | bc3fe55a0322f3a9f1185cb2036eb3d92936074e | bigcode/the-stack | train |
1c5fdfb878316d0627dc049f | train | function | def setCurrentLetter(letter):
for textBlock in textBlocks:
textBlock['text'] = letter
| def setCurrentLetter(letter):
| for textBlock in textBlocks:
textBlock['text'] = letter
| ():
setup()
drawFrames()
if saveEnabled:
saveImage(exportPath)
def setup():
variableFontInfo()
newDrawing()
#setCurrentLetter(letter)
prepKeyframes()
setBlockHeights()
setBlockYpositions()
def setCurrentLetter(letter):
| 63 | 64 | 23 | 6 | 57 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | setCurrentLetter | setCurrentLetter | 142 | 144 | 142 | 142 | 53cca2a4316c4128cb10fc74f3b2f2c6d3dd3624 | bigcode/the-stack | train |
ba2c9e9f9f9cc9f537c79af8 | train | function | def drawFrames():
for frameIndex in range(numFrames):
drawFrame(frameIndex)
| def drawFrames():
| for frameIndex in range(numFrames):
drawFrame(frameIndex)
|
def equalizeKeyframePct():
for textBlock in textBlocks:
i = 0
for keyframe in textBlock['keyframes']:
keyframe['pct'] = i / (len(textBlock['keyframes']) - 1)
i += 1
def drawFrames():
| 64 | 64 | 19 | 4 | 59 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | drawFrames | drawFrames | 164 | 166 | 164 | 164 | ab9756f5ac732c2b58ad40997b9078e8ab75f61e | bigcode/the-stack | train |
a9702ecd81d699a9322b774c | train | function | def easeInOutQuad(t, b, c, d):
t /= d/2
if t < 1:
return c/2*t*t + b
t-=1
return -c/2 * (t*(t-2) - 1) + b
| def easeInOutQuad(t, b, c, d):
| t /= d/2
if t < 1:
return c/2*t*t + b
t-=1
return -c/2 * (t*(t-2) - 1) + b
| of the tween.
t /= d/2
if t < 1:
return c/2*t*t*t*t + b
t -= 2
return -c/2 * (t*t*t*t - 2) + b
def easeInOutQuad(t, b, c, d):
| 64 | 64 | 59 | 13 | 50 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | easeInOutQuad | easeInOutQuad | 219 | 224 | 219 | 219 | bf8f0fb99a795e2370cc1a94acf2b8ab97bd0415 | bigcode/the-stack | train |
c173643d28976c300fc13ef3 | train | function | def setup():
variableFontInfo()
newDrawing()
#setCurrentLetter(letter)
prepKeyframes()
setBlockHeights()
setBlockYpositions()
| def setup():
| variableFontInfo()
newDrawing()
#setCurrentLetter(letter)
prepKeyframes()
setBlockHeights()
setBlockYpositions()
| baseline to the top of the main mass of your letterforms.
heightOffsetPct = 0.8
# show this to help set theHeight offset.
displayHelpers = False
def main():
setup()
drawFrames()
if saveEnabled:
saveImage(exportPath)
def setup():
| 63 | 64 | 36 | 3 | 60 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | setup | setup | 134 | 140 | 134 | 134 | 9d4839a4df94997ff2e7c4055a25ac55d1a4ab6b | bigcode/the-stack | train |
e023689e2d66e4a834f95931 | train | function | def addIndexesToTextBlocks():
for textBlock in textBlocks:
for keyframe in textBlock['keyframes']:
keyframe['frameIndex'] = int((numFrames-1) * keyframe['pct'])
| def addIndexesToTextBlocks():
| for textBlock in textBlocks:
for keyframe in textBlock['keyframes']:
keyframe['frameIndex'] = int((numFrames-1) * keyframe['pct'])
| Ypositions()
def setCurrentLetter(letter):
for textBlock in textBlocks:
textBlock['text'] = letter
def prepKeyframes():
if shouldEqualizeKeyframePct:
equalizeKeyframePct()
addIndexesToTextBlocks()
def addIndexesToTextBlocks():
| 63 | 64 | 47 | 7 | 56 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | addIndexesToTextBlocks | addIndexesToTextBlocks | 152 | 155 | 152 | 152 | fdc53dba90a5e323e64197d4aba665d170183aeb | bigcode/the-stack | train |
b83c37656dd435d37382d099 | train | function | def prepKeyframes():
if shouldEqualizeKeyframePct:
equalizeKeyframePct()
addIndexesToTextBlocks()
| def prepKeyframes():
| if shouldEqualizeKeyframePct:
equalizeKeyframePct()
addIndexesToTextBlocks()
| ():
variableFontInfo()
newDrawing()
#setCurrentLetter(letter)
prepKeyframes()
setBlockHeights()
setBlockYpositions()
def setCurrentLetter(letter):
for textBlock in textBlocks:
textBlock['text'] = letter
def prepKeyframes():
| 63 | 64 | 28 | 5 | 57 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | prepKeyframes | prepKeyframes | 147 | 150 | 147 | 147 | 9d9259e6429e49745accc91e41ac2473b9cfe9e6 | bigcode/the-stack | train |
cbb9d2160d888782cd02ce93 | train | function | def relevantKeyframes(frameIndex, textBlock):
minKeyframe = list(filter(lambda x: x['frameIndex'] <= frameIndex, textBlock['keyframes']))
maxKeyframe = list(filter(lambda x: x['frameIndex'] >= frameIndex, textBlock['keyframes']))
return minKeyframe[len(minKeyframe)-1], maxKeyframe[0]
| def relevantKeyframes(frameIndex, textBlock):
| minKeyframe = list(filter(lambda x: x['frameIndex'] <= frameIndex, textBlock['keyframes']))
maxKeyframe = list(filter(lambda x: x['frameIndex'] >= frameIndex, textBlock['keyframes']))
return minKeyframe[len(minKeyframe)-1], maxKeyframe[0]
| 0]['frameIndex']
if frameSpan == 0:
frameSpan = 1
framesIntoKeyframe = frameIndex - keyframes[0]['frameIndex']
pctComplete = framesIntoKeyframe / frameSpan
return pctComplete
def relevantKeyframes(frameIndex, textBlock):
| 64 | 64 | 78 | 10 | 53 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | relevantKeyframes | relevantKeyframes | 234 | 237 | 234 | 234 | 3217975daad369a02d12e48f15a3fda1d5824d50 | bigcode/the-stack | train |
837d458f60a9d1fe5f17e690 | train | function | def setBlockYpositions():
# calculate y position of line
textBlockHeightTotal = sum(textBlock['height'] for textBlock in textBlocks)
spacerHeightTotal = len(textBlocks) * spaceBetweenBlocks
totalHeight = textBlockHeightTotal + spacerHeightTotal
top = docHeight - ((docHeight - totalHeight) / 2) + tex... | def setBlockYpositions():
# calculate y position of line
| textBlockHeightTotal = sum(textBlock['height'] for textBlock in textBlocks)
spacerHeightTotal = len(textBlocks) * spaceBetweenBlocks
totalHeight = textBlockHeightTotal + spacerHeightTotal
top = docHeight - ((docHeight - totalHeight) / 2) + textBoxVerticalOffset
for textBlock in textBlocks:
... | 0]
def setBlockHeights():
# calculate height of text
for textBlock in textBlocks:
tbHeight = (textBlock['textSize'] * heightOffsetPct)
textBlock['height'] = tbHeight
def setBlockYpositions():
# calculate y position of line
| 64 | 64 | 121 | 14 | 49 | futurefonts/type-animations | variable-fonts-blog-post/tweak-dance.py | Python | setBlockYpositions | setBlockYpositions | 245 | 254 | 245 | 246 | 04362e3c5ddac5afd05bea15279c26d6dc26ebfb | bigcode/the-stack | train |
f29c5bab35ea3d3ee8f0127d | train | class | class AxrefValidator(_plotly_utils.basevalidators.EnumeratedValidator):
def __init__(self, plotly_name="axref", parent_name="layout.annotation", **kwargs):
super(AxrefValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
edit_type=kwargs.pop("edit_t... | class AxrefValidator(_plotly_utils.basevalidators.EnumeratedValidator):
| def __init__(self, plotly_name="axref", parent_name="layout.annotation", **kwargs):
super(AxrefValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
edit_type=kwargs.pop("edit_type", "calc"),
values=kwargs.pop(
"values", ... | import _plotly_utils.basevalidators
class AxrefValidator(_plotly_utils.basevalidators.EnumeratedValidator):
| 23 | 64 | 121 | 15 | 7 | mastermind88/plotly.py | packages/python/plotly/plotly/validators/layout/annotation/_axref.py | Python | AxrefValidator | AxrefValidator | 4 | 14 | 4 | 4 | 8919198d43d8b851435bebc46a2eecf62c677832 | bigcode/the-stack | train |
5827647d2738fb02ba8eed4a | train | function | def uninitializePlugin(mobject):
mplugin = OpenMayaMPx.MFnPlugin(mobject)
try:
mplugin.deregisterCommand(kPluginCmdName)
except:
sys.stderr.write("Failed to unregister command: %s\n" % kPluginCmdName)
raise
try:
mplugin.deregisterNode(kPluginNodeId)
except:
sys.stderr.write("Failed to deregis... | def uninitializePlugin(mobject):
| mplugin = OpenMayaMPx.MFnPlugin(mobject)
try:
mplugin.deregisterCommand(kPluginCmdName)
except:
sys.stderr.write("Failed to unregister command: %s\n" % kPluginCmdName)
raise
try:
mplugin.deregisterNode(kPluginNodeId)
except:
sys.stderr.write("Failed to deregister node: %s" % kPluginNodeTypeNam... | PluginCmdName)
raise
try:
mplugin.registerNode(kPluginNodeTypeName, kPluginNodeId, nodeCreator, nodeInitializer)
except:
sys.stderr.write( "Failed to register node: %s" % kPluginNodeTypeName)
raise
def uninitializePlugin(mobject):
| 64 | 64 | 98 | 7 | 56 | leegoonz/Maya-devkit | win/devkit/plug-ins/scripted/splitUVCmd.py | Python | uninitializePlugin | uninitializePlugin | 688 | 700 | 688 | 688 | 5a216685d8c463134490b640f4540ed27546fa77 | bigcode/the-stack | train |
a387bff9f6fc26db10bf600a | train | class | class splitUVFty(polyModifier.polyModifierFty):
def __init__(self):
polyModifier.polyModifierFty.__init__(self)
# Mesh Node
# Note: We only make use of this MObject during a single call of
# the splitUV plugin. It is never maintained and used between
# calls to the plugin as the MObject handle could ... | class splitUVFty(polyModifier.polyModifierFty):
| def __init__(self):
polyModifier.polyModifierFty.__init__(self)
# Mesh Node
# Note: We only make use of this MObject during a single call of
# the splitUV plugin. It is never maintained and used between
# calls to the plugin as the MObject handle could be invalidated
# between calls to the plugin.... | List = compListFn.object()
#####################################################################
## FACTORY ##########################################################
#####################################################################
# Overview:
#
# The splitUV factory implements the actual splitUV oper... | 256 | 256 | 989 | 12 | 244 | leegoonz/Maya-devkit | win/devkit/plug-ins/scripted/splitUVCmd.py | Python | splitUVFty | splitUVFty | 387 | 507 | 387 | 387 | 7983cb71c5e618ad43eb95d06309f99cc2805284 | bigcode/the-stack | train |
92c6498a6ec58983cbfe7949 | train | function | def cmdCreator():
return OpenMayaMPx.asMPxPtr(splitUV())
| def cmdCreator():
| return OpenMayaMPx.asMPxPtr(splitUV())
| statusError("ERROR in splitUVFty.doIt()")
# Mark the output mesh as clean
#
outputData.setClean()
else:
return OpenMaya.kUnknownParameter
return None
#####################################################################
## REGISTRATION ##############################################... | 64 | 64 | 17 | 4 | 59 | leegoonz/Maya-devkit | win/devkit/plug-ins/scripted/splitUVCmd.py | Python | cmdCreator | cmdCreator | 636 | 637 | 636 | 636 | 879ea8e754b45ba460e3e9b050a8c2da82a9cf1c | bigcode/the-stack | train |
b3d9322975122930d2ec8e0d | train | function | def nodeCreator():
return OpenMayaMPx.asMPxPtr(splitUVNode())
| def nodeCreator():
| return OpenMayaMPx.asMPxPtr(splitUVNode())
| output mesh as clean
#
outputData.setClean()
else:
return OpenMaya.kUnknownParameter
return None
#####################################################################
## REGISTRATION #####################################################
###################################################... | 63 | 64 | 18 | 4 | 59 | leegoonz/Maya-devkit | win/devkit/plug-ins/scripted/splitUVCmd.py | Python | nodeCreator | nodeCreator | 640 | 641 | 640 | 640 | 080747779721fa78652012421688247e417ee235 | bigcode/the-stack | train |
8cc68e6ae4e8f53846c1870b | train | function | def statusError(message):
fullMsg = "Status failed: %s\n" % message
sys.stderr.write(fullMsg)
OpenMaya.MGlobal.displayError(fullMsg)
raise # called from exception handlers only, reraise exception
| def statusError(message):
| fullMsg = "Status failed: %s\n" % message
sys.stderr.write(fullMsg)
OpenMaya.MGlobal.displayError(fullMsg)
raise # called from exception handlers only, reraise exception
| OR ITS LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY
# OR PROBABILITY OF SUCH DAMAGES.
#
# ==========================================================================
#+
import maya.OpenMaya as OpenMaya
import maya.OpenMayaMPx as OpenMayaMPx
import sys
import polyModifier
def statusError(message):
| 64 | 64 | 50 | 5 | 58 | leegoonz/Maya-devkit | win/devkit/plug-ins/scripted/splitUVCmd.py | Python | statusError | statusError | 45 | 49 | 45 | 45 | e843b308bbb835352ddc865d4aa4752ce49fa437 | bigcode/the-stack | train |
46f26ba9c412d2237f1356fd | train | class | class splitUV(polyModifier.polyModifierCmd):
def __init__(self):
polyModifier.polyModifierCmd.__init__(self)
# Selected UVs
#
# Note: The MObject, fComponentList, is only ever accessed on a single call to the plugin.
# It is never accessed between calls and is stored on the class for access in the
... | class splitUV(polyModifier.polyModifierCmd):
| def __init__(self):
polyModifier.polyModifierCmd.__init__(self)
# Selected UVs
#
# Note: The MObject, fComponentList, is only ever accessed on a single call to the plugin.
# It is never accessed between calls and is stored on the class for access in the
# overriden initModifierNode() method.
#... | (fullMsg)
raise # called from exception handlers only, reraise exception
kPluginCmdName = "spSplitUV"
kPluginNodeTypeName = "spSplitUVNode"
kPluginNodeId = OpenMaya.MTypeId(0x87013)
#####################################################################
## COMMAND ##########################################... | 255 | 256 | 2,275 | 9 | 246 | leegoonz/Maya-devkit | win/devkit/plug-ins/scripted/splitUVCmd.py | Python | splitUV | splitUV | 81 | 353 | 81 | 81 | c0012b80f2255a62040a9c2ba2c292e6a4f9a378 | bigcode/the-stack | train |
25f918df5538f485d9c3ae63 | train | function | def nodeInitializer():
attrFn = OpenMaya.MFnTypedAttribute()
splitUVNode.uvList = attrFn.create("inputComponents", "ics", OpenMaya.MFnComponentListData.kComponentList)
attrFn.setStorable(True) # To be stored during file-save
splitUVNode.inMesh = attrFn.create("inMesh", "im", OpenMaya.MFnMeshData.kMesh)
at... | def nodeInitializer():
| attrFn = OpenMaya.MFnTypedAttribute()
splitUVNode.uvList = attrFn.create("inputComponents", "ics", OpenMaya.MFnComponentListData.kComponentList)
attrFn.setStorable(True) # To be stored during file-save
splitUVNode.inMesh = attrFn.create("inMesh", "im", OpenMaya.MFnMeshData.kMesh)
attrFn.setStorable(True) #... | It()")
# Mark the output mesh as clean
#
outputData.setClean()
else:
return OpenMaya.kUnknownParameter
return None
#####################################################################
## REGISTRATION #####################################################
###########################... | 90 | 91 | 304 | 4 | 86 | leegoonz/Maya-devkit | win/devkit/plug-ins/scripted/splitUVCmd.py | Python | nodeInitializer | nodeInitializer | 644 | 670 | 644 | 644 | 43a301100605528373f58e97af040ac7a60168a0 | bigcode/the-stack | train |
5c30e8fc0ea270cda21629b9 | train | class | class splitUVNode(polyModifier.polyModifierNode):
uvList = OpenMaya.MObject()
def __init__(self):
polyModifier.polyModifierNode.__init__(self)
self.fSplitUVFactory = splitUVFty()
def compute(self, plug, data):
"""
Description:
This method computes the value of the given output plug based
... | class splitUVNode(polyModifier.polyModifierNode):
| uvList = OpenMaya.MObject()
def __init__(self):
polyModifier.polyModifierNode.__init__(self)
self.fSplitUVFactory = splitUVFty()
def compute(self, plug, data):
"""
Description:
This method computes the value of the given output plug based
on the values of the input attributes.
Arg... | 0)
uPtr = uParam.asFloatPtr()
vParam = OpenMaya.MScriptUtil(0.0)
vPtr = vParam.asFloatPtr()
meshFn.getUV(uvId, uPtr, vPtr, selUVSet)
u = uParam.getFloat(uPtr)
v = vParam.getFloat(vPtr)
# Get the number of faces sharing the current UV
#
faceCount = selUVFaceOffsetMap[i + 1] - sel... | 256 | 256 | 875 | 10 | 245 | leegoonz/Maya-devkit | win/devkit/plug-ins/scripted/splitUVCmd.py | Python | splitUVNode | splitUVNode | 514 | 629 | 514 | 514 | 458a06288b758dcdc9d90ba4bcefa5e8f1d80b66 | bigcode/the-stack | train |
eb6e3410c4ceea180ccfcb4a | train | function | def initializePlugin(mobject):
mplugin = OpenMayaMPx.MFnPlugin(mobject, "Autodesk", "1.0", "Any")
try:
mplugin.registerCommand(kPluginCmdName, cmdCreator)
except:
sys.stderr.write( "Failed to register command: %s\n" % kPluginCmdName)
raise
try:
mplugin.registerNode(kPluginNodeTypeName, kPluginNode... | def initializePlugin(mobject):
| mplugin = OpenMayaMPx.MFnPlugin(mobject, "Autodesk", "1.0", "Any")
try:
mplugin.registerCommand(kPluginCmdName, cmdCreator)
except:
sys.stderr.write( "Failed to register command: %s\n" % kPluginCmdName)
raise
try:
mplugin.registerNode(kPluginNodeTypeName, kPluginNodeId, nodeCreator, nodeInitializer... | # then be recomputed the next time the value of the output is requested.
#
splitUVNode.attributeAffects(splitUVNode.inMesh, splitUVNode.outMesh)
splitUVNode.attributeAffects(splitUVNode.uvList, splitUVNode.outMesh)
def initializePlugin(mobject):
| 64 | 64 | 123 | 6 | 58 | leegoonz/Maya-devkit | win/devkit/plug-ins/scripted/splitUVCmd.py | Python | initializePlugin | initializePlugin | 673 | 685 | 673 | 673 | d0467d1d136bd528cfe4940785c986666a910fa6 | bigcode/the-stack | train |
14de7a0675a4de1b627541dd | train | class | class TestEventServer(unittest.TestCase):
def test_event_server(self):
"""
Tests that the EventServer correctly broadcasts events to multiple
clients.
"""
event_srv = event_server.EventServer(PORT)
event_srv.start()
time.sleep(5) # Allow the event server time ... | class TestEventServer(unittest.TestCase):
| def test_event_server(self):
"""
Tests that the EventServer correctly broadcasts events to multiple
clients.
"""
event_srv = event_server.EventServer(PORT)
event_srv.start()
time.sleep(5) # Allow the event server time to accept clients
event_client_a ... | import logging
import os
import select
import socket
import time
import unittest
from jobmon.protocol import *
from jobmon import event_server, transport
logging.basicConfig(filename='jobmon-test_event_server.log', level=logging.DEBUG)
PORT = 9999
class TestEventServer(unittest.TestCase):
| 63 | 75 | 252 | 8 | 54 | adamnew123456/jobmon | jobmon/test/test_event_server.py | Python | TestEventServer | TestEventServer | 15 | 49 | 15 | 15 | 7a6a5d1c129bb476f2fb533746eb0d98ce0853b9 | bigcode/the-stack | train |
dc1385d79d014a7019302848 | train | function | @jit
def core(n):
a = np.zeros(8, dtype=np.uint8)
for i in range(8):
a[i] = (n >> i * 2) & 3
if a[1] == 1 and a[0] == 0:
a[0] = 1
if a[1] == 1 and a[2] == 0:
a[0] = 1
if a[3] == 1 and a[2] == 0:
a[2] = 1
if a[3] == 1 and a[4] == 0:
a[4] = 1
if a[5] == ... | @jit
def core(n):
| a = np.zeros(8, dtype=np.uint8)
for i in range(8):
a[i] = (n >> i * 2) & 3
if a[1] == 1 and a[0] == 0:
a[0] = 1
if a[1] == 1 and a[2] == 0:
a[0] = 1
if a[3] == 1 and a[2] == 0:
a[2] = 1
if a[3] == 1 and a[4] == 0:
a[4] = 1
if a[5] == 1 and a[4] == 0:
... | 7], 0, a[3]], [a[6], a[5], a[4]]])
n = label(a, strc)[1]
return n < 2
"""
lut = np.array([count(n) for n in range(256)])
lut = np.dot(lut.reshape((-1,8)), [1,2,4,8,16,32,64,128]).astype(np.uint8)
print(lut)
"""
@jit
def core(n):
| 103 | 103 | 344 | 7 | 96 | Pad0y/imagepy | imagepy/ipyalg/hydrology/ridge.py | Python | core | core | 27 | 56 | 27 | 28 | 2f2b67e4fb5a8a590baea98c4b9be8c0ecf6c3e0 | bigcode/the-stack | train |
fc1685646549f47c770c7c32 | train | function | @jit
def fill(img, msk, p, level, up, pts, s, c, nbs, buf):
n = 0
cur = 0
buf[0] = p
msk[p] = 2
bs = 1
while cur < bs:
p = buf[cur]
for dp in nbs:
cp = p + dp
if msk[cp] != 0:
continue
if up and img[cp] < level or not up and img... | @jit
def fill(img, msk, p, level, up, pts, s, c, nbs, buf):
| n = 0
cur = 0
buf[0] = p
msk[p] = 2
bs = 1
while cur < bs:
p = buf[cur]
for dp in nbs:
cp = p + dp
if msk[cp] != 0:
continue
if up and img[cp] < level or not up and img[cp] > level:
buf[bs] = cp
m... | w, +w - 1, -1], dtype=np.int32)
def nbs4(h, w):
return np.array([-1, -w, 1, w], dtype=np.int32)
@jit
def fill(img, msk, p, level, up, pts, s, c, nbs, buf):
| 71 | 71 | 239 | 27 | 44 | Pad0y/imagepy | imagepy/ipyalg/hydrology/ridge.py | Python | fill | fill | 109 | 137 | 109 | 110 | 9b1755dd8c4e651de64a0c0d170f1656554b8bf4 | bigcode/the-stack | train |
76276e847dc7b87c91f3d2fc | train | function | @jit
def clear(msk, pts, s, cur):
ns = 0
nc = 0
for c in range(s):
if msk[pts[c]] == 1:
pts[ns] = pts[c]
ns += 1
if c < cur:
nc += 1
return ns, nc
| @jit
def clear(msk, pts, s, cur):
| ns = 0
nc = 0
for c in range(s):
if msk[pts[c]] == 1:
pts[ns] = pts[c]
ns += 1
if c < cur:
nc += 1
return ns, nc
| filled = True
if filled:
cur += 1
continue
elif msk[p] == 1:
check(msk, p, nbs8, lut)
cur += 1
return cur
@jit
def clear(msk, pts, s, cur):
| 64 | 64 | 78 | 14 | 49 | Pad0y/imagepy | imagepy/ipyalg/hydrology/ridge.py | Python | clear | clear | 201 | 211 | 201 | 202 | 314ac3ba905df40153c12308b9f8be2097a13cf3 | bigcode/the-stack | train |
e54e4d98349612ddfbc922bd | train | function | def nbs8(h, w):
return np.array([-w - 1, -w, -w + 1, +1, +w + 1, +w, +w - 1, -1], dtype=np.int32)
| def nbs8(h, w):
| return np.array([-w - 1, -w, -w + 1, +1, +w + 1, +w, +w - 1, -1], dtype=np.int32)
| 207,
51,
207,
1,
207,
204,
0,
204,
207,
51,
207,
51,
],
dtype=np.uint8,
)
def nbs8(h, w):
| 64 | 64 | 53 | 8 | 56 | Pad0y/imagepy | imagepy/ipyalg/hydrology/ridge.py | Python | nbs8 | nbs8 | 101 | 102 | 101 | 101 | 7f9aff28931eb2a4a368316ee44178c5ddeacb54 | bigcode/the-stack | train |
6498a5b35e7b498a140b82da | train | function | @jit
def step(img, msk, pts, s, level, up, nbs, nbs8):
ddd = 0
cur = 0
buf = np.zeros(10240, dtype=np.int64)
while cur < s:
p = pts[cur]
if up and img[p] > level or not up and img[p] < level:
cur += 1
continue
filled = False
for dp in nbs:
... | @jit
def step(img, msk, pts, s, level, up, nbs, nbs8):
| ddd = 0
cur = 0
buf = np.zeros(10240, dtype=np.int64)
while cur < s:
p = pts[cur]
if up and img[p] > level or not up and img[p] < level:
cur += 1
continue
filled = False
for dp in nbs:
cp = p + dp
if msk[cp] == 4:
... | i * 2
if v == 3:
c |= 3 << i * 2
v = index[c]
if lut[v // 8] >> v % 8 & 1:
msk[p] = 2
else:
msk[p] = 3
@jit
def step(img, msk, pts, s, level, up, nbs, nbs8):
| 92 | 92 | 308 | 25 | 66 | Pad0y/imagepy | imagepy/ipyalg/hydrology/ridge.py | Python | step | step | 160 | 198 | 160 | 161 | 80040018ed5075ede10a0549a9ab12d86c5bc413 | bigcode/the-stack | train |
262f7e06341f1c000622a001 | train | function | def nbs4(h, w):
return np.array([-1, -w, 1, w], dtype=np.int32)
| def nbs4(h, w):
| return np.array([-1, -w, 1, w], dtype=np.int32)
| 8,
)
def nbs8(h, w):
return np.array([-w - 1, -w, -w + 1, +1, +w + 1, +w, +w - 1, -1], dtype=np.int32)
def nbs4(h, w):
| 64 | 64 | 28 | 8 | 56 | Pad0y/imagepy | imagepy/ipyalg/hydrology/ridge.py | Python | nbs4 | nbs4 | 105 | 106 | 105 | 105 | 2f2502198c4295619a421ec9cb3c19a2360cbc87 | bigcode/the-stack | train |
ce3a4eb4717eddeab1e3bf55 | train | function | @jit
def ridge(img, mark, up=True):
oimg, omark = img, mark
ndim = img.ndim
mark[[0, -1], :] = 4
mark[:, [0, -1]] = 4
nb4 = nbs4(*img.shape)
nb8 = nbs8(*img.shape)
acc = np.cumprod((1,) + img.shape[::-1][:-1])[::-1]
img = img.ravel()
mark = mark.ravel()
pts = np.zeros(131072, d... | @jit
def ridge(img, mark, up=True):
| oimg, omark = img, mark
ndim = img.ndim
mark[[0, -1], :] = 4
mark[:, [0, -1]] = 4
nb4 = nbs4(*img.shape)
nb8 = nbs8(*img.shape)
acc = np.cumprod((1,) + img.shape[::-1][:-1])[::-1]
img = img.ravel()
mark = mark.ravel()
pts = np.zeros(131072, dtype=np.int64)
s, bins = collect... | 0
for dp in nbs:
if mark[p + dp] == 2:
s += 0
mark[p] = 1
pts[cur] = p
cur += 1
break
if s == 0:
bins[img[p]] += 1
return cur, bins
@jit
def ridge(img, mark, up=True):
| 86 | 86 | 289 | 12 | 73 | Pad0y/imagepy | imagepy/ipyalg/hydrology/ridge.py | Python | ridge | ridge | 246 | 280 | 246 | 247 | a7a539c06c519d7b14bb88ece6ccf9eb0652594a | bigcode/the-stack | train |
51e812719a0b1895ea3fee1a | train | function | def count(n):
a = [(n >> i) & 1 for i in range(8)]
if sum(a) <= 1:
return False
if a[1] & a[3] & a[5] & a[7]:
return False
a = np.array([[a[0], a[1], a[2]], [a[7], 0, a[3]], [a[6], a[5], a[4]]])
n = label(a, strc)[1]
return n < 2
| def count(n):
| a = [(n >> i) & 1 for i in range(8)]
if sum(a) <= 1:
return False
if a[1] & a[3] & a[5] & a[7]:
return False
a = np.array([[a[0], a[1], a[2]], [a[7], 0, a[3]], [a[6], a[5], a[4]]])
n = label(a, strc)[1]
return n < 2
| import numpy as np
from numba import jit
from scipy.ndimage import label, generate_binary_structure
strc = np.ones((3, 3), dtype=np.bool)
def count(n):
| 41 | 64 | 122 | 4 | 37 | Pad0y/imagepy | imagepy/ipyalg/hydrology/ridge.py | Python | count | count | 9 | 17 | 9 | 9 | 13250e073c58dfa6be0d69215df277588faec723 | bigcode/the-stack | train |
a6cd1a672252fd51c150e901 | train | function | @jit
def collect(img, mark, nbs, pts):
bins = np.zeros(img.max() + 1, dtype=np.uint32)
cur = 0
for p in range(len(mark)):
if mark[p] != 0:
continue
for dp in nbs:
if mark[p + dp] == 1:
mark[p] = 2
for p in range(len(mark)):
if mark[p] == ... | @jit
def collect(img, mark, nbs, pts):
| bins = np.zeros(img.max() + 1, dtype=np.uint32)
cur = 0
for p in range(len(mark)):
if mark[p] != 0:
continue
for dp in nbs:
if mark[p + dp] == 1:
mark[p] = 2
for p in range(len(mark)):
if mark[p] == 1:
mark[p] = 2
for p i... | c in range(s):
if msk[pts[c]] == 1:
pts[ns] = pts[c]
ns += 1
if c < cur:
nc += 1
return ns, nc
@jit
def collect(img, mark, nbs, pts):
| 64 | 64 | 205 | 14 | 49 | Pad0y/imagepy | imagepy/ipyalg/hydrology/ridge.py | Python | collect | collect | 214 | 243 | 214 | 215 | 8a259736586f4597dacae9542d6269e50f1a975d | bigcode/the-stack | train |
cf6b078a9fd43c2dd24e9ab9 | train | function | @jit
def check(msk, p, nbs, lut):
c = 0
s = 0
for i in range(8):
v = msk[p + nbs[i]]
# if v==0: c|=(0<<i*2)
if v == 1:
c |= 1 << i * 2
if v == 2:
c |= 2 << i * 2
if v == 3:
c |= 3 << i * 2
v = index[c]
if lut[v // 8] >> v % ... | @jit
def check(msk, p, nbs, lut):
| c = 0
s = 0
for i in range(8):
v = msk[p + nbs[i]]
# if v==0: c|=(0<<i*2)
if v == 1:
c |= 1 << i * 2
if v == 2:
c |= 2 << i * 2
if v == 3:
c |= 3 << i * 2
v = index[c]
if lut[v // 8] >> v % 8 & 1:
msk[p] = 2
else... | s, c = clear(msk, pts, s, c)
pts[s] = cp
msk[cp] = 1
s += 1
cur += 1
return s, c
@jit
def check(msk, p, nbs, lut):
| 64 | 64 | 160 | 15 | 48 | Pad0y/imagepy | imagepy/ipyalg/hydrology/ridge.py | Python | check | check | 140 | 157 | 140 | 141 | aef1304e2efad57366e5cd41d1c1e3a9f9779deb | bigcode/the-stack | train |
4e4dfce893cbe4c62843843f | train | function | def is_enrollment_row(tag):
"""
True if the tag is an enrollment row
:param tag: the tag to check
:return: true if the tag is an enrollment row
"""
is_tr = tag.name == 'tr'
cells = tag.find_all('td')
has_2_cells = len(cells) == 2
has_enrollment_title = cells[0].get_text() == 'Enrol... | def is_enrollment_row(tag):
| """
True if the tag is an enrollment row
:param tag: the tag to check
:return: true if the tag is an enrollment row
"""
is_tr = tag.name == 'tr'
cells = tag.find_all('td')
has_2_cells = len(cells) == 2
has_enrollment_title = cells[0].get_text() == 'Enroll' \
if has_2_cells ... | """
Register me silly
Notifies me when classes are available
Author: Anshul Kharbanda
Created: 5 - 26 - 2019
"""
from requests import get
from bs4 import BeautifulSoup
def is_enrollment_row(tag):
| 56 | 64 | 119 | 7 | 48 | andydevs/register-me-silly | register_me_silly/enrollment.py | Python | is_enrollment_row | is_enrollment_row | 12 | 25 | 12 | 12 | d232f793861f6cb5312710331aac2f38b2458a56 | bigcode/the-stack | train |
38dc8d8ab60e90f29d1ac883 | train | function | def has_enrollment_available(url):
"""
Returns true if the url has enrollment available
:param url: the url of the class to pull from
:return: true if the url has enrollment available
"""
try:
# Get soup
soup = BeautifulSoup(get(url).content, 'html.parser')
# Return t... | def has_enrollment_available(url):
| """
Returns true if the url has enrollment available
:param url: the url of the class to pull from
:return: true if the url has enrollment available
"""
try:
# Get soup
soup = BeautifulSoup(get(url).content, 'html.parser')
# Return true if enrollment row is not closed... | ')
has_2_cells = len(cells) == 2
has_enrollment_title = cells[0].get_text() == 'Enroll' \
if has_2_cells else False
return is_tr and has_2_cells and has_enrollment_title
def has_enrollment_available(url):
| 64 | 64 | 122 | 7 | 56 | andydevs/register-me-silly | register_me_silly/enrollment.py | Python | has_enrollment_available | has_enrollment_available | 28 | 46 | 28 | 28 | e49c5c520fc0dc773f5d9bdb7959868c762e2fd1 | bigcode/the-stack | train |
c9556f81cceb17f95ac1d523 | train | class | class CNNInterface(object):
# Optionally provdide a the location of the CIFAR-10 batches. If not provided,
# Keras will download the data set.
def __init__(self, data_dir=None):
self.data = self.__load_data(data_dir)
# Initial individuals contain no layers in the backbone, and have a default l... | class CNNInterface(object):
# Optionally provdide a the location of the CIFAR-10 batches. If not provided,
# Keras will download the data set.
| def __init__(self, data_dir=None):
self.data = self.__load_data(data_dir)
# Initial individuals contain no layers in the backbone, and have a default learning rate.
def generate_init(self):
return {'layers': [], 'skips': [], 'lr': 0.1}
def read_dna(self, individual):
try:
... | import copy
import glob
import os
import pickle
import random
import time
import keras
import keras.backend as K
from keras.datasets import cifar10
from keras.layers import Activation, Conv2D, Dense, Dropout, Flatten, Input, MaxPooling2D
from keras.layers.normalization import BatchNormalization
from keras.models impor... | 168 | 256 | 3,141 | 37 | 131 | wn9081/LargeScaleEvolution | lse/lse_cnn.py | Python | CNNInterface | CNNInterface | 20 | 335 | 20 | 23 | c4203cc16ff58e5eaa2f4cb0a7d40addb8e961c1 | bigcode/the-stack | train |
112ec9557f4cf720a13dc762 | train | class | class CartPoleEnv(gym.Env):
# This is a continuous version of gym's cartpole environment, with the only difference
# being valid actions are any numbers in the range [-1, 1], and the are applied as
# a multiplicative factor to the total force.
metadata = {"render.modes": ["human", "rgb_array"], "video.f... | class CartPoleEnv(gym.Env):
# This is a continuous version of gym's cartpole environment, with the only difference
# being valid actions are any numbers in the range [-1, 1], and the are applied as
# a multiplicative factor to the total force.
| metadata = {"render.modes": ["human", "rgb_array"], "video.frames_per_second": 50}
def __init__(self):
self.gravity = 9.8
self.masscart = 1.0
self.masspole = 0.1
self.total_mass = self.masspole + self.masscart
self.length = 2.5 # actually half the pole's length
s... | import math
import gym
import numpy as np
from gym import logger, spaces
from gym.utils import seeding
class CartPoleEnv(gym.Env):
# This is a continuous version of gym's cartpole environment, with the only difference
# being valid actions are any numbers in the range [-1, 1], and the are applied as
# a mu... | 86 | 256 | 1,768 | 61 | 24 | MarkSelden/mbrl-lib | mbrl/env/cartpole_continuous.py | Python | CartPoleEnv | CartPoleEnv | 9 | 197 | 9 | 12 | 080cfd4d717d7ae5e847c607fd280b270d9e02fa | bigcode/the-stack | train |
8f4ff00e83a6ac9e8e486337 | train | class | class CartPoleMorphEnv(gym.Env):
"""
Description:
A pole is attached by an un-actuated joint to a cart, which moves along
a frictionless track. The pendulum starts upright, and the goal is to
prevent it from falling over by increasing and reducing the cart's
velocity. The environ... | class CartPoleMorphEnv(gym.Env):
| """
Description:
A pole is attached by an un-actuated joint to a cart, which moves along
a frictionless track. The pendulum starts upright, and the goal is to
prevent it from falling over by increasing and reducing the cart's
velocity. The environment also has the added functiona... | width / 2,
-polewidth / 2,
)
pole.v = [(l, b), (l, t), (r, t), (r, b)]
x = self.state
cartx = x[0] * scale + screen_width / 2.0 # MIDDLE OF CART
self.carttrans.set_translation(cartx, carty)
self.poletrans.set_rotation(-x[2])
return self.viewer.rende... | 256 | 256 | 2,697 | 9 | 246 | MarkSelden/mbrl-lib | mbrl/env/cartpole_continuous.py | Python | CartPoleMorphEnv | CartPoleMorphEnv | 200 | 484 | 200 | 200 | 2ea69f1eed3789611da9c75196195674c17d8275 | bigcode/the-stack | train |
64f330b5434f8bca34fb91aa | train | function | def test_bar_color_none_alpha():
ax = plt.gca()
rects = ax.bar([1, 2], [2, 4], alpha=0.3, color='none', edgecolor='r')
for rect in rects:
assert rect.get_facecolor() == (0, 0, 0, 0)
assert rect.get_edgecolor() == (1, 0, 0, 0.3)
| def test_bar_color_none_alpha():
| ax = plt.gca()
rects = ax.bar([1, 2], [2, 4], alpha=0.3, color='none', edgecolor='r')
for rect in rects:
assert rect.get_facecolor() == (0, 0, 0, 0)
assert rect.get_edgecolor() == (1, 0, 0, 0.3)
| chart with Decimal() height
ax = fig_test.subplots()
ax.barh(x, y, height=h, align='center')
# Reference image
ax = fig_ref.subplots()
ax.barh(x, y, height=h0, align='center')
def test_bar_color_none_alpha():
| 63 | 64 | 96 | 7 | 56 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_bar_color_none_alpha | test_bar_color_none_alpha | 1,596 | 1,601 | 1,596 | 1,596 | 03b5b3708d8d59d697509c053fc169b29c96d6ea | bigcode/the-stack | train |
3f1607df095f7eaf8a18a4a5 | train | function | @check_figures_equal(extensions=["png"])
def test_barh_decimal_height(fig_test, fig_ref):
x = [1.5, 8.4, 5.3, 4.2]
y = [1.1, 2.2, 3.3, 4.4]
h0 = [0.7, 1.45, 1, 2]
h = [Decimal(i) for i in h0]
# Test image - horizontal bar chart with Decimal() height
ax = fig_test.subplots()
ax.barh(x... | @check_figures_equal(extensions=["png"])
def test_barh_decimal_height(fig_test, fig_ref):
| x = [1.5, 8.4, 5.3, 4.2]
y = [1.1, 2.2, 3.3, 4.4]
h0 = [0.7, 1.45, 1, 2]
h = [Decimal(i) for i in h0]
# Test image - horizontal bar chart with Decimal() height
ax = fig_test.subplots()
ax.barh(x, y, height=h, align='center')
# Reference image
ax = fig_ref.subplots()
ax.b... | ax.bar(x, y, width=w, align='center')
# Reference image
ax = fig_ref.subplots()
ax.bar(x, y, width=w0, align='center')
@check_figures_equal(extensions=["png"])
def test_barh_decimal_height(fig_test, fig_ref):
| 63 | 64 | 165 | 23 | 40 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_barh_decimal_height | test_barh_decimal_height | 1,582 | 1,593 | 1,582 | 1,583 | 42e7250baff53566180fbf5f77f2e9d31aaf6b4d | bigcode/the-stack | train |
664ea78f86c37100aca5c55e | train | function | def test_annotate_default_arrow():
# Check that we can make an annotation arrow with only default properties.
fig, ax = plt.subplots()
ann = ax.annotate("foo", (0, 1), xytext=(2, 3))
assert ann.arrow_patch is None
ann = ax.annotate("foo", (0, 1), xytext=(2, 3), arrowprops={})
assert ann.ar... | def test_annotate_default_arrow():
# Check that we can make an annotation arrow with only default properties.
| fig, ax = plt.subplots()
ann = ax.annotate("foo", (0, 1), xytext=(2, 3))
assert ann.arrow_patch is None
ann = ax.annotate("foo", (0, 1), xytext=(2, 3), arrowprops={})
assert ann.arrow_patch is not None
| , 1, 1)
assert ax.get_xlim() == (0.8, 2.2)
assert ax.get_ylim() == (0.8, 2.2)
def test_annotate_default_arrow():
# Check that we can make an annotation arrow with only default properties.
| 64 | 64 | 98 | 23 | 41 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_annotate_default_arrow | test_annotate_default_arrow | 578 | 584 | 578 | 579 | a5f5f6d780d34071fe3845c2e06e6d3bdd388605 | bigcode/the-stack | train |
a3f30f8f74c19d6051602384 | train | function | def test_invalid_axis_limits():
plt.plot([0, 1], [0, 1])
with pytest.raises(ValueError):
plt.xlim(np.nan)
with pytest.raises(ValueError):
plt.xlim(np.inf)
with pytest.raises(ValueError):
plt.ylim(np.nan)
with pytest.raises(ValueError):
plt.ylim(np.inf)
| def test_invalid_axis_limits():
| plt.plot([0, 1], [0, 1])
with pytest.raises(ValueError):
plt.xlim(np.nan)
with pytest.raises(ValueError):
plt.xlim(np.inf)
with pytest.raises(ValueError):
plt.ylim(np.nan)
with pytest.raises(ValueError):
plt.ylim(np.inf)
| = ax.bar([0, 1], [0, 1], edgecolor=(.1, .2, .3, .4))
assert rect1.get_edgecolor() == rect2.get_edgecolor() == (.1, .2, .3, .4)
def test_invalid_axis_limits():
| 64 | 64 | 77 | 6 | 58 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_invalid_axis_limits | test_invalid_axis_limits | 6,203 | 6,212 | 6,203 | 6,203 | ad21e79ba05f811cb2cb6e816b944557cc6620b7 | bigcode/the-stack | train |
f8ac583c5dd1ed2e1c87038b | train | function | @image_comparison(['stackplot_test_image', 'stackplot_test_image'])
def test_stackplot():
fig = plt.figure()
x = np.linspace(0, 10, 10)
y1 = 1.0 * x
y2 = 2.0 * x + 1
y3 = 3.0 * x + 2
ax = fig.add_subplot(1, 1, 1)
ax.stackplot(x, y1, y2, y3)
ax.set_xlim((0, 10))
ax.set_ylim(... | @image_comparison(['stackplot_test_image', 'stackplot_test_image'])
def test_stackplot():
| fig = plt.figure()
x = np.linspace(0, 10, 10)
y1 = 1.0 * x
y2 = 2.0 * x + 1
y3 = 3.0 * x + 2
ax = fig.add_subplot(1, 1, 1)
ax.stackplot(x, y1, y2, y3)
ax.set_xlim((0, 10))
ax.set_ylim((0, 70))
# Reuse testcase from above for a labeled data test
data = {"x": x, "y1... | ax.set_xlim(-1, 10)
ax.set_yscale('log')
with pytest.warns(UserWarning, match='Attempted to set non-positive'):
ax.set_ylim(-1, 10)
@image_comparison(['stackplot_test_image', 'stackplot_test_image'])
def test_stackplot():
| 66 | 66 | 222 | 21 | 45 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_stackplot | test_stackplot | 2,549 | 2,566 | 2,549 | 2,550 | ee4ec6203cbf69e56feb07f4644fac7514e21c3d | bigcode/the-stack | train |
23aaf500b163617e1dc21399 | train | function | @pytest.mark.parametrize("use_line_collection", [True, False],
ids=['w/ line collection', 'w/o line collection'])
@image_comparison(['stem.png'], style='mpl20', remove_text=True)
def test_stem(use_line_collection):
x = np.linspace(0.1, 2 * np.pi, 100)
fig, ax = plt.subplots()
... | @pytest.mark.parametrize("use_line_collection", [True, False],
ids=['w/ line collection', 'w/o line collection'])
@image_comparison(['stem.png'], style='mpl20', remove_text=True)
def test_stem(use_line_collection):
| x = np.linspace(0.1, 2 * np.pi, 100)
fig, ax = plt.subplots()
# Label is a single space to force a legend to be drawn, but to avoid any
# text being drawn
ax.stem(x, np.cos(x),
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ',
use_line_collection=use_line_col... | w2), histtype="stepfilled", stacked=True)
@pytest.mark.parametrize("use_line_collection", [True, False],
ids=['w/ line collection', 'w/o line collection'])
@image_comparison(['stem.png'], style='mpl20', remove_text=True)
def test_stem(use_line_collection):
| 64 | 64 | 152 | 52 | 12 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_stem | test_stem | 3,622 | 3,634 | 3,622 | 3,625 | 2bd7325ac88079b7fd29cbfb454623701ab6b0ce | bigcode/the-stack | train |
908e8dc5fbc2e677ad5427c6 | train | function | @pytest.mark.parametrize(
'x, y1, y2', [
(np.zeros((2, 2)), 3, 3),
(np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3),
(np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2)))
], ids=[
'2d_x_input',
'2d_y1_input',
'2d_y2_input'
]
)
def test_fill_between_input(x, ... | @pytest.mark.parametrize(
'x, y1, y2', [
(np.zeros((2, 2)), 3, 3),
(np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3),
(np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2)))
], ids=[
'2d_x_input',
'2d_y1_input',
'2d_y2_input'
]
)
def test_fill_between_input(x, ... | fig, ax = plt.subplots()
with pytest.raises(ValueError):
ax.fill_between(x, y1, y2)
| @pytest.mark.parametrize(
'x, y1, y2', [
(np.zeros((2, 2)), 3, 3),
(np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3),
(np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2)))
], ids=[
'2d_x_input',
'2d_y1_input',
'2d_y2_input'
]
)
def test_fill_between_input(x, ... | 131 | 64 | 158 | 131 | 0 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_fill_between_input | test_fill_between_input | 919 | 933 | 919 | 930 | 127a3dc94c61919e2f9abbb8d1d007cbe0794113 | bigcode/the-stack | train |
08e26fdf2f1ae1833414bf94 | train | function | @image_comparison(['transparent_markers'], remove_text=True)
def test_transparent_markers():
np.random.seed(0)
data = np.random.random(50)
fig, ax = plt.subplots()
ax.plot(data, 'D', mfc='none', markersize=100)
| @image_comparison(['transparent_markers'], remove_text=True)
def test_transparent_markers():
| np.random.seed(0)
data = np.random.random(50)
fig, ax = plt.subplots()
ax.plot(data, 'D', mfc='none', markersize=100)
| assert bars[0].get_label() == '0'
_, _, bars = ax.hist([0, 1], label='00')
assert bars[0].get_label() == '00'
@image_comparison(['transparent_markers'], remove_text=True)
def test_transparent_markers():
| 63 | 64 | 62 | 20 | 43 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_transparent_markers | test_transparent_markers | 3,879 | 3,885 | 3,879 | 3,880 | 5710d5f9b7125b0a4b923a2e137226d9be5eb8ff | bigcode/the-stack | train |
6269ff3922490fc97fd8cde6 | train | function | def test_pcolorflaterror():
fig, ax = plt.subplots()
x = np.arange(0, 9)
y = np.arange(0, 3)
np.random.seed(19680801)
Z = np.random.randn(3, 9)
with pytest.raises(TypeError, match='Dimensions of C'):
ax.pcolormesh(x, y, Z, shading='flat')
| def test_pcolorflaterror():
| fig, ax = plt.subplots()
x = np.arange(0, 9)
y = np.arange(0, 3)
np.random.seed(19680801)
Z = np.random.randn(3, 9)
with pytest.raises(TypeError, match='Dimensions of C'):
ax.pcolormesh(x, y, Z, shading='flat')
| timestamp((x + 0.5) * 3600) for x in range(9)]
y2 = y[:-1] + np.diff(y) / 2
ax.pcolormesh(x2, y2, Z, shading='nearest')
def test_pcolorflaterror():
| 63 | 64 | 87 | 7 | 56 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_pcolorflaterror | test_pcolorflaterror | 1,242 | 1,249 | 1,242 | 1,242 | cb85f6b339dffd32f03a50f4b3e5ff9d21d3c253 | bigcode/the-stack | train |
6cb923de3f6a4391dbd568b8 | train | function | @image_comparison(['pie_linewidth_2.png'])
def test_pie_linewidth_2():
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0.1, 0, 0) # only "... | @image_comparison(['pie_linewidth_2.png'])
def test_pie_linewidth_2():
# The slices will be ordered and plotted counter-clockwise.
| labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', ... | facecolor="lightgrey"))
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')
@image_comparison(['pie_linewidth_2.png'])
def test_pie_linewidth_2():
# The slices will be ordered and plotted counter-clockwise.
| 63 | 64 | 192 | 34 | 29 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_pie_linewidth_2 | test_pie_linewidth_2 | 5,039 | 5,051 | 5,039 | 5,041 | b26953986340593f51ecb3dfb9c295617a05f013 | bigcode/the-stack | train |
677951d5a77605a2e63ba661 | train | function | @image_comparison(['imshow_clip'], style='mpl20')
def test_imshow_clip():
# As originally reported by Gellule Xg <gellule.xg@free.fr>
# use former defaults to match existing baseline image
matplotlib.rcParams['image.interpolation'] = 'nearest'
# Create a NxN image
N = 100
(x, y) = np.in... | @image_comparison(['imshow_clip'], style='mpl20')
def test_imshow_clip():
# As originally reported by Gellule Xg <gellule.xg@free.fr>
# use former defaults to match existing baseline image
| matplotlib.rcParams['image.interpolation'] = 'nearest'
# Create a NxN image
N = 100
(x, y) = np.indices((N, N))
x -= N//2
y -= N//2
r = np.sqrt(x**2+y**2-x*y)
# Create a contour plot at N/4 and extract both the clip path and transform
fig, ax = plt.subplots()
c = a... | fig, ax = plt.subplots()
ax.imshow("r", data=data)
@image_comparison(['imshow_clip'], style='mpl20')
def test_imshow_clip():
# As originally reported by Gellule Xg <gellule.xg@free.fr>
# use former defaults to match existing baseline image
| 67 | 67 | 224 | 51 | 16 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_imshow_clip | test_imshow_clip | 871 | 895 | 871 | 874 | 0048e16c87b57e396790f9b9db23214142c5792a | bigcode/the-stack | train |
fdea0cc9786ae16e89e5c5c1 | train | function | def test_adjust_numtick_aspect():
fig, ax = plt.subplots()
ax.yaxis.get_major_locator().set_params(nbins='auto')
ax.set_xlim(0, 1000)
ax.set_aspect('equal')
fig.canvas.draw()
assert len(ax.yaxis.get_major_locator()()) == 2
ax.set_ylim(0, 1000)
fig.canvas.draw()
assert len(ax... | def test_adjust_numtick_aspect():
| fig, ax = plt.subplots()
ax.yaxis.get_major_locator().set_params(nbins='auto')
ax.set_xlim(0, 1000)
ax.set_aspect('equal')
fig.canvas.draw()
assert len(ax.yaxis.get_major_locator()()) == 2
ax.set_ylim(0, 1000)
fig.canvas.draw()
assert len(ax.yaxis.get_major_locator()()) > 2
| () and not ax2.get_autoscaley_on()
assert ax1.get_xlim() == ax2.get_xlim() == (-1000, 1000)
assert ax1.get_ylim() == ax2.get_ylim() == (-1000, 1000)
def test_adjust_numtick_aspect():
| 64 | 64 | 101 | 8 | 56 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_adjust_numtick_aspect | test_adjust_numtick_aspect | 5,750 | 5,759 | 5,750 | 5,750 | 7135aee77637cd1d720a5f3d98ff4fd2c0d49150 | bigcode/the-stack | train |
9ba398762a4dd67e8dcc6f56 | train | function | @image_comparison(['step_linestyle', 'step_linestyle'], remove_text=True)
def test_step_linestyle():
x = y = np.arange(10)
# First illustrate basic pyplot interface, using defaults where possible.
fig, ax_lst = plt.subplots(2, 2)
ax_lst = ax_lst.flatten()
ln_styles = ['-', '--', '-.', ':']... | @image_comparison(['step_linestyle', 'step_linestyle'], remove_text=True)
def test_step_linestyle():
| x = y = np.arange(10)
# First illustrate basic pyplot interface, using defaults where possible.
fig, ax_lst = plt.subplots(2, 2)
ax_lst = ax_lst.flatten()
ln_styles = ['-', '--', '-.', ':']
for ax, ls in zip(ax_lst, ln_styles):
ax.step(x, y, lw=5, linestyle=ls, where='pre')
... | _color = ['red', 'green', 'blue', 'orange']
fig_ref.add_subplot(2, 1, 1).vlines(expect_xy, 0, 1,
colors=expect_color, linewidth=5)
fig_ref.add_subplot(2, 1, 2).hlines(expect_xy, 0, 1,
colors=expect_color, linewidth=5)
@image_com... | 108 | 108 | 363 | 24 | 84 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_step_linestyle | test_step_linestyle | 4,400 | 4,427 | 4,400 | 4,401 | ea8cc0fe3c5b2bdc972fbc6524ceb11d2df0edf1 | bigcode/the-stack | train |
e384bd9fa133522062de1986 | train | function | def test_gettightbbox_ignore_nan():
fig, ax = plt.subplots()
remove_ticks_and_titles(fig)
ax.text(np.NaN, 1, 'Boo')
renderer = fig.canvas.get_renderer()
np.testing.assert_allclose(ax.get_tightbbox(renderer).width, 496)
| def test_gettightbbox_ignore_nan():
| fig, ax = plt.subplots()
remove_ticks_and_titles(fig)
ax.text(np.NaN, 1, 'Boo')
renderer = fig.canvas.get_renderer()
np.testing.assert_allclose(ax.get_tightbbox(renderer).width, 496)
| , 500, 500), 'in',
None, False, False)
bb2 = ax.spines.bottom.get_window_extent(fig.canvas.get_renderer())
np.testing.assert_allclose(bb.get_points(), bb2.get_points(), rtol=1e-6)
def test_gettightbbox_ignore_nan():
| 64 | 64 | 63 | 8 | 56 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_gettightbbox_ignore_nan | test_gettightbbox_ignore_nan | 6,395 | 6,400 | 6,395 | 6,395 | dc6db3b7274ce7bacd0268e8821f812c164434cb | bigcode/the-stack | train |
dd86be4d5558f4093b132971 | train | function | @image_comparison(['arc_ellipse'], remove_text=True)
def test_arc_ellipse():
xcenter, ycenter = 0.38, 0.52
width, height = 1e-1, 3e-1
angle = -30
theta = np.deg2rad(np.arange(360))
x = width / 2. * np.cos(theta)
y = height / 2. * np.sin(theta)
rtheta = np.deg2rad(angle)
R = ... | @image_comparison(['arc_ellipse'], remove_text=True)
def test_arc_ellipse():
| xcenter, ycenter = 0.38, 0.52
width, height = 1e-1, 3e-1
angle = -30
theta = np.deg2rad(np.arange(360))
x = width / 2. * np.cos(theta)
y = height / 2. * np.sin(theta)
rtheta = np.deg2rad(angle)
R = np.array([
[np.cos(rtheta), -np.sin(rtheta)],
[np.sin(rtheta)... | )) + centre[1]])
ax.set_xlim(-scale, scale)
ax.set_ylim(-scale, scale)
# This looks the same, but it triggers a different code path when it
# gets large enough.
w *= 10
h *= 10
centre = (centre[0] * 10, centre[1] * 10)
scale *= 10
@image_compar... | 105 | 105 | 352 | 19 | 85 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_arc_ellipse | test_arc_ellipse | 1,311 | 1,345 | 1,311 | 1,312 | 7f2c6954450848ca89bc6d3d93999546c30592c0 | bigcode/the-stack | train |
1730d33f94062343aed57e62 | train | function | def test_aspect_nonlinear_adjustable_datalim():
fig = plt.figure(figsize=(10, 10)) # Square.
ax = fig.add_axes([.1, .1, .8, .8]) # Square.
ax.plot([.4, .6], [.4, .6]) # Set minpos to keep logit happy.
ax.set(xscale="log", xlim=(1, 100),
yscale="logit", ylim=(1 / 101, 1 / 11),
... | def test_aspect_nonlinear_adjustable_datalim():
| fig = plt.figure(figsize=(10, 10)) # Square.
ax = fig.add_axes([.1, .1, .8, .8]) # Square.
ax.plot([.4, .6], [.4, .6]) # Set minpos to keep logit happy.
ax.set(xscale="log", xlim=(1, 100),
yscale="logit", ylim=(1 / 101, 1 / 11),
aspect=1, adjustable="datalim")
ax.mar... | 11, 1/1001),
aspect=1, adjustable="box")
ax.margins(0)
pos = fig.transFigure.transform_bbox(ax.get_position())
assert pos.height / pos.width == pytest.approx(2)
def test_aspect_nonlinear_adjustable_datalim():
| 64 | 64 | 190 | 13 | 51 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_aspect_nonlinear_adjustable_datalim | test_aspect_nonlinear_adjustable_datalim | 6,813 | 6,825 | 6,813 | 6,813 | e0509c9a35f574034a46f3312320c6b0078ef251 | bigcode/the-stack | train |
3520b86c224b7327ad2028a0 | train | function | @image_comparison(['pcolormesh'], remove_text=True)
def test_pcolormesh():
# Remove this line when this test image is regenerated.
plt.rcParams['pcolormesh.snap'] = False
n = 12
x = np.linspace(-1.5, 1.5, n)
y = np.linspace(-1.5, 1.5, n*2)
X, Y = np.meshgrid(x, y)
Qx = np.cos(Y) - ... | @image_comparison(['pcolormesh'], remove_text=True)
def test_pcolormesh():
# Remove this line when this test image is regenerated.
| plt.rcParams['pcolormesh.snap'] = False
n = 12
x = np.linspace(-1.5, 1.5, n)
y = np.linspace(-1.5, 1.5, n*2)
X, Y = np.meshgrid(x, y)
Qx = np.cos(Y) - np.cos(X)
Qz = np.sin(Y) + np.sin(X)
Qx = (Qx + 1.1)
Z = np.hypot(X, Y) / 5
Z = (Z - Z.min()) / Z.ptp()
# The c... | (x, y)
Z = np.hypot(X, Y)
plt.pcolor(Z)
plt.pcolor(list(Z))
plt.pcolor(x, y, Z[:-1, :-1])
plt.pcolor(X, Y, list(Z[:-1, :-1]))
@image_comparison(['pcolormesh'], remove_text=True)
def test_pcolormesh():
# Remove this line when this test image is regenerated.
| 92 | 93 | 311 | 33 | 59 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_pcolormesh | test_pcolormesh | 1,063 | 1,084 | 1,063 | 1,065 | fec14c8c76e0351846c29c0e0967a6b892525822 | bigcode/the-stack | train |
eea29b3bc934ac467118340c | train | function | def test_bad_plot_args():
with pytest.raises(ValueError):
plt.plot(None)
with pytest.raises(ValueError):
plt.plot(None, None)
with pytest.raises(ValueError):
plt.plot(np.zeros((2, 2)), np.zeros((2, 3)))
with pytest.raises(ValueError):
plt.plot((np.arange(5).reshap... | def test_bad_plot_args():
| with pytest.raises(ValueError):
plt.plot(None)
with pytest.raises(ValueError):
plt.plot(None, None)
with pytest.raises(ValueError):
plt.plot(np.zeros((2, 2)), np.zeros((2, 3)))
with pytest.raises(ValueError):
plt.plot((np.arange(5).reshape((1, -1)), np.arange(5).re... | .125, 0.1, 0.9, 0.9))
assert_array_almost_equal(
ax.get_position(original=False).extents, (0.2125, 0.1, 0.8125, 0.9))
def test_bad_plot_args():
| 63 | 64 | 93 | 6 | 57 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_bad_plot_args | test_bad_plot_args | 5,485 | 5,493 | 5,485 | 5,485 | f39140e4467d8ee9f82e53bce157c562c469c1e2 | bigcode/the-stack | train |
469188f7a476d7be2cd42bd6 | train | function | @image_comparison(['bxp_nobox.png'],
remove_text=True,
savefig_kwarg={'dpi': 40},
style='default')
def test_bxp_nobox():
_bxp_test_helper(bxp_kwargs=dict(showbox=False))
| @image_comparison(['bxp_nobox.png'],
remove_text=True,
savefig_kwarg={'dpi': 40},
style='default')
def test_bxp_nobox():
| _bxp_test_helper(bxp_kwargs=dict(showbox=False))
| default')
def test_bxp_nocaps():
_bxp_test_helper(bxp_kwargs=dict(showcaps=False))
@image_comparison(['bxp_nobox.png'],
remove_text=True,
savefig_kwarg={'dpi': 40},
style='default')
def test_bxp_nobox():
| 63 | 64 | 53 | 39 | 24 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_bxp_nobox | test_bxp_nobox | 2,757 | 2,762 | 2,757 | 2,761 | 0875bb129a371fc1a62491100709ae3a2949b96b | bigcode/the-stack | train |
92e75d194303dc700ac05901 | train | function | @pytest.mark.parametrize(
"xy, cls", [
((), mpl.image.AxesImage), # (0, N)
(((3, 7), (2, 6)), mpl.image.AxesImage), # (xmin, xmax)
((range(5), range(4)), mpl.image.AxesImage), # regular grid
(([1, 2, 4, 8, 16], [0, 1, 2, 3]), # irregular grid
mpl.image.PcolorImage)... | @pytest.mark.parametrize(
"xy, cls", [
((), mpl.image.AxesImage), # (0, N)
(((3, 7), (2, 6)), mpl.image.AxesImage), # (xmin, xmax)
((range(5), range(4)), mpl.image.AxesImage), # regular grid
(([1, 2, 4, 8, 16], [0, 1, 2, 3]), # irregular grid
mpl.image.PcolorImage)... | fig, ax = plt.subplots()
assert type(ax.pcolorfast(*xy, data)) == cls
| @pytest.mark.parametrize(
"xy, cls", [
((), mpl.image.AxesImage), # (0, N)
(((3, 7), (2, 6)), mpl.image.AxesImage), # (xmin, xmax)
((range(5), range(4)), mpl.image.AxesImage), # regular grid
(([1, 2, 4, 8, 16], [0, 1, 2, 3]), # irregular grid
mpl.image.PcolorImage)... | 198 | 66 | 221 | 198 | 0 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_pcolorfast | test_pcolorfast | 5,496 | 5,512 | 5,496 | 5,510 | 7fc878128ebb941ab13b93de22b0fb93635a2a28 | bigcode/the-stack | train |
7c305187a769700892c4bd33 | train | function | def test_offset_label_color():
# Tests issue 6440
fig, ax = plt.subplots()
ax.plot([1.01e9, 1.02e9, 1.03e9])
ax.yaxis.set_tick_params(labelcolor='red')
assert ax.yaxis.get_offset_text().get_color() == 'red'
| def test_offset_label_color():
# Tests issue 6440
| fig, ax = plt.subplots()
ax.plot([1.01e9, 1.02e9, 1.03e9])
ax.yaxis.set_tick_params(labelcolor='red')
assert ax.yaxis.get_offset_text().get_color() == 'red'
| .tick_params(axis="x",
bottom=True, top=True, labelbottom=True, labeltop=True)
tt = ax.set_title('Boo')
fig.canvas.draw()
assert tt.get_position()[1] == 1.0
def test_offset_label_color():
# Tests issue 6440
| 64 | 64 | 74 | 14 | 49 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_offset_label_color | test_offset_label_color | 6,065 | 6,070 | 6,065 | 6,066 | 39906991301da1f1791cf4fceb4bc093f5f17a62 | bigcode/the-stack | train |
0cd42921ff062d6a9629b932 | train | function | @image_comparison(
["specgram_freqs.png", "specgram_freqs_linear.png",
"specgram_noise.png", "specgram_noise_linear.png"],
remove_text=True, tol=0.07, style="default")
def test_specgram():
"""Test axes.specgram in default (psd) mode."""
# use former defaults to match existing baseline image... | @image_comparison(
["specgram_freqs.png", "specgram_freqs_linear.png",
"specgram_noise.png", "specgram_noise_linear.png"],
remove_text=True, tol=0.07, style="default")
def test_specgram():
| """Test axes.specgram in default (psd) mode."""
# use former defaults to match existing baseline image
matplotlib.rcParams['image.interpolation'] = 'nearest'
n = 1000
Fs = 10.
fstims = [[Fs/4, Fs/5, Fs/11], [Fs/4.7, Fs/5.6, Fs/11.9]]
NFFT_freqs = int(10 * Fs / np.min(fstims))
... | ax.set_xlim(0, 16)
ax.set_ylim(0, 16)
def test_subplot_key_hash():
ax = plt.subplot(np.int32(5), np.int64(1), 1)
ax.twinx()
assert ax.get_subplotspec().get_geometry() == (5, 1, 0, 0)
@image_comparison(
["specgram_freqs.png", "specgram_freqs_linear.png",
"specgram_noise.png", "specgr... | 130 | 130 | 436 | 55 | 75 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_specgram | test_specgram | 4,462 | 4,495 | 4,462 | 4,466 | b2fda153e91df8c632a02a1209800acf4b276961 | bigcode/the-stack | train |
4fddccd7a08ca760454d712a | train | function | @image_comparison(['bxp_withmean_point.png'],
remove_text=True,
savefig_kwarg={'dpi': 40},
style='default')
def test_bxp_showmean():
_bxp_test_helper(bxp_kwargs=dict(showmeans=True, meanline=False))
| @image_comparison(['bxp_withmean_point.png'],
remove_text=True,
savefig_kwarg={'dpi': 40},
style='default')
def test_bxp_showmean():
| _bxp_test_helper(bxp_kwargs=dict(showmeans=True, meanline=False))
| stats
_bxp_test_helper(transform_stats=transform,
bxp_kwargs=dict(showfliers=False))
@image_comparison(['bxp_withmean_point.png'],
remove_text=True,
savefig_kwarg={'dpi': 40},
style='default')
def test_bxp_showmean():
| 63 | 64 | 58 | 40 | 23 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_bxp_showmean | test_bxp_showmean | 2,779 | 2,784 | 2,779 | 2,783 | 9d00a76ec4120ea323ed38e6e6570eda53ed6120 | bigcode/the-stack | train |
961002c963ee11987284d216 | train | function | def test_axes_tick_params_ylabelside():
# Tests fix for issue 10267
ax = plt.subplot()
ax.tick_params(labelleft=False, labelright=True,
which='major')
ax.tick_params(labelleft=False, labelright=True,
which='minor')
# expects left false, right true
as... | def test_axes_tick_params_ylabelside():
# Tests fix for issue 10267
| ax = plt.subplot()
ax.tick_params(labelleft=False, labelright=True,
which='major')
ax.tick_params(labelleft=False, labelright=True,
which='minor')
# expects left false, right true
assert ax.yaxis.majorTicks[0].label1.get_visible() is False
assert ax.y... | line.get_linewidth() == 5
assert axis.majorTicks[0].gridline.get_alpha() == 0.5
assert axis.majorTicks[0].gridline.get_linestyle() == '-.'
def test_axes_tick_params_ylabelside():
# Tests fix for issue 10267
| 63 | 64 | 141 | 18 | 45 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_axes_tick_params_ylabelside | test_axes_tick_params_ylabelside | 5,887 | 5,898 | 5,887 | 5,888 | 982856b5fdd439ce0d0a248cc6939851761d60fd | bigcode/the-stack | train |
ed019a6e03a9f1d807c15284 | train | function | @pytest.mark.parametrize('twin', ('x', 'y'))
def test_twin_with_aspect(twin):
fig, ax = plt.subplots()
# test twinx or twiny
ax_twin = getattr(ax, 'twin{}'.format(twin))()
ax.set_aspect(5)
ax_twin.set_aspect(2)
assert_array_equal(ax.bbox.extents,
ax_twin.bbox.exten... | @pytest.mark.parametrize('twin', ('x', 'y'))
def test_twin_with_aspect(twin):
| fig, ax = plt.subplots()
# test twinx or twiny
ax_twin = getattr(ax, 'twin{}'.format(twin))()
ax.set_aspect(5)
ax_twin.set_aspect(2)
assert_array_equal(ax.bbox.extents,
ax_twin.bbox.extents)
| Lim.height / ax.viewLim.width
expected = fig_aspect * box_aspect / lim_aspect
assert round(expected, 4) == round(ax.get_aspect(), 4)
@pytest.mark.parametrize('twin', ('x', 'y'))
def test_twin_with_aspect(twin):
| 64 | 64 | 94 | 23 | 41 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_twin_with_aspect | test_twin_with_aspect | 4,928 | 4,936 | 4,928 | 4,929 | 9d100310a2316c33e07df8c76c7b4f68e3d5c018 | bigcode/the-stack | train |
9bc16304e6ed5567f4ca4de7 | train | function | @image_comparison(['o_marker_path_snap.png'], savefig_kwarg={'dpi': 72})
def test_o_marker_path_snap():
fig, ax = plt.subplots()
ax.margins(.1)
for ms in range(1, 15):
ax.plot([1, 2, ], np.ones(2) + ms, 'o', ms=ms)
for ms in np.linspace(1, 10, 25):
ax.plot([3, 4, ], np.ones(2) +... | @image_comparison(['o_marker_path_snap.png'], savefig_kwarg={'dpi': 72})
def test_o_marker_path_snap():
| fig, ax = plt.subplots()
ax.margins(.1)
for ms in range(1, 15):
ax.plot([1, 2, ], np.ones(2) + ms, 'o', ms=ms)
for ms in np.linspace(1, 10, 25):
ax.plot([3, 4, ], np.ones(2) + ms, 'o', ms=ms)
| _texts = [tick.get_text() for tick in ax.xaxis.get_ticklabels()]
assert tick_texts == ["", "", "unit value", "", ""]
@image_comparison(['o_marker_path_snap.png'], savefig_kwarg={'dpi': 72})
def test_o_marker_path_snap():
| 63 | 64 | 120 | 28 | 35 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_o_marker_path_snap | test_o_marker_path_snap | 5,266 | 5,274 | 5,266 | 5,267 | 15915d989391c112db657d337ae3f345e062e22c | bigcode/the-stack | train |
02be456bf5db869bbd6ece29 | train | function | def test_color_None():
# issue 3855
fig, ax = plt.subplots()
ax.plot([1, 2], [1, 2], color=None)
| def test_color_None():
# issue 3855
| fig, ax = plt.subplots()
ax.plot([1, 2], [1, 2], color=None)
|
mylist = [10] * 100
fig, ax = plt.subplots(1, 1)
ax.hexbin(mylist, mylist)
fig.savefig(io.BytesIO()) # Check that no warning is emitted.
def test_color_None():
# issue 3855
| 63 | 64 | 38 | 12 | 51 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_color_None | test_color_None | 5,335 | 5,338 | 5,335 | 5,336 | 98d3918f2695e3aba2e608568408dffba6b3311c | bigcode/the-stack | train |
d91f81c6ac1c63a6a7103929 | train | function | @check_figures_equal(extensions=['png'])
def test_stairs(fig_test, fig_ref):
import matplotlib.lines as mlines
y = np.array([6, 14, 32, 37, 48, 32, 21, 4]) # hist
x = np.array([1., 2., 3., 4., 5., 6., 7., 8., 9.]) # bins
test_axes = fig_test.subplots(3, 2).flatten()
test_axes[0].stairs(y,... | @check_figures_equal(extensions=['png'])
def test_stairs(fig_test, fig_ref):
| import matplotlib.lines as mlines
y = np.array([6, 14, 32, 37, 48, 32, 21, 4]) # hist
x = np.array([1., 2., 3., 4., 5., 6., 7., 8., 9.]) # bins
test_axes = fig_test.subplots(3, 2).flatten()
test_axes[0].stairs(y, x, baseline=None)
test_axes[1].stairs(y, x, baseline=None, orientation='h... | 1),
([[]], 1),
([[], []], 2)])
def test_hist_with_empty_input(data, expected_number_of_hists):
hists, _, _ = plt.hist(data)
hists = np.asarray(hists)
if hists.ndim == 1:
assert 1 == expected_number_of_hists
else:
assert hist... | 221 | 221 | 739 | 20 | 200 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_stairs | test_stairs | 1,879 | 1,920 | 1,879 | 1,880 | b89df748c24de3a455a0e71f58a3c0878f414603 | bigcode/the-stack | train |
07650d9f88c81b39a8a31235 | train | function | def test_specgram_origin_kwarg():
"""Ensure passing origin as a kwarg raises a TypeError."""
t = np.arange(500)
signal = np.sin(t)
with pytest.raises(TypeError):
plt.specgram(signal, origin='lower')
| def test_specgram_origin_kwarg():
| """Ensure passing origin as a kwarg raises a TypeError."""
t = np.arange(500)
signal = np.sin(t)
with pytest.raises(TypeError):
plt.specgram(signal, origin='lower')
| fig_ref.subplots().specgram(signal)
# Try to overwrite the setting trying to flip the specgram
plt.rcParams["image.origin"] = 'lower'
# Test: origin='lower' should be ignored
fig_test.subplots().specgram(signal)
def test_specgram_origin_kwarg():
| 64 | 64 | 55 | 8 | 56 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_specgram_origin_kwarg | test_specgram_origin_kwarg | 4,598 | 4,604 | 4,598 | 4,598 | 180477068f6c3dbfbe48830d03f263854a7a4d4f | bigcode/the-stack | train |
ae99339708cfe6c13649c811 | train | function | def test_inset():
"""
Ensure that inset_ax argument is indeed optional
"""
dx, dy = 0.05, 0.05
# generate 2 2d grids for the x & y bounds
y, x = np.mgrid[slice(1, 5 + dy, dy),
slice(1, 5 + dx, dx)]
z = np.sin(x) ** 10 + np.cos(10 + y * x) * np.cos(x)
fig, a... | def test_inset():
| """
Ensure that inset_ax argument is indeed optional
"""
dx, dy = 0.05, 0.05
# generate 2 2d grids for the x & y bounds
y, x = np.mgrid[slice(1, 5 + dy, dy),
slice(1, 5 + dx, dx)]
z = np.sin(x) ** 10 + np.cos(10 + y * x) * np.cos(x)
fig, ax = plt.subplots()
... | = "out"
plt.rcParams["ytick.direction"] = "out"
fig, ax = plt.subplots()
bb = ax.get_tightbbox(fig.canvas.get_renderer())
ax.axis('off')
bb2 = ax.get_tightbbox(fig.canvas.get_renderer())
assert bb.x0 < bb2.x0
assert bb.y0 < bb2.y0
def test_inset():
| 85 | 85 | 286 | 5 | 79 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_inset | test_inset | 6,284 | 6,310 | 6,284 | 6,284 | f673cf18be06d61a78a8200dc34cf6423eac304b | bigcode/the-stack | train |
dd854ab970949437537b7bbb | train | function | @image_comparison(['contour_colorbar'], style='mpl20')
def test_contour_colorbar():
x, y, z = contour_dat()
fig, ax = plt.subplots()
cs = ax.contourf(x, y, z, levels=np.arange(-1.8, 1.801, 0.2),
cmap=plt.get_cmap('RdBu'),
vmin=-0.6,
vma... | @image_comparison(['contour_colorbar'], style='mpl20')
def test_contour_colorbar():
| x, y, z = contour_dat()
fig, ax = plt.subplots()
cs = ax.contourf(x, y, z, levels=np.arange(-1.8, 1.801, 0.2),
cmap=plt.get_cmap('RdBu'),
vmin=-0.6,
vmax=0.6,
extend='both')
cs1 = ax.contour(x, y, z, levels=np.a... | ax.contourf(x, y, z, 7, hatches=['/', '\\', '//', '-'],
cmap=plt.get_cmap('gray'),
extend='both', alpha=0.5)
@image_comparison(['contour_colorbar'], style='mpl20')
def test_contour_colorbar():
| 67 | 67 | 224 | 22 | 45 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_contour_colorbar | test_contour_colorbar | 2,064 | 2,083 | 2,064 | 2,065 | 08eba697135ebf28d5a8ba8d625f821a9a24d7c1 | bigcode/the-stack | train |
ab851abcc40bb5cd64cd0778 | train | function | @image_comparison(['markevery_log_scales'], remove_text=True)
def test_markevery_log_scales():
cases = [None,
8,
(30, 8),
[16, 24, 30], [0, -1],
slice(100, 200, 3),
0.1, 0.3, 1.5,
(0.0, 0.1), (0.45, 0.1)]
cols = 3
gs =... | @image_comparison(['markevery_log_scales'], remove_text=True)
def test_markevery_log_scales():
| cases = [None,
8,
(30, 8),
[16, 24, 30], [0, -1],
slice(100, 200, 3),
0.1, 0.3, 1.5,
(0.0, 0.1), (0.45, 0.1)]
cols = 3
gs = matplotlib.gridspec.GridSpec(len(cases) // cols + 1, cols)
delta = 0.11
x = np.linsp... | ' % str(case))
plt.plot(x, y, 'o', ls='-', ms=4, markevery=case)
plt.xlim((6, 6.7))
plt.ylim((1.1, 1.7))
@image_comparison(['markevery_log_scales'], remove_text=True)
def test_markevery_log_scales():
| 77 | 78 | 261 | 23 | 54 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_markevery_log_scales | test_markevery_log_scales | 1,440 | 1,464 | 1,440 | 1,441 | 2097e1d504c62f8053a8b060d51a3e50c62bca56 | bigcode/the-stack | train |
c3f0e6fad7141b734d71f181 | train | function | def test_inverted_cla():
# GitHub PR #5450. Setting autoscale should reset
# axes to be non-inverted.
# plotting an image, then 1d graph, axis is now down
fig = plt.figure(0)
ax = fig.gca()
# 1. test that a new axis is not inverted per default
assert not ax.xaxis_inverted()
asser... | def test_inverted_cla():
# GitHub PR #5450. Setting autoscale should reset
# axes to be non-inverted.
# plotting an image, then 1d graph, axis is now down
| fig = plt.figure(0)
ax = fig.gca()
# 1. test that a new axis is not inverted per default
assert not ax.xaxis_inverted()
assert not ax.yaxis_inverted()
img = np.random.random((100, 100))
ax.imshow(img)
# 2. test that a image axis is inverted
assert not ax.xaxis_inverted()
... | x()
assert ax_x_on.get_autoscalex_on()
assert not ax_x_off.get_autoscalex_on()
ax_y_on = ax.twiny()
ax.set_autoscaley_on(False)
ax_y_off = ax.twiny()
assert ax_y_on.get_autoscaley_on()
assert not ax_y_off.get_autoscaley_on()
def test_inverted_cla():
# GitHub PR #5450. Setti... | 128 | 128 | 429 | 48 | 80 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_inverted_cla | test_inverted_cla | 390 | 437 | 390 | 393 | 69bdf538633b312b3fa8fde01e5ad59c976db8e1 | bigcode/the-stack | train |
2c01e5dfcc6a0972547aefd4 | train | function | def test_box_aspect():
# Test if axes with box_aspect=1 has same dimensions
# as axes with aspect equal and adjustable="box"
fig1, ax1 = plt.subplots()
axtwin = ax1.twinx()
axtwin.plot([12, 344])
ax1.set_box_aspect(1)
fig2, ax2 = plt.subplots()
ax2.margins(0)
ax2.plot(... | def test_box_aspect():
# Test if axes with box_aspect=1 has same dimensions
# as axes with aspect equal and adjustable="box"
| fig1, ax1 = plt.subplots()
axtwin = ax1.twinx()
axtwin.plot([12, 344])
ax1.set_box_aspect(1)
fig2, ax2 = plt.subplots()
ax2.margins(0)
ax2.plot([0, 2], [6, 8])
ax2.set_aspect("equal", adjustable="box")
fig1.canvas.draw()
fig2.canvas.draw()
bb1 = ax1.get_posi... | ), 100/10**(1/2)])
assert ax.get_ylim() == (1 / 101, 1 / 11)
def test_box_aspect():
# Test if axes with box_aspect=1 has same dimensions
# as axes with aspect equal and adjustable="box"
| 64 | 64 | 191 | 33 | 31 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_box_aspect | test_box_aspect | 6,828 | 6,851 | 6,828 | 6,831 | e8398ce1655e5b13c6c26cad3de09e9856a65a47 | bigcode/the-stack | train |
92dfe2245a1cfc8808455a8e | train | function | @image_comparison(
["specgram_angle_freqs.png", "specgram_phase_freqs.png",
"specgram_angle_noise.png", "specgram_phase_noise.png"],
remove_text=True, tol=0.07, style="default")
def test_specgram_angle():
"""Test axes.specgram in angle and phase modes."""
# use former defaults to match exis... | @image_comparison(
["specgram_angle_freqs.png", "specgram_phase_freqs.png",
"specgram_angle_noise.png", "specgram_phase_noise.png"],
remove_text=True, tol=0.07, style="default")
def test_specgram_angle():
| """Test axes.specgram in angle and phase modes."""
# use former defaults to match existing baseline image
matplotlib.rcParams['image.interpolation'] = 'nearest'
n = 1000
Fs = 10.
fstims = [[Fs/4, Fs/5, Fs/11], [Fs/4.7, Fs/5.6, Fs/11.9]]
NFFT_freqs = int(10 * Fs / np.min(fstims))
... | mode="magnitude")
for ax, sides in zip(plt.figure().subplots(3), all_sides):
ax.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap,
pad_to=pad_to, sides=sides, mode="magnitude",
scale="linear", norm=matplotlib.colors.LogNorm())
@image_comparison(
... | 134 | 135 | 450 | 58 | 76 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_specgram_angle | test_specgram_angle | 4,535 | 4,570 | 4,535 | 4,539 | 89a6058ef94d1ce1fca58de9463437927726410f | bigcode/the-stack | train |
5d9493273b27f500f3f31e13 | train | function | @check_figures_equal(extensions=["png"])
def test_pcolornearestunits(fig_test, fig_ref):
ax = fig_test.subplots()
x = [datetime.datetime.fromtimestamp(x * 3600) for x in range(10)]
y = np.arange(0, 3)
np.random.seed(19680801)
Z = np.random.randn(2, 9)
ax.pcolormesh(x, y, Z, shading='flat'... | @check_figures_equal(extensions=["png"])
def test_pcolornearestunits(fig_test, fig_ref):
| ax = fig_test.subplots()
x = [datetime.datetime.fromtimestamp(x * 3600) for x in range(10)]
y = np.arange(0, 3)
np.random.seed(19680801)
Z = np.random.randn(2, 9)
ax.pcolormesh(x, y, Z, shading='flat')
ax = fig_ref.subplots()
# specify the centers
x2 = [datetime.datetime.fr... | ) / 2
y2 = y[:-1] + np.diff(y) / 2
ax.pcolormesh(x2, y2, Z, shading='nearest')
@check_figures_equal(extensions=["png"])
def test_pcolornearestunits(fig_test, fig_ref):
| 63 | 64 | 176 | 23 | 40 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_pcolornearestunits | test_pcolornearestunits | 1,226 | 1,239 | 1,226 | 1,227 | 6f9a30fb45eb9224cc6494124728f8217433db22 | bigcode/the-stack | train |
c48b14084d658743cc13d0df | train | function | def test_as_mpl_axes_api():
# tests the _as_mpl_axes api
from matplotlib.projections.polar import PolarAxes
class Polar:
def __init__(self):
self.theta_offset = 0
def _as_mpl_axes(self):
# implement the matplotlib axes interface
return PolarAxe... | def test_as_mpl_axes_api():
# tests the _as_mpl_axes api
| from matplotlib.projections.polar import PolarAxes
class Polar:
def __init__(self):
self.theta_offset = 0
def _as_mpl_axes(self):
# implement the matplotlib axes interface
return PolarAxes, {'theta_offset': self.theta_offset}
prj = Polar()
... | =2, get_next_color_func=get_next_color)
assert result_edgecolors == expected_edgecolors
def test_parse_scatter_color_args_error():
def get_next_color():
return 'blue' # currently unused
with pytest.raises(ValueError,
match="RGBA values should be within 0-1 range")... | 160 | 160 | 534 | 19 | 141 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_as_mpl_axes_api | test_as_mpl_axes_api | 2,453 | 2,509 | 2,453 | 2,454 | 6fa3aad516cab3496c219ef303dd6e509f5b31ae | bigcode/the-stack | train |
ca6e34c640e3881875864b10 | train | function | @image_comparison(['pie_frame_grid.png'])
def test_pie_frame_grid():
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
# only "explode" the 2nd slice (i.e.... | @image_comparison(['pie_frame_grid.png'])
def test_pie_frame_grid():
# The slices will be ordered and plotted counter-clockwise.
| labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
# only "explode" the 2nd slice (i.e. 'Hogs')
explode = (0, 0.1, 0, 0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%... | plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=90,
counterclock=True)
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')
@image_comparison(['pie_frame_grid.png'])
def test_pie_frame_grid():
... | 94 | 95 | 317 | 30 | 64 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_pie_frame_grid | test_pie_frame_grid | 5,069 | 5,093 | 5,069 | 5,071 | 38e539dff419b9675928e500b0dbade5499ee90a | bigcode/the-stack | train |
bfecce73be280be96cedfdff | train | function | def test_set_margin_updates_limits():
mpl.style.use("default")
fig, ax = plt.subplots()
ax.plot([1, 2], [1, 2])
ax.set(xscale="log", xmargin=0)
assert ax.get_xlim() == (1, 2)
| def test_set_margin_updates_limits():
| mpl.style.use("default")
fig, ax = plt.subplots()
ax.plot([1, 2], [1, 2])
ax.set(xscale="log", xmargin=0)
assert ax.get_xlim() == (1, 2)
| .2,
xmax + (xmax - xmin) * -0.2)
assert ax3.get_ylim() == (ymin - (ymax - ymin) * 0.5,
ymax + (ymax - ymin) * 0.5)
def test_set_margin_updates_limits():
| 64 | 64 | 63 | 7 | 57 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_set_margin_updates_limits | test_set_margin_updates_limits | 5,313 | 5,318 | 5,313 | 5,313 | 90cbcd6123c3223873f10bcf699780cea1e2f496 | bigcode/the-stack | train |
2b7aa113d05eda1cd425bdb5 | train | function | @image_comparison(
["magnitude_spectrum_freqs_linear.png",
"magnitude_spectrum_freqs_dB.png",
"angle_spectrum_freqs.png",
"phase_spectrum_freqs.png",
"magnitude_spectrum_noise_linear.png",
"magnitude_spectrum_noise_dB.png",
"angle_spectrum_noise.png",
"phase_spectrum_noise... | @image_comparison(
["magnitude_spectrum_freqs_linear.png",
"magnitude_spectrum_freqs_dB.png",
"angle_spectrum_freqs.png",
"phase_spectrum_freqs.png",
"magnitude_spectrum_noise_linear.png",
"magnitude_spectrum_noise_dB.png",
"angle_spectrum_noise.png",
"phase_spectrum_noise... | n = 10000
Fs = 100.
fstims1 = [Fs/4, Fs/5, Fs/11]
NFFT = int(1000 * Fs / min(fstims1))
pad_to = int(2 ** np.ceil(np.log2(NFFT)))
x = np.arange(0, n, 1/Fs)
y_freqs = ((np.sin(2 * np.pi * np.outer(x, fstims1)) * 10**np.arange(3))
.sum(axis=1))
np.random.seed(0)
... | , NFFT=NFFT, Fs=Fs,
noverlap=noverlap, pad_to=pad_to, **kwargs)
assert len(ret) == 2 + kwargs.get("return_line", False)
ax.set(xlabel="", ylabel="")
@image_comparison(
["magnitude_spectrum_freqs_linear.png",
"magnitude_spectrum_freqs_dB.png",
"angle_s... | 145 | 147 | 493 | 93 | 53 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_spectrum | test_spectrum | 4,641 | 4,680 | 4,641 | 4,651 | 8b3ebc0e157a21bef72868a2458f828bbf6d456d | bigcode/the-stack | train |
4f4d86649ecd673de1353443 | train | function | @image_comparison(['errorbar_basic', 'errorbar_mixed', 'errorbar_basic'])
def test_errorbar():
x = np.arange(0.1, 4, 0.5)
y = np.exp(-x)
yerr = 0.1 + 0.2*np.sqrt(x)
xerr = 0.1 + yerr
# First illustrate basic pyplot interface, using defaults where possible.
fig = plt.figure()
ax =... | @image_comparison(['errorbar_basic', 'errorbar_mixed', 'errorbar_basic'])
def test_errorbar():
| x = np.arange(0.1, 4, 0.5)
y = np.exp(-x)
yerr = 0.1 + 0.2*np.sqrt(x)
xerr = 0.1 + yerr
# First illustrate basic pyplot interface, using defaults where possible.
fig = plt.figure()
ax = fig.gca()
ax.errorbar(x, y, xerr=0.2, yerr=0.4)
ax.set_title("Simplest errorbars, 0.2 ... | positions=[5])
fig.canvas.draw()
assert ax.get_xlim() == (2.5, 5.5)
assert list(ax.get_xticks()) == [3, 5]
assert [t.get_text() for t in ax.get_xticklabels()] == ["3", "5"]
def test_tick_space_size_0():
# allow font size to be zero, which affects ticks when there is
# no other text i... | 169 | 170 | 567 | 25 | 144 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_errorbar | test_errorbar | 3,305 | 3,353 | 3,305 | 3,306 | 30dd8634ec6bd9e1185100f0d05427f64ca0b017 | bigcode/the-stack | train |
8b341d4fa6a923a6bee77711 | train | function | def test_twinx_cla():
fig, ax = plt.subplots()
ax2 = ax.twinx()
ax3 = ax2.twiny()
plt.draw()
assert not ax2.xaxis.get_visible()
assert not ax2.patch.get_visible()
ax2.cla()
ax3.cla()
assert not ax2.xaxis.get_visible()
assert not ax2.patch.get_visible()
assert ax2... | def test_twinx_cla():
| fig, ax = plt.subplots()
ax2 = ax.twinx()
ax3 = ax2.twiny()
plt.draw()
assert not ax2.xaxis.get_visible()
assert not ax2.patch.get_visible()
ax2.cla()
ax3.cla()
assert not ax2.xaxis.get_visible()
assert not ax2.patch.get_visible()
assert ax2.yaxis.get_visible()
... | ax1.xaxis.set_major_formatter(plt.FormatStrFormatter('%05.2lf'))
ax1.xaxis.set_minor_formatter(plt.FixedFormatter(['c', '3', 'p', 'o']))
ax1.twiny()
ax1.twinx()
def test_twinx_cla():
| 64 | 64 | 148 | 8 | 56 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_twinx_cla | test_twinx_cla | 288 | 308 | 288 | 288 | f2616b291f064506522a0bfc53a5e517894e54f5 | bigcode/the-stack | train |
80081dd0c97c07771b90e4c7 | train | function | @pytest.mark.parametrize('snap', [False, True])
@check_figures_equal(extensions=["png"])
def test_pcolorauto(fig_test, fig_ref, snap):
ax = fig_test.subplots()
x = np.arange(0, 10)
y = np.arange(0, 4)
np.random.seed(19680801)
Z = np.random.randn(3, 9)
# this is the same as flat; note tha... | @pytest.mark.parametrize('snap', [False, True])
@check_figures_equal(extensions=["png"])
def test_pcolorauto(fig_test, fig_ref, snap):
| ax = fig_test.subplots()
x = np.arange(0, 10)
y = np.arange(0, 4)
np.random.seed(19680801)
Z = np.random.randn(3, 9)
# this is the same as flat; note that auto is default
ax.pcolormesh(x, y, Z, snap=snap)
ax = fig_ref.subplots()
# specify the centers
x2 = x[:-1] + np.d... | with pytest.raises(TypeError, match='Dimensions of C'):
ax.pcolormesh(x, y, Z, shading='flat')
@pytest.mark.parametrize('snap', [False, True])
@check_figures_equal(extensions=["png"])
def test_pcolorauto(fig_test, fig_ref, snap):
| 63 | 64 | 189 | 35 | 28 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_pcolorauto | test_pcolorauto | 1,252 | 1,268 | 1,252 | 1,254 | 594405f1172f0749cdd223296e588a2e002fea19 | bigcode/the-stack | train |
749377bacbbdab477f402be5 | train | function | @image_comparison(['hist_step_bottom.png'], remove_text=True)
def test_hist_step_bottom():
# make some data
d1 = np.linspace(1, 3, 20)
fig, ax = plt.subplots()
ax.hist(d1, bottom=np.arange(10), histtype="stepfilled")
| @image_comparison(['hist_step_bottom.png'], remove_text=True)
def test_hist_step_bottom():
# make some data
| d1 = np.linspace(1, 3, 20)
fig, ax = plt.subplots()
ax.hist(d1, bottom=np.arange(10), histtype="stepfilled")
| d2 = np.linspace(0, 10, 50)
fig, ax = plt.subplots()
ax.hist((d1, d2), stacked=True, density=True)
@image_comparison(['hist_step_bottom.png'], remove_text=True)
def test_hist_step_bottom():
# make some data
| 64 | 64 | 67 | 26 | 38 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_hist_step_bottom | test_hist_step_bottom | 3,697 | 3,702 | 3,697 | 3,699 | b609af60471927fcfdd4c7de2fb20283db9fcae7 | bigcode/the-stack | train |
153d92f646a39c04be0c2d92 | train | function | @check_figures_equal(extensions=['png'])
def test_stairs_fill(fig_test, fig_ref):
h, bins = [1, 2, 3, 4, 2], [0, 1, 2, 3, 4, 5]
bs = -2
# Test
test_axes = fig_test.subplots(2, 2).flatten()
test_axes[0].stairs(h, bins, fill=True)
test_axes[1].stairs(h, bins, orientation='horizontal', fill=... | @check_figures_equal(extensions=['png'])
def test_stairs_fill(fig_test, fig_ref):
| h, bins = [1, 2, 3, 4, 2], [0, 1, 2, 3, 4, 5]
bs = -2
# Test
test_axes = fig_test.subplots(2, 2).flatten()
test_axes[0].stairs(h, bins, fill=True)
test_axes[1].stairs(h, bins, orientation='horizontal', fill=True)
test_axes[2].stairs(h, bins, baseline=bs, fill=True)
test_axes[3].st... | , drawstyle='steps-post', **style)
ref_axes[5].add_line(mlines.Line2D([0, y[0]], [x[0], x[0]], **style))
ref_axes[5].add_line(mlines.Line2D([0, y[-1]], [x[-1], x[-1]], **style))
ref_axes[5].semilogx()
@check_figures_equal(extensions=['png'])
def test_stairs_fill(fig_test, fig_ref):
| 107 | 107 | 359 | 21 | 86 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_stairs_fill | test_stairs_fill | 1,923 | 1,946 | 1,923 | 1,924 | 513b5a11d3fb8ed8c21b96b468e14d81070ed275 | bigcode/the-stack | train |
437e72bc658bedc6bef6c771 | train | function | def test_title_location_roundtrip():
fig, ax = plt.subplots()
# set default title location
plt.rcParams['axes.titlelocation'] = 'center'
ax.set_title('aardvark')
ax.set_title('left', loc='left')
ax.set_title('right', loc='right')
assert 'left' == ax.get_title(loc='left')
assert... | def test_title_location_roundtrip():
| fig, ax = plt.subplots()
# set default title location
plt.rcParams['axes.titlelocation'] = 'center'
ax.set_title('aardvark')
ax.set_title('left', loc='left')
ax.set_title('right', loc='right')
assert 'left' == ax.get_title(loc='left')
assert 'right' == ax.get_title(loc='right')
... | check that it is reverted...
ax.set_title('aardvark', pad=None)
m = ax.titleOffsetTrans.get_matrix()
assert m[1, -1] == (matplotlib.rcParams['axes.titlepad'] / 72. * fig.dpi)
def test_title_location_roundtrip():
| 64 | 64 | 140 | 7 | 57 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_title_location_roundtrip | test_title_location_roundtrip | 5,599 | 5,614 | 5,599 | 5,599 | 8140a508f1e140aeccde17c42ccd78ad03bb60c9 | bigcode/the-stack | train |
806611705551e649ed0b2343 | train | function | @image_comparison(['pie_default.png'])
def test_pie_default():
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0.1, 0, 0) # only "explode"... | @image_comparison(['pie_default.png'])
def test_pie_default():
# The slices will be ordered and plotted counter-clockwise.
| labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
fig1, ax1 = plt.subplots(figsize=(8, 6))
ax1.pie(sizes, explode=explode, labels=labels, col... | 1172
"""
fig = plt.figure()
ax = fig.gca()
ax.tick_params(labelsize='large')
ax.tick_params(direction='out')
@image_comparison(['pie_default.png'])
def test_pie_default():
# The slices will be ordered and plotted counter-clockwise.
| 63 | 64 | 171 | 28 | 35 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_pie_default | test_pie_default | 4,974 | 4,983 | 4,974 | 4,976 | 98abbd1adf9e48b503ddf1110af3fc74e52a44fc | bigcode/the-stack | train |
3eef799eb9e1ca040645dcad | train | function | def test_hist_emptydata():
fig, ax = plt.subplots()
ax.hist([[], range(10), range(10)], histtype="step")
| def test_hist_emptydata():
| fig, ax = plt.subplots()
ax.hist([[], range(10), range(10)], histtype="step")
| ed_bottom_unchanged():
b = np.array([10, 20])
plt.hist([[0, 1], [0, 1]], 2, histtype="barstacked", bottom=b)
assert b.tolist() == [10, 20]
def test_hist_emptydata():
| 63 | 64 | 32 | 6 | 57 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_hist_emptydata | test_hist_emptydata | 3,859 | 3,861 | 3,859 | 3,859 | 3fe8fbc39e64687c26cde1d996a83dad4af43726 | bigcode/the-stack | train |
7e2807759bb5f76a3c787b9f | train | function | def test_remove_shared_axes(shared_axes_generator, shared_axis_remover):
# test all of the ways to get fig/ax sets
fig, ax = shared_axes_generator
shared_axis_remover(ax)
| def test_remove_shared_axes(shared_axes_generator, shared_axis_remover):
# test all of the ways to get fig/ax sets
| fig, ax = shared_axes_generator
shared_axis_remover(ax)
| == 'add_axes':
fig = plt.figure()
ax = fig.add_axes([.1, .1, .8, .8])
return fig, ax
def test_remove_shared_axes(shared_axes_generator, shared_axis_remover):
# test all of the ways to get fig/ax sets
| 64 | 64 | 44 | 28 | 35 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_remove_shared_axes | test_remove_shared_axes | 5,718 | 5,721 | 5,718 | 5,719 | 3b7412fd5e9d0e8245badc8fce80c5e99cfba457 | bigcode/the-stack | train |
6b4b55c51905c1e6f1f4733e | train | function | def test_bar_pandas_indexed(pd):
# Smoke test for indexed pandas
df = pd.DataFrame({"x": [1., 2., 3.], "width": [.2, .4, .6]},
index=[1, 2, 3])
fig, ax = plt.subplots()
ax.bar(df.x, 1., width=df.width)
| def test_bar_pandas_indexed(pd):
# Smoke test for indexed pandas
| df = pd.DataFrame({"x": [1., 2., 3.], "width": [.2, .4, .6]},
index=[1, 2, 3])
fig, ax = plt.subplots()
ax.bar(df.x, 1., width=df.width)
| baseline = monthly['value']
fig, ax = plt.subplots()
ax.bar(dates, forecast, width=10, align='center')
ax.plot(dates, baseline, color='orange', lw=4)
def test_bar_pandas_indexed(pd):
# Smoke test for indexed pandas
| 64 | 64 | 81 | 17 | 47 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_bar_pandas_indexed | test_bar_pandas_indexed | 1,704 | 1,709 | 1,704 | 1,705 | 64651d0df828a0525b37f371c84bf8e9811e1723 | bigcode/the-stack | train |
703676872a3a02b61e44ef87 | train | function | def test_pandas_bar_align_center(pd):
# Tests fix for issue 8767
df = pd.DataFrame({'a': range(2), 'b': range(2)})
fig, ax = plt.subplots(1)
ax.bar(df.loc[df['a'] == 1, 'b'],
df.loc[df['a'] == 1, 'b'],
align='center')
fig.canvas.draw()
| def test_pandas_bar_align_center(pd):
# Tests fix for issue 8767
| df = pd.DataFrame({'a': range(2), 'b': range(2)})
fig, ax = plt.subplots(1)
ax.bar(df.loc[df['a'] == 1, 'b'],
df.loc[df['a'] == 1, 'b'],
align='center')
fig.canvas.draw()
| , 4, 4, 4, 4, 5])
ser_2 = ser_1.iloc[1:]
fig, ax = plt.subplots()
ax.hist(ser_2)
def test_pandas_bar_align_center(pd):
# Tests fix for issue 8767
| 64 | 64 | 90 | 19 | 45 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_pandas_bar_align_center | test_pandas_bar_align_center | 5,831 | 5,841 | 5,831 | 5,832 | 80082f0193f9e4b79a2ffe39955bd5836896bed2 | bigcode/the-stack | train |
2e1e6e349fbeae7ddc6522b4 | train | function | @image_comparison(['fill_between_interpolate_nan'], remove_text=True)
def test_fill_between_interpolate_nan():
# Tests fix for issue #18986.
x = np.arange(10)
y1 = np.asarray([8, 18, np.nan, 18, 8, 18, 24, 18, 8, 18])
y2 = np.asarray([18, 11, 8, 11, 18, 26, 32, 30, np.nan, np.nan])
# NumPy <... | @image_comparison(['fill_between_interpolate_nan'], remove_text=True)
def test_fill_between_interpolate_nan():
# Tests fix for issue #18986.
| x = np.arange(10)
y1 = np.asarray([8, 18, np.nan, 18, 8, 18, 24, 18, 8, 18])
y2 = np.asarray([18, 11, 8, 11, 18, 26, 32, 30, np.nan, np.nan])
# NumPy <1.19 issues warning 'invalid value encountered in greater_equal'
# for comparisons that include nan.
with np.errstate(invalid='ignore'):
... | , t, prof, where=prof > t,
facecolor='red', interpolate=True, alpha=0.4)
ax.set_xlim(0, 30)
ax.set_ylim(800, 600)
@image_comparison(['fill_between_interpolate_nan'], remove_text=True)
def test_fill_between_interpolate_nan():
# Tests fix for issue #18986.
| 79 | 79 | 265 | 33 | 46 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_fill_between_interpolate_nan | test_fill_between_interpolate_nan | 998 | 1,018 | 998 | 1,000 | 04673d23d3fea9de9afa7e6c4b7d9cbf8a7c66e0 | bigcode/the-stack | train |
366406f6c032a418f42be2bd | train | function | @image_comparison(['pcolormesh_datetime_axis.png'],
remove_text=False, style='mpl20')
def test_pcolormesh_datetime_axis():
# Remove this line when this test image is regenerated.
plt.rcParams['pcolormesh.snap'] = False
fig = plt.figure()
fig.subplots_adjust(hspace=0.4, top=0.98... | @image_comparison(['pcolormesh_datetime_axis.png'],
remove_text=False, style='mpl20')
def test_pcolormesh_datetime_axis():
# Remove this line when this test image is regenerated.
| plt.rcParams['pcolormesh.snap'] = False
fig = plt.figure()
fig.subplots_adjust(hspace=0.4, top=0.98, bottom=.15)
base = datetime.datetime(2013, 1, 1)
x = np.array([base + datetime.timedelta(days=d) for d in range(21)])
y = np.arange(21)
z1, z2 = np.meshgrid(np.arange(20), np.arange(2... | y, Z[:-1, :-1], cmap=cmap, shading='flat', zorder=1)
ax4.pcolormesh(Qx, Qy, Z, cmap=cmap, shading='gouraud', zorder=1)
@image_comparison(['pcolormesh_datetime_axis.png'],
remove_text=False, style='mpl20')
def test_pcolormesh_datetime_axis():
# Remove this line when this test image is regen... | 96 | 96 | 321 | 44 | 52 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_pcolormesh_datetime_axis | test_pcolormesh_datetime_axis | 1,122 | 1,148 | 1,122 | 1,125 | 9759756be2ae62ccc04c6c0169549708646094bd | bigcode/the-stack | train |
651c980b6ec6e1eaae2e9ea1 | train | function | @image_comparison(['polycollection_joinstyle'], remove_text=True)
def test_polycollection_joinstyle():
# Bug #2890979 reported by Matthew West
fig, ax = plt.subplots()
verts = np.array([[1, 1], [1, 2], [2, 2], [2, 1]])
c = mpl.collections.PolyCollection([verts], linewidths=40)
ax.add_collectio... | @image_comparison(['polycollection_joinstyle'], remove_text=True)
def test_polycollection_joinstyle():
# Bug #2890979 reported by Matthew West
| fig, ax = plt.subplots()
verts = np.array([[1, 1], [1, 2], [2, 2], [2, 1]])
c = mpl.collections.PolyCollection([verts], linewidths=40)
ax.add_collection(c)
ax.set_xbound(0, 3)
ax.set_ybound(0, 3)
| ultaneously is not supported."):
ax.imshow(a, norm=mcolors.Normalize(-10, 10), vmin=0, vmax=5)
@image_comparison(['polycollection_joinstyle'], remove_text=True)
def test_polycollection_joinstyle():
# Bug #2890979 reported by Matthew West
| 64 | 64 | 115 | 33 | 31 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_polycollection_joinstyle | test_polycollection_joinstyle | 908 | 916 | 908 | 910 | abd7b0f04acfaace2f0d2602c450ebfc6299ea62 | bigcode/the-stack | train |
689d8367549afed08a066c70 | train | function | @image_comparison(['bar_tick_label_single.png', 'bar_tick_label_single.png'])
def test_bar_tick_label_single():
# From 2516: plot bar with array of string labels for x axis
ax = plt.gca()
ax.bar(0, 1, align='edge', tick_label='0')
# Reuse testcase from above for a labeled data test
data = {"... | @image_comparison(['bar_tick_label_single.png', 'bar_tick_label_single.png'])
def test_bar_tick_label_single():
# From 2516: plot bar with array of string labels for x axis
| ax = plt.gca()
ax.bar(0, 1, align='edge', tick_label='0')
# Reuse testcase from above for a labeled data test
data = {"a": 0, "b": 1}
fig, ax = plt.subplots()
ax = plt.gca()
ax.bar("a", "b", align='edge', tick_label='0', data=data)
| (x), 'y.', ms=30.0, mew=2, mec='b')
@image_comparison(['bar_tick_label_single.png', 'bar_tick_label_single.png'])
def test_bar_tick_label_single():
# From 2516: plot bar with array of string labels for x axis
| 63 | 64 | 132 | 43 | 20 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_bar_tick_label_single | test_bar_tick_label_single | 1,500 | 1,510 | 1,500 | 1,502 | 5ef961efd937227f75e7ec2ba71a8ce81212f456 | bigcode/the-stack | train |
55e768a5f1105a5dc3ca215a | train | function | @image_comparison(["auto_numticks.png"], style='default')
def test_auto_numticks():
# Make tiny, empty subplots, verify that there are only 3 ticks.
plt.subplots(4, 4)
| @image_comparison(["auto_numticks.png"], style='default')
def test_auto_numticks():
# Make tiny, empty subplots, verify that there are only 3 ticks.
| plt.subplots(4, 4)
| 0, 1000)
fig.canvas.draw()
assert len(ax.yaxis.get_major_locator()()) > 2
@image_comparison(["auto_numticks.png"], style='default')
def test_auto_numticks():
# Make tiny, empty subplots, verify that there are only 3 ticks.
| 64 | 64 | 47 | 38 | 25 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_auto_numticks | test_auto_numticks | 5,762 | 5,765 | 5,762 | 5,764 | 0324b501197b6643cb1e007a1ba4cf4cd0685660 | bigcode/the-stack | train |
9bbe8b26f5144dbb961fa184 | train | function | @image_comparison(["twin_axis_locators_formatters"])
def test_twin_axis_locators_formatters():
vals = np.linspace(0, 1, num=5, endpoint=True)
locs = np.sin(np.pi * vals / 2.0)
majl = plt.FixedLocator(locs)
minl = plt.FixedLocator([0.1, 0.2, 0.3])
fig = plt.figure()
ax1 = fig.add_subpl... | @image_comparison(["twin_axis_locators_formatters"])
def test_twin_axis_locators_formatters():
| vals = np.linspace(0, 1, num=5, endpoint=True)
locs = np.sin(np.pi * vals / 2.0)
majl = plt.FixedLocator(locs)
minl = plt.FixedLocator([0.1, 0.2, 0.3])
fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1)
ax1.plot([0.1, 100], [0, 1])
ax1.yaxis.set_major_locator(majl)
ax1.yax... | _majfmt
assert not ax.yaxis.isDefault_minfmt
targ_strformatter = mticker.StrMethodFormatter(formstr)
assert isinstance(ax.yaxis.get_minor_formatter(),
mticker.StrMethodFormatter)
assert ax.yaxis.get_minor_formatter().fmt == targ_strformatter.fmt
@image_comparison(["twin_... | 86 | 86 | 289 | 24 | 61 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_twin_axis_locators_formatters | test_twin_axis_locators_formatters | 263 | 285 | 263 | 264 | 984b8b58c023c650a00fc321a15419a2b7e83212 | bigcode/the-stack | train |
ab20e00e6c7b59f445503194 | train | function | def test_hist_stepfilled_bottom_geometry():
bins = [0, 1, 2, 3]
data = [0, 0, 1, 1, 1, 2]
_, _, (polygon, ) = plt.hist(data,
bins=bins,
bottom=[1, 2, 1.5],
histtype='stepfilled')
xy = [[0, 1], [0, 3... | def test_hist_stepfilled_bottom_geometry():
| bins = [0, 1, 2, 3]
data = [0, 0, 1, 1, 1, 2]
_, _, (polygon, ) = plt.hist(data,
bins=bins,
bottom=[1, 2, 1.5],
histtype='stepfilled')
xy = [[0, 1], [0, 3], [1, 3], [1, 5], [2, 5], [2, 2.5], [3, 2.5]... | 0], [0, 2], [1, 2], [1, 3], [2, 3], [2, 1], [3, 1], [3, 0]]
assert_array_equal(polygon.get_xy(), xy)
def test_hist_stepfilled_bottom_geometry():
| 64 | 64 | 182 | 8 | 56 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_hist_stepfilled_bottom_geometry | test_hist_stepfilled_bottom_geometry | 3,726 | 3,735 | 3,726 | 3,726 | 42e83b60d55c8b5b3d5b1be3cbb96279c890db86 | bigcode/the-stack | train |
d8259f8d0c081b3a32bf4ab3 | train | function | def test_plot_format_kwarg_redundant():
with pytest.warns(UserWarning, match="marker .* redundantly defined"):
plt.plot([0], [0], 'o', marker='x')
with pytest.warns(UserWarning, match="linestyle .* redundantly defined"):
plt.plot([0], [0], '-', linestyle='--')
with pytest.warns(UserWarn... | def test_plot_format_kwarg_redundant():
| with pytest.warns(UserWarning, match="marker .* redundantly defined"):
plt.plot([0], [0], 'o', marker='x')
with pytest.warns(UserWarning, match="linestyle .* redundantly defined"):
plt.plot([0], [0], '-', linestyle='--')
with pytest.warns(UserWarning, match="color .* redundantly defined"... | t, t + day, t + day],
[0 * units.deg, 0 * units.deg, 90 * units.deg, 0 * units.deg],
facecolor="blue")
fig.autofmt_xdate()
def test_plot_format_kwarg_redundant():
| 64 | 64 | 133 | 11 | 53 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_plot_format_kwarg_redundant | test_plot_format_kwarg_redundant | 621 | 629 | 621 | 621 | fb61450877ff5484251b8aa25a0a632d596998ed | bigcode/the-stack | train |
78838f558c10c1aabc43e680 | train | function | @image_comparison(['marker_styles.png'], remove_text=True)
def test_marker_styles():
fig, ax = plt.subplots()
for y, marker in enumerate(sorted(matplotlib.markers.MarkerStyle.markers,
key=lambda x: str(type(x))+str(x))):
ax.plot((y % 2)*5 + np.arange(10)*10, np... | @image_comparison(['marker_styles.png'], remove_text=True)
def test_marker_styles():
| fig, ax = plt.subplots()
for y, marker in enumerate(sorted(matplotlib.markers.MarkerStyle.markers,
key=lambda x: str(type(x))+str(x))):
ax.plot((y % 2)*5 + np.arange(10)*10, np.ones(10)*10*y, linestyle='',
marker=marker, markersize=10+y/5, label=... | plot(ts_1, lineoffsets=0)
ax.eventplot(ts_2, lineoffsets=1)
ax = fig_test.subplots()
ax.eventplot([ts_1, ts_2])
@image_comparison(['marker_styles.png'], remove_text=True)
def test_marker_styles():
| 63 | 64 | 102 | 18 | 45 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_marker_styles | test_marker_styles | 4,134 | 4,140 | 4,134 | 4,135 | 9bd45aee6f3eeacc6ddaef87b99b1e3ba11074e8 | bigcode/the-stack | train |
a207a12cc6d6de1b22298936 | train | function | @image_comparison(['secondary_xy.png'], style='mpl20')
def test_secondary_xy():
fig, axs = plt.subplots(1, 2, figsize=(10, 5), constrained_layout=True)
def invert(x):
with np.errstate(divide='ignore'):
return 1 / x
for nn, ax in enumerate(axs):
ax.plot(np.arange(2, 11)... | @image_comparison(['secondary_xy.png'], style='mpl20')
def test_secondary_xy():
| fig, axs = plt.subplots(1, 2, figsize=(10, 5), constrained_layout=True)
def invert(x):
with np.errstate(divide='ignore'):
return 1 / x
for nn, ax in enumerate(axs):
ax.plot(np.arange(2, 11), np.arange(2, 11))
if nn == 0:
secax = ax.secondary_xaxis
... | ate("", xy=(x[150], y[150]), xycoords=ax.transData,
xytext=(1, 0), textcoords=axins.transAxes,
arrowprops=dict(arrowstyle="->"))
@image_comparison(['secondary_xy.png'], style='mpl20')
def test_secondary_xy():
| 63 | 64 | 197 | 19 | 44 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_secondary_xy | test_secondary_xy | 6,435 | 6,453 | 6,435 | 6,436 | 8e2736a7bbcd794de3a7366642344bfa694bad17 | bigcode/the-stack | train |
3a985495ecd799a189994c65 | train | function | @image_comparison(['violinplot_vert_baseline.png',
'violinplot_vert_baseline.png'])
def test_vert_violinplot_baseline():
# First 9 digits of frac(sqrt(2))
np.random.seed(414213562)
data = [np.random.normal(size=100) for _ in range(4)]
ax = plt.axes()
ax.violinplot(data, pos... | @image_comparison(['violinplot_vert_baseline.png',
'violinplot_vert_baseline.png'])
def test_vert_violinplot_baseline():
# First 9 digits of frac(sqrt(2))
| np.random.seed(414213562)
data = [np.random.normal(size=100) for _ in range(4)]
ax = plt.axes()
ax.violinplot(data, positions=range(4), showmeans=0, showextrema=0,
showmedians=0)
# Reuse testcase from above for a labeled data test
data = {"d": data}
fig, ax = plt.s... | key in bp:
for obj in bp[key]:
obj.set_color('green')
@image_comparison(['violinplot_vert_baseline.png',
'violinplot_vert_baseline.png'])
def test_vert_violinplot_baseline():
# First 9 digits of frac(sqrt(2))
| 63 | 64 | 173 | 45 | 18 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_vert_violinplot_baseline | test_vert_violinplot_baseline | 3,055 | 3,069 | 3,055 | 3,058 | 1edf871048cb032d3d6daa009d9b01e1946bef32 | bigcode/the-stack | train |
210edb7a88771cd10ced1a8d | train | function | def test_bar_label_fmt():
ax = plt.gca()
rects = ax.bar([1, 2], [3, -4])
labels = ax.bar_label(rects, fmt='%.2f')
assert labels[0].get_text() == '3.00'
assert labels[1].get_text() == '-4.00'
| def test_bar_label_fmt():
| ax = plt.gca()
rects = ax.bar([1, 2], [3, -4])
labels = ax.bar_label(rects, fmt='%.2f')
assert labels[0].get_text() == '3.00'
assert labels[1].get_text() == '-4.00'
| 0].get_va() == 'bottom'
assert labels[1].xy == (xs[1], heights[1] - 1)
assert labels[1].get_ha() == 'center'
assert labels[1].get_va() == 'top'
def test_bar_label_fmt():
| 63 | 64 | 76 | 6 | 57 | arnoyu-hub/COMP0016miemie | venv/Lib/site-packages/matplotlib/tests/test_axes.py | Python | test_bar_label_fmt | test_bar_label_fmt | 7,121 | 7,126 | 7,121 | 7,121 | c6d03768402bc6f17831962668ce37a3410c9e52 | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.