body_hash stringlengths 64 64 | body stringlengths 23 109k | docstring stringlengths 1 57k | path stringlengths 4 198 | name stringlengths 1 115 | repository_name stringlengths 7 111 | repository_stars float64 0 191k | lang stringclasses 1 value | body_without_docstring stringlengths 14 108k | unified stringlengths 45 133k |
|---|---|---|---|---|---|---|---|---|---|
fd2f6aaa2d0c9d36759ca0160656954375717a4ebb5543c9d3e3eb670ea579d1 | def fill_line(self, line_direction, other_coords, colours):
'Fills the given line with the given colours.\n\n The direction represents the direction that the line is pointing in.\n other_coords is a Pos that represents the other two coordinates, the component in line_direction is ignored.'
if (type(colours) is Colour):
colours = [colours for i in range(SIZE)]
cs = colours[:]
line_direction_value = (line_direction.value.x if (line_direction.value.x != 0) else (line_direction.value.y if (line_direction.value.y != 0) else line_direction.value.z))
if (line_direction_value < 0):
cs.reverse()
for i in range(SIZE):
x = (i if (line_direction.value.x != 0) else other_coords.x)
y = (i if (line_direction.value.y != 0) else other_coords.y)
z = (i if (line_direction.value.z != 0) else other_coords.z)
self.grid[x][y][z] = cs[i] | Fills the given line with the given colours.
The direction represents the direction that the line is pointing in.
other_coords is a Pos that represents the other two coordinates, the component in line_direction is ignored. | visuals/cube.py | fill_line | daliasen/LED-Cube | 4 | python | def fill_line(self, line_direction, other_coords, colours):
'Fills the given line with the given colours.\n\n The direction represents the direction that the line is pointing in.\n other_coords is a Pos that represents the other two coordinates, the component in line_direction is ignored.'
if (type(colours) is Colour):
colours = [colours for i in range(SIZE)]
cs = colours[:]
line_direction_value = (line_direction.value.x if (line_direction.value.x != 0) else (line_direction.value.y if (line_direction.value.y != 0) else line_direction.value.z))
if (line_direction_value < 0):
cs.reverse()
for i in range(SIZE):
x = (i if (line_direction.value.x != 0) else other_coords.x)
y = (i if (line_direction.value.y != 0) else other_coords.y)
z = (i if (line_direction.value.z != 0) else other_coords.z)
self.grid[x][y][z] = cs[i] | def fill_line(self, line_direction, other_coords, colours):
'Fills the given line with the given colours.\n\n The direction represents the direction that the line is pointing in.\n other_coords is a Pos that represents the other two coordinates, the component in line_direction is ignored.'
if (type(colours) is Colour):
colours = [colours for i in range(SIZE)]
cs = colours[:]
line_direction_value = (line_direction.value.x if (line_direction.value.x != 0) else (line_direction.value.y if (line_direction.value.y != 0) else line_direction.value.z))
if (line_direction_value < 0):
cs.reverse()
for i in range(SIZE):
x = (i if (line_direction.value.x != 0) else other_coords.x)
y = (i if (line_direction.value.y != 0) else other_coords.y)
z = (i if (line_direction.value.z != 0) else other_coords.z)
self.grid[x][y][z] = cs[i]<|docstring|>Fills the given line with the given colours.
The direction represents the direction that the line is pointing in.
other_coords is a Pos that represents the other two coordinates, the component in line_direction is ignored.<|endoftext|> |
1e38c8ccfc4387c948c96fe6a7626fdc6ee27ca15f6ea5936a48263ccf79c13e | def get_line(self, line_direction, other_coords):
'Gets the colours on the given line\n\n The direction represents the direction that the line is pointing in.\n other_coords is a Pos that represents the other two coordinates, the component in line_direction is ignored.'
line_direction_value = (line_direction.value.x if (line_direction.value.x != 0) else (line_direction.value.y if (line_direction.value.y != 0) else line_direction.value.z))
cs = [Colour.BLACK for i in range(SIZE)]
for i in range(SIZE):
x = (i if (line_direction.value.x != 0) else other_coords.x)
y = (i if (line_direction.value.y != 0) else other_coords.y)
z = (i if (line_direction.value.z != 0) else other_coords.z)
cs[i] = self.grid[x][y][z]
if (line_direction_value < 0):
cs.reverse()
return cs | Gets the colours on the given line
The direction represents the direction that the line is pointing in.
other_coords is a Pos that represents the other two coordinates, the component in line_direction is ignored. | visuals/cube.py | get_line | daliasen/LED-Cube | 4 | python | def get_line(self, line_direction, other_coords):
'Gets the colours on the given line\n\n The direction represents the direction that the line is pointing in.\n other_coords is a Pos that represents the other two coordinates, the component in line_direction is ignored.'
line_direction_value = (line_direction.value.x if (line_direction.value.x != 0) else (line_direction.value.y if (line_direction.value.y != 0) else line_direction.value.z))
cs = [Colour.BLACK for i in range(SIZE)]
for i in range(SIZE):
x = (i if (line_direction.value.x != 0) else other_coords.x)
y = (i if (line_direction.value.y != 0) else other_coords.y)
z = (i if (line_direction.value.z != 0) else other_coords.z)
cs[i] = self.grid[x][y][z]
if (line_direction_value < 0):
cs.reverse()
return cs | def get_line(self, line_direction, other_coords):
'Gets the colours on the given line\n\n The direction represents the direction that the line is pointing in.\n other_coords is a Pos that represents the other two coordinates, the component in line_direction is ignored.'
line_direction_value = (line_direction.value.x if (line_direction.value.x != 0) else (line_direction.value.y if (line_direction.value.y != 0) else line_direction.value.z))
cs = [Colour.BLACK for i in range(SIZE)]
for i in range(SIZE):
x = (i if (line_direction.value.x != 0) else other_coords.x)
y = (i if (line_direction.value.y != 0) else other_coords.y)
z = (i if (line_direction.value.z != 0) else other_coords.z)
cs[i] = self.grid[x][y][z]
if (line_direction_value < 0):
cs.reverse()
return cs<|docstring|>Gets the colours on the given line
The direction represents the direction that the line is pointing in.
other_coords is a Pos that represents the other two coordinates, the component in line_direction is ignored.<|endoftext|> |
d6e8419b95dc9e0ba0a061d02a4e51de75fce40bcf57fc17f189c5883c54fa3c | def transform_colours(self, f):
'Transforms all of the colours in the cube using f(colour)'
for x in range(SIZE):
for y in range(SIZE):
for z in range(SIZE):
self.grid[x][y][z] = f(self.grid[x][y][z]) | Transforms all of the colours in the cube using f(colour) | visuals/cube.py | transform_colours | daliasen/LED-Cube | 4 | python | def transform_colours(self, f):
for x in range(SIZE):
for y in range(SIZE):
for z in range(SIZE):
self.grid[x][y][z] = f(self.grid[x][y][z]) | def transform_colours(self, f):
for x in range(SIZE):
for y in range(SIZE):
for z in range(SIZE):
self.grid[x][y][z] = f(self.grid[x][y][z])<|docstring|>Transforms all of the colours in the cube using f(colour)<|endoftext|> |
05afd8894ede634825989edad17a5b5159cdd1acbba260f740b7c6da8d59088c | def test_post_json_success(self):
'Test for POST application/json success'
test_json = {'wasser': 'stein'}
json_string = json.dumps(test_json)
message_len = len(json_string)
expecting_response = 'HTTP/1.0 200 OK\nContent-Type: text/plain\nContent-Length: {0}\n\n{1}'.format(message_len, json_string)
wasser_post_json_response = self.request.post('https://localhost:1027/', test_json)
self.assertEqual(expecting_response, wasser_post_json_response) | Test for POST application/json success | test.py | test_post_json_success | wkrzemien/Wasser | 0 | python | def test_post_json_success(self):
test_json = {'wasser': 'stein'}
json_string = json.dumps(test_json)
message_len = len(json_string)
expecting_response = 'HTTP/1.0 200 OK\nContent-Type: text/plain\nContent-Length: {0}\n\n{1}'.format(message_len, json_string)
wasser_post_json_response = self.request.post('https://localhost:1027/', test_json)
self.assertEqual(expecting_response, wasser_post_json_response) | def test_post_json_success(self):
test_json = {'wasser': 'stein'}
json_string = json.dumps(test_json)
message_len = len(json_string)
expecting_response = 'HTTP/1.0 200 OK\nContent-Type: text/plain\nContent-Length: {0}\n\n{1}'.format(message_len, json_string)
wasser_post_json_response = self.request.post('https://localhost:1027/', test_json)
self.assertEqual(expecting_response, wasser_post_json_response)<|docstring|>Test for POST application/json success<|endoftext|> |
a64a40b6125e72cd21cb43d21a2ab66ebee77e94e4c96b558247584f8c08677d | def test_post_text_success(self):
'Test for POST text/plain success'
message = 'How are you'
message_len = len(message)
expecting_response = 'HTTP/1.0 200 OK\nContent-Type: text/plain\nContent-Length: {0}\n\n{1}'.format(message_len, message)
wasser_post_text_response = self.request.post('https://localhost:1027/', message)
self.assertEqual(expecting_response, wasser_post_text_response) | Test for POST text/plain success | test.py | test_post_text_success | wkrzemien/Wasser | 0 | python | def test_post_text_success(self):
message = 'How are you'
message_len = len(message)
expecting_response = 'HTTP/1.0 200 OK\nContent-Type: text/plain\nContent-Length: {0}\n\n{1}'.format(message_len, message)
wasser_post_text_response = self.request.post('https://localhost:1027/', message)
self.assertEqual(expecting_response, wasser_post_text_response) | def test_post_text_success(self):
message = 'How are you'
message_len = len(message)
expecting_response = 'HTTP/1.0 200 OK\nContent-Type: text/plain\nContent-Length: {0}\n\n{1}'.format(message_len, message)
wasser_post_text_response = self.request.post('https://localhost:1027/', message)
self.assertEqual(expecting_response, wasser_post_text_response)<|docstring|>Test for POST text/plain success<|endoftext|> |
39cc1555afce9db3e2f4238ddfc440a5821978803663c210f3a6a4201f16f7e2 | def test_get_success(self):
'Test for GET */* success'
expecting_response = 'HTTP/1.0 200 OK\n Content-Type: text/html\n\n\n <head>Test message ...</head>\n <body>Hello there, general Kenobi</body>\n '
wasser_get_response = self.request.get('https://localhost:1027/')
self.assertEqual(expecting_response, wasser_get_response) | Test for GET */* success | test.py | test_get_success | wkrzemien/Wasser | 0 | python | def test_get_success(self):
expecting_response = 'HTTP/1.0 200 OK\n Content-Type: text/html\n\n\n <head>Test message ...</head>\n <body>Hello there, general Kenobi</body>\n '
wasser_get_response = self.request.get('https://localhost:1027/')
self.assertEqual(expecting_response, wasser_get_response) | def test_get_success(self):
expecting_response = 'HTTP/1.0 200 OK\n Content-Type: text/html\n\n\n <head>Test message ...</head>\n <body>Hello there, general Kenobi</body>\n '
wasser_get_response = self.request.get('https://localhost:1027/')
self.assertEqual(expecting_response, wasser_get_response)<|docstring|>Test for GET */* success<|endoftext|> |
13eca16856472d62c9c833923209c0bcb68f4cd9d138bece641a5e1d7b10c1d6 | def _build_model(self):
'\n Helper method to build a model for the agent\n '
self.State = tf.placeholder(tf.float32, [None, self.state_dim])
self.Target = tf.placeholder(tf.float32, [None, 1])
self.W = tf.Variable(tf.ones([self.state_dim, self.n_actions]))
self.b = tf.Variable(tf.ones([self.n_actions]))
self.y_ = tf.add(tf.matmul(self.State, self.W), self.b)
self.cost = tf.reduce_mean(tf.square((self.Target - self.y_)))
self.training_step = tf.train.GradientDescentOptimizer(self.learning_rate).minimize(self.cost)
self.sess = tf.Session()
init = tf.global_variables_initializer()
self.sess.run(init) | Helper method to build a model for the agent | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | _build_model | fqzhou/LoadBalanceControl-RL | 11 | python | def _build_model(self):
'\n \n '
self.State = tf.placeholder(tf.float32, [None, self.state_dim])
self.Target = tf.placeholder(tf.float32, [None, 1])
self.W = tf.Variable(tf.ones([self.state_dim, self.n_actions]))
self.b = tf.Variable(tf.ones([self.n_actions]))
self.y_ = tf.add(tf.matmul(self.State, self.W), self.b)
self.cost = tf.reduce_mean(tf.square((self.Target - self.y_)))
self.training_step = tf.train.GradientDescentOptimizer(self.learning_rate).minimize(self.cost)
self.sess = tf.Session()
init = tf.global_variables_initializer()
self.sess.run(init) | def _build_model(self):
'\n \n '
self.State = tf.placeholder(tf.float32, [None, self.state_dim])
self.Target = tf.placeholder(tf.float32, [None, 1])
self.W = tf.Variable(tf.ones([self.state_dim, self.n_actions]))
self.b = tf.Variable(tf.ones([self.n_actions]))
self.y_ = tf.add(tf.matmul(self.State, self.W), self.b)
self.cost = tf.reduce_mean(tf.square((self.Target - self.y_)))
self.training_step = tf.train.GradientDescentOptimizer(self.learning_rate).minimize(self.cost)
self.sess = tf.Session()
init = tf.global_variables_initializer()
self.sess.run(init)<|docstring|>Helper method to build a model for the agent<|endoftext|> |
70740c458dd7ed57c4820a92e62ea0fc58ace09bb2d74ceb22d58951af7ab6be | def predict(self, state):
"\n Helper method to predict models's output\n "
return self.sess.run(self.y_, feed_dict={self.State: state}) | Helper method to predict models's output | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | predict | fqzhou/LoadBalanceControl-RL | 11 | python | def predict(self, state):
"\n \n "
return self.sess.run(self.y_, feed_dict={self.State: state}) | def predict(self, state):
"\n \n "
return self.sess.run(self.y_, feed_dict={self.State: state})<|docstring|>Helper method to predict models's output<|endoftext|> |
f4cef7f135469f55dec5b7cb771c74a0cfe5066dfdaa6ff094bfbc516c47353a | def train(self, state, target):
'\n Helper method to train the model\n '
self.sess.run(self.training_step, feed_dict={self.State: state, self.Target: target}) | Helper method to train the model | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | train | fqzhou/LoadBalanceControl-RL | 11 | python | def train(self, state, target):
'\n \n '
self.sess.run(self.training_step, feed_dict={self.State: state, self.Target: target}) | def train(self, state, target):
'\n \n '
self.sess.run(self.training_step, feed_dict={self.State: state, self.Target: target})<|docstring|>Helper method to train the model<|endoftext|> |
4997da0a5df1784c5bf3015fb9b1da1a11b090e4f89587e3ef28ff8b3ba381e3 | def model_cost(self, state, target):
'\n Calculate cost\n '
return self.sess.run(self.cost, feed_dict={self.State: state, self.Target: target}) | Calculate cost | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | model_cost | fqzhou/LoadBalanceControl-RL | 11 | python | def model_cost(self, state, target):
'\n \n '
return self.sess.run(self.cost, feed_dict={self.State: state, self.Target: target}) | def model_cost(self, state, target):
'\n \n '
return self.sess.run(self.cost, feed_dict={self.State: state, self.Target: target})<|docstring|>Calculate cost<|endoftext|> |
a7a7f185029c9c2eec868919d7512fd26d0bffd4324b3a24923b7a9de1083ff3 | def model_error(self, pred_y, test_y):
'\n Calculate mean sqare error\n '
return tf.reduce_mean(tf.square((pred_y - test_y))) | Calculate mean sqare error | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | model_error | fqzhou/LoadBalanceControl-RL | 11 | python | def model_error(self, pred_y, test_y):
'\n \n '
return tf.reduce_mean(tf.square((pred_y - test_y))) | def model_error(self, pred_y, test_y):
'\n \n '
return tf.reduce_mean(tf.square((pred_y - test_y)))<|docstring|>Calculate mean sqare error<|endoftext|> |
29d8b56c8817d1e0a665e751fed9ca235d1c1f2f579f29bf74a2dc75155bba06 | def _take_action(self, state):
'\n Implements how to take actions when provided with a state\n\n This follows epsilon-greedy policy (behavior policy)\n\n Args:\n state: (tuple)\n\n Returns:\n action: (float)\n '
if (np.random.rand() < self.epsilon):
return np.random.choice(list(range(self.n_actions)))
return np.argmax(self.predict(np.reshape(state, (1, self.state_dim)))) | Implements how to take actions when provided with a state
This follows epsilon-greedy policy (behavior policy)
Args:
state: (tuple)
Returns:
action: (float) | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | _take_action | fqzhou/LoadBalanceControl-RL | 11 | python | def _take_action(self, state):
'\n Implements how to take actions when provided with a state\n\n This follows epsilon-greedy policy (behavior policy)\n\n Args:\n state: (tuple)\n\n Returns:\n action: (float)\n '
if (np.random.rand() < self.epsilon):
return np.random.choice(list(range(self.n_actions)))
return np.argmax(self.predict(np.reshape(state, (1, self.state_dim)))) | def _take_action(self, state):
'\n Implements how to take actions when provided with a state\n\n This follows epsilon-greedy policy (behavior policy)\n\n Args:\n state: (tuple)\n\n Returns:\n action: (float)\n '
if (np.random.rand() < self.epsilon):
return np.random.choice(list(range(self.n_actions)))
return np.argmax(self.predict(np.reshape(state, (1, self.state_dim))))<|docstring|>Implements how to take actions when provided with a state
This follows epsilon-greedy policy (behavior policy)
Args:
state: (tuple)
Returns:
action: (float)<|endoftext|> |
3aacc2aa124bfda44aab038e5e1e7615b86277c7cbbf0e9c20f2ec1f010f3be6 | def _learn(self, state, action, reward, next_state):
'\n Implements how the agent learns\n\n Args:\n state: (tuple)\n Current state of the environment.\n action: (float)\n Current action taken by the agent.\n reward: (float):\n Reward produced by the environment.\n next_state: (tuple)\n Next state of the environment.\n\n '
if (self.epsilon > self.epsilon_min):
self.epsilon *= self.epsilon_decay
state = np.reshape(state, (1, self.state_dim))
target = self.predict(state)
self.train(state, target) | Implements how the agent learns
Args:
state: (tuple)
Current state of the environment.
action: (float)
Current action taken by the agent.
reward: (float):
Reward produced by the environment.
next_state: (tuple)
Next state of the environment. | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | _learn | fqzhou/LoadBalanceControl-RL | 11 | python | def _learn(self, state, action, reward, next_state):
'\n Implements how the agent learns\n\n Args:\n state: (tuple)\n Current state of the environment.\n action: (float)\n Current action taken by the agent.\n reward: (float):\n Reward produced by the environment.\n next_state: (tuple)\n Next state of the environment.\n\n '
if (self.epsilon > self.epsilon_min):
self.epsilon *= self.epsilon_decay
state = np.reshape(state, (1, self.state_dim))
target = self.predict(state)
self.train(state, target) | def _learn(self, state, action, reward, next_state):
'\n Implements how the agent learns\n\n Args:\n state: (tuple)\n Current state of the environment.\n action: (float)\n Current action taken by the agent.\n reward: (float):\n Reward produced by the environment.\n next_state: (tuple)\n Next state of the environment.\n\n '
if (self.epsilon > self.epsilon_min):
self.epsilon *= self.epsilon_decay
state = np.reshape(state, (1, self.state_dim))
target = self.predict(state)
self.train(state, target)<|docstring|>Implements how the agent learns
Args:
state: (tuple)
Current state of the environment.
action: (float)
Current action taken by the agent.
reward: (float):
Reward produced by the environment.
next_state: (tuple)
Next state of the environment.<|endoftext|> |
af400eac45d8e15aa1f151a6be216bd27ed3a3cd56aab65ebc877fbaccf3dbbf | def _build_model(self):
'\n Helper method to build a model for the agent\n '
self.State = tf.placeholder(tf.float32, [None, self.state_dim])
self.Target = tf.placeholder(tf.float32, [None, self.n_actions])
self.W = tf.Variable(tf.random_normal([self.state_dim, self.n_actions], stddev=0.1))
self.b = tf.Variable(tf.random_normal([self.n_actions], stddev=0.1))
self.y_ = tf.add(tf.matmul(self.State, self.W), self.b)
self.a = tf.placeholder(tf.int32)
self.one_hot_mask = tf.one_hot(self.a, self.n_actions)
self.cost = (tf.reduce_mean(tf.square((self.y_ - self.Target))) + (0.1 * tf.nn.l2_loss(tf.reduce_sum(tf.multiply(self.W, self.one_hot_mask), axis=1))))
self.optimizer = tf.train.AdamOptimizer(learning_rate=self.learning_rate)
self.grads_and_vars = self.optimizer.compute_gradients(self.cost)
self.clipped_grads_and_vars = [(tf.clip_by_norm(item[0], 1), item[1]) for item in self.grads_and_vars]
self.training_step = self.optimizer.apply_gradients(self.clipped_grads_and_vars)
self.sess = tf.Session()
init = tf.global_variables_initializer()
self.sess.run(init)
tf.summary.FileWriter('logs/linear', self.sess.graph) | Helper method to build a model for the agent | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | _build_model | fqzhou/LoadBalanceControl-RL | 11 | python | def _build_model(self):
'\n \n '
self.State = tf.placeholder(tf.float32, [None, self.state_dim])
self.Target = tf.placeholder(tf.float32, [None, self.n_actions])
self.W = tf.Variable(tf.random_normal([self.state_dim, self.n_actions], stddev=0.1))
self.b = tf.Variable(tf.random_normal([self.n_actions], stddev=0.1))
self.y_ = tf.add(tf.matmul(self.State, self.W), self.b)
self.a = tf.placeholder(tf.int32)
self.one_hot_mask = tf.one_hot(self.a, self.n_actions)
self.cost = (tf.reduce_mean(tf.square((self.y_ - self.Target))) + (0.1 * tf.nn.l2_loss(tf.reduce_sum(tf.multiply(self.W, self.one_hot_mask), axis=1))))
self.optimizer = tf.train.AdamOptimizer(learning_rate=self.learning_rate)
self.grads_and_vars = self.optimizer.compute_gradients(self.cost)
self.clipped_grads_and_vars = [(tf.clip_by_norm(item[0], 1), item[1]) for item in self.grads_and_vars]
self.training_step = self.optimizer.apply_gradients(self.clipped_grads_and_vars)
self.sess = tf.Session()
init = tf.global_variables_initializer()
self.sess.run(init)
tf.summary.FileWriter('logs/linear', self.sess.graph) | def _build_model(self):
'\n \n '
self.State = tf.placeholder(tf.float32, [None, self.state_dim])
self.Target = tf.placeholder(tf.float32, [None, self.n_actions])
self.W = tf.Variable(tf.random_normal([self.state_dim, self.n_actions], stddev=0.1))
self.b = tf.Variable(tf.random_normal([self.n_actions], stddev=0.1))
self.y_ = tf.add(tf.matmul(self.State, self.W), self.b)
self.a = tf.placeholder(tf.int32)
self.one_hot_mask = tf.one_hot(self.a, self.n_actions)
self.cost = (tf.reduce_mean(tf.square((self.y_ - self.Target))) + (0.1 * tf.nn.l2_loss(tf.reduce_sum(tf.multiply(self.W, self.one_hot_mask), axis=1))))
self.optimizer = tf.train.AdamOptimizer(learning_rate=self.learning_rate)
self.grads_and_vars = self.optimizer.compute_gradients(self.cost)
self.clipped_grads_and_vars = [(tf.clip_by_norm(item[0], 1), item[1]) for item in self.grads_and_vars]
self.training_step = self.optimizer.apply_gradients(self.clipped_grads_and_vars)
self.sess = tf.Session()
init = tf.global_variables_initializer()
self.sess.run(init)
tf.summary.FileWriter('logs/linear', self.sess.graph)<|docstring|>Helper method to build a model for the agent<|endoftext|> |
a70707a33ba65f94e059ee0e6eb948bf33e7e6e1f2ece05c966bd9868ade976b | def _build_ap_model(self):
'\n Implements Q(s, stay) for APs only\n '
return defaultdict(float) | Implements Q(s, stay) for APs only | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | _build_ap_model | fqzhou/LoadBalanceControl-RL | 11 | python | def _build_ap_model(self):
'\n \n '
return defaultdict(float) | def _build_ap_model(self):
'\n \n '
return defaultdict(float)<|docstring|>Implements Q(s, stay) for APs only<|endoftext|> |
70740c458dd7ed57c4820a92e62ea0fc58ace09bb2d74ceb22d58951af7ab6be | def predict(self, state):
"\n Helper method to predict models's output\n "
return self.sess.run(self.y_, feed_dict={self.State: state}) | Helper method to predict models's output | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | predict | fqzhou/LoadBalanceControl-RL | 11 | python | def predict(self, state):
"\n \n "
return self.sess.run(self.y_, feed_dict={self.State: state}) | def predict(self, state):
"\n \n "
return self.sess.run(self.y_, feed_dict={self.State: state})<|docstring|>Helper method to predict models's output<|endoftext|> |
4997da0a5df1784c5bf3015fb9b1da1a11b090e4f89587e3ef28ff8b3ba381e3 | def model_cost(self, state, target):
'\n Calculate cost\n '
return self.sess.run(self.cost, feed_dict={self.State: state, self.Target: target}) | Calculate cost | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | model_cost | fqzhou/LoadBalanceControl-RL | 11 | python | def model_cost(self, state, target):
'\n \n '
return self.sess.run(self.cost, feed_dict={self.State: state, self.Target: target}) | def model_cost(self, state, target):
'\n \n '
return self.sess.run(self.cost, feed_dict={self.State: state, self.Target: target})<|docstring|>Calculate cost<|endoftext|> |
a7a7f185029c9c2eec868919d7512fd26d0bffd4324b3a24923b7a9de1083ff3 | def model_error(self, pred_y, test_y):
'\n Calculate mean sqare error\n '
return tf.reduce_mean(tf.square((pred_y - test_y))) | Calculate mean sqare error | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | model_error | fqzhou/LoadBalanceControl-RL | 11 | python | def model_error(self, pred_y, test_y):
'\n \n '
return tf.reduce_mean(tf.square((pred_y - test_y))) | def model_error(self, pred_y, test_y):
'\n \n '
return tf.reduce_mean(tf.square((pred_y - test_y)))<|docstring|>Calculate mean sqare error<|endoftext|> |
e71f351d96ff342e4aecb70e9c28b739d9a57c161af561a1920226710e9b1ab9 | def q_from_ap_model(self, state):
'\n Helper method to fetch the Q value of the state during stay\n\n Args\n ----\n state: (tuple)\n State of the environment.\n\n\n Returns\n -------\n value: (float)\n Q Value of stay for the given state.\n '
return self.ap_model[state] | Helper method to fetch the Q value of the state during stay
Args
----
state: (tuple)
State of the environment.
Returns
-------
value: (float)
Q Value of stay for the given state. | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | q_from_ap_model | fqzhou/LoadBalanceControl-RL | 11 | python | def q_from_ap_model(self, state):
'\n Helper method to fetch the Q value of the state during stay\n\n Args\n ----\n state: (tuple)\n State of the environment.\n\n\n Returns\n -------\n value: (float)\n Q Value of stay for the given state.\n '
return self.ap_model[state] | def q_from_ap_model(self, state):
'\n Helper method to fetch the Q value of the state during stay\n\n Args\n ----\n state: (tuple)\n State of the environment.\n\n\n Returns\n -------\n value: (float)\n Q Value of stay for the given state.\n '
return self.ap_model[state]<|docstring|>Helper method to fetch the Q value of the state during stay
Args
----
state: (tuple)
State of the environment.
Returns
-------
value: (float)
Q Value of stay for the given state.<|endoftext|> |
56a29a9bb11ea2cc9759da6acba2ca419fc9f6693bc7d7bc53a50fce1c2d2aa4 | def get_random_action(self, ap_list, seed=None):
'\n Helper to return a random action\n\n Args\n ----\n ap_list: (list)\n list containing current ap and neighboring aps\n\n Returns\n -------\n action: (int)\n 0 (stay), 1(handoff)\n ap_id: (int)\n id of the next ap\n '
self.logger.debug('Taking a random action!')
if seed:
np.random.seed(seed)
random_action = 0
ap_id = ap_list[0]
if (len(ap_list) > 1):
random_action = np.random.choice(self.n_actions)
if (random_action == 1):
ap_id = np.random.choice(ap_list[1:])
random_action_info = CELLULAR_AGENT_ACTION(action=random_action, ap_id=ap_id)
self.logger.debug('random_action_info: {}'.format(random_action_info))
return random_action_info | Helper to return a random action
Args
----
ap_list: (list)
list containing current ap and neighboring aps
Returns
-------
action: (int)
0 (stay), 1(handoff)
ap_id: (int)
id of the next ap | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | get_random_action | fqzhou/LoadBalanceControl-RL | 11 | python | def get_random_action(self, ap_list, seed=None):
'\n Helper to return a random action\n\n Args\n ----\n ap_list: (list)\n list containing current ap and neighboring aps\n\n Returns\n -------\n action: (int)\n 0 (stay), 1(handoff)\n ap_id: (int)\n id of the next ap\n '
self.logger.debug('Taking a random action!')
if seed:
np.random.seed(seed)
random_action = 0
ap_id = ap_list[0]
if (len(ap_list) > 1):
random_action = np.random.choice(self.n_actions)
if (random_action == 1):
ap_id = np.random.choice(ap_list[1:])
random_action_info = CELLULAR_AGENT_ACTION(action=random_action, ap_id=ap_id)
self.logger.debug('random_action_info: {}'.format(random_action_info))
return random_action_info | def get_random_action(self, ap_list, seed=None):
'\n Helper to return a random action\n\n Args\n ----\n ap_list: (list)\n list containing current ap and neighboring aps\n\n Returns\n -------\n action: (int)\n 0 (stay), 1(handoff)\n ap_id: (int)\n id of the next ap\n '
self.logger.debug('Taking a random action!')
if seed:
np.random.seed(seed)
random_action = 0
ap_id = ap_list[0]
if (len(ap_list) > 1):
random_action = np.random.choice(self.n_actions)
if (random_action == 1):
ap_id = np.random.choice(ap_list[1:])
random_action_info = CELLULAR_AGENT_ACTION(action=random_action, ap_id=ap_id)
self.logger.debug('random_action_info: {}'.format(random_action_info))
return random_action_info<|docstring|>Helper to return a random action
Args
----
ap_list: (list)
list containing current ap and neighboring aps
Returns
-------
action: (int)
0 (stay), 1(handoff)
ap_id: (int)
id of the next ap<|endoftext|> |
4330ff7f20ca394df9ffca8172559cc8b962294c34cf75cee863d85d2d5d3bfe | def _take_action(self, network_state, ap_list, prob, seed=None):
'\n Implements how to take actions when provided with a state\n\n This follows epsilon-greedy policy (behavior policy)\n\n Args:\n state: (tuple)\n\n Returns:\n action: (float)\n '
if (prob < self.epsilon):
return self.get_random_action(ap_list, seed)
return self.get_max_action(network_state, ap_list) | Implements how to take actions when provided with a state
This follows epsilon-greedy policy (behavior policy)
Args:
state: (tuple)
Returns:
action: (float) | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | _take_action | fqzhou/LoadBalanceControl-RL | 11 | python | def _take_action(self, network_state, ap_list, prob, seed=None):
'\n Implements how to take actions when provided with a state\n\n This follows epsilon-greedy policy (behavior policy)\n\n Args:\n state: (tuple)\n\n Returns:\n action: (float)\n '
if (prob < self.epsilon):
return self.get_random_action(ap_list, seed)
return self.get_max_action(network_state, ap_list) | def _take_action(self, network_state, ap_list, prob, seed=None):
'\n Implements how to take actions when provided with a state\n\n This follows epsilon-greedy policy (behavior policy)\n\n Args:\n state: (tuple)\n\n Returns:\n action: (float)\n '
if (prob < self.epsilon):
return self.get_random_action(ap_list, seed)
return self.get_max_action(network_state, ap_list)<|docstring|>Implements how to take actions when provided with a state
This follows epsilon-greedy policy (behavior policy)
Args:
state: (tuple)
Returns:
action: (float)<|endoftext|> |
6d3dcaeaabbf4a1840f36afc0783223732ab306b1d3f1d7028f2e8f7c4c689ea | def get_max_action(self, network_state, ap_list):
'\n Helper to return action with max Q value\n\n If there are no neighboring_aps, then action defaults to "stay"\n else return the max with max Q. The first step it to max the approximate \n Q value to decide to "stay" or "handoff", the second step is based the \n second Q table based on the ue_ap_state\n\n Args\n ----\n network_state: (tuple)\n State of the network.\n ap_list: (list)\n list containing current ap and neighboring aps\n\n Returns\n -------\n action: (int)\n 0 (stay), 1(handoff)\n ap_id: (int)\n id of the next ap\n '
max_action = 0
ap_id = ap_list[0]
if (len(ap_list) > 1):
action_values = self.predict(np.reshape(network_state, (1, self.state_dim)))
max_action = np.argmax(action_values)
if (max_action == 1):
max_action = (- 1)
max_action_info = CELLULAR_AGENT_ACTION(action=max_action, ap_id=ap_id)
return max_action_info | Helper to return action with max Q value
If there are no neighboring_aps, then action defaults to "stay"
else return the max with max Q. The first step it to max the approximate
Q value to decide to "stay" or "handoff", the second step is based the
second Q table based on the ue_ap_state
Args
----
network_state: (tuple)
State of the network.
ap_list: (list)
list containing current ap and neighboring aps
Returns
-------
action: (int)
0 (stay), 1(handoff)
ap_id: (int)
id of the next ap | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | get_max_action | fqzhou/LoadBalanceControl-RL | 11 | python | def get_max_action(self, network_state, ap_list):
'\n Helper to return action with max Q value\n\n If there are no neighboring_aps, then action defaults to "stay"\n else return the max with max Q. The first step it to max the approximate \n Q value to decide to "stay" or "handoff", the second step is based the \n second Q table based on the ue_ap_state\n\n Args\n ----\n network_state: (tuple)\n State of the network.\n ap_list: (list)\n list containing current ap and neighboring aps\n\n Returns\n -------\n action: (int)\n 0 (stay), 1(handoff)\n ap_id: (int)\n id of the next ap\n '
max_action = 0
ap_id = ap_list[0]
if (len(ap_list) > 1):
action_values = self.predict(np.reshape(network_state, (1, self.state_dim)))
max_action = np.argmax(action_values)
if (max_action == 1):
max_action = (- 1)
max_action_info = CELLULAR_AGENT_ACTION(action=max_action, ap_id=ap_id)
return max_action_info | def get_max_action(self, network_state, ap_list):
'\n Helper to return action with max Q value\n\n If there are no neighboring_aps, then action defaults to "stay"\n else return the max with max Q. The first step it to max the approximate \n Q value to decide to "stay" or "handoff", the second step is based the \n second Q table based on the ue_ap_state\n\n Args\n ----\n network_state: (tuple)\n State of the network.\n ap_list: (list)\n list containing current ap and neighboring aps\n\n Returns\n -------\n action: (int)\n 0 (stay), 1(handoff)\n ap_id: (int)\n id of the next ap\n '
max_action = 0
ap_id = ap_list[0]
if (len(ap_list) > 1):
action_values = self.predict(np.reshape(network_state, (1, self.state_dim)))
max_action = np.argmax(action_values)
if (max_action == 1):
max_action = (- 1)
max_action_info = CELLULAR_AGENT_ACTION(action=max_action, ap_id=ap_id)
return max_action_info<|docstring|>Helper to return action with max Q value
If there are no neighboring_aps, then action defaults to "stay"
else return the max with max Q. The first step it to max the approximate
Q value to decide to "stay" or "handoff", the second step is based the
second Q table based on the ue_ap_state
Args
----
network_state: (tuple)
State of the network.
ap_list: (list)
list containing current ap and neighboring aps
Returns
-------
action: (int)
0 (stay), 1(handoff)
ap_id: (int)
id of the next ap<|endoftext|> |
b218ddedcd71e02ddf2c4673cc034f3ce5f4c6c1cf185d923d600bc8770b4bfa | def _learn(self, state, action, reward, next_state, ue_ap_state):
'\n Implements how the agent learns and the training step\n\n Args:\n state: (tuple)\n Current state of the environment.\n action: (float)\n Current action taken by the agent.\n reward: (float):\n Reward produced by the environment.\n next_state: (tuple)\n Next state of the environment.\n\n '
if (self.epsilon > self.epsilon_min):
self.epsilon *= self.epsilon_decay
state = np.reshape(state, (1, self.state_dim))
next_state = np.reshape(next_state, (1, self.state_dim))
target = self.predict(state)
target[0][action] = (reward + (self.gamma * self.max_q_for_state(next_state)))
if ue_ap_state:
second_q_target = reward
second_q_error = (second_q_target - self.ap_model[ue_ap_state])
self.logger.debug('Updating second Q table in regression method!')
self.ap_model[ue_ap_state] += (self.alpha * second_q_error)
self.train_step += 1
self.train(state, target, action, self.train_step) | Implements how the agent learns and the training step
Args:
state: (tuple)
Current state of the environment.
action: (float)
Current action taken by the agent.
reward: (float):
Reward produced by the environment.
next_state: (tuple)
Next state of the environment. | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | _learn | fqzhou/LoadBalanceControl-RL | 11 | python | def _learn(self, state, action, reward, next_state, ue_ap_state):
'\n Implements how the agent learns and the training step\n\n Args:\n state: (tuple)\n Current state of the environment.\n action: (float)\n Current action taken by the agent.\n reward: (float):\n Reward produced by the environment.\n next_state: (tuple)\n Next state of the environment.\n\n '
if (self.epsilon > self.epsilon_min):
self.epsilon *= self.epsilon_decay
state = np.reshape(state, (1, self.state_dim))
next_state = np.reshape(next_state, (1, self.state_dim))
target = self.predict(state)
target[0][action] = (reward + (self.gamma * self.max_q_for_state(next_state)))
if ue_ap_state:
second_q_target = reward
second_q_error = (second_q_target - self.ap_model[ue_ap_state])
self.logger.debug('Updating second Q table in regression method!')
self.ap_model[ue_ap_state] += (self.alpha * second_q_error)
self.train_step += 1
self.train(state, target, action, self.train_step) | def _learn(self, state, action, reward, next_state, ue_ap_state):
'\n Implements how the agent learns and the training step\n\n Args:\n state: (tuple)\n Current state of the environment.\n action: (float)\n Current action taken by the agent.\n reward: (float):\n Reward produced by the environment.\n next_state: (tuple)\n Next state of the environment.\n\n '
if (self.epsilon > self.epsilon_min):
self.epsilon *= self.epsilon_decay
state = np.reshape(state, (1, self.state_dim))
next_state = np.reshape(next_state, (1, self.state_dim))
target = self.predict(state)
target[0][action] = (reward + (self.gamma * self.max_q_for_state(next_state)))
if ue_ap_state:
second_q_target = reward
second_q_error = (second_q_target - self.ap_model[ue_ap_state])
self.logger.debug('Updating second Q table in regression method!')
self.ap_model[ue_ap_state] += (self.alpha * second_q_error)
self.train_step += 1
self.train(state, target, action, self.train_step)<|docstring|>Implements how the agent learns and the training step
Args:
state: (tuple)
Current state of the environment.
action: (float)
Current action taken by the agent.
reward: (float):
Reward produced by the environment.
next_state: (tuple)
Next state of the environment.<|endoftext|> |
60f60baa0cacf697c7dbb094ea8dc619e4cb39f4b9ab12cb2929dfe9b43d0984 | def max_q_for_state(self, network_state):
'\n Helper method to fetch the max Q value of the network_state\n '
return np.max(self.predict(np.reshape(network_state, (1, self.state_dim)))) | Helper method to fetch the max Q value of the network_state | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | max_q_for_state | fqzhou/LoadBalanceControl-RL | 11 | python | def max_q_for_state(self, network_state):
'\n \n '
return np.max(self.predict(np.reshape(network_state, (1, self.state_dim)))) | def max_q_for_state(self, network_state):
'\n \n '
return np.max(self.predict(np.reshape(network_state, (1, self.state_dim))))<|docstring|>Helper method to fetch the max Q value of the network_state<|endoftext|> |
b246c711ea7923541dff4be25af94799589ad945afa9d7d9c7a97c6bc3d38a92 | def train(self, state, target, action, train_step):
'\n Helper method to train the model, including:\n update the loss, update the optimizer, and the gradients\n '
for i in range(10):
(_, loss) = self.sess.run([self.training_step, self.cost], feed_dict={self.State: state, self.Target: target, self.a: action})
self.l += loss
self.Q = self.sess.run(self.W) | Helper method to train the model, including:
update the loss, update the optimizer, and the gradients | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | train | fqzhou/LoadBalanceControl-RL | 11 | python | def train(self, state, target, action, train_step):
'\n Helper method to train the model, including:\n update the loss, update the optimizer, and the gradients\n '
for i in range(10):
(_, loss) = self.sess.run([self.training_step, self.cost], feed_dict={self.State: state, self.Target: target, self.a: action})
self.l += loss
self.Q = self.sess.run(self.W) | def train(self, state, target, action, train_step):
'\n Helper method to train the model, including:\n update the loss, update the optimizer, and the gradients\n '
for i in range(10):
(_, loss) = self.sess.run([self.training_step, self.cost], feed_dict={self.State: state, self.Target: target, self.a: action})
self.l += loss
self.Q = self.sess.run(self.W)<|docstring|>Helper method to train the model, including:
update the loss, update the optimizer, and the gradients<|endoftext|> |
1c76c9bcc0e79f32db05deff0b6cb9bf35d73ad8bb1768ddc56a07f1e47b8e8a | @property
def Q_ap(self):
'\n Public method that keeps Q_ap(s) values\n '
return self.ap_model | Public method that keeps Q_ap(s) values | loadbalanceRL/lib/algorithm/Qlearning/agents/regression2.py | Q_ap | fqzhou/LoadBalanceControl-RL | 11 | python | @property
def Q_ap(self):
'\n \n '
return self.ap_model | @property
def Q_ap(self):
'\n \n '
return self.ap_model<|docstring|>Public method that keeps Q_ap(s) values<|endoftext|> |
12de5bc105b6ecadac6836f47b2450a2741aca0514d46ef82a1be3885123e707 | def main():
'Parse baidu image search engine results to mongodb.\n\n\n img_url: image url in Baidu cdn\n person_id:\n person_name:\n album_id:\n width: image width\n height: image height\n pic_id: picId in baidu html\n record_date: crawl record data\n\n # determine during download\n type: image type (typically, jpg or png)\n try_download\n download_date\n download_from: img_url or invalid\n md5\n rel_path:\n\n\n save path: person_id/md5.extension\n\n\n '
verbose = False
session = setup_session()
mongo_client = pymongo.MongoClient('mongodb://localhost:27017/')
crawl_img_db = mongo_client['baike_stars']
star_albums_col = crawl_img_db['star_albums']
img_col = crawl_img_db['all_imgs']
num_new_records = 0
num_exist_records = 0
for document in star_albums_col.find():
mongo_id = document['_id']
person_id = document['id']
person_name = document['name']
lemma_id = document['lemma_id']
new_lemma_id = document['new_lemma_id']
sub_lemma_id = document['sub_lemma_id']
albums = document['albums']
has_parsed_imgs = document.get('has_parsed_imgs', False)
if has_parsed_imgs:
print(f'{person_name} has parsed, skip.')
else:
for (idx, album) in enumerate(albums):
album_id = album['album_id']
album_title = album['album_title']
album_num_photo = album['album_num_photo']
print(f'Parse {person_name} - [{idx}/{len(albums)}] {album_title}, {album_num_photo} photos...')
img_list = parse_imgs(lemma_id, new_lemma_id, sub_lemma_id, album_id, album_num_photo, session)
if (len(img_list) != album_num_photo):
print(f'WARNING: the number of image {len(img_list)} is different from album_num_photo {album_num_photo}.')
for img_info in img_list:
src = img_info['src']
width = img_info['width']
height = img_info['height']
pic_id = img_info['pic_id']
img_url = f'https://bkimg.cdn.bcebos.com/pic/{src}'
result = img_col.find_one({'img_url': img_url})
if (result is None):
num_new_records += 1
record = dict(img_url=img_url, person_id=person_id, person_name=person_name, album_id=album_id, album_title=album_title, width=width, height=height, pic_id=pic_id, record_data=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
insert_rlt = img_col.insert_one(record)
if verbose:
print(f' Insert one record: {insert_rlt.inserted_id}')
else:
num_exist_records += 1
star_albums_col.update_one({'_id': mongo_id}, {'$set': dict(has_parsed_imgs=True)})
print(f'''New added records: {num_new_records}.
Existed records: {num_exist_records}.''')
stat = crawl_img_db.command('dbstats')
print(f'''Stats:
Number of entries: {stat['objects']} Size of database: {sizeof_fmt(stat['dataSize'])}''')
mongo_client.close() | Parse baidu image search engine results to mongodb.
img_url: image url in Baidu cdn
person_id:
person_name:
album_id:
width: image width
height: image height
pic_id: picId in baidu html
record_date: crawl record data
# determine during download
type: image type (typically, jpg or png)
try_download
download_date
download_from: img_url or invalid
md5
rel_path:
save path: person_id/md5.extension | tools/baike_stars/crawl_image_list.py | main | xinntao/HandyCrawler | 5 | python | def main():
'Parse baidu image search engine results to mongodb.\n\n\n img_url: image url in Baidu cdn\n person_id:\n person_name:\n album_id:\n width: image width\n height: image height\n pic_id: picId in baidu html\n record_date: crawl record data\n\n # determine during download\n type: image type (typically, jpg or png)\n try_download\n download_date\n download_from: img_url or invalid\n md5\n rel_path:\n\n\n save path: person_id/md5.extension\n\n\n '
verbose = False
session = setup_session()
mongo_client = pymongo.MongoClient('mongodb://localhost:27017/')
crawl_img_db = mongo_client['baike_stars']
star_albums_col = crawl_img_db['star_albums']
img_col = crawl_img_db['all_imgs']
num_new_records = 0
num_exist_records = 0
for document in star_albums_col.find():
mongo_id = document['_id']
person_id = document['id']
person_name = document['name']
lemma_id = document['lemma_id']
new_lemma_id = document['new_lemma_id']
sub_lemma_id = document['sub_lemma_id']
albums = document['albums']
has_parsed_imgs = document.get('has_parsed_imgs', False)
if has_parsed_imgs:
print(f'{person_name} has parsed, skip.')
else:
for (idx, album) in enumerate(albums):
album_id = album['album_id']
album_title = album['album_title']
album_num_photo = album['album_num_photo']
print(f'Parse {person_name} - [{idx}/{len(albums)}] {album_title}, {album_num_photo} photos...')
img_list = parse_imgs(lemma_id, new_lemma_id, sub_lemma_id, album_id, album_num_photo, session)
if (len(img_list) != album_num_photo):
print(f'WARNING: the number of image {len(img_list)} is different from album_num_photo {album_num_photo}.')
for img_info in img_list:
src = img_info['src']
width = img_info['width']
height = img_info['height']
pic_id = img_info['pic_id']
img_url = f'https://bkimg.cdn.bcebos.com/pic/{src}'
result = img_col.find_one({'img_url': img_url})
if (result is None):
num_new_records += 1
record = dict(img_url=img_url, person_id=person_id, person_name=person_name, album_id=album_id, album_title=album_title, width=width, height=height, pic_id=pic_id, record_data=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
insert_rlt = img_col.insert_one(record)
if verbose:
print(f' Insert one record: {insert_rlt.inserted_id}')
else:
num_exist_records += 1
star_albums_col.update_one({'_id': mongo_id}, {'$set': dict(has_parsed_imgs=True)})
print(f'New added records: {num_new_records}.
Existed records: {num_exist_records}.')
stat = crawl_img_db.command('dbstats')
print(f'Stats:
Number of entries: {stat['objects']} Size of database: {sizeof_fmt(stat['dataSize'])}')
mongo_client.close() | def main():
'Parse baidu image search engine results to mongodb.\n\n\n img_url: image url in Baidu cdn\n person_id:\n person_name:\n album_id:\n width: image width\n height: image height\n pic_id: picId in baidu html\n record_date: crawl record data\n\n # determine during download\n type: image type (typically, jpg or png)\n try_download\n download_date\n download_from: img_url or invalid\n md5\n rel_path:\n\n\n save path: person_id/md5.extension\n\n\n '
verbose = False
session = setup_session()
mongo_client = pymongo.MongoClient('mongodb://localhost:27017/')
crawl_img_db = mongo_client['baike_stars']
star_albums_col = crawl_img_db['star_albums']
img_col = crawl_img_db['all_imgs']
num_new_records = 0
num_exist_records = 0
for document in star_albums_col.find():
mongo_id = document['_id']
person_id = document['id']
person_name = document['name']
lemma_id = document['lemma_id']
new_lemma_id = document['new_lemma_id']
sub_lemma_id = document['sub_lemma_id']
albums = document['albums']
has_parsed_imgs = document.get('has_parsed_imgs', False)
if has_parsed_imgs:
print(f'{person_name} has parsed, skip.')
else:
for (idx, album) in enumerate(albums):
album_id = album['album_id']
album_title = album['album_title']
album_num_photo = album['album_num_photo']
print(f'Parse {person_name} - [{idx}/{len(albums)}] {album_title}, {album_num_photo} photos...')
img_list = parse_imgs(lemma_id, new_lemma_id, sub_lemma_id, album_id, album_num_photo, session)
if (len(img_list) != album_num_photo):
print(f'WARNING: the number of image {len(img_list)} is different from album_num_photo {album_num_photo}.')
for img_info in img_list:
src = img_info['src']
width = img_info['width']
height = img_info['height']
pic_id = img_info['pic_id']
img_url = f'https://bkimg.cdn.bcebos.com/pic/{src}'
result = img_col.find_one({'img_url': img_url})
if (result is None):
num_new_records += 1
record = dict(img_url=img_url, person_id=person_id, person_name=person_name, album_id=album_id, album_title=album_title, width=width, height=height, pic_id=pic_id, record_data=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
insert_rlt = img_col.insert_one(record)
if verbose:
print(f' Insert one record: {insert_rlt.inserted_id}')
else:
num_exist_records += 1
star_albums_col.update_one({'_id': mongo_id}, {'$set': dict(has_parsed_imgs=True)})
print(f'New added records: {num_new_records}.
Existed records: {num_exist_records}.')
stat = crawl_img_db.command('dbstats')
print(f'Stats:
Number of entries: {stat['objects']} Size of database: {sizeof_fmt(stat['dataSize'])}')
mongo_client.close()<|docstring|>Parse baidu image search engine results to mongodb.
img_url: image url in Baidu cdn
person_id:
person_name:
album_id:
width: image width
height: image height
pic_id: picId in baidu html
record_date: crawl record data
# determine during download
type: image type (typically, jpg or png)
try_download
download_date
download_from: img_url or invalid
md5
rel_path:
save path: person_id/md5.extension<|endoftext|> |
ca07e4342cf1bc31e1e6a2893d6d452869425f5f47314909701d56e8bbdd79be | def __init__(self, config):
'\n The constructor gets config file and fills out the class members.\n\n Parameters\n ----------\n config : str\n configuration file name\n\n Returns\n -------\n none\n '
deg2rad = (np.pi / 180.0)
try:
specfile = config['specfile']
last_scan = config['last_scan']
(self.delta, self.gamma, self.th, self.phi, self.chi, self.scanmot, self.scanmot_del, self.detdist, self.detector, self.energy) = sput.parse_spec(specfile, last_scan)
except:
pass
if ((self.detector is not None) and self.detector.endswith(':')):
self.detector = self.detector[:(- 1)]
try:
self.energy = config['energy']
except KeyError:
if (self.energy is None):
print('energy not in spec, please configure')
try:
self.delta = config['delta']
except KeyError:
if (self.delta is None):
print('delta not in spec, please configure')
try:
self.gamma = config['gamma']
except KeyError:
if (self.gamma is None):
print('gamma not in spec, please configure')
try:
self.detdist = config['detdist']
except KeyError:
if (self.detdist is None):
print('detdist not in spec, please configure')
try:
self.th = config['theta']
except KeyError:
if (self.th is None):
print('theta not in spec, please configure')
try:
self.chi = config['chi']
except KeyError:
if (self.chi is None):
print('chi not in spec, please configure')
try:
self.phi = config['phi']
except KeyError:
if (self.phi is None):
print('phi not in spec, please configure')
try:
self.scanmot = config['scanmot']
except KeyError:
if (self.scanmot is None):
print('scanmot not in spec, please configure')
try:
self.scanmot_del = config['scanmot_del']
except KeyError:
if (self.scanmot_del is None):
print('scanmot_del not in spec, please configure')
try:
self.binning = []
binning = config['binning']
for i in range(len(binning)):
self.binning.append(binning[i])
for _ in range((3 - len(self.binning))):
self.binning.append(1)
except KeyError:
self.binning = [1, 1, 1]
try:
self.crop = []
crop = config['crop']
for i in range(len(crop)):
if (crop[i] > 1):
crop[i] = 1.0
self.crop.append(crop[i])
for _ in range((3 - len(self.crop))):
self.crop.append(1.0)
(crop[0], crop[1]) = (crop[1], crop[0])
except KeyError:
self.crop = (1.0, 1.0, 1.0) | The constructor gets config file and fills out the class members.
Parameters
----------
config : str
configuration file name
Returns
-------
none | reccdi/src_py/beamlines/viz.py | __init__ | AdvancedPhotonSource/cdi | 4 | python | def __init__(self, config):
'\n The constructor gets config file and fills out the class members.\n\n Parameters\n ----------\n config : str\n configuration file name\n\n Returns\n -------\n none\n '
deg2rad = (np.pi / 180.0)
try:
specfile = config['specfile']
last_scan = config['last_scan']
(self.delta, self.gamma, self.th, self.phi, self.chi, self.scanmot, self.scanmot_del, self.detdist, self.detector, self.energy) = sput.parse_spec(specfile, last_scan)
except:
pass
if ((self.detector is not None) and self.detector.endswith(':')):
self.detector = self.detector[:(- 1)]
try:
self.energy = config['energy']
except KeyError:
if (self.energy is None):
print('energy not in spec, please configure')
try:
self.delta = config['delta']
except KeyError:
if (self.delta is None):
print('delta not in spec, please configure')
try:
self.gamma = config['gamma']
except KeyError:
if (self.gamma is None):
print('gamma not in spec, please configure')
try:
self.detdist = config['detdist']
except KeyError:
if (self.detdist is None):
print('detdist not in spec, please configure')
try:
self.th = config['theta']
except KeyError:
if (self.th is None):
print('theta not in spec, please configure')
try:
self.chi = config['chi']
except KeyError:
if (self.chi is None):
print('chi not in spec, please configure')
try:
self.phi = config['phi']
except KeyError:
if (self.phi is None):
print('phi not in spec, please configure')
try:
self.scanmot = config['scanmot']
except KeyError:
if (self.scanmot is None):
print('scanmot not in spec, please configure')
try:
self.scanmot_del = config['scanmot_del']
except KeyError:
if (self.scanmot_del is None):
print('scanmot_del not in spec, please configure')
try:
self.binning = []
binning = config['binning']
for i in range(len(binning)):
self.binning.append(binning[i])
for _ in range((3 - len(self.binning))):
self.binning.append(1)
except KeyError:
self.binning = [1, 1, 1]
try:
self.crop = []
crop = config['crop']
for i in range(len(crop)):
if (crop[i] > 1):
crop[i] = 1.0
self.crop.append(crop[i])
for _ in range((3 - len(self.crop))):
self.crop.append(1.0)
(crop[0], crop[1]) = (crop[1], crop[0])
except KeyError:
self.crop = (1.0, 1.0, 1.0) | def __init__(self, config):
'\n The constructor gets config file and fills out the class members.\n\n Parameters\n ----------\n config : str\n configuration file name\n\n Returns\n -------\n none\n '
deg2rad = (np.pi / 180.0)
try:
specfile = config['specfile']
last_scan = config['last_scan']
(self.delta, self.gamma, self.th, self.phi, self.chi, self.scanmot, self.scanmot_del, self.detdist, self.detector, self.energy) = sput.parse_spec(specfile, last_scan)
except:
pass
if ((self.detector is not None) and self.detector.endswith(':')):
self.detector = self.detector[:(- 1)]
try:
self.energy = config['energy']
except KeyError:
if (self.energy is None):
print('energy not in spec, please configure')
try:
self.delta = config['delta']
except KeyError:
if (self.delta is None):
print('delta not in spec, please configure')
try:
self.gamma = config['gamma']
except KeyError:
if (self.gamma is None):
print('gamma not in spec, please configure')
try:
self.detdist = config['detdist']
except KeyError:
if (self.detdist is None):
print('detdist not in spec, please configure')
try:
self.th = config['theta']
except KeyError:
if (self.th is None):
print('theta not in spec, please configure')
try:
self.chi = config['chi']
except KeyError:
if (self.chi is None):
print('chi not in spec, please configure')
try:
self.phi = config['phi']
except KeyError:
if (self.phi is None):
print('phi not in spec, please configure')
try:
self.scanmot = config['scanmot']
except KeyError:
if (self.scanmot is None):
print('scanmot not in spec, please configure')
try:
self.scanmot_del = config['scanmot_del']
except KeyError:
if (self.scanmot_del is None):
print('scanmot_del not in spec, please configure')
try:
self.binning = []
binning = config['binning']
for i in range(len(binning)):
self.binning.append(binning[i])
for _ in range((3 - len(self.binning))):
self.binning.append(1)
except KeyError:
self.binning = [1, 1, 1]
try:
self.crop = []
crop = config['crop']
for i in range(len(crop)):
if (crop[i] > 1):
crop[i] = 1.0
self.crop.append(crop[i])
for _ in range((3 - len(self.crop))):
self.crop.append(1.0)
(crop[0], crop[1]) = (crop[1], crop[0])
except KeyError:
self.crop = (1.0, 1.0, 1.0)<|docstring|>The constructor gets config file and fills out the class members.
Parameters
----------
config : str
configuration file name
Returns
-------
none<|endoftext|> |
e2d4b249ee2c4bd8bbd49e20a11801f9e63ee03738e82f73c39601388b2617c7 | def __init__(self, p):
'\n The constructor creates objects assisting with visualization.\n '
self.params = p | The constructor creates objects assisting with visualization. | reccdi/src_py/beamlines/viz.py | __init__ | AdvancedPhotonSource/cdi | 4 | python | def __init__(self, p):
'\n \n '
self.params = p | def __init__(self, p):
'\n \n '
self.params = p<|docstring|>The constructor creates objects assisting with visualization.<|endoftext|> |
1dae52dd8c5c824d401a6edc67db037ac8ab7433da8aa20ce6f1f0a8430f9904 | def set_geometry(self, shape):
'\n Sets geometry.\n\n Parameters\n ----------\n p : DispalyParams object\n this object contains configuration parameters\n \n shape : tuple\n shape of reconstructed array\n\n Returns\n -------\n nothing\n '
p = self.params
px = (p.pixel[0] * p.binning[0])
py = (p.pixel[1] * p.binning[1])
detdist = (p.detdist / 1000.0)
scanmot = p.scanmot.strip()
enfix = 1
if (m.floor(m.log10(p.energy)) < 3):
enfix = 1000
energy = (p.energy * enfix)
if (scanmot == 'en'):
scanen = np.array((energy, (energy + (p.scanmot_del * enfix))))
else:
scanen = np.array((energy,))
self.qc = xuexp.QConversion(p.sampleaxes, p.detectoraxes, p.incidentaxis, en=scanen)
self.qc.init_area(p.pixelorientation[0], p.pixelorientation[1], shape[0], shape[1], 2, 2, distance=detdist, pwidth1=px, pwidth2=py)
if (scanmot == 'en'):
q2 = np.array(self.qc.area(p.th, p.chi, p.phi, p.delta, p.gamma, deg=True))
elif (scanmot in p.sampleaxes_name):
args = []
axisindex = p.sampleaxes_name.index(scanmot)
for n in range(len(p.sampleaxes_name)):
if (n == axisindex):
scanstart = p.__dict__[scanmot]
args.append(np.array((scanstart, (scanstart + (p.scanmot_del * p.binning[2])))))
else:
args.append(p.__dict__[p.sampleaxes_name[n]])
for axis in p.detectoraxes_name:
args.append(p.__dict__[axis])
q2 = np.array(self.qc.area(*args, deg=True))
else:
print('scanmot not in sample axes or energy')
Astar = (q2[(:, 0, 1, 0)] - q2[(:, 0, 0, 0)])
Bstar = (q2[(:, 0, 0, 1)] - q2[(:, 0, 0, 0)])
Cstar = (q2[(:, 1, 0, 0)] - q2[(:, 0, 0, 0)])
Astar = (self.qc.transformSample2Lab(Astar, p.th, p.chi, p.phi) * 10.0)
Bstar = (self.qc.transformSample2Lab(Bstar, p.th, p.chi, p.phi) * 10.0)
Cstar = (self.qc.transformSample2Lab(Cstar, p.th, p.chi, p.phi) * 10.0)
denom = np.dot(Astar, np.cross(Bstar, Cstar))
A = (((2 * m.pi) * np.cross(Bstar, Cstar)) / denom)
B = (((2 * m.pi) * np.cross(Cstar, Astar)) / denom)
C = (((2 * m.pi) * np.cross(Astar, Bstar)) / denom)
self.Trecip = np.zeros(9)
self.Trecip.shape = (3, 3)
self.Trecip[(:, 0)] = Astar
self.Trecip[(:, 1)] = Bstar
self.Trecip[(:, 2)] = Cstar
self.Tdir = np.zeros(9)
self.Tdir.shape = (3, 3)
self.Tdir = np.array((A, B, C)).transpose()
self.dirspace_uptodate = 0
self.recipspace_uptodate = 0 | Sets geometry.
Parameters
----------
p : DispalyParams object
this object contains configuration parameters
shape : tuple
shape of reconstructed array
Returns
-------
nothing | reccdi/src_py/beamlines/viz.py | set_geometry | AdvancedPhotonSource/cdi | 4 | python | def set_geometry(self, shape):
'\n Sets geometry.\n\n Parameters\n ----------\n p : DispalyParams object\n this object contains configuration parameters\n \n shape : tuple\n shape of reconstructed array\n\n Returns\n -------\n nothing\n '
p = self.params
px = (p.pixel[0] * p.binning[0])
py = (p.pixel[1] * p.binning[1])
detdist = (p.detdist / 1000.0)
scanmot = p.scanmot.strip()
enfix = 1
if (m.floor(m.log10(p.energy)) < 3):
enfix = 1000
energy = (p.energy * enfix)
if (scanmot == 'en'):
scanen = np.array((energy, (energy + (p.scanmot_del * enfix))))
else:
scanen = np.array((energy,))
self.qc = xuexp.QConversion(p.sampleaxes, p.detectoraxes, p.incidentaxis, en=scanen)
self.qc.init_area(p.pixelorientation[0], p.pixelorientation[1], shape[0], shape[1], 2, 2, distance=detdist, pwidth1=px, pwidth2=py)
if (scanmot == 'en'):
q2 = np.array(self.qc.area(p.th, p.chi, p.phi, p.delta, p.gamma, deg=True))
elif (scanmot in p.sampleaxes_name):
args = []
axisindex = p.sampleaxes_name.index(scanmot)
for n in range(len(p.sampleaxes_name)):
if (n == axisindex):
scanstart = p.__dict__[scanmot]
args.append(np.array((scanstart, (scanstart + (p.scanmot_del * p.binning[2])))))
else:
args.append(p.__dict__[p.sampleaxes_name[n]])
for axis in p.detectoraxes_name:
args.append(p.__dict__[axis])
q2 = np.array(self.qc.area(*args, deg=True))
else:
print('scanmot not in sample axes or energy')
Astar = (q2[(:, 0, 1, 0)] - q2[(:, 0, 0, 0)])
Bstar = (q2[(:, 0, 0, 1)] - q2[(:, 0, 0, 0)])
Cstar = (q2[(:, 1, 0, 0)] - q2[(:, 0, 0, 0)])
Astar = (self.qc.transformSample2Lab(Astar, p.th, p.chi, p.phi) * 10.0)
Bstar = (self.qc.transformSample2Lab(Bstar, p.th, p.chi, p.phi) * 10.0)
Cstar = (self.qc.transformSample2Lab(Cstar, p.th, p.chi, p.phi) * 10.0)
denom = np.dot(Astar, np.cross(Bstar, Cstar))
A = (((2 * m.pi) * np.cross(Bstar, Cstar)) / denom)
B = (((2 * m.pi) * np.cross(Cstar, Astar)) / denom)
C = (((2 * m.pi) * np.cross(Astar, Bstar)) / denom)
self.Trecip = np.zeros(9)
self.Trecip.shape = (3, 3)
self.Trecip[(:, 0)] = Astar
self.Trecip[(:, 1)] = Bstar
self.Trecip[(:, 2)] = Cstar
self.Tdir = np.zeros(9)
self.Tdir.shape = (3, 3)
self.Tdir = np.array((A, B, C)).transpose()
self.dirspace_uptodate = 0
self.recipspace_uptodate = 0 | def set_geometry(self, shape):
'\n Sets geometry.\n\n Parameters\n ----------\n p : DispalyParams object\n this object contains configuration parameters\n \n shape : tuple\n shape of reconstructed array\n\n Returns\n -------\n nothing\n '
p = self.params
px = (p.pixel[0] * p.binning[0])
py = (p.pixel[1] * p.binning[1])
detdist = (p.detdist / 1000.0)
scanmot = p.scanmot.strip()
enfix = 1
if (m.floor(m.log10(p.energy)) < 3):
enfix = 1000
energy = (p.energy * enfix)
if (scanmot == 'en'):
scanen = np.array((energy, (energy + (p.scanmot_del * enfix))))
else:
scanen = np.array((energy,))
self.qc = xuexp.QConversion(p.sampleaxes, p.detectoraxes, p.incidentaxis, en=scanen)
self.qc.init_area(p.pixelorientation[0], p.pixelorientation[1], shape[0], shape[1], 2, 2, distance=detdist, pwidth1=px, pwidth2=py)
if (scanmot == 'en'):
q2 = np.array(self.qc.area(p.th, p.chi, p.phi, p.delta, p.gamma, deg=True))
elif (scanmot in p.sampleaxes_name):
args = []
axisindex = p.sampleaxes_name.index(scanmot)
for n in range(len(p.sampleaxes_name)):
if (n == axisindex):
scanstart = p.__dict__[scanmot]
args.append(np.array((scanstart, (scanstart + (p.scanmot_del * p.binning[2])))))
else:
args.append(p.__dict__[p.sampleaxes_name[n]])
for axis in p.detectoraxes_name:
args.append(p.__dict__[axis])
q2 = np.array(self.qc.area(*args, deg=True))
else:
print('scanmot not in sample axes or energy')
Astar = (q2[(:, 0, 1, 0)] - q2[(:, 0, 0, 0)])
Bstar = (q2[(:, 0, 0, 1)] - q2[(:, 0, 0, 0)])
Cstar = (q2[(:, 1, 0, 0)] - q2[(:, 0, 0, 0)])
Astar = (self.qc.transformSample2Lab(Astar, p.th, p.chi, p.phi) * 10.0)
Bstar = (self.qc.transformSample2Lab(Bstar, p.th, p.chi, p.phi) * 10.0)
Cstar = (self.qc.transformSample2Lab(Cstar, p.th, p.chi, p.phi) * 10.0)
denom = np.dot(Astar, np.cross(Bstar, Cstar))
A = (((2 * m.pi) * np.cross(Bstar, Cstar)) / denom)
B = (((2 * m.pi) * np.cross(Cstar, Astar)) / denom)
C = (((2 * m.pi) * np.cross(Astar, Bstar)) / denom)
self.Trecip = np.zeros(9)
self.Trecip.shape = (3, 3)
self.Trecip[(:, 0)] = Astar
self.Trecip[(:, 1)] = Bstar
self.Trecip[(:, 2)] = Cstar
self.Tdir = np.zeros(9)
self.Tdir.shape = (3, 3)
self.Tdir = np.array((A, B, C)).transpose()
self.dirspace_uptodate = 0
self.recipspace_uptodate = 0<|docstring|>Sets geometry.
Parameters
----------
p : DispalyParams object
this object contains configuration parameters
shape : tuple
shape of reconstructed array
Returns
-------
nothing<|endoftext|> |
9b94bb55564d4d6cd3e46e5b16c1cce4d65134da2c6b45f3c140825ac519ad10 | def update_dirspace(self, shape):
'\n Updates direct space grid.\n\n Parameters\n ----------\n shape : tuple\n shape of reconstructed array\n\n Returns\n -------\n nothing\n '
dims = list(shape)
self.dxdir = (1.0 / shape[0])
self.dydir = (1.0 / shape[1])
self.dzdir = (1.0 / shape[2])
r = np.mgrid[(0:(dims[0] * self.dxdir):self.dxdir, 0:(dims[1] * self.dydir):self.dydir, 0:(dims[2] * self.dzdir):self.dzdir)]
origshape = r.shape
r.shape = (3, ((dims[0] * dims[1]) * dims[2]))
self.dir_coords = np.dot(self.Tdir, r).transpose()
self.dirspace_uptodate = 1 | Updates direct space grid.
Parameters
----------
shape : tuple
shape of reconstructed array
Returns
-------
nothing | reccdi/src_py/beamlines/viz.py | update_dirspace | AdvancedPhotonSource/cdi | 4 | python | def update_dirspace(self, shape):
'\n Updates direct space grid.\n\n Parameters\n ----------\n shape : tuple\n shape of reconstructed array\n\n Returns\n -------\n nothing\n '
dims = list(shape)
self.dxdir = (1.0 / shape[0])
self.dydir = (1.0 / shape[1])
self.dzdir = (1.0 / shape[2])
r = np.mgrid[(0:(dims[0] * self.dxdir):self.dxdir, 0:(dims[1] * self.dydir):self.dydir, 0:(dims[2] * self.dzdir):self.dzdir)]
origshape = r.shape
r.shape = (3, ((dims[0] * dims[1]) * dims[2]))
self.dir_coords = np.dot(self.Tdir, r).transpose()
self.dirspace_uptodate = 1 | def update_dirspace(self, shape):
'\n Updates direct space grid.\n\n Parameters\n ----------\n shape : tuple\n shape of reconstructed array\n\n Returns\n -------\n nothing\n '
dims = list(shape)
self.dxdir = (1.0 / shape[0])
self.dydir = (1.0 / shape[1])
self.dzdir = (1.0 / shape[2])
r = np.mgrid[(0:(dims[0] * self.dxdir):self.dxdir, 0:(dims[1] * self.dydir):self.dydir, 0:(dims[2] * self.dzdir):self.dzdir)]
origshape = r.shape
r.shape = (3, ((dims[0] * dims[1]) * dims[2]))
self.dir_coords = np.dot(self.Tdir, r).transpose()
self.dirspace_uptodate = 1<|docstring|>Updates direct space grid.
Parameters
----------
shape : tuple
shape of reconstructed array
Returns
-------
nothing<|endoftext|> |
d459ba036dee45dd0cfd12ce4468263b22a5d3597fb89110aab9d4a61dacb5b8 | def update_recipspace(self, shape):
'\n Updates reciprocal space grid.\n\n Parameters\n ----------\n shape : tuple\n shape of reconstructed array\n\n Returns\n -------\n nothing\n '
dims = list(shape)
q = np.mgrid[(0:dims[0], 0:dims[1], 0:dims[2])]
origshape = q.shape
q.shape = (3, ((dims[0] * dims[1]) * dims[2]))
self.recip_coords = np.dot(self.Trecip, q).transpose()
self.recipspace_uptodate = 1 | Updates reciprocal space grid.
Parameters
----------
shape : tuple
shape of reconstructed array
Returns
-------
nothing | reccdi/src_py/beamlines/viz.py | update_recipspace | AdvancedPhotonSource/cdi | 4 | python | def update_recipspace(self, shape):
'\n Updates reciprocal space grid.\n\n Parameters\n ----------\n shape : tuple\n shape of reconstructed array\n\n Returns\n -------\n nothing\n '
dims = list(shape)
q = np.mgrid[(0:dims[0], 0:dims[1], 0:dims[2])]
origshape = q.shape
q.shape = (3, ((dims[0] * dims[1]) * dims[2]))
self.recip_coords = np.dot(self.Trecip, q).transpose()
self.recipspace_uptodate = 1 | def update_recipspace(self, shape):
'\n Updates reciprocal space grid.\n\n Parameters\n ----------\n shape : tuple\n shape of reconstructed array\n\n Returns\n -------\n nothing\n '
dims = list(shape)
q = np.mgrid[(0:dims[0], 0:dims[1], 0:dims[2])]
origshape = q.shape
q.shape = (3, ((dims[0] * dims[1]) * dims[2]))
self.recip_coords = np.dot(self.Trecip, q).transpose()
self.recipspace_uptodate = 1<|docstring|>Updates reciprocal space grid.
Parameters
----------
shape : tuple
shape of reconstructed array
Returns
-------
nothing<|endoftext|> |
0d5a05f82873f7b58afd284b1245f8fe370fcd8550a00a434fa3219e708c0e0b | def get_stripped_DataParallel_state_dict(m, base_name='', newdict=OrderedDict()):
" strip 'module.' caused by DataParallel.\n "
try:
next(m.children())
if isinstance(m, torch.nn.DataParallel):
assert (len([x for x in m.children()]) == 1), 'DataParallel module should only have one child, namely, m.module'
get_stripped_DataParallel_state_dict(m.module, base_name, newdict)
else:
for (_name, _module) in m.named_children():
new_base_name = (((base_name + '.') + _name) if (base_name != '') else _name)
get_stripped_DataParallel_state_dict(_module, new_base_name, newdict)
return newdict
except StopIteration:
assert (not isinstance(m, torch.nn.DataParallel)), 'Leaf Node cannot be "torch.nn.DataParallel" (since no children ==> no *.module )'
for (k, v) in m.state_dict().items():
new_k = ((base_name + '.') + k)
newdict[new_k] = v
return newdict | strip 'module.' caused by DataParallel. | pylibs/pytorch_util/libtrain/tools.py | get_stripped_DataParallel_state_dict | leoshine/Spherical_Regression | 133 | python | def get_stripped_DataParallel_state_dict(m, base_name=, newdict=OrderedDict()):
" \n "
try:
next(m.children())
if isinstance(m, torch.nn.DataParallel):
assert (len([x for x in m.children()]) == 1), 'DataParallel module should only have one child, namely, m.module'
get_stripped_DataParallel_state_dict(m.module, base_name, newdict)
else:
for (_name, _module) in m.named_children():
new_base_name = (((base_name + '.') + _name) if (base_name != ) else _name)
get_stripped_DataParallel_state_dict(_module, new_base_name, newdict)
return newdict
except StopIteration:
assert (not isinstance(m, torch.nn.DataParallel)), 'Leaf Node cannot be "torch.nn.DataParallel" (since no children ==> no *.module )'
for (k, v) in m.state_dict().items():
new_k = ((base_name + '.') + k)
newdict[new_k] = v
return newdict | def get_stripped_DataParallel_state_dict(m, base_name=, newdict=OrderedDict()):
" \n "
try:
next(m.children())
if isinstance(m, torch.nn.DataParallel):
assert (len([x for x in m.children()]) == 1), 'DataParallel module should only have one child, namely, m.module'
get_stripped_DataParallel_state_dict(m.module, base_name, newdict)
else:
for (_name, _module) in m.named_children():
new_base_name = (((base_name + '.') + _name) if (base_name != ) else _name)
get_stripped_DataParallel_state_dict(_module, new_base_name, newdict)
return newdict
except StopIteration:
assert (not isinstance(m, torch.nn.DataParallel)), 'Leaf Node cannot be "torch.nn.DataParallel" (since no children ==> no *.module )'
for (k, v) in m.state_dict().items():
new_k = ((base_name + '.') + k)
newdict[new_k] = v
return newdict<|docstring|>strip 'module.' caused by DataParallel.<|endoftext|> |
1f6615fd61914a4161454f47911ff33b5ebbe7f1649893b853556bc48ff6de0c | def build_filters(self, trans, **kwds):
'\n Build list of filters to check tools against given current context.\n '
filters = deepcopy(self.default_filters)
if trans.user:
for (name, value) in trans.user.preferences.items():
if value.strip():
user_filters = listify(value, do_strip=True)
category = ''
if (name == 'toolbox_tool_filters'):
category = 'tool'
elif (name == 'toolbox_section_filters'):
category = 'section'
elif (name == 'toolbox_label_filters'):
category = 'label'
if category:
validate = getattr(trans.app.config, ('user_%s_filters' % category), [])
self.__init_filters(category, user_filters, filters, validate=validate)
elif kwds.get('trackster', False):
filters['tool'].append(_has_trackster_conf)
return filters | Build list of filters to check tools against given current context. | lib/galaxy/tools/filters/__init__.py | build_filters | bioinfo-center-pasteur-fr/galaxy-pasteur | 0 | python | def build_filters(self, trans, **kwds):
'\n \n '
filters = deepcopy(self.default_filters)
if trans.user:
for (name, value) in trans.user.preferences.items():
if value.strip():
user_filters = listify(value, do_strip=True)
category =
if (name == 'toolbox_tool_filters'):
category = 'tool'
elif (name == 'toolbox_section_filters'):
category = 'section'
elif (name == 'toolbox_label_filters'):
category = 'label'
if category:
validate = getattr(trans.app.config, ('user_%s_filters' % category), [])
self.__init_filters(category, user_filters, filters, validate=validate)
elif kwds.get('trackster', False):
filters['tool'].append(_has_trackster_conf)
return filters | def build_filters(self, trans, **kwds):
'\n \n '
filters = deepcopy(self.default_filters)
if trans.user:
for (name, value) in trans.user.preferences.items():
if value.strip():
user_filters = listify(value, do_strip=True)
category =
if (name == 'toolbox_tool_filters'):
category = 'tool'
elif (name == 'toolbox_section_filters'):
category = 'section'
elif (name == 'toolbox_label_filters'):
category = 'label'
if category:
validate = getattr(trans.app.config, ('user_%s_filters' % category), [])
self.__init_filters(category, user_filters, filters, validate=validate)
elif kwds.get('trackster', False):
filters['tool'].append(_has_trackster_conf)
return filters<|docstring|>Build list of filters to check tools against given current context.<|endoftext|> |
970b4bfaa45c96304e53b99aba36b954ff0cf9a2132185115a7f3a82c15b07f2 | def __build_filter_function(self, filter_name):
'Obtain python function (importing a submodule if needed)\n corresponding to filter_name.\n '
if (':' in filter_name):
(module_name, function_name) = filter_name.rsplit(':', 1)
module = __import__(module_name.strip(), globals())
function = getattr(module, function_name.strip())
else:
function = getattr(globals(), filter_name.strip())
return function | Obtain python function (importing a submodule if needed)
corresponding to filter_name. | lib/galaxy/tools/filters/__init__.py | __build_filter_function | bioinfo-center-pasteur-fr/galaxy-pasteur | 0 | python | def __build_filter_function(self, filter_name):
'Obtain python function (importing a submodule if needed)\n corresponding to filter_name.\n '
if (':' in filter_name):
(module_name, function_name) = filter_name.rsplit(':', 1)
module = __import__(module_name.strip(), globals())
function = getattr(module, function_name.strip())
else:
function = getattr(globals(), filter_name.strip())
return function | def __build_filter_function(self, filter_name):
'Obtain python function (importing a submodule if needed)\n corresponding to filter_name.\n '
if (':' in filter_name):
(module_name, function_name) = filter_name.rsplit(':', 1)
module = __import__(module_name.strip(), globals())
function = getattr(module, function_name.strip())
else:
function = getattr(globals(), filter_name.strip())
return function<|docstring|>Obtain python function (importing a submodule if needed)
corresponding to filter_name.<|endoftext|> |
7e0a6651296c05e2921f94542aca1a7fbe035eebba3dc0232372ced1b2f49c39 | def __init__(self):
'\n Inicializa la clase C{DeclarationNode}.\n '
super(DeclarationNode, self).__init__() | Inicializa la clase C{DeclarationNode}. | packages/pytiger2c/ast/declarationnode.py | __init__ | yasserglez/pytiger2c | 2 | python | def __init__(self):
'\n \n '
super(DeclarationNode, self).__init__() | def __init__(self):
'\n \n '
super(DeclarationNode, self).__init__()<|docstring|>Inicializa la clase C{DeclarationNode}.<|endoftext|> |
c2c139e1398aeed1dfe0828e14c00bf7d6a452fb948ee6d0fc6ed04fad9187f8 | def get_text_from_file(path):
'Return text from a text filename path'
textout = ''
fh = open(path, 'r', encoding='utf8')
for line in fh:
textout += line
fh.close()
return textout | Return text from a text filename path | spliter.py | get_text_from_file | mattbriggs/Create-files-tools | 0 | python | def get_text_from_file(path):
textout =
fh = open(path, 'r', encoding='utf8')
for line in fh:
textout += line
fh.close()
return textout | def get_text_from_file(path):
textout =
fh = open(path, 'r', encoding='utf8')
for line in fh:
textout += line
fh.close()
return textout<|docstring|>Return text from a text filename path<|endoftext|> |
950bc36ea316cf6ef5cb2efea3420d0beb1f80dd52da004e6baaaf47e05bdf02 | def get_title(inbody):
'With a text, get the first line.'
lines = inbody.split('\n')
title = lines[0].strip()
return title | With a text, get the first line. | spliter.py | get_title | mattbriggs/Create-files-tools | 0 | python | def get_title(inbody):
lines = inbody.split('\n')
title = lines[0].strip()
return title | def get_title(inbody):
lines = inbody.split('\n')
title = lines[0].strip()
return title<|docstring|>With a text, get the first line.<|endoftext|> |
f17ed22ca6b415ef8ea480bd92b4c49b4db2d6499a6114bcf63cba8e878fe41a | def save_md(filename, outbody):
'Export the content of the current item as a markdown file.'
with open(filename, 'w') as f:
try:
f.write(outbody)
except Exception as e:
print(e) | Export the content of the current item as a markdown file. | spliter.py | save_md | mattbriggs/Create-files-tools | 0 | python | def save_md(filename, outbody):
with open(filename, 'w') as f:
try:
f.write(outbody)
except Exception as e:
print(e) | def save_md(filename, outbody):
with open(filename, 'w') as f:
try:
f.write(outbody)
except Exception as e:
print(e)<|docstring|>Export the content of the current item as a markdown file.<|endoftext|> |
f7201e4853c7b01621d7418ceb7d07fa3de73abcc4f2d4c6406dcb26bdeef405 | def main():
'Open markdown file and split by `chapter` and three carriage returns.'
novel = get_text_from_file(InFile)
chapters = novel.split('## ')
chap = (- 1)
for chapter in chapters:
chap += 1
sec = 0
sections = chapter.split('\n\n\n')
for section in sections:
print(chap)
title = get_title(section)
filename_root = title.replace(' ', '-')
sec += 1
filename = '{}\\{}.md'.format(OutFile, filename_root)
body = '# {}'.format(section)
save_md(filename, body) | Open markdown file and split by `chapter` and three carriage returns. | spliter.py | main | mattbriggs/Create-files-tools | 0 | python | def main():
novel = get_text_from_file(InFile)
chapters = novel.split('## ')
chap = (- 1)
for chapter in chapters:
chap += 1
sec = 0
sections = chapter.split('\n\n\n')
for section in sections:
print(chap)
title = get_title(section)
filename_root = title.replace(' ', '-')
sec += 1
filename = '{}\\{}.md'.format(OutFile, filename_root)
body = '# {}'.format(section)
save_md(filename, body) | def main():
novel = get_text_from_file(InFile)
chapters = novel.split('## ')
chap = (- 1)
for chapter in chapters:
chap += 1
sec = 0
sections = chapter.split('\n\n\n')
for section in sections:
print(chap)
title = get_title(section)
filename_root = title.replace(' ', '-')
sec += 1
filename = '{}\\{}.md'.format(OutFile, filename_root)
body = '# {}'.format(section)
save_md(filename, body)<|docstring|>Open markdown file and split by `chapter` and three carriage returns.<|endoftext|> |
62189b5fef725a565f5b70c77833c598bbe5cadb09762721e33de609919ccf4b | def init_tracing(tracer):
'\n Set our tracer for gevent. Tracer objects from the\n OpenTracing django/flask/pyramid libraries can be passed as well.\n\n :param tracer: the tracer object.\n '
if hasattr(tracer, '_tracer'):
tracer = tracer._tracer
_patch_greenlet_class(tracer) | Set our tracer for gevent. Tracer objects from the
OpenTracing django/flask/pyramid libraries can be passed as well.
:param tracer: the tracer object. | gevent_opentracing/__init__.py | init_tracing | carlosalberto/python-gevent | 2 | python | def init_tracing(tracer):
'\n Set our tracer for gevent. Tracer objects from the\n OpenTracing django/flask/pyramid libraries can be passed as well.\n\n :param tracer: the tracer object.\n '
if hasattr(tracer, '_tracer'):
tracer = tracer._tracer
_patch_greenlet_class(tracer) | def init_tracing(tracer):
'\n Set our tracer for gevent. Tracer objects from the\n OpenTracing django/flask/pyramid libraries can be passed as well.\n\n :param tracer: the tracer object.\n '
if hasattr(tracer, '_tracer'):
tracer = tracer._tracer
_patch_greenlet_class(tracer)<|docstring|>Set our tracer for gevent. Tracer objects from the
OpenTracing django/flask/pyramid libraries can be passed as well.
:param tracer: the tracer object.<|endoftext|> |
61baeef5a64b04255a8ef2b2cfafcadacc678afd6f2aea1cd9ab4d6a462c79c3 | def __init__(self, backend, node, user, content=None, ctime=None, mtime=None):
'\n Construct a DjangoComment.\n\n :param node: a Node instance\n :param user: a User instance\n :param content: the comment content\n :param ctime: The creation time as datetime object\n :param mtime: The modification time as datetime object\n :return: a Comment object associated to the given node and user\n '
super().__init__(backend)
lang.type_check(user, users.DjangoUser)
arguments = {'dbnode': node.dbmodel, 'user': user.dbmodel, 'content': content}
if ctime:
lang.type_check(ctime, datetime, f'the given ctime is of type {type(ctime)}')
arguments['ctime'] = ctime
if mtime:
lang.type_check(mtime, datetime, f'the given mtime is of type {type(mtime)}')
arguments['mtime'] = mtime
self._dbmodel = ModelWrapper(models.DbComment(**arguments), auto_flush=self._auto_flush) | Construct a DjangoComment.
:param node: a Node instance
:param user: a User instance
:param content: the comment content
:param ctime: The creation time as datetime object
:param mtime: The modification time as datetime object
:return: a Comment object associated to the given node and user | aiida/orm/implementation/django/comments.py | __init__ | azadoks/aiida-core | 180 | python | def __init__(self, backend, node, user, content=None, ctime=None, mtime=None):
'\n Construct a DjangoComment.\n\n :param node: a Node instance\n :param user: a User instance\n :param content: the comment content\n :param ctime: The creation time as datetime object\n :param mtime: The modification time as datetime object\n :return: a Comment object associated to the given node and user\n '
super().__init__(backend)
lang.type_check(user, users.DjangoUser)
arguments = {'dbnode': node.dbmodel, 'user': user.dbmodel, 'content': content}
if ctime:
lang.type_check(ctime, datetime, f'the given ctime is of type {type(ctime)}')
arguments['ctime'] = ctime
if mtime:
lang.type_check(mtime, datetime, f'the given mtime is of type {type(mtime)}')
arguments['mtime'] = mtime
self._dbmodel = ModelWrapper(models.DbComment(**arguments), auto_flush=self._auto_flush) | def __init__(self, backend, node, user, content=None, ctime=None, mtime=None):
'\n Construct a DjangoComment.\n\n :param node: a Node instance\n :param user: a User instance\n :param content: the comment content\n :param ctime: The creation time as datetime object\n :param mtime: The modification time as datetime object\n :return: a Comment object associated to the given node and user\n '
super().__init__(backend)
lang.type_check(user, users.DjangoUser)
arguments = {'dbnode': node.dbmodel, 'user': user.dbmodel, 'content': content}
if ctime:
lang.type_check(ctime, datetime, f'the given ctime is of type {type(ctime)}')
arguments['ctime'] = ctime
if mtime:
lang.type_check(mtime, datetime, f'the given mtime is of type {type(mtime)}')
arguments['mtime'] = mtime
self._dbmodel = ModelWrapper(models.DbComment(**arguments), auto_flush=self._auto_flush)<|docstring|>Construct a DjangoComment.
:param node: a Node instance
:param user: a User instance
:param content: the comment content
:param ctime: The creation time as datetime object
:param mtime: The modification time as datetime object
:return: a Comment object associated to the given node and user<|endoftext|> |
0518b19fc7c4626a3a339fa96cd4d041dea2cdf671cad7a6e07c29aa3d595c28 | def store(self):
'Can only store if both the node and user are stored as well.'
from aiida.backends.djsite.db.models import suppress_auto_now
if ((self._dbmodel.dbnode.id is None) or (self._dbmodel.user.id is None)):
raise exceptions.ModificationNotAllowed('The corresponding node and/or user are not stored')
with (suppress_auto_now([(models.DbComment, ['mtime'])]) if self.mtime else contextlib.nullcontext()):
super().store() | Can only store if both the node and user are stored as well. | aiida/orm/implementation/django/comments.py | store | azadoks/aiida-core | 180 | python | def store(self):
from aiida.backends.djsite.db.models import suppress_auto_now
if ((self._dbmodel.dbnode.id is None) or (self._dbmodel.user.id is None)):
raise exceptions.ModificationNotAllowed('The corresponding node and/or user are not stored')
with (suppress_auto_now([(models.DbComment, ['mtime'])]) if self.mtime else contextlib.nullcontext()):
super().store() | def store(self):
from aiida.backends.djsite.db.models import suppress_auto_now
if ((self._dbmodel.dbnode.id is None) or (self._dbmodel.user.id is None)):
raise exceptions.ModificationNotAllowed('The corresponding node and/or user are not stored')
with (suppress_auto_now([(models.DbComment, ['mtime'])]) if self.mtime else contextlib.nullcontext()):
super().store()<|docstring|>Can only store if both the node and user are stored as well.<|endoftext|> |
a51e4760ff7ed6962b77bc5b5671c88c3b6ef9ee77b7c7f01b0fc1b467fddea9 | def create(self, node, user, content=None, **kwargs):
'\n Create a Comment for a given node and user\n\n :param node: a Node instance\n :param user: a User instance\n :param content: the comment content\n :return: a Comment object associated to the given node and user\n '
return DjangoComment(self.backend, node, user, content, **kwargs) | Create a Comment for a given node and user
:param node: a Node instance
:param user: a User instance
:param content: the comment content
:return: a Comment object associated to the given node and user | aiida/orm/implementation/django/comments.py | create | azadoks/aiida-core | 180 | python | def create(self, node, user, content=None, **kwargs):
'\n Create a Comment for a given node and user\n\n :param node: a Node instance\n :param user: a User instance\n :param content: the comment content\n :return: a Comment object associated to the given node and user\n '
return DjangoComment(self.backend, node, user, content, **kwargs) | def create(self, node, user, content=None, **kwargs):
'\n Create a Comment for a given node and user\n\n :param node: a Node instance\n :param user: a User instance\n :param content: the comment content\n :return: a Comment object associated to the given node and user\n '
return DjangoComment(self.backend, node, user, content, **kwargs)<|docstring|>Create a Comment for a given node and user
:param node: a Node instance
:param user: a User instance
:param content: the comment content
:return: a Comment object associated to the given node and user<|endoftext|> |
49ad0309bf3d1bc8d34e900f5edba74bc87ee5d183b4e6ac1272746516d84676 | def delete(self, comment_id):
'\n Remove a Comment from the collection with the given id\n\n :param comment_id: the id of the comment to delete\n :type comment_id: int\n\n :raises TypeError: if ``comment_id`` is not an `int`\n :raises `~aiida.common.exceptions.NotExistent`: if Comment with ID ``comment_id`` is not found\n '
if (not isinstance(comment_id, int)):
raise TypeError('comment_id must be an int')
try:
models.DbComment.objects.get(id=comment_id).delete()
except ObjectDoesNotExist:
raise exceptions.NotExistent(f"Comment with id '{comment_id}' not found") | Remove a Comment from the collection with the given id
:param comment_id: the id of the comment to delete
:type comment_id: int
:raises TypeError: if ``comment_id`` is not an `int`
:raises `~aiida.common.exceptions.NotExistent`: if Comment with ID ``comment_id`` is not found | aiida/orm/implementation/django/comments.py | delete | azadoks/aiida-core | 180 | python | def delete(self, comment_id):
'\n Remove a Comment from the collection with the given id\n\n :param comment_id: the id of the comment to delete\n :type comment_id: int\n\n :raises TypeError: if ``comment_id`` is not an `int`\n :raises `~aiida.common.exceptions.NotExistent`: if Comment with ID ``comment_id`` is not found\n '
if (not isinstance(comment_id, int)):
raise TypeError('comment_id must be an int')
try:
models.DbComment.objects.get(id=comment_id).delete()
except ObjectDoesNotExist:
raise exceptions.NotExistent(f"Comment with id '{comment_id}' not found") | def delete(self, comment_id):
'\n Remove a Comment from the collection with the given id\n\n :param comment_id: the id of the comment to delete\n :type comment_id: int\n\n :raises TypeError: if ``comment_id`` is not an `int`\n :raises `~aiida.common.exceptions.NotExistent`: if Comment with ID ``comment_id`` is not found\n '
if (not isinstance(comment_id, int)):
raise TypeError('comment_id must be an int')
try:
models.DbComment.objects.get(id=comment_id).delete()
except ObjectDoesNotExist:
raise exceptions.NotExistent(f"Comment with id '{comment_id}' not found")<|docstring|>Remove a Comment from the collection with the given id
:param comment_id: the id of the comment to delete
:type comment_id: int
:raises TypeError: if ``comment_id`` is not an `int`
:raises `~aiida.common.exceptions.NotExistent`: if Comment with ID ``comment_id`` is not found<|endoftext|> |
aa0981993a97df3b961a4a3719233b44d1061be553e829a55810d072f64ea676 | def delete_all(self):
'\n Delete all Comment entries.\n\n :raises `~aiida.common.exceptions.IntegrityError`: if all Comments could not be deleted\n '
from django.db import transaction
try:
with transaction.atomic():
models.DbComment.objects.all().delete()
except Exception as exc:
raise exceptions.IntegrityError(f'Could not delete all Comments. Full exception: {exc}') | Delete all Comment entries.
:raises `~aiida.common.exceptions.IntegrityError`: if all Comments could not be deleted | aiida/orm/implementation/django/comments.py | delete_all | azadoks/aiida-core | 180 | python | def delete_all(self):
'\n Delete all Comment entries.\n\n :raises `~aiida.common.exceptions.IntegrityError`: if all Comments could not be deleted\n '
from django.db import transaction
try:
with transaction.atomic():
models.DbComment.objects.all().delete()
except Exception as exc:
raise exceptions.IntegrityError(f'Could not delete all Comments. Full exception: {exc}') | def delete_all(self):
'\n Delete all Comment entries.\n\n :raises `~aiida.common.exceptions.IntegrityError`: if all Comments could not be deleted\n '
from django.db import transaction
try:
with transaction.atomic():
models.DbComment.objects.all().delete()
except Exception as exc:
raise exceptions.IntegrityError(f'Could not delete all Comments. Full exception: {exc}')<|docstring|>Delete all Comment entries.
:raises `~aiida.common.exceptions.IntegrityError`: if all Comments could not be deleted<|endoftext|> |
287d21519953072574da004434a0cba378ae9925f1ec517758810316d8dfd81f | def delete_many(self, filters):
'\n Delete Comments based on ``filters``\n\n :param filters: similar to QueryBuilder filter\n :type filters: dict\n\n :return: (former) ``PK`` s of deleted Comments\n :rtype: list\n\n :raises TypeError: if ``filters`` is not a `dict`\n :raises `~aiida.common.exceptions.ValidationError`: if ``filters`` is empty\n '
from aiida.orm import Comment, QueryBuilder
if (not isinstance(filters, dict)):
raise TypeError('filters must be a dictionary')
if (not filters):
raise exceptions.ValidationError('filters must not be empty')
builder = QueryBuilder(backend=self.backend).append(Comment, filters=filters, project='id').all()
entities_to_delete = [_[0] for _ in builder]
for entity in entities_to_delete:
self.delete(entity)
return entities_to_delete | Delete Comments based on ``filters``
:param filters: similar to QueryBuilder filter
:type filters: dict
:return: (former) ``PK`` s of deleted Comments
:rtype: list
:raises TypeError: if ``filters`` is not a `dict`
:raises `~aiida.common.exceptions.ValidationError`: if ``filters`` is empty | aiida/orm/implementation/django/comments.py | delete_many | azadoks/aiida-core | 180 | python | def delete_many(self, filters):
'\n Delete Comments based on ``filters``\n\n :param filters: similar to QueryBuilder filter\n :type filters: dict\n\n :return: (former) ``PK`` s of deleted Comments\n :rtype: list\n\n :raises TypeError: if ``filters`` is not a `dict`\n :raises `~aiida.common.exceptions.ValidationError`: if ``filters`` is empty\n '
from aiida.orm import Comment, QueryBuilder
if (not isinstance(filters, dict)):
raise TypeError('filters must be a dictionary')
if (not filters):
raise exceptions.ValidationError('filters must not be empty')
builder = QueryBuilder(backend=self.backend).append(Comment, filters=filters, project='id').all()
entities_to_delete = [_[0] for _ in builder]
for entity in entities_to_delete:
self.delete(entity)
return entities_to_delete | def delete_many(self, filters):
'\n Delete Comments based on ``filters``\n\n :param filters: similar to QueryBuilder filter\n :type filters: dict\n\n :return: (former) ``PK`` s of deleted Comments\n :rtype: list\n\n :raises TypeError: if ``filters`` is not a `dict`\n :raises `~aiida.common.exceptions.ValidationError`: if ``filters`` is empty\n '
from aiida.orm import Comment, QueryBuilder
if (not isinstance(filters, dict)):
raise TypeError('filters must be a dictionary')
if (not filters):
raise exceptions.ValidationError('filters must not be empty')
builder = QueryBuilder(backend=self.backend).append(Comment, filters=filters, project='id').all()
entities_to_delete = [_[0] for _ in builder]
for entity in entities_to_delete:
self.delete(entity)
return entities_to_delete<|docstring|>Delete Comments based on ``filters``
:param filters: similar to QueryBuilder filter
:type filters: dict
:return: (former) ``PK`` s of deleted Comments
:rtype: list
:raises TypeError: if ``filters`` is not a `dict`
:raises `~aiida.common.exceptions.ValidationError`: if ``filters`` is empty<|endoftext|> |
8c5c694f3073ebf7bc01a77ca9f9a89c2f0eb5505c1159559b2ba7a905c17061 | @pytest.mark.parametrize('datatype', [np.float32, np.float64])
@pytest.mark.parametrize('data_info', [unit_param([500, 20, 10, 5]), stress_param([500000, 1000, 500, 50])])
def test_neighbors_pickle_nofit(tmpdir, datatype, data_info):
"\n Note: This test digs down a bit far into the\n internals of the implementation, but it's\n important that regressions do not occur\n from changes to the class.\n "
(nrows, ncols, n_info, k) = data_info
model = cuml.neighbors.NearestNeighbors()
unpickled = pickle_save_load(tmpdir, model)
state = unpickled.__dict__
assert (state['n_indices'] == 0)
assert ('X_m' not in state)
(X_train, _, X_test) = make_dataset(datatype, nrows, ncols, n_info)
model.fit(X_train)
unpickled = pickle_save_load(tmpdir, model)
state = unpickled.__dict__
assert (state['n_indices'] == 1)
assert ('X_m' in state) | Note: This test digs down a bit far into the
internals of the implementation, but it's
important that regressions do not occur
from changes to the class. | python/cuml/test/test_pickle.py | test_neighbors_pickle_nofit | Ignoramuss/cuml | 0 | python | @pytest.mark.parametrize('datatype', [np.float32, np.float64])
@pytest.mark.parametrize('data_info', [unit_param([500, 20, 10, 5]), stress_param([500000, 1000, 500, 50])])
def test_neighbors_pickle_nofit(tmpdir, datatype, data_info):
"\n Note: This test digs down a bit far into the\n internals of the implementation, but it's\n important that regressions do not occur\n from changes to the class.\n "
(nrows, ncols, n_info, k) = data_info
model = cuml.neighbors.NearestNeighbors()
unpickled = pickle_save_load(tmpdir, model)
state = unpickled.__dict__
assert (state['n_indices'] == 0)
assert ('X_m' not in state)
(X_train, _, X_test) = make_dataset(datatype, nrows, ncols, n_info)
model.fit(X_train)
unpickled = pickle_save_load(tmpdir, model)
state = unpickled.__dict__
assert (state['n_indices'] == 1)
assert ('X_m' in state) | @pytest.mark.parametrize('datatype', [np.float32, np.float64])
@pytest.mark.parametrize('data_info', [unit_param([500, 20, 10, 5]), stress_param([500000, 1000, 500, 50])])
def test_neighbors_pickle_nofit(tmpdir, datatype, data_info):
"\n Note: This test digs down a bit far into the\n internals of the implementation, but it's\n important that regressions do not occur\n from changes to the class.\n "
(nrows, ncols, n_info, k) = data_info
model = cuml.neighbors.NearestNeighbors()
unpickled = pickle_save_load(tmpdir, model)
state = unpickled.__dict__
assert (state['n_indices'] == 0)
assert ('X_m' not in state)
(X_train, _, X_test) = make_dataset(datatype, nrows, ncols, n_info)
model.fit(X_train)
unpickled = pickle_save_load(tmpdir, model)
state = unpickled.__dict__
assert (state['n_indices'] == 1)
assert ('X_m' in state)<|docstring|>Note: This test digs down a bit far into the
internals of the implementation, but it's
important that regressions do not occur
from changes to the class.<|endoftext|> |
08395084d02e772a5568386e465a0e6280b2ff463bb9666f68b3ae322e7ecccd | def lcm(a: int, b: int):
'least common multiple'
return ((a * b) // gcd(a, b)) | least common multiple | qupulse/utils/numeric.py | lcm | zea2/qupulse | 30 | python | def lcm(a: int, b: int):
return ((a * b) // gcd(a, b)) | def lcm(a: int, b: int):
return ((a * b) // gcd(a, b))<|docstring|>least common multiple<|endoftext|> |
24e2d6ae991c2d295f26181d55bd7d8c6c38ef041ae780962bfe2f9915ea1804 | def _approximate_int(alpha_num: int, d_num: int, den: int) -> Tuple[(int, int)]:
'Find the best fraction approximation of alpha_num / den with an error smaller d_num / den. Best means the\n fraction with the smallest denominator.\n\n Algorithm from https://link.springer.com/content/pdf/10.1007%2F978-3-540-72914-3.pdf\n\n Args:s\n alpha_num: Numerator of number to approximate. 0 < alpha_num < den\n d_num: Numerator of allowed absolute error.\n den: Denominator of both numbers above.\n\n Returns:\n (numerator, denominator)\n '
assert (0 < alpha_num < den)
lower_num = (alpha_num - d_num)
upper_num = (alpha_num + d_num)
(p_a, q_a) = (0, 1)
(p_b, q_b) = (1, 1)
(p_full, q_full) = (p_b, q_b)
to_left = True
while True:
x_num = ((den * p_b) - (alpha_num * q_b))
x_den = (((- den) * p_a) + (alpha_num * q_a))
x = (((x_num + x_den) - 1) // x_den)
p_full += (x * p_a)
q_full += (x * q_a)
p_prev = (p_full - p_a)
q_prev = (q_full - q_a)
if (((q_full * lower_num) < (p_full * den) < (q_full * upper_num)) or ((q_prev * lower_num) < (p_prev * den) < (q_prev * upper_num))):
bound_num = (upper_num if to_left else lower_num)
k_num = ((den * p_b) - (bound_num * q_b))
k_den = ((bound_num * q_a) - (den * p_a))
k = ((k_num // k_den) + 1)
return ((p_b + (k * p_a)), (q_b + (k * q_a)))
p_a = p_prev
q_a = q_prev
p_b = p_full
q_b = q_full
to_left = (not to_left) | Find the best fraction approximation of alpha_num / den with an error smaller d_num / den. Best means the
fraction with the smallest denominator.
Algorithm from https://link.springer.com/content/pdf/10.1007%2F978-3-540-72914-3.pdf
Args:s
alpha_num: Numerator of number to approximate. 0 < alpha_num < den
d_num: Numerator of allowed absolute error.
den: Denominator of both numbers above.
Returns:
(numerator, denominator) | qupulse/utils/numeric.py | _approximate_int | zea2/qupulse | 30 | python | def _approximate_int(alpha_num: int, d_num: int, den: int) -> Tuple[(int, int)]:
'Find the best fraction approximation of alpha_num / den with an error smaller d_num / den. Best means the\n fraction with the smallest denominator.\n\n Algorithm from https://link.springer.com/content/pdf/10.1007%2F978-3-540-72914-3.pdf\n\n Args:s\n alpha_num: Numerator of number to approximate. 0 < alpha_num < den\n d_num: Numerator of allowed absolute error.\n den: Denominator of both numbers above.\n\n Returns:\n (numerator, denominator)\n '
assert (0 < alpha_num < den)
lower_num = (alpha_num - d_num)
upper_num = (alpha_num + d_num)
(p_a, q_a) = (0, 1)
(p_b, q_b) = (1, 1)
(p_full, q_full) = (p_b, q_b)
to_left = True
while True:
x_num = ((den * p_b) - (alpha_num * q_b))
x_den = (((- den) * p_a) + (alpha_num * q_a))
x = (((x_num + x_den) - 1) // x_den)
p_full += (x * p_a)
q_full += (x * q_a)
p_prev = (p_full - p_a)
q_prev = (q_full - q_a)
if (((q_full * lower_num) < (p_full * den) < (q_full * upper_num)) or ((q_prev * lower_num) < (p_prev * den) < (q_prev * upper_num))):
bound_num = (upper_num if to_left else lower_num)
k_num = ((den * p_b) - (bound_num * q_b))
k_den = ((bound_num * q_a) - (den * p_a))
k = ((k_num // k_den) + 1)
return ((p_b + (k * p_a)), (q_b + (k * q_a)))
p_a = p_prev
q_a = q_prev
p_b = p_full
q_b = q_full
to_left = (not to_left) | def _approximate_int(alpha_num: int, d_num: int, den: int) -> Tuple[(int, int)]:
'Find the best fraction approximation of alpha_num / den with an error smaller d_num / den. Best means the\n fraction with the smallest denominator.\n\n Algorithm from https://link.springer.com/content/pdf/10.1007%2F978-3-540-72914-3.pdf\n\n Args:s\n alpha_num: Numerator of number to approximate. 0 < alpha_num < den\n d_num: Numerator of allowed absolute error.\n den: Denominator of both numbers above.\n\n Returns:\n (numerator, denominator)\n '
assert (0 < alpha_num < den)
lower_num = (alpha_num - d_num)
upper_num = (alpha_num + d_num)
(p_a, q_a) = (0, 1)
(p_b, q_b) = (1, 1)
(p_full, q_full) = (p_b, q_b)
to_left = True
while True:
x_num = ((den * p_b) - (alpha_num * q_b))
x_den = (((- den) * p_a) + (alpha_num * q_a))
x = (((x_num + x_den) - 1) // x_den)
p_full += (x * p_a)
q_full += (x * q_a)
p_prev = (p_full - p_a)
q_prev = (q_full - q_a)
if (((q_full * lower_num) < (p_full * den) < (q_full * upper_num)) or ((q_prev * lower_num) < (p_prev * den) < (q_prev * upper_num))):
bound_num = (upper_num if to_left else lower_num)
k_num = ((den * p_b) - (bound_num * q_b))
k_den = ((bound_num * q_a) - (den * p_a))
k = ((k_num // k_den) + 1)
return ((p_b + (k * p_a)), (q_b + (k * q_a)))
p_a = p_prev
q_a = q_prev
p_b = p_full
q_b = q_full
to_left = (not to_left)<|docstring|>Find the best fraction approximation of alpha_num / den with an error smaller d_num / den. Best means the
fraction with the smallest denominator.
Algorithm from https://link.springer.com/content/pdf/10.1007%2F978-3-540-72914-3.pdf
Args:s
alpha_num: Numerator of number to approximate. 0 < alpha_num < den
d_num: Numerator of allowed absolute error.
den: Denominator of both numbers above.
Returns:
(numerator, denominator)<|endoftext|> |
9d643d737869e9baa50c7c1d0147f803ba0d8b6400280516d124c007f1f35206 | def approximate_rational(x: Rational, abs_err: Rational, fraction_type: Type[Rational]) -> Rational:
'Return the fraction with the smallest denominator in (x - abs_err, x + abs_err)'
if (abs_err <= 0):
raise ValueError('abs_err must be > 0')
(xp, xq) = (x.numerator, x.denominator)
if (xq == 1):
return x
(dp, dq) = (abs_err.numerator, abs_err.denominator)
(n, alpha_num) = divmod(xp, xq)
den = lcm(xq, dq)
alpha_num = ((alpha_num * den) // xq)
d_num = ((dp * den) // dq)
if (alpha_num < d_num):
(p, q) = (0, 1)
else:
(p, q) = _approximate_int(alpha_num, d_num, den)
return fraction_type((p + (n * q)), q) | Return the fraction with the smallest denominator in (x - abs_err, x + abs_err) | qupulse/utils/numeric.py | approximate_rational | zea2/qupulse | 30 | python | def approximate_rational(x: Rational, abs_err: Rational, fraction_type: Type[Rational]) -> Rational:
if (abs_err <= 0):
raise ValueError('abs_err must be > 0')
(xp, xq) = (x.numerator, x.denominator)
if (xq == 1):
return x
(dp, dq) = (abs_err.numerator, abs_err.denominator)
(n, alpha_num) = divmod(xp, xq)
den = lcm(xq, dq)
alpha_num = ((alpha_num * den) // xq)
d_num = ((dp * den) // dq)
if (alpha_num < d_num):
(p, q) = (0, 1)
else:
(p, q) = _approximate_int(alpha_num, d_num, den)
return fraction_type((p + (n * q)), q) | def approximate_rational(x: Rational, abs_err: Rational, fraction_type: Type[Rational]) -> Rational:
if (abs_err <= 0):
raise ValueError('abs_err must be > 0')
(xp, xq) = (x.numerator, x.denominator)
if (xq == 1):
return x
(dp, dq) = (abs_err.numerator, abs_err.denominator)
(n, alpha_num) = divmod(xp, xq)
den = lcm(xq, dq)
alpha_num = ((alpha_num * den) // xq)
d_num = ((dp * den) // dq)
if (alpha_num < d_num):
(p, q) = (0, 1)
else:
(p, q) = _approximate_int(alpha_num, d_num, den)
return fraction_type((p + (n * q)), q)<|docstring|>Return the fraction with the smallest denominator in (x - abs_err, x + abs_err)<|endoftext|> |
f43b40bd608e3e9021fede16af1b38a4bef076ad6a6696994b82a6596a61a5d3 | def approximate_double(x: float, abs_err: float, fraction_type: Type[Rational]) -> Rational:
'Return the fraction with the smallest denominator in (x - abs_err, x + abs_err).'
return approximate_rational(fraction_type(x), fraction_type(abs_err), fraction_type=fraction_type) | Return the fraction with the smallest denominator in (x - abs_err, x + abs_err). | qupulse/utils/numeric.py | approximate_double | zea2/qupulse | 30 | python | def approximate_double(x: float, abs_err: float, fraction_type: Type[Rational]) -> Rational:
return approximate_rational(fraction_type(x), fraction_type(abs_err), fraction_type=fraction_type) | def approximate_double(x: float, abs_err: float, fraction_type: Type[Rational]) -> Rational:
return approximate_rational(fraction_type(x), fraction_type(abs_err), fraction_type=fraction_type)<|docstring|>Return the fraction with the smallest denominator in (x - abs_err, x + abs_err).<|endoftext|> |
dab40d207e5f24295550b309ca1b5a5ad57f703c4ac6409d391320a4caed8737 | def image_upload_url(article_id):
'Return URL for uploading image'
return reverse('article:article-upload-image', args=[article_id]) | Return URL for uploading image | app/article/tests/test_article_api.py | image_upload_url | YukaSadaoka/django-api-recipe-backend | 0 | python | def image_upload_url(article_id):
return reverse('article:article-upload-image', args=[article_id]) | def image_upload_url(article_id):
return reverse('article:article-upload-image', args=[article_id])<|docstring|>Return URL for uploading image<|endoftext|> |
dff73a3ffd36cf04a1f1b91aa820580ee754755960803d2e86afa5e8b956d72a | def detail_url(article_id):
'Return article detail URL'
return reverse('article:article-detail', args=[article_id]) | Return article detail URL | app/article/tests/test_article_api.py | detail_url | YukaSadaoka/django-api-recipe-backend | 0 | python | def detail_url(article_id):
return reverse('article:article-detail', args=[article_id]) | def detail_url(article_id):
return reverse('article:article-detail', args=[article_id])<|docstring|>Return article detail URL<|endoftext|> |
446b404b96925c87493a7e5713794d1dcc6abaa05a3eccba3a7f5fc959964422 | def sample_article(user, **params):
'Create and return a sample article'
defaults = {'title': 'Sample title', 'author': 'Sample Author', 'body': 'This is a sample article', 'date': now()}
defaults.update(params)
return Article.objects.create(user=user, **defaults) | Create and return a sample article | app/article/tests/test_article_api.py | sample_article | YukaSadaoka/django-api-recipe-backend | 0 | python | def sample_article(user, **params):
defaults = {'title': 'Sample title', 'author': 'Sample Author', 'body': 'This is a sample article', 'date': now()}
defaults.update(params)
return Article.objects.create(user=user, **defaults) | def sample_article(user, **params):
defaults = {'title': 'Sample title', 'author': 'Sample Author', 'body': 'This is a sample article', 'date': now()}
defaults.update(params)
return Article.objects.create(user=user, **defaults)<|docstring|>Create and return a sample article<|endoftext|> |
9d0b1d6732b6098cd9990e5d0a62c70fae70862dd4aa957c2c03141b0e6ee42a | def test_article_view(self):
'Test unauthenticated user can view articles'
res = self.client.get(ARTICLE_URL)
self.assertEqual(res.status_code, status.HTTP_200_OK) | Test unauthenticated user can view articles | app/article/tests/test_article_api.py | test_article_view | YukaSadaoka/django-api-recipe-backend | 0 | python | def test_article_view(self):
res = self.client.get(ARTICLE_URL)
self.assertEqual(res.status_code, status.HTTP_200_OK) | def test_article_view(self):
res = self.client.get(ARTICLE_URL)
self.assertEqual(res.status_code, status.HTTP_200_OK)<|docstring|>Test unauthenticated user can view articles<|endoftext|> |
676f6bb7d3188bfa1f82fe6deb43a7b7907f1c7ba847b5394400ef1dfb7ac71a | def test_retrieve_article(self):
'Test retrieving a list of articles'
sample_article(self.user)
sample_article(self.user)
res = self.client.get(ARTICLE_URL)
articles = Article.objects.all().order_by('-id')
serializer = ArticleSerializer(articles, many=True)
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(len(res.data), len(serializer.data))
self.assertEqual(res.data, serializer.data) | Test retrieving a list of articles | app/article/tests/test_article_api.py | test_retrieve_article | YukaSadaoka/django-api-recipe-backend | 0 | python | def test_retrieve_article(self):
sample_article(self.user)
sample_article(self.user)
res = self.client.get(ARTICLE_URL)
articles = Article.objects.all().order_by('-id')
serializer = ArticleSerializer(articles, many=True)
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(len(res.data), len(serializer.data))
self.assertEqual(res.data, serializer.data) | def test_retrieve_article(self):
sample_article(self.user)
sample_article(self.user)
res = self.client.get(ARTICLE_URL)
articles = Article.objects.all().order_by('-id')
serializer = ArticleSerializer(articles, many=True)
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(len(res.data), len(serializer.data))
self.assertEqual(res.data, serializer.data)<|docstring|>Test retrieving a list of articles<|endoftext|> |
0e82fd84c9c3d31dd5c48cfd75c212be22421b5940726f305a53d9e8c2b75a51 | def test_partial_update(self):
'Test updating article with patch'
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'Summar cocktail ideas', 'date': now()}
res = self.client.patch(url, payload)
article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(article.title, payload['title']) | Test updating article with patch | app/article/tests/test_article_api.py | test_partial_update | YukaSadaoka/django-api-recipe-backend | 0 | python | def test_partial_update(self):
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'Summar cocktail ideas', 'date': now()}
res = self.client.patch(url, payload)
article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(article.title, payload['title']) | def test_partial_update(self):
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'Summar cocktail ideas', 'date': now()}
res = self.client.patch(url, payload)
article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(article.title, payload['title'])<|docstring|>Test updating article with patch<|endoftext|> |
b87ccd7cac747ef0d3c9e41e3f4a1502496a0c7bde95d9a0fed5e62b3189b674 | def test_full_update_article(self):
'Test authenticated user updates article'
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'Bread baking tips for absolute beginners', 'author': 'Baking Master', 'body': 'If you are wondering how to make a very first baking successful', 'date': now()}
res = self.client.put(url, payload)
article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(article.title, payload['title'])
self.assertEqual(article.author, payload['author'])
self.assertEqual(article.body, payload['body'])
self.assertEqual(article.date, payload['date']) | Test authenticated user updates article | app/article/tests/test_article_api.py | test_full_update_article | YukaSadaoka/django-api-recipe-backend | 0 | python | def test_full_update_article(self):
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'Bread baking tips for absolute beginners', 'author': 'Baking Master', 'body': 'If you are wondering how to make a very first baking successful', 'date': now()}
res = self.client.put(url, payload)
article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(article.title, payload['title'])
self.assertEqual(article.author, payload['author'])
self.assertEqual(article.body, payload['body'])
self.assertEqual(article.date, payload['date']) | def test_full_update_article(self):
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'Bread baking tips for absolute beginners', 'author': 'Baking Master', 'body': 'If you are wondering how to make a very first baking successful', 'date': now()}
res = self.client.put(url, payload)
article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(article.title, payload['title'])
self.assertEqual(article.author, payload['author'])
self.assertEqual(article.body, payload['body'])
self.assertEqual(article.date, payload['date'])<|docstring|>Test authenticated user updates article<|endoftext|> |
c1dc50fb6eb91994580c3677ddc7c82eeefe8cdab0bc045177332c4bf3491d5a | def test_partial_update_limited_to_user(self):
'Test unauthorized user update partial article'
other = APIClient()
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'Christmas Decoration trend 2020'}
res = other.put(url, payload)
article.refresh_from_db()
self.assertNotEqual(article.title, payload['title'])
self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED) | Test unauthorized user update partial article | app/article/tests/test_article_api.py | test_partial_update_limited_to_user | YukaSadaoka/django-api-recipe-backend | 0 | python | def test_partial_update_limited_to_user(self):
other = APIClient()
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'Christmas Decoration trend 2020'}
res = other.put(url, payload)
article.refresh_from_db()
self.assertNotEqual(article.title, payload['title'])
self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED) | def test_partial_update_limited_to_user(self):
other = APIClient()
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'Christmas Decoration trend 2020'}
res = other.put(url, payload)
article.refresh_from_db()
self.assertNotEqual(article.title, payload['title'])
self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)<|docstring|>Test unauthorized user update partial article<|endoftext|> |
316630cec095402f3c165f3c294273f678530c5d3f9164a1e40df1d6c0a22479 | def test_full_update_limited_to_user(self):
'Test unauthorized user update full article'
other = APIClient()
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'The best hit recipes in 2020', 'author': 'Yuka Sadaoka', 'body': 'This is the list of the most popular recipes 2020', 'date': now()}
res = other.put(url, payload)
article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)
self.assertNotEqual(article.title, payload['title'])
self.assertNotEqual(article.author, payload['author'])
self.assertNotEqual(article.body, payload['body'])
self.assertNotEqual(article.date, payload['date']) | Test unauthorized user update full article | app/article/tests/test_article_api.py | test_full_update_limited_to_user | YukaSadaoka/django-api-recipe-backend | 0 | python | def test_full_update_limited_to_user(self):
other = APIClient()
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'The best hit recipes in 2020', 'author': 'Yuka Sadaoka', 'body': 'This is the list of the most popular recipes 2020', 'date': now()}
res = other.put(url, payload)
article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)
self.assertNotEqual(article.title, payload['title'])
self.assertNotEqual(article.author, payload['author'])
self.assertNotEqual(article.body, payload['body'])
self.assertNotEqual(article.date, payload['date']) | def test_full_update_limited_to_user(self):
other = APIClient()
article = sample_article(self.user)
url = detail_url(article.id)
payload = {'title': 'The best hit recipes in 2020', 'author': 'Yuka Sadaoka', 'body': 'This is the list of the most popular recipes 2020', 'date': now()}
res = other.put(url, payload)
article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)
self.assertNotEqual(article.title, payload['title'])
self.assertNotEqual(article.author, payload['author'])
self.assertNotEqual(article.body, payload['body'])
self.assertNotEqual(article.date, payload['date'])<|docstring|>Test unauthorized user update full article<|endoftext|> |
50c0f7dd151c6d7fdfc5ca46a199eeaab77ad5dc5dca00fbf5099453106331bd | def tearDown(self):
'Clean up image after testing in case'
self.article.image.delete() | Clean up image after testing in case | app/article/tests/test_article_api.py | tearDown | YukaSadaoka/django-api-recipe-backend | 0 | python | def tearDown(self):
self.article.image.delete() | def tearDown(self):
self.article.image.delete()<|docstring|>Clean up image after testing in case<|endoftext|> |
fffba13e81ffe4e9420744213b4e2fe724d65a6d91bb1a509c6f2e6793d9de29 | def test_upload_iamge_to_article(self):
'Test uploading image to article'
url = image_upload_url(self.article.id)
with tempfile.NamedTemporaryFile(suffix='.jpg') as nt:
img = Image.new('RGB', (10, 10))
img.save(nt, format='JPEG')
nt.seek(0)
res = self.client.post(url, {'image': nt}, format='multipart')
self.article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertIn('image', res.data)
self.assertTrue(os.path.exists(self.article.image.path)) | Test uploading image to article | app/article/tests/test_article_api.py | test_upload_iamge_to_article | YukaSadaoka/django-api-recipe-backend | 0 | python | def test_upload_iamge_to_article(self):
url = image_upload_url(self.article.id)
with tempfile.NamedTemporaryFile(suffix='.jpg') as nt:
img = Image.new('RGB', (10, 10))
img.save(nt, format='JPEG')
nt.seek(0)
res = self.client.post(url, {'image': nt}, format='multipart')
self.article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertIn('image', res.data)
self.assertTrue(os.path.exists(self.article.image.path)) | def test_upload_iamge_to_article(self):
url = image_upload_url(self.article.id)
with tempfile.NamedTemporaryFile(suffix='.jpg') as nt:
img = Image.new('RGB', (10, 10))
img.save(nt, format='JPEG')
nt.seek(0)
res = self.client.post(url, {'image': nt}, format='multipart')
self.article.refresh_from_db()
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertIn('image', res.data)
self.assertTrue(os.path.exists(self.article.image.path))<|docstring|>Test uploading image to article<|endoftext|> |
02727bd244dce9c028983910f32317e3d6920a9b13d997ae20869e0e43d61f3f | def test_upload_bad_image(self):
'Test uploading bad image'
url = image_upload_url(self.article.id)
res = self.client.post(url, {'image': 'none'}, format='multipart')
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) | Test uploading bad image | app/article/tests/test_article_api.py | test_upload_bad_image | YukaSadaoka/django-api-recipe-backend | 0 | python | def test_upload_bad_image(self):
url = image_upload_url(self.article.id)
res = self.client.post(url, {'image': 'none'}, format='multipart')
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) | def test_upload_bad_image(self):
url = image_upload_url(self.article.id)
res = self.client.post(url, {'image': 'none'}, format='multipart')
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)<|docstring|>Test uploading bad image<|endoftext|> |
c26c6fb900fbdd3688b44b3ba3f4eee46496043c5415dc4b4cec848fb48de40c | def __init__(self, employee_id=None, employment_basis=None, tfn_exemption_type=None, tax_file_number=None, australian_resident_for_tax_purposes=None, residency_status=None, tax_free_threshold_claimed=None, tax_offset_estimated_amount=None, has_help_debt=None, has_sfss_debt=None, has_trade_support_loan_debt=None, upward_variation_tax_withholding_amount=None, eligible_to_receive_leave_loading=None, approved_withholding_variation_percentage=None, has_student_startup_loan=None, updated_date_utc=None):
'TaxDeclaration - a model defined in OpenAPI'
self._employee_id = None
self._employment_basis = None
self._tfn_exemption_type = None
self._tax_file_number = None
self._australian_resident_for_tax_purposes = None
self._residency_status = None
self._tax_free_threshold_claimed = None
self._tax_offset_estimated_amount = None
self._has_help_debt = None
self._has_sfss_debt = None
self._has_trade_support_loan_debt = None
self._upward_variation_tax_withholding_amount = None
self._eligible_to_receive_leave_loading = None
self._approved_withholding_variation_percentage = None
self._has_student_startup_loan = None
self._updated_date_utc = None
self.discriminator = None
if (employee_id is not None):
self.employee_id = employee_id
if (employment_basis is not None):
self.employment_basis = employment_basis
if (tfn_exemption_type is not None):
self.tfn_exemption_type = tfn_exemption_type
if (tax_file_number is not None):
self.tax_file_number = tax_file_number
if (australian_resident_for_tax_purposes is not None):
self.australian_resident_for_tax_purposes = australian_resident_for_tax_purposes
if (residency_status is not None):
self.residency_status = residency_status
if (tax_free_threshold_claimed is not None):
self.tax_free_threshold_claimed = tax_free_threshold_claimed
if (tax_offset_estimated_amount is not None):
self.tax_offset_estimated_amount = tax_offset_estimated_amount
if (has_help_debt is not None):
self.has_help_debt = has_help_debt
if (has_sfss_debt is not None):
self.has_sfss_debt = has_sfss_debt
if (has_trade_support_loan_debt is not None):
self.has_trade_support_loan_debt = has_trade_support_loan_debt
if (upward_variation_tax_withholding_amount is not None):
self.upward_variation_tax_withholding_amount = upward_variation_tax_withholding_amount
if (eligible_to_receive_leave_loading is not None):
self.eligible_to_receive_leave_loading = eligible_to_receive_leave_loading
if (approved_withholding_variation_percentage is not None):
self.approved_withholding_variation_percentage = approved_withholding_variation_percentage
if (has_student_startup_loan is not None):
self.has_student_startup_loan = has_student_startup_loan
if (updated_date_utc is not None):
self.updated_date_utc = updated_date_utc | TaxDeclaration - a model defined in OpenAPI | xero_python/payrollau/models/tax_declaration.py | __init__ | gavinwhyte/xero-python | 77 | python | def __init__(self, employee_id=None, employment_basis=None, tfn_exemption_type=None, tax_file_number=None, australian_resident_for_tax_purposes=None, residency_status=None, tax_free_threshold_claimed=None, tax_offset_estimated_amount=None, has_help_debt=None, has_sfss_debt=None, has_trade_support_loan_debt=None, upward_variation_tax_withholding_amount=None, eligible_to_receive_leave_loading=None, approved_withholding_variation_percentage=None, has_student_startup_loan=None, updated_date_utc=None):
self._employee_id = None
self._employment_basis = None
self._tfn_exemption_type = None
self._tax_file_number = None
self._australian_resident_for_tax_purposes = None
self._residency_status = None
self._tax_free_threshold_claimed = None
self._tax_offset_estimated_amount = None
self._has_help_debt = None
self._has_sfss_debt = None
self._has_trade_support_loan_debt = None
self._upward_variation_tax_withholding_amount = None
self._eligible_to_receive_leave_loading = None
self._approved_withholding_variation_percentage = None
self._has_student_startup_loan = None
self._updated_date_utc = None
self.discriminator = None
if (employee_id is not None):
self.employee_id = employee_id
if (employment_basis is not None):
self.employment_basis = employment_basis
if (tfn_exemption_type is not None):
self.tfn_exemption_type = tfn_exemption_type
if (tax_file_number is not None):
self.tax_file_number = tax_file_number
if (australian_resident_for_tax_purposes is not None):
self.australian_resident_for_tax_purposes = australian_resident_for_tax_purposes
if (residency_status is not None):
self.residency_status = residency_status
if (tax_free_threshold_claimed is not None):
self.tax_free_threshold_claimed = tax_free_threshold_claimed
if (tax_offset_estimated_amount is not None):
self.tax_offset_estimated_amount = tax_offset_estimated_amount
if (has_help_debt is not None):
self.has_help_debt = has_help_debt
if (has_sfss_debt is not None):
self.has_sfss_debt = has_sfss_debt
if (has_trade_support_loan_debt is not None):
self.has_trade_support_loan_debt = has_trade_support_loan_debt
if (upward_variation_tax_withholding_amount is not None):
self.upward_variation_tax_withholding_amount = upward_variation_tax_withholding_amount
if (eligible_to_receive_leave_loading is not None):
self.eligible_to_receive_leave_loading = eligible_to_receive_leave_loading
if (approved_withholding_variation_percentage is not None):
self.approved_withholding_variation_percentage = approved_withholding_variation_percentage
if (has_student_startup_loan is not None):
self.has_student_startup_loan = has_student_startup_loan
if (updated_date_utc is not None):
self.updated_date_utc = updated_date_utc | def __init__(self, employee_id=None, employment_basis=None, tfn_exemption_type=None, tax_file_number=None, australian_resident_for_tax_purposes=None, residency_status=None, tax_free_threshold_claimed=None, tax_offset_estimated_amount=None, has_help_debt=None, has_sfss_debt=None, has_trade_support_loan_debt=None, upward_variation_tax_withholding_amount=None, eligible_to_receive_leave_loading=None, approved_withholding_variation_percentage=None, has_student_startup_loan=None, updated_date_utc=None):
self._employee_id = None
self._employment_basis = None
self._tfn_exemption_type = None
self._tax_file_number = None
self._australian_resident_for_tax_purposes = None
self._residency_status = None
self._tax_free_threshold_claimed = None
self._tax_offset_estimated_amount = None
self._has_help_debt = None
self._has_sfss_debt = None
self._has_trade_support_loan_debt = None
self._upward_variation_tax_withholding_amount = None
self._eligible_to_receive_leave_loading = None
self._approved_withholding_variation_percentage = None
self._has_student_startup_loan = None
self._updated_date_utc = None
self.discriminator = None
if (employee_id is not None):
self.employee_id = employee_id
if (employment_basis is not None):
self.employment_basis = employment_basis
if (tfn_exemption_type is not None):
self.tfn_exemption_type = tfn_exemption_type
if (tax_file_number is not None):
self.tax_file_number = tax_file_number
if (australian_resident_for_tax_purposes is not None):
self.australian_resident_for_tax_purposes = australian_resident_for_tax_purposes
if (residency_status is not None):
self.residency_status = residency_status
if (tax_free_threshold_claimed is not None):
self.tax_free_threshold_claimed = tax_free_threshold_claimed
if (tax_offset_estimated_amount is not None):
self.tax_offset_estimated_amount = tax_offset_estimated_amount
if (has_help_debt is not None):
self.has_help_debt = has_help_debt
if (has_sfss_debt is not None):
self.has_sfss_debt = has_sfss_debt
if (has_trade_support_loan_debt is not None):
self.has_trade_support_loan_debt = has_trade_support_loan_debt
if (upward_variation_tax_withholding_amount is not None):
self.upward_variation_tax_withholding_amount = upward_variation_tax_withholding_amount
if (eligible_to_receive_leave_loading is not None):
self.eligible_to_receive_leave_loading = eligible_to_receive_leave_loading
if (approved_withholding_variation_percentage is not None):
self.approved_withholding_variation_percentage = approved_withholding_variation_percentage
if (has_student_startup_loan is not None):
self.has_student_startup_loan = has_student_startup_loan
if (updated_date_utc is not None):
self.updated_date_utc = updated_date_utc<|docstring|>TaxDeclaration - a model defined in OpenAPI<|endoftext|> |
a237c4dd60b2bbcfa70fc432ec76100e02b9ecc3dc570add8471a03aa3b56f00 | @property
def employee_id(self):
'Gets the employee_id of this TaxDeclaration. # noqa: E501\n\n Address line 1 for employee home address # noqa: E501\n\n :return: The employee_id of this TaxDeclaration. # noqa: E501\n :rtype: str\n '
return self._employee_id | Gets the employee_id of this TaxDeclaration. # noqa: E501
Address line 1 for employee home address # noqa: E501
:return: The employee_id of this TaxDeclaration. # noqa: E501
:rtype: str | xero_python/payrollau/models/tax_declaration.py | employee_id | gavinwhyte/xero-python | 77 | python | @property
def employee_id(self):
'Gets the employee_id of this TaxDeclaration. # noqa: E501\n\n Address line 1 for employee home address # noqa: E501\n\n :return: The employee_id of this TaxDeclaration. # noqa: E501\n :rtype: str\n '
return self._employee_id | @property
def employee_id(self):
'Gets the employee_id of this TaxDeclaration. # noqa: E501\n\n Address line 1 for employee home address # noqa: E501\n\n :return: The employee_id of this TaxDeclaration. # noqa: E501\n :rtype: str\n '
return self._employee_id<|docstring|>Gets the employee_id of this TaxDeclaration. # noqa: E501
Address line 1 for employee home address # noqa: E501
:return: The employee_id of this TaxDeclaration. # noqa: E501
:rtype: str<|endoftext|> |
a8f2f8e71ab0eb50bdffaffbc72f3fe4d59f46050c791dc33821fcb97ced2571 | @employee_id.setter
def employee_id(self, employee_id):
'Sets the employee_id of this TaxDeclaration.\n\n Address line 1 for employee home address # noqa: E501\n\n :param employee_id: The employee_id of this TaxDeclaration. # noqa: E501\n :type: str\n '
self._employee_id = employee_id | Sets the employee_id of this TaxDeclaration.
Address line 1 for employee home address # noqa: E501
:param employee_id: The employee_id of this TaxDeclaration. # noqa: E501
:type: str | xero_python/payrollau/models/tax_declaration.py | employee_id | gavinwhyte/xero-python | 77 | python | @employee_id.setter
def employee_id(self, employee_id):
'Sets the employee_id of this TaxDeclaration.\n\n Address line 1 for employee home address # noqa: E501\n\n :param employee_id: The employee_id of this TaxDeclaration. # noqa: E501\n :type: str\n '
self._employee_id = employee_id | @employee_id.setter
def employee_id(self, employee_id):
'Sets the employee_id of this TaxDeclaration.\n\n Address line 1 for employee home address # noqa: E501\n\n :param employee_id: The employee_id of this TaxDeclaration. # noqa: E501\n :type: str\n '
self._employee_id = employee_id<|docstring|>Sets the employee_id of this TaxDeclaration.
Address line 1 for employee home address # noqa: E501
:param employee_id: The employee_id of this TaxDeclaration. # noqa: E501
:type: str<|endoftext|> |
2888f7642492b21e48d7160c58f3c8fd60633dbf6a897a4d36a912018a86059a | @property
def employment_basis(self):
'Gets the employment_basis of this TaxDeclaration. # noqa: E501\n\n\n :return: The employment_basis of this TaxDeclaration. # noqa: E501\n :rtype: EmploymentBasis\n '
return self._employment_basis | Gets the employment_basis of this TaxDeclaration. # noqa: E501
:return: The employment_basis of this TaxDeclaration. # noqa: E501
:rtype: EmploymentBasis | xero_python/payrollau/models/tax_declaration.py | employment_basis | gavinwhyte/xero-python | 77 | python | @property
def employment_basis(self):
'Gets the employment_basis of this TaxDeclaration. # noqa: E501\n\n\n :return: The employment_basis of this TaxDeclaration. # noqa: E501\n :rtype: EmploymentBasis\n '
return self._employment_basis | @property
def employment_basis(self):
'Gets the employment_basis of this TaxDeclaration. # noqa: E501\n\n\n :return: The employment_basis of this TaxDeclaration. # noqa: E501\n :rtype: EmploymentBasis\n '
return self._employment_basis<|docstring|>Gets the employment_basis of this TaxDeclaration. # noqa: E501
:return: The employment_basis of this TaxDeclaration. # noqa: E501
:rtype: EmploymentBasis<|endoftext|> |
80ebfadf4665cca5303374709e7ed284d88bfa987f49549c05398348f2247569 | @employment_basis.setter
def employment_basis(self, employment_basis):
'Sets the employment_basis of this TaxDeclaration.\n\n\n :param employment_basis: The employment_basis of this TaxDeclaration. # noqa: E501\n :type: EmploymentBasis\n '
self._employment_basis = employment_basis | Sets the employment_basis of this TaxDeclaration.
:param employment_basis: The employment_basis of this TaxDeclaration. # noqa: E501
:type: EmploymentBasis | xero_python/payrollau/models/tax_declaration.py | employment_basis | gavinwhyte/xero-python | 77 | python | @employment_basis.setter
def employment_basis(self, employment_basis):
'Sets the employment_basis of this TaxDeclaration.\n\n\n :param employment_basis: The employment_basis of this TaxDeclaration. # noqa: E501\n :type: EmploymentBasis\n '
self._employment_basis = employment_basis | @employment_basis.setter
def employment_basis(self, employment_basis):
'Sets the employment_basis of this TaxDeclaration.\n\n\n :param employment_basis: The employment_basis of this TaxDeclaration. # noqa: E501\n :type: EmploymentBasis\n '
self._employment_basis = employment_basis<|docstring|>Sets the employment_basis of this TaxDeclaration.
:param employment_basis: The employment_basis of this TaxDeclaration. # noqa: E501
:type: EmploymentBasis<|endoftext|> |
29e5ce861dde4e9c1ab0d775c322baff69f122313b78a5fc64c4e90ddf8abafa | @property
def tfn_exemption_type(self):
'Gets the tfn_exemption_type of this TaxDeclaration. # noqa: E501\n\n\n :return: The tfn_exemption_type of this TaxDeclaration. # noqa: E501\n :rtype: TFNExemptionType\n '
return self._tfn_exemption_type | Gets the tfn_exemption_type of this TaxDeclaration. # noqa: E501
:return: The tfn_exemption_type of this TaxDeclaration. # noqa: E501
:rtype: TFNExemptionType | xero_python/payrollau/models/tax_declaration.py | tfn_exemption_type | gavinwhyte/xero-python | 77 | python | @property
def tfn_exemption_type(self):
'Gets the tfn_exemption_type of this TaxDeclaration. # noqa: E501\n\n\n :return: The tfn_exemption_type of this TaxDeclaration. # noqa: E501\n :rtype: TFNExemptionType\n '
return self._tfn_exemption_type | @property
def tfn_exemption_type(self):
'Gets the tfn_exemption_type of this TaxDeclaration. # noqa: E501\n\n\n :return: The tfn_exemption_type of this TaxDeclaration. # noqa: E501\n :rtype: TFNExemptionType\n '
return self._tfn_exemption_type<|docstring|>Gets the tfn_exemption_type of this TaxDeclaration. # noqa: E501
:return: The tfn_exemption_type of this TaxDeclaration. # noqa: E501
:rtype: TFNExemptionType<|endoftext|> |
8133f79b8d2b09b0cab4291bea86ab7cb99db7399cdce61897cc7f25b6d8c113 | @tfn_exemption_type.setter
def tfn_exemption_type(self, tfn_exemption_type):
'Sets the tfn_exemption_type of this TaxDeclaration.\n\n\n :param tfn_exemption_type: The tfn_exemption_type of this TaxDeclaration. # noqa: E501\n :type: TFNExemptionType\n '
self._tfn_exemption_type = tfn_exemption_type | Sets the tfn_exemption_type of this TaxDeclaration.
:param tfn_exemption_type: The tfn_exemption_type of this TaxDeclaration. # noqa: E501
:type: TFNExemptionType | xero_python/payrollau/models/tax_declaration.py | tfn_exemption_type | gavinwhyte/xero-python | 77 | python | @tfn_exemption_type.setter
def tfn_exemption_type(self, tfn_exemption_type):
'Sets the tfn_exemption_type of this TaxDeclaration.\n\n\n :param tfn_exemption_type: The tfn_exemption_type of this TaxDeclaration. # noqa: E501\n :type: TFNExemptionType\n '
self._tfn_exemption_type = tfn_exemption_type | @tfn_exemption_type.setter
def tfn_exemption_type(self, tfn_exemption_type):
'Sets the tfn_exemption_type of this TaxDeclaration.\n\n\n :param tfn_exemption_type: The tfn_exemption_type of this TaxDeclaration. # noqa: E501\n :type: TFNExemptionType\n '
self._tfn_exemption_type = tfn_exemption_type<|docstring|>Sets the tfn_exemption_type of this TaxDeclaration.
:param tfn_exemption_type: The tfn_exemption_type of this TaxDeclaration. # noqa: E501
:type: TFNExemptionType<|endoftext|> |
aa80956b822f39a326f1208467bde5d87fed691fb9d2cad179b462893292d3b8 | @property
def tax_file_number(self):
'Gets the tax_file_number of this TaxDeclaration. # noqa: E501\n\n The tax file number e.g 123123123. # noqa: E501\n\n :return: The tax_file_number of this TaxDeclaration. # noqa: E501\n :rtype: str\n '
return self._tax_file_number | Gets the tax_file_number of this TaxDeclaration. # noqa: E501
The tax file number e.g 123123123. # noqa: E501
:return: The tax_file_number of this TaxDeclaration. # noqa: E501
:rtype: str | xero_python/payrollau/models/tax_declaration.py | tax_file_number | gavinwhyte/xero-python | 77 | python | @property
def tax_file_number(self):
'Gets the tax_file_number of this TaxDeclaration. # noqa: E501\n\n The tax file number e.g 123123123. # noqa: E501\n\n :return: The tax_file_number of this TaxDeclaration. # noqa: E501\n :rtype: str\n '
return self._tax_file_number | @property
def tax_file_number(self):
'Gets the tax_file_number of this TaxDeclaration. # noqa: E501\n\n The tax file number e.g 123123123. # noqa: E501\n\n :return: The tax_file_number of this TaxDeclaration. # noqa: E501\n :rtype: str\n '
return self._tax_file_number<|docstring|>Gets the tax_file_number of this TaxDeclaration. # noqa: E501
The tax file number e.g 123123123. # noqa: E501
:return: The tax_file_number of this TaxDeclaration. # noqa: E501
:rtype: str<|endoftext|> |
0f0520a55383d1f895e44db78eca429011775511b2645b2f23c2eb5e30e6027c | @tax_file_number.setter
def tax_file_number(self, tax_file_number):
'Sets the tax_file_number of this TaxDeclaration.\n\n The tax file number e.g 123123123. # noqa: E501\n\n :param tax_file_number: The tax_file_number of this TaxDeclaration. # noqa: E501\n :type: str\n '
self._tax_file_number = tax_file_number | Sets the tax_file_number of this TaxDeclaration.
The tax file number e.g 123123123. # noqa: E501
:param tax_file_number: The tax_file_number of this TaxDeclaration. # noqa: E501
:type: str | xero_python/payrollau/models/tax_declaration.py | tax_file_number | gavinwhyte/xero-python | 77 | python | @tax_file_number.setter
def tax_file_number(self, tax_file_number):
'Sets the tax_file_number of this TaxDeclaration.\n\n The tax file number e.g 123123123. # noqa: E501\n\n :param tax_file_number: The tax_file_number of this TaxDeclaration. # noqa: E501\n :type: str\n '
self._tax_file_number = tax_file_number | @tax_file_number.setter
def tax_file_number(self, tax_file_number):
'Sets the tax_file_number of this TaxDeclaration.\n\n The tax file number e.g 123123123. # noqa: E501\n\n :param tax_file_number: The tax_file_number of this TaxDeclaration. # noqa: E501\n :type: str\n '
self._tax_file_number = tax_file_number<|docstring|>Sets the tax_file_number of this TaxDeclaration.
The tax file number e.g 123123123. # noqa: E501
:param tax_file_number: The tax_file_number of this TaxDeclaration. # noqa: E501
:type: str<|endoftext|> |
41f06b450b30cfdd414be169ef483f90b1fc6ea60f6271754d5895da0d2be906 | @property
def australian_resident_for_tax_purposes(self):
'Gets the australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501\n\n If the employee is Australian resident for tax purposes. e.g true or false # noqa: E501\n\n :return: The australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._australian_resident_for_tax_purposes | Gets the australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501
If the employee is Australian resident for tax purposes. e.g true or false # noqa: E501
:return: The australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501
:rtype: bool | xero_python/payrollau/models/tax_declaration.py | australian_resident_for_tax_purposes | gavinwhyte/xero-python | 77 | python | @property
def australian_resident_for_tax_purposes(self):
'Gets the australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501\n\n If the employee is Australian resident for tax purposes. e.g true or false # noqa: E501\n\n :return: The australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._australian_resident_for_tax_purposes | @property
def australian_resident_for_tax_purposes(self):
'Gets the australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501\n\n If the employee is Australian resident for tax purposes. e.g true or false # noqa: E501\n\n :return: The australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._australian_resident_for_tax_purposes<|docstring|>Gets the australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501
If the employee is Australian resident for tax purposes. e.g true or false # noqa: E501
:return: The australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501
:rtype: bool<|endoftext|> |
73a5507854cc795b9ac39882fce55e0ac2b482d7de1ed6d75531b9070ca68231 | @australian_resident_for_tax_purposes.setter
def australian_resident_for_tax_purposes(self, australian_resident_for_tax_purposes):
'Sets the australian_resident_for_tax_purposes of this TaxDeclaration.\n\n If the employee is Australian resident for tax purposes. e.g true or false # noqa: E501\n\n :param australian_resident_for_tax_purposes: The australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._australian_resident_for_tax_purposes = australian_resident_for_tax_purposes | Sets the australian_resident_for_tax_purposes of this TaxDeclaration.
If the employee is Australian resident for tax purposes. e.g true or false # noqa: E501
:param australian_resident_for_tax_purposes: The australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501
:type: bool | xero_python/payrollau/models/tax_declaration.py | australian_resident_for_tax_purposes | gavinwhyte/xero-python | 77 | python | @australian_resident_for_tax_purposes.setter
def australian_resident_for_tax_purposes(self, australian_resident_for_tax_purposes):
'Sets the australian_resident_for_tax_purposes of this TaxDeclaration.\n\n If the employee is Australian resident for tax purposes. e.g true or false # noqa: E501\n\n :param australian_resident_for_tax_purposes: The australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._australian_resident_for_tax_purposes = australian_resident_for_tax_purposes | @australian_resident_for_tax_purposes.setter
def australian_resident_for_tax_purposes(self, australian_resident_for_tax_purposes):
'Sets the australian_resident_for_tax_purposes of this TaxDeclaration.\n\n If the employee is Australian resident for tax purposes. e.g true or false # noqa: E501\n\n :param australian_resident_for_tax_purposes: The australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._australian_resident_for_tax_purposes = australian_resident_for_tax_purposes<|docstring|>Sets the australian_resident_for_tax_purposes of this TaxDeclaration.
If the employee is Australian resident for tax purposes. e.g true or false # noqa: E501
:param australian_resident_for_tax_purposes: The australian_resident_for_tax_purposes of this TaxDeclaration. # noqa: E501
:type: bool<|endoftext|> |
82a0e722cc207f2243ca531f091cf5655b379a3be867ce6d81e64ced5df1f9e9 | @property
def residency_status(self):
'Gets the residency_status of this TaxDeclaration. # noqa: E501\n\n\n :return: The residency_status of this TaxDeclaration. # noqa: E501\n :rtype: ResidencyStatus\n '
return self._residency_status | Gets the residency_status of this TaxDeclaration. # noqa: E501
:return: The residency_status of this TaxDeclaration. # noqa: E501
:rtype: ResidencyStatus | xero_python/payrollau/models/tax_declaration.py | residency_status | gavinwhyte/xero-python | 77 | python | @property
def residency_status(self):
'Gets the residency_status of this TaxDeclaration. # noqa: E501\n\n\n :return: The residency_status of this TaxDeclaration. # noqa: E501\n :rtype: ResidencyStatus\n '
return self._residency_status | @property
def residency_status(self):
'Gets the residency_status of this TaxDeclaration. # noqa: E501\n\n\n :return: The residency_status of this TaxDeclaration. # noqa: E501\n :rtype: ResidencyStatus\n '
return self._residency_status<|docstring|>Gets the residency_status of this TaxDeclaration. # noqa: E501
:return: The residency_status of this TaxDeclaration. # noqa: E501
:rtype: ResidencyStatus<|endoftext|> |
4b6e30d26455679260736cb21d380d882f97736c6be300e99fbf0e067d4b6de2 | @residency_status.setter
def residency_status(self, residency_status):
'Sets the residency_status of this TaxDeclaration.\n\n\n :param residency_status: The residency_status of this TaxDeclaration. # noqa: E501\n :type: ResidencyStatus\n '
self._residency_status = residency_status | Sets the residency_status of this TaxDeclaration.
:param residency_status: The residency_status of this TaxDeclaration. # noqa: E501
:type: ResidencyStatus | xero_python/payrollau/models/tax_declaration.py | residency_status | gavinwhyte/xero-python | 77 | python | @residency_status.setter
def residency_status(self, residency_status):
'Sets the residency_status of this TaxDeclaration.\n\n\n :param residency_status: The residency_status of this TaxDeclaration. # noqa: E501\n :type: ResidencyStatus\n '
self._residency_status = residency_status | @residency_status.setter
def residency_status(self, residency_status):
'Sets the residency_status of this TaxDeclaration.\n\n\n :param residency_status: The residency_status of this TaxDeclaration. # noqa: E501\n :type: ResidencyStatus\n '
self._residency_status = residency_status<|docstring|>Sets the residency_status of this TaxDeclaration.
:param residency_status: The residency_status of this TaxDeclaration. # noqa: E501
:type: ResidencyStatus<|endoftext|> |
c4937514160ae22b978076f0102f5284383700b4cf2b70d37a1f992314d2e167 | @property
def tax_free_threshold_claimed(self):
'Gets the tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501\n\n If tax free threshold claimed. e.g true or false # noqa: E501\n\n :return: The tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._tax_free_threshold_claimed | Gets the tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501
If tax free threshold claimed. e.g true or false # noqa: E501
:return: The tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501
:rtype: bool | xero_python/payrollau/models/tax_declaration.py | tax_free_threshold_claimed | gavinwhyte/xero-python | 77 | python | @property
def tax_free_threshold_claimed(self):
'Gets the tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501\n\n If tax free threshold claimed. e.g true or false # noqa: E501\n\n :return: The tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._tax_free_threshold_claimed | @property
def tax_free_threshold_claimed(self):
'Gets the tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501\n\n If tax free threshold claimed. e.g true or false # noqa: E501\n\n :return: The tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._tax_free_threshold_claimed<|docstring|>Gets the tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501
If tax free threshold claimed. e.g true or false # noqa: E501
:return: The tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501
:rtype: bool<|endoftext|> |
2623660a32143ca2ac1479de1930d1e7c68bb03de926103a962a27007c8602c4 | @tax_free_threshold_claimed.setter
def tax_free_threshold_claimed(self, tax_free_threshold_claimed):
'Sets the tax_free_threshold_claimed of this TaxDeclaration.\n\n If tax free threshold claimed. e.g true or false # noqa: E501\n\n :param tax_free_threshold_claimed: The tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._tax_free_threshold_claimed = tax_free_threshold_claimed | Sets the tax_free_threshold_claimed of this TaxDeclaration.
If tax free threshold claimed. e.g true or false # noqa: E501
:param tax_free_threshold_claimed: The tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501
:type: bool | xero_python/payrollau/models/tax_declaration.py | tax_free_threshold_claimed | gavinwhyte/xero-python | 77 | python | @tax_free_threshold_claimed.setter
def tax_free_threshold_claimed(self, tax_free_threshold_claimed):
'Sets the tax_free_threshold_claimed of this TaxDeclaration.\n\n If tax free threshold claimed. e.g true or false # noqa: E501\n\n :param tax_free_threshold_claimed: The tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._tax_free_threshold_claimed = tax_free_threshold_claimed | @tax_free_threshold_claimed.setter
def tax_free_threshold_claimed(self, tax_free_threshold_claimed):
'Sets the tax_free_threshold_claimed of this TaxDeclaration.\n\n If tax free threshold claimed. e.g true or false # noqa: E501\n\n :param tax_free_threshold_claimed: The tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._tax_free_threshold_claimed = tax_free_threshold_claimed<|docstring|>Sets the tax_free_threshold_claimed of this TaxDeclaration.
If tax free threshold claimed. e.g true or false # noqa: E501
:param tax_free_threshold_claimed: The tax_free_threshold_claimed of this TaxDeclaration. # noqa: E501
:type: bool<|endoftext|> |
8fb061323421aa215f5ceb0c0a520ec90e66def6ffcde2d72b61e425f1ece2d1 | @property
def tax_offset_estimated_amount(self):
'Gets the tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501\n\n If has tax offset estimated then the tax offset estimated amount. e.g 100 # noqa: E501\n\n :return: The tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501\n :rtype: float\n '
return self._tax_offset_estimated_amount | Gets the tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501
If has tax offset estimated then the tax offset estimated amount. e.g 100 # noqa: E501
:return: The tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501
:rtype: float | xero_python/payrollau/models/tax_declaration.py | tax_offset_estimated_amount | gavinwhyte/xero-python | 77 | python | @property
def tax_offset_estimated_amount(self):
'Gets the tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501\n\n If has tax offset estimated then the tax offset estimated amount. e.g 100 # noqa: E501\n\n :return: The tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501\n :rtype: float\n '
return self._tax_offset_estimated_amount | @property
def tax_offset_estimated_amount(self):
'Gets the tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501\n\n If has tax offset estimated then the tax offset estimated amount. e.g 100 # noqa: E501\n\n :return: The tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501\n :rtype: float\n '
return self._tax_offset_estimated_amount<|docstring|>Gets the tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501
If has tax offset estimated then the tax offset estimated amount. e.g 100 # noqa: E501
:return: The tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501
:rtype: float<|endoftext|> |
4d780573c955e0b5f608d9cd9ce9695d7521eb729a436b4d33605ce3212fdf7e | @tax_offset_estimated_amount.setter
def tax_offset_estimated_amount(self, tax_offset_estimated_amount):
'Sets the tax_offset_estimated_amount of this TaxDeclaration.\n\n If has tax offset estimated then the tax offset estimated amount. e.g 100 # noqa: E501\n\n :param tax_offset_estimated_amount: The tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501\n :type: float\n '
self._tax_offset_estimated_amount = tax_offset_estimated_amount | Sets the tax_offset_estimated_amount of this TaxDeclaration.
If has tax offset estimated then the tax offset estimated amount. e.g 100 # noqa: E501
:param tax_offset_estimated_amount: The tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501
:type: float | xero_python/payrollau/models/tax_declaration.py | tax_offset_estimated_amount | gavinwhyte/xero-python | 77 | python | @tax_offset_estimated_amount.setter
def tax_offset_estimated_amount(self, tax_offset_estimated_amount):
'Sets the tax_offset_estimated_amount of this TaxDeclaration.\n\n If has tax offset estimated then the tax offset estimated amount. e.g 100 # noqa: E501\n\n :param tax_offset_estimated_amount: The tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501\n :type: float\n '
self._tax_offset_estimated_amount = tax_offset_estimated_amount | @tax_offset_estimated_amount.setter
def tax_offset_estimated_amount(self, tax_offset_estimated_amount):
'Sets the tax_offset_estimated_amount of this TaxDeclaration.\n\n If has tax offset estimated then the tax offset estimated amount. e.g 100 # noqa: E501\n\n :param tax_offset_estimated_amount: The tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501\n :type: float\n '
self._tax_offset_estimated_amount = tax_offset_estimated_amount<|docstring|>Sets the tax_offset_estimated_amount of this TaxDeclaration.
If has tax offset estimated then the tax offset estimated amount. e.g 100 # noqa: E501
:param tax_offset_estimated_amount: The tax_offset_estimated_amount of this TaxDeclaration. # noqa: E501
:type: float<|endoftext|> |
12cd6453ff8337575cac9d920e4c042f924e3ffee157cec2e41d5798c27dbc75 | @property
def has_help_debt(self):
'Gets the has_help_debt of this TaxDeclaration. # noqa: E501\n\n If employee has HECS or HELP debt. e.g true or false # noqa: E501\n\n :return: The has_help_debt of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_help_debt | Gets the has_help_debt of this TaxDeclaration. # noqa: E501
If employee has HECS or HELP debt. e.g true or false # noqa: E501
:return: The has_help_debt of this TaxDeclaration. # noqa: E501
:rtype: bool | xero_python/payrollau/models/tax_declaration.py | has_help_debt | gavinwhyte/xero-python | 77 | python | @property
def has_help_debt(self):
'Gets the has_help_debt of this TaxDeclaration. # noqa: E501\n\n If employee has HECS or HELP debt. e.g true or false # noqa: E501\n\n :return: The has_help_debt of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_help_debt | @property
def has_help_debt(self):
'Gets the has_help_debt of this TaxDeclaration. # noqa: E501\n\n If employee has HECS or HELP debt. e.g true or false # noqa: E501\n\n :return: The has_help_debt of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_help_debt<|docstring|>Gets the has_help_debt of this TaxDeclaration. # noqa: E501
If employee has HECS or HELP debt. e.g true or false # noqa: E501
:return: The has_help_debt of this TaxDeclaration. # noqa: E501
:rtype: bool<|endoftext|> |
9c4b65789e274c122a046339845bc446f6e88fc9a856b8ff274b7b81013c4046 | @has_help_debt.setter
def has_help_debt(self, has_help_debt):
'Sets the has_help_debt of this TaxDeclaration.\n\n If employee has HECS or HELP debt. e.g true or false # noqa: E501\n\n :param has_help_debt: The has_help_debt of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_help_debt = has_help_debt | Sets the has_help_debt of this TaxDeclaration.
If employee has HECS or HELP debt. e.g true or false # noqa: E501
:param has_help_debt: The has_help_debt of this TaxDeclaration. # noqa: E501
:type: bool | xero_python/payrollau/models/tax_declaration.py | has_help_debt | gavinwhyte/xero-python | 77 | python | @has_help_debt.setter
def has_help_debt(self, has_help_debt):
'Sets the has_help_debt of this TaxDeclaration.\n\n If employee has HECS or HELP debt. e.g true or false # noqa: E501\n\n :param has_help_debt: The has_help_debt of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_help_debt = has_help_debt | @has_help_debt.setter
def has_help_debt(self, has_help_debt):
'Sets the has_help_debt of this TaxDeclaration.\n\n If employee has HECS or HELP debt. e.g true or false # noqa: E501\n\n :param has_help_debt: The has_help_debt of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_help_debt = has_help_debt<|docstring|>Sets the has_help_debt of this TaxDeclaration.
If employee has HECS or HELP debt. e.g true or false # noqa: E501
:param has_help_debt: The has_help_debt of this TaxDeclaration. # noqa: E501
:type: bool<|endoftext|> |
1b2ad89d1bc4ea50578b8dc583fb6f48e78e10f8e50fac7efa7e61ede77de248 | @property
def has_sfss_debt(self):
'Gets the has_sfss_debt of this TaxDeclaration. # noqa: E501\n\n If employee has financial supplement debt. e.g true or false # noqa: E501\n\n :return: The has_sfss_debt of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_sfss_debt | Gets the has_sfss_debt of this TaxDeclaration. # noqa: E501
If employee has financial supplement debt. e.g true or false # noqa: E501
:return: The has_sfss_debt of this TaxDeclaration. # noqa: E501
:rtype: bool | xero_python/payrollau/models/tax_declaration.py | has_sfss_debt | gavinwhyte/xero-python | 77 | python | @property
def has_sfss_debt(self):
'Gets the has_sfss_debt of this TaxDeclaration. # noqa: E501\n\n If employee has financial supplement debt. e.g true or false # noqa: E501\n\n :return: The has_sfss_debt of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_sfss_debt | @property
def has_sfss_debt(self):
'Gets the has_sfss_debt of this TaxDeclaration. # noqa: E501\n\n If employee has financial supplement debt. e.g true or false # noqa: E501\n\n :return: The has_sfss_debt of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_sfss_debt<|docstring|>Gets the has_sfss_debt of this TaxDeclaration. # noqa: E501
If employee has financial supplement debt. e.g true or false # noqa: E501
:return: The has_sfss_debt of this TaxDeclaration. # noqa: E501
:rtype: bool<|endoftext|> |
a940965ec71d0b18481258b8b03b5385273eea25e3b0d44a9b9cf5239abd30ab | @has_sfss_debt.setter
def has_sfss_debt(self, has_sfss_debt):
'Sets the has_sfss_debt of this TaxDeclaration.\n\n If employee has financial supplement debt. e.g true or false # noqa: E501\n\n :param has_sfss_debt: The has_sfss_debt of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_sfss_debt = has_sfss_debt | Sets the has_sfss_debt of this TaxDeclaration.
If employee has financial supplement debt. e.g true or false # noqa: E501
:param has_sfss_debt: The has_sfss_debt of this TaxDeclaration. # noqa: E501
:type: bool | xero_python/payrollau/models/tax_declaration.py | has_sfss_debt | gavinwhyte/xero-python | 77 | python | @has_sfss_debt.setter
def has_sfss_debt(self, has_sfss_debt):
'Sets the has_sfss_debt of this TaxDeclaration.\n\n If employee has financial supplement debt. e.g true or false # noqa: E501\n\n :param has_sfss_debt: The has_sfss_debt of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_sfss_debt = has_sfss_debt | @has_sfss_debt.setter
def has_sfss_debt(self, has_sfss_debt):
'Sets the has_sfss_debt of this TaxDeclaration.\n\n If employee has financial supplement debt. e.g true or false # noqa: E501\n\n :param has_sfss_debt: The has_sfss_debt of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_sfss_debt = has_sfss_debt<|docstring|>Sets the has_sfss_debt of this TaxDeclaration.
If employee has financial supplement debt. e.g true or false # noqa: E501
:param has_sfss_debt: The has_sfss_debt of this TaxDeclaration. # noqa: E501
:type: bool<|endoftext|> |
5feae0e1b13077902ba13355be82b6b5cc6822882bdf7eda4baba9e32830c40c | @property
def has_trade_support_loan_debt(self):
'Gets the has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501\n\n If employee has trade support loan. e.g true or false # noqa: E501\n\n :return: The has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_trade_support_loan_debt | Gets the has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501
If employee has trade support loan. e.g true or false # noqa: E501
:return: The has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501
:rtype: bool | xero_python/payrollau/models/tax_declaration.py | has_trade_support_loan_debt | gavinwhyte/xero-python | 77 | python | @property
def has_trade_support_loan_debt(self):
'Gets the has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501\n\n If employee has trade support loan. e.g true or false # noqa: E501\n\n :return: The has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_trade_support_loan_debt | @property
def has_trade_support_loan_debt(self):
'Gets the has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501\n\n If employee has trade support loan. e.g true or false # noqa: E501\n\n :return: The has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_trade_support_loan_debt<|docstring|>Gets the has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501
If employee has trade support loan. e.g true or false # noqa: E501
:return: The has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501
:rtype: bool<|endoftext|> |
56dbbfaed8141e7b93cd804be4d999b38ed62c7762be3c1c17f1d8dbb4a8983f | @has_trade_support_loan_debt.setter
def has_trade_support_loan_debt(self, has_trade_support_loan_debt):
'Sets the has_trade_support_loan_debt of this TaxDeclaration.\n\n If employee has trade support loan. e.g true or false # noqa: E501\n\n :param has_trade_support_loan_debt: The has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_trade_support_loan_debt = has_trade_support_loan_debt | Sets the has_trade_support_loan_debt of this TaxDeclaration.
If employee has trade support loan. e.g true or false # noqa: E501
:param has_trade_support_loan_debt: The has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501
:type: bool | xero_python/payrollau/models/tax_declaration.py | has_trade_support_loan_debt | gavinwhyte/xero-python | 77 | python | @has_trade_support_loan_debt.setter
def has_trade_support_loan_debt(self, has_trade_support_loan_debt):
'Sets the has_trade_support_loan_debt of this TaxDeclaration.\n\n If employee has trade support loan. e.g true or false # noqa: E501\n\n :param has_trade_support_loan_debt: The has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_trade_support_loan_debt = has_trade_support_loan_debt | @has_trade_support_loan_debt.setter
def has_trade_support_loan_debt(self, has_trade_support_loan_debt):
'Sets the has_trade_support_loan_debt of this TaxDeclaration.\n\n If employee has trade support loan. e.g true or false # noqa: E501\n\n :param has_trade_support_loan_debt: The has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_trade_support_loan_debt = has_trade_support_loan_debt<|docstring|>Sets the has_trade_support_loan_debt of this TaxDeclaration.
If employee has trade support loan. e.g true or false # noqa: E501
:param has_trade_support_loan_debt: The has_trade_support_loan_debt of this TaxDeclaration. # noqa: E501
:type: bool<|endoftext|> |
d4e261e556ce8fc92f206a0d989152fcbfcb01d0c75270896579b727bddab5bc | @property
def upward_variation_tax_withholding_amount(self):
'Gets the upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501\n\n If the employee has requested that additional tax be withheld each pay run. e.g 50 # noqa: E501\n\n :return: The upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501\n :rtype: float\n '
return self._upward_variation_tax_withholding_amount | Gets the upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501
If the employee has requested that additional tax be withheld each pay run. e.g 50 # noqa: E501
:return: The upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501
:rtype: float | xero_python/payrollau/models/tax_declaration.py | upward_variation_tax_withholding_amount | gavinwhyte/xero-python | 77 | python | @property
def upward_variation_tax_withholding_amount(self):
'Gets the upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501\n\n If the employee has requested that additional tax be withheld each pay run. e.g 50 # noqa: E501\n\n :return: The upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501\n :rtype: float\n '
return self._upward_variation_tax_withholding_amount | @property
def upward_variation_tax_withholding_amount(self):
'Gets the upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501\n\n If the employee has requested that additional tax be withheld each pay run. e.g 50 # noqa: E501\n\n :return: The upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501\n :rtype: float\n '
return self._upward_variation_tax_withholding_amount<|docstring|>Gets the upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501
If the employee has requested that additional tax be withheld each pay run. e.g 50 # noqa: E501
:return: The upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501
:rtype: float<|endoftext|> |
0752db567febefcf534d1fd69bb56c1092ff46480ad2e66efcc93673602b3d0d | @upward_variation_tax_withholding_amount.setter
def upward_variation_tax_withholding_amount(self, upward_variation_tax_withholding_amount):
'Sets the upward_variation_tax_withholding_amount of this TaxDeclaration.\n\n If the employee has requested that additional tax be withheld each pay run. e.g 50 # noqa: E501\n\n :param upward_variation_tax_withholding_amount: The upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501\n :type: float\n '
self._upward_variation_tax_withholding_amount = upward_variation_tax_withholding_amount | Sets the upward_variation_tax_withholding_amount of this TaxDeclaration.
If the employee has requested that additional tax be withheld each pay run. e.g 50 # noqa: E501
:param upward_variation_tax_withholding_amount: The upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501
:type: float | xero_python/payrollau/models/tax_declaration.py | upward_variation_tax_withholding_amount | gavinwhyte/xero-python | 77 | python | @upward_variation_tax_withholding_amount.setter
def upward_variation_tax_withholding_amount(self, upward_variation_tax_withholding_amount):
'Sets the upward_variation_tax_withholding_amount of this TaxDeclaration.\n\n If the employee has requested that additional tax be withheld each pay run. e.g 50 # noqa: E501\n\n :param upward_variation_tax_withholding_amount: The upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501\n :type: float\n '
self._upward_variation_tax_withholding_amount = upward_variation_tax_withholding_amount | @upward_variation_tax_withholding_amount.setter
def upward_variation_tax_withholding_amount(self, upward_variation_tax_withholding_amount):
'Sets the upward_variation_tax_withholding_amount of this TaxDeclaration.\n\n If the employee has requested that additional tax be withheld each pay run. e.g 50 # noqa: E501\n\n :param upward_variation_tax_withholding_amount: The upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501\n :type: float\n '
self._upward_variation_tax_withholding_amount = upward_variation_tax_withholding_amount<|docstring|>Sets the upward_variation_tax_withholding_amount of this TaxDeclaration.
If the employee has requested that additional tax be withheld each pay run. e.g 50 # noqa: E501
:param upward_variation_tax_withholding_amount: The upward_variation_tax_withholding_amount of this TaxDeclaration. # noqa: E501
:type: float<|endoftext|> |
a19e16865b1eac40ab1d543c6c651ea81a7451035ad51fce037fbb07f6373a7b | @property
def eligible_to_receive_leave_loading(self):
'Gets the eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501\n\n If the employee is eligible to receive an additional percentage on top of ordinary earnings when they take leave (typically 17.5%). e.g true or false # noqa: E501\n\n :return: The eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._eligible_to_receive_leave_loading | Gets the eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501
If the employee is eligible to receive an additional percentage on top of ordinary earnings when they take leave (typically 17.5%). e.g true or false # noqa: E501
:return: The eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501
:rtype: bool | xero_python/payrollau/models/tax_declaration.py | eligible_to_receive_leave_loading | gavinwhyte/xero-python | 77 | python | @property
def eligible_to_receive_leave_loading(self):
'Gets the eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501\n\n If the employee is eligible to receive an additional percentage on top of ordinary earnings when they take leave (typically 17.5%). e.g true or false # noqa: E501\n\n :return: The eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._eligible_to_receive_leave_loading | @property
def eligible_to_receive_leave_loading(self):
'Gets the eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501\n\n If the employee is eligible to receive an additional percentage on top of ordinary earnings when they take leave (typically 17.5%). e.g true or false # noqa: E501\n\n :return: The eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._eligible_to_receive_leave_loading<|docstring|>Gets the eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501
If the employee is eligible to receive an additional percentage on top of ordinary earnings when they take leave (typically 17.5%). e.g true or false # noqa: E501
:return: The eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501
:rtype: bool<|endoftext|> |
7f0ecdd4560ae2d95d0b3019badeef94a082dbc3fa353cd0a9bb3177ecfa8b94 | @eligible_to_receive_leave_loading.setter
def eligible_to_receive_leave_loading(self, eligible_to_receive_leave_loading):
'Sets the eligible_to_receive_leave_loading of this TaxDeclaration.\n\n If the employee is eligible to receive an additional percentage on top of ordinary earnings when they take leave (typically 17.5%). e.g true or false # noqa: E501\n\n :param eligible_to_receive_leave_loading: The eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._eligible_to_receive_leave_loading = eligible_to_receive_leave_loading | Sets the eligible_to_receive_leave_loading of this TaxDeclaration.
If the employee is eligible to receive an additional percentage on top of ordinary earnings when they take leave (typically 17.5%). e.g true or false # noqa: E501
:param eligible_to_receive_leave_loading: The eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501
:type: bool | xero_python/payrollau/models/tax_declaration.py | eligible_to_receive_leave_loading | gavinwhyte/xero-python | 77 | python | @eligible_to_receive_leave_loading.setter
def eligible_to_receive_leave_loading(self, eligible_to_receive_leave_loading):
'Sets the eligible_to_receive_leave_loading of this TaxDeclaration.\n\n If the employee is eligible to receive an additional percentage on top of ordinary earnings when they take leave (typically 17.5%). e.g true or false # noqa: E501\n\n :param eligible_to_receive_leave_loading: The eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._eligible_to_receive_leave_loading = eligible_to_receive_leave_loading | @eligible_to_receive_leave_loading.setter
def eligible_to_receive_leave_loading(self, eligible_to_receive_leave_loading):
'Sets the eligible_to_receive_leave_loading of this TaxDeclaration.\n\n If the employee is eligible to receive an additional percentage on top of ordinary earnings when they take leave (typically 17.5%). e.g true or false # noqa: E501\n\n :param eligible_to_receive_leave_loading: The eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._eligible_to_receive_leave_loading = eligible_to_receive_leave_loading<|docstring|>Sets the eligible_to_receive_leave_loading of this TaxDeclaration.
If the employee is eligible to receive an additional percentage on top of ordinary earnings when they take leave (typically 17.5%). e.g true or false # noqa: E501
:param eligible_to_receive_leave_loading: The eligible_to_receive_leave_loading of this TaxDeclaration. # noqa: E501
:type: bool<|endoftext|> |
fffd4c63a413de015d7339787e92580248dd7b865e19f6022981689792dd73f2 | @property
def approved_withholding_variation_percentage(self):
'Gets the approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501\n\n If the employee has approved withholding variation. e.g (0 - 100) # noqa: E501\n\n :return: The approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501\n :rtype: float\n '
return self._approved_withholding_variation_percentage | Gets the approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501
If the employee has approved withholding variation. e.g (0 - 100) # noqa: E501
:return: The approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501
:rtype: float | xero_python/payrollau/models/tax_declaration.py | approved_withholding_variation_percentage | gavinwhyte/xero-python | 77 | python | @property
def approved_withholding_variation_percentage(self):
'Gets the approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501\n\n If the employee has approved withholding variation. e.g (0 - 100) # noqa: E501\n\n :return: The approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501\n :rtype: float\n '
return self._approved_withholding_variation_percentage | @property
def approved_withholding_variation_percentage(self):
'Gets the approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501\n\n If the employee has approved withholding variation. e.g (0 - 100) # noqa: E501\n\n :return: The approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501\n :rtype: float\n '
return self._approved_withholding_variation_percentage<|docstring|>Gets the approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501
If the employee has approved withholding variation. e.g (0 - 100) # noqa: E501
:return: The approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501
:rtype: float<|endoftext|> |
163817c56c525d7d1498eada80ebd8d01ef7c27701e3654eae23c451db88ea99 | @approved_withholding_variation_percentage.setter
def approved_withholding_variation_percentage(self, approved_withholding_variation_percentage):
'Sets the approved_withholding_variation_percentage of this TaxDeclaration.\n\n If the employee has approved withholding variation. e.g (0 - 100) # noqa: E501\n\n :param approved_withholding_variation_percentage: The approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501\n :type: float\n '
self._approved_withholding_variation_percentage = approved_withholding_variation_percentage | Sets the approved_withholding_variation_percentage of this TaxDeclaration.
If the employee has approved withholding variation. e.g (0 - 100) # noqa: E501
:param approved_withholding_variation_percentage: The approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501
:type: float | xero_python/payrollau/models/tax_declaration.py | approved_withholding_variation_percentage | gavinwhyte/xero-python | 77 | python | @approved_withholding_variation_percentage.setter
def approved_withholding_variation_percentage(self, approved_withholding_variation_percentage):
'Sets the approved_withholding_variation_percentage of this TaxDeclaration.\n\n If the employee has approved withholding variation. e.g (0 - 100) # noqa: E501\n\n :param approved_withholding_variation_percentage: The approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501\n :type: float\n '
self._approved_withholding_variation_percentage = approved_withholding_variation_percentage | @approved_withholding_variation_percentage.setter
def approved_withholding_variation_percentage(self, approved_withholding_variation_percentage):
'Sets the approved_withholding_variation_percentage of this TaxDeclaration.\n\n If the employee has approved withholding variation. e.g (0 - 100) # noqa: E501\n\n :param approved_withholding_variation_percentage: The approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501\n :type: float\n '
self._approved_withholding_variation_percentage = approved_withholding_variation_percentage<|docstring|>Sets the approved_withholding_variation_percentage of this TaxDeclaration.
If the employee has approved withholding variation. e.g (0 - 100) # noqa: E501
:param approved_withholding_variation_percentage: The approved_withholding_variation_percentage of this TaxDeclaration. # noqa: E501
:type: float<|endoftext|> |
c561aec332b3422bdb816c57ea044ccfa10fb6f355ccee4357d4524103cb5e6b | @property
def has_student_startup_loan(self):
'Gets the has_student_startup_loan of this TaxDeclaration. # noqa: E501\n\n If the employee is eligible for student startup loan rules # noqa: E501\n\n :return: The has_student_startup_loan of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_student_startup_loan | Gets the has_student_startup_loan of this TaxDeclaration. # noqa: E501
If the employee is eligible for student startup loan rules # noqa: E501
:return: The has_student_startup_loan of this TaxDeclaration. # noqa: E501
:rtype: bool | xero_python/payrollau/models/tax_declaration.py | has_student_startup_loan | gavinwhyte/xero-python | 77 | python | @property
def has_student_startup_loan(self):
'Gets the has_student_startup_loan of this TaxDeclaration. # noqa: E501\n\n If the employee is eligible for student startup loan rules # noqa: E501\n\n :return: The has_student_startup_loan of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_student_startup_loan | @property
def has_student_startup_loan(self):
'Gets the has_student_startup_loan of this TaxDeclaration. # noqa: E501\n\n If the employee is eligible for student startup loan rules # noqa: E501\n\n :return: The has_student_startup_loan of this TaxDeclaration. # noqa: E501\n :rtype: bool\n '
return self._has_student_startup_loan<|docstring|>Gets the has_student_startup_loan of this TaxDeclaration. # noqa: E501
If the employee is eligible for student startup loan rules # noqa: E501
:return: The has_student_startup_loan of this TaxDeclaration. # noqa: E501
:rtype: bool<|endoftext|> |
723a556b3ea46adcec46de27430982626ed88c4cfbfed95935ecb029fe2dd893 | @has_student_startup_loan.setter
def has_student_startup_loan(self, has_student_startup_loan):
'Sets the has_student_startup_loan of this TaxDeclaration.\n\n If the employee is eligible for student startup loan rules # noqa: E501\n\n :param has_student_startup_loan: The has_student_startup_loan of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_student_startup_loan = has_student_startup_loan | Sets the has_student_startup_loan of this TaxDeclaration.
If the employee is eligible for student startup loan rules # noqa: E501
:param has_student_startup_loan: The has_student_startup_loan of this TaxDeclaration. # noqa: E501
:type: bool | xero_python/payrollau/models/tax_declaration.py | has_student_startup_loan | gavinwhyte/xero-python | 77 | python | @has_student_startup_loan.setter
def has_student_startup_loan(self, has_student_startup_loan):
'Sets the has_student_startup_loan of this TaxDeclaration.\n\n If the employee is eligible for student startup loan rules # noqa: E501\n\n :param has_student_startup_loan: The has_student_startup_loan of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_student_startup_loan = has_student_startup_loan | @has_student_startup_loan.setter
def has_student_startup_loan(self, has_student_startup_loan):
'Sets the has_student_startup_loan of this TaxDeclaration.\n\n If the employee is eligible for student startup loan rules # noqa: E501\n\n :param has_student_startup_loan: The has_student_startup_loan of this TaxDeclaration. # noqa: E501\n :type: bool\n '
self._has_student_startup_loan = has_student_startup_loan<|docstring|>Sets the has_student_startup_loan of this TaxDeclaration.
If the employee is eligible for student startup loan rules # noqa: E501
:param has_student_startup_loan: The has_student_startup_loan of this TaxDeclaration. # noqa: E501
:type: bool<|endoftext|> |
933571ac26da6504ecbcbdba3a522d79ff206e71409f1992da1711f7b5a844c9 | @property
def updated_date_utc(self):
'Gets the updated_date_utc of this TaxDeclaration. # noqa: E501\n\n Last modified timestamp # noqa: E501\n\n :return: The updated_date_utc of this TaxDeclaration. # noqa: E501\n :rtype: datetime\n '
return self._updated_date_utc | Gets the updated_date_utc of this TaxDeclaration. # noqa: E501
Last modified timestamp # noqa: E501
:return: The updated_date_utc of this TaxDeclaration. # noqa: E501
:rtype: datetime | xero_python/payrollau/models/tax_declaration.py | updated_date_utc | gavinwhyte/xero-python | 77 | python | @property
def updated_date_utc(self):
'Gets the updated_date_utc of this TaxDeclaration. # noqa: E501\n\n Last modified timestamp # noqa: E501\n\n :return: The updated_date_utc of this TaxDeclaration. # noqa: E501\n :rtype: datetime\n '
return self._updated_date_utc | @property
def updated_date_utc(self):
'Gets the updated_date_utc of this TaxDeclaration. # noqa: E501\n\n Last modified timestamp # noqa: E501\n\n :return: The updated_date_utc of this TaxDeclaration. # noqa: E501\n :rtype: datetime\n '
return self._updated_date_utc<|docstring|>Gets the updated_date_utc of this TaxDeclaration. # noqa: E501
Last modified timestamp # noqa: E501
:return: The updated_date_utc of this TaxDeclaration. # noqa: E501
:rtype: datetime<|endoftext|> |
7c5f95439d04eca4c7c0d733ff0d6b7fa991b1f496289d4e5aabd6c023f4fac8 | @updated_date_utc.setter
def updated_date_utc(self, updated_date_utc):
'Sets the updated_date_utc of this TaxDeclaration.\n\n Last modified timestamp # noqa: E501\n\n :param updated_date_utc: The updated_date_utc of this TaxDeclaration. # noqa: E501\n :type: datetime\n '
self._updated_date_utc = updated_date_utc | Sets the updated_date_utc of this TaxDeclaration.
Last modified timestamp # noqa: E501
:param updated_date_utc: The updated_date_utc of this TaxDeclaration. # noqa: E501
:type: datetime | xero_python/payrollau/models/tax_declaration.py | updated_date_utc | gavinwhyte/xero-python | 77 | python | @updated_date_utc.setter
def updated_date_utc(self, updated_date_utc):
'Sets the updated_date_utc of this TaxDeclaration.\n\n Last modified timestamp # noqa: E501\n\n :param updated_date_utc: The updated_date_utc of this TaxDeclaration. # noqa: E501\n :type: datetime\n '
self._updated_date_utc = updated_date_utc | @updated_date_utc.setter
def updated_date_utc(self, updated_date_utc):
'Sets the updated_date_utc of this TaxDeclaration.\n\n Last modified timestamp # noqa: E501\n\n :param updated_date_utc: The updated_date_utc of this TaxDeclaration. # noqa: E501\n :type: datetime\n '
self._updated_date_utc = updated_date_utc<|docstring|>Sets the updated_date_utc of this TaxDeclaration.
Last modified timestamp # noqa: E501
:param updated_date_utc: The updated_date_utc of this TaxDeclaration. # noqa: E501
:type: datetime<|endoftext|> |
2af9e03dc648687b4ac5a4fbcd4ff69754c13d30c93c0decab78432075e1386f | def run(command) -> Dict:
'Execute a command after an initial dry-run'
try:
command(DryRun=True)
except ClientError as err:
if ('DryRunOperation' not in str(err)):
raise
return command(DryRun=False) | Execute a command after an initial dry-run | aws_instance/backend.py | run | geekysuavo/aws-instance-tool | 0 | python | def run(command) -> Dict:
try:
command(DryRun=True)
except ClientError as err:
if ('DryRunOperation' not in str(err)):
raise
return command(DryRun=False) | def run(command) -> Dict:
try:
command(DryRun=True)
except ClientError as err:
if ('DryRunOperation' not in str(err)):
raise
return command(DryRun=False)<|docstring|>Execute a command after an initial dry-run<|endoftext|> |
bf73dbeb28a4a11452050c1698cddedad21e7d232af03eee5d22b4fe96bdd3a5 | def start(ids: List[str]):
'Start one or more instances'
return functools.partial(ec2.start_instances, InstanceIds=ids) | Start one or more instances | aws_instance/backend.py | start | geekysuavo/aws-instance-tool | 0 | python | def start(ids: List[str]):
return functools.partial(ec2.start_instances, InstanceIds=ids) | def start(ids: List[str]):
return functools.partial(ec2.start_instances, InstanceIds=ids)<|docstring|>Start one or more instances<|endoftext|> |
a7ccf574298625c25cbe9c790888fccb4937563c2277b7d0ecdc625190d7f599 | def stop(ids: List[str]):
'Stop one or more instances'
return functools.partial(ec2.stop_instances, InstanceIds=ids) | Stop one or more instances | aws_instance/backend.py | stop | geekysuavo/aws-instance-tool | 0 | python | def stop(ids: List[str]):
return functools.partial(ec2.stop_instances, InstanceIds=ids) | def stop(ids: List[str]):
return functools.partial(ec2.stop_instances, InstanceIds=ids)<|docstring|>Stop one or more instances<|endoftext|> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.