Skip to content

Instantly share code, notes, and snippets.

var chai = require("chai");
var chaiHttp = require("chai-http");
var server = require("../server");
var db = require("../models");
// Configure chai
chai.use(chaiHttp);
chai.should();
describe("Basic Example API Test", function() {
describe("GET ALL Examples", () => {
var chai = require("chai");
var chaiHttp = require("chai-http");
var server = require("../server");
var db = require("../models");
// Configure chai
chai.use(chaiHttp);
chai.should();
describe("Basic Example API Test", function() {
describe("GET ALL Examples", () => {
query getConversationMessages($conversationId: ID!, $after: String, $first: Int) {
allMessageConnection(conversationId: $conversationId, after: $after, first: $first) {
__typename
nextToken,
messages {
__typename
id
conversationId
content
createdAt
import numpy as np
def expSum(items):
temp = np.copy(items)
for x in np.nditer(temp, op_flags=['readwrite']):
x[...] = np.exp( x)
print "Using nditer and loop"
print temp
for row in items
import numpy as np
def expSum(items):
temp = np.copy(items)
for x in np.nditer(temp, op_flags=['readwrite']):
x[...] = np.exp( x)
print "Using nditer and loop"
print temp
print "transpose"
x = np.array((9,5,8,6,4,11)).reshape(3,2)
>>> x
array([[ 9, 5],
[ 8, 6],
[ 4, 11]])
>>> x.min(axis=0)
array([4, 5])
>>> x.min(axis=1)
array([5, 6, 4])
def expSum(items):
temp = np.copy(items)
for x in np.nditer(temp, op_flags=['readwrite']):
x[...] = np.exp( x)
return np.sum(temp)
import numpy as np
# Create the following rank 2 array with shape (3, 4)
# [[ 1 2 3 4]
# [ 5 6 7 8]
# [ 9 10 11 12]]
a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
# Use slicing to pull out the subarray consisting of the first 2 rows
# and columns 1 and 2; b is the following array of shape (2, 2):
nums = range(5) # range is a built-in function that creates a list of integers
print nums # Prints "[0, 1, 2, 3, 4]"
print nums[2:4] # Get a slice from index 2 to 4 (exclusive); prints "[2, 3]"
print nums[2:] # Get a slice from index 2 to the end; prints "[2, 3, 4]"
print nums[:2] # Get a slice from the start to index 2 (exclusive); prints "[0, 1]"
print nums[:] # Get a slice of the whole list; prints ["0, 1, 2, 3, 4]"
print nums[:-1] # Slice indices can be negative; prints ["0, 1, 2, 3]"
nums[2:4] = [8, 9] # Assign a new sublist to a slice
print nums # Prints "[0, 1, 8, 9, 4]"
nums = range(5) # range is a built-in function that creates a list of integers
print nums # Prints "[0, 1, 2, 3, 4]"
print nums[2:4] # Get a slice from index 2 to 4 (exclusive); prints "[2, 3]"
print nums[2:] # Get a slice from index 2 to the end; prints "[2, 3, 4]"
print nums[:2] # Get a slice from the start to index 2 (exclusive); prints "[0, 1]"
print nums[:] # Get a slice of the whole list; prints ["0, 1, 2, 3, 4]"
print nums[:-1] # Slice indices can be negative; prints ["0, 1, 2, 3]"
nums[2:4] = [8, 9] # Assign a new sublist to a slice
print nums # Prints "[0, 1, 8, 9, 4]"